[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 23/150: curl_ctype: private is*() type macros and f
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 23/150: curl_ctype: private is*() type macros and functions |
Date: |
Fri, 30 Mar 2018 16:47:57 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit 4272a0b0fc49a1ac0ceab5c4a365c9f6ab8bf8e2
Author: Daniel Stenberg <address@hidden>
AuthorDate: Mon Jan 29 00:58:59 2018 +0100
curl_ctype: private is*() type macros and functions
... since the libc provided one are locale dependent in a way we don't
want. Also, the "native" isalnum() (for example) works differently on
different platforms which caused test 1307 failures on macos only.
Closes #2269
---
lib/Makefile.inc | 6 +--
lib/curl_ctype.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++
lib/curl_ctype.h | 48 +++++++++++++++++++
lib/curl_setup_once.h | 23 +---------
lib/http_chunks.c | 11 +----
src/Makefile.inc | 6 ++-
tests/server/Makefile.inc | 6 ++-
7 files changed, 176 insertions(+), 38 deletions(-)
diff --git a/lib/Makefile.inc b/lib/Makefile.inc
index 61e80cf52..ade22f13a 100644
--- a/lib/Makefile.inc
+++ b/lib/Makefile.inc
@@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
-# Copyright (C) 1998 - 2017, Daniel Stenberg, <address@hidden>, et al.
+# Copyright (C) 1998 - 2018, Daniel Stenberg, <address@hidden>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
@@ -54,7 +54,7 @@ LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c
formdata.c \
http_ntlm.c curl_ntlm_wb.c curl_ntlm_core.c curl_sasl.c rand.c \
curl_multibyte.c hostcheck.c conncache.c pipeline.c dotdot.c \
x509asn1.c http2.c smb.c curl_endian.c curl_des.c system_win32.c \
- mime.c sha256.c setopt.c curl_path.c
+ mime.c sha256.c setopt.c curl_path.c curl_ctype.c
LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \
formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h \
@@ -74,7 +74,7 @@ LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h
progress.h \
curl_setup_once.h multihandle.h setup-vms.h pipeline.h dotdot.h \
x509asn1.h http2.h sigpipe.h smb.h curl_endian.h curl_des.h \
curl_printf.h system_win32.h rand.h mime.h curl_sha256.h setopt.h \
- curl_path.h
+ curl_path.h curl_ctype.h
LIB_RCFILES = libcurl.rc
diff --git a/lib/curl_ctype.c b/lib/curl_ctype.c
new file mode 100644
index 000000000..70db1630d
--- /dev/null
+++ b/lib/curl_ctype.c
@@ -0,0 +1,114 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <address@hidden>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#define _U (1<<0) /* upper case */
+#define _L (1<<1) /* lower case */
+#define _N (1<<2) /* decimal numerical digit */
+#define _S (1<<3) /* space */
+#define _P (1<<4) /* punctuation */
+#define _C (1<<5) /* control */
+#define _X (1<<6) /* hexadecimal letter */
+#define _B (1<<7) /* blank */
+
+static const unsigned char ascii[128] = {
+ _C, _C, _C, _C, _C, _C, _C, _C,
+ _C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C,
+ _C, _C, _C, _C, _C, _C, _C, _C,
+ _C, _C, _C, _C, _C, _C, _C, _C,
+ _S|_B, _P, _P, _P, _P, _P, _P, _P,
+ _P, _P, _P, _P, _P, _P, _P, _P,
+ _N, _N, _N, _N, _N, _N, _N, _N,
+ _N, _N, _P, _P, _P, _P, _P, _P,
+ _P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U,
+ _U, _U, _U, _U, _U, _U, _U, _U,
+ _U, _U, _U, _U, _U, _U, _U, _U,
+ _U, _U, _U, _P, _P, _P, _P, _P,
+ _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L,
+ _L, _L, _L, _L, _L, _L, _L, _L,
+ _L, _L, _L, _L, _L, _L, _L, _L,
+ _L, _L, _L, _P, _P, _P, _P, _C
+};
+
+int Curl_isspace(int c)
+{
+ if((c < 0) || (c >= 0x80))
+ return FALSE;
+ return (ascii[c] & _S);
+}
+
+int Curl_isdigit(int c)
+{
+ if((c < 0) || (c >= 0x80))
+ return FALSE;
+ return (ascii[c] & _N);
+}
+
+int Curl_isalnum(int c)
+{
+ if((c < 0) || (c >= 0x80))
+ return FALSE;
+ return (ascii[c] & (_N|_U|_L));
+}
+
+int Curl_isxdigit(int c)
+{
+ if((c < 0) || (c >= 0x80))
+ return FALSE;
+ return (ascii[c] & (_N|_X));
+}
+
+int Curl_isgraph(int c)
+{
+ if((c < 0) || (c >= 0x80) || (c == ' '))
+ return FALSE;
+ return (ascii[c] & (_N|_X|_U|_L|_P|_S));
+}
+
+int Curl_isprint(int c)
+{
+ if((c < 0) || (c >= 0x80))
+ return FALSE;
+ return (ascii[c] & (_N|_X|_U|_L|_P|_S));
+}
+
+int Curl_isalpha(int c)
+{
+ if((c < 0) || (c >= 0x80))
+ return FALSE;
+ return (ascii[c] & (_U|_L));
+}
+
+int Curl_isupper(int c)
+{
+ if((c < 0) || (c >= 0x80))
+ return FALSE;
+ return (ascii[c] & (_U));
+}
+
+int Curl_islower(int c)
+{
+ if((c < 0) || (c >= 0x80))
+ return FALSE;
+ return (ascii[c] & (_L));
+}
diff --git a/lib/curl_ctype.h b/lib/curl_ctype.h
new file mode 100644
index 000000000..da3bd95a6
--- /dev/null
+++ b/lib/curl_ctype.h
@@ -0,0 +1,48 @@
+#ifndef HEADER_CURL_CTYPE_H
+#define HEADER_CURL_CTYPE_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <address@hidden>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+int Curl_isspace(int c);
+int Curl_isdigit(int c);
+int Curl_isalnum(int c);
+int Curl_isxdigit(int c);
+int Curl_isgraph(int c);
+int Curl_isprint(int c);
+int Curl_isalpha(int c);
+int Curl_isupper(int c);
+int Curl_islower(int c);
+
+#define ISSPACE(x) (Curl_isspace((int) ((unsigned char)x)))
+#define ISDIGIT(x) (Curl_isdigit((int) ((unsigned char)x)))
+#define ISALNUM(x) (Curl_isalnum((int) ((unsigned char)x)))
+#define ISXDIGIT(x) (Curl_isxdigit((int) ((unsigned char)x)))
+#define ISGRAPH(x) (Curl_isgraph((int) ((unsigned char)x)))
+#define ISALPHA(x) (Curl_isalpha((int) ((unsigned char)x)))
+#define ISPRINT(x) (Curl_isprint((int) ((unsigned char)x)))
+#define ISUPPER(x) (Curl_isupper((int) ((unsigned char)x)))
+#define ISLOWER(x) (Curl_islower((int) ((unsigned char)x)))
+#define ISASCII(x) (((x) >= 0) && ((x) <= 0x80))
+#define ISBLANK(x) (int)((((unsigned char)x) == ' ') || \
+ (((unsigned char)x) == '\t'))
+
+#endif /* HEADER_CURL_CTYPE_H */
diff --git a/lib/curl_setup_once.h b/lib/curl_setup_once.h
index a5b542c6e..6d01ea156 100644
--- a/lib/curl_setup_once.h
+++ b/lib/curl_setup_once.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2013, Daniel Stenberg, <address@hidden>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <address@hidden>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -101,7 +101,6 @@
# endif
#endif
-
/*
* Definition of timeval struct for platforms that don't have it.
*/
@@ -274,25 +273,6 @@ struct timeval {
# define sfcntl fcntl
#endif
-/*
- * Uppercase macro versions of ANSI/ISO is*() functions/macros which
- * avoid negative number inputs with argument byte codes > 127.
- */
-
-#define ISSPACE(x) (isspace((int) ((unsigned char)x)))
-#define ISDIGIT(x) (isdigit((int) ((unsigned char)x)))
-#define ISALNUM(x) (isalnum((int) ((unsigned char)x)))
-#define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x)))
-#define ISGRAPH(x) (isgraph((int) ((unsigned char)x)))
-#define ISALPHA(x) (isalpha((int) ((unsigned char)x)))
-#define ISPRINT(x) (isprint((int) ((unsigned char)x)))
-#define ISUPPER(x) (isupper((int) ((unsigned char)x)))
-#define ISLOWER(x) (islower((int) ((unsigned char)x)))
-#define ISASCII(x) (isascii((int) ((unsigned char)x)))
-
-#define ISBLANK(x) (int)((((unsigned char)x) == ' ') || \
- (((unsigned char)x) == '\t'))
-
#define TOLOWER(x) (tolower((int) ((unsigned char)x)))
@@ -347,6 +327,7 @@ struct timeval {
#define FALSE false
#endif
+#include "curl_ctype.h"
/*
* Macro WHILE_FALSE may be used to build single-iteration do-while loops,
diff --git a/lib/http_chunks.c b/lib/http_chunks.c
index 161642969..2d9999f18 100644
--- a/lib/http_chunks.c
+++ b/lib/http_chunks.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <address@hidden>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <address@hidden>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -74,15 +74,6 @@
*/
-/* Check for an ASCII hex digit.
- We avoid the use of isxdigit to accommodate non-ASCII hosts. */
-static bool Curl_isxdigit(char digit)
-{
- return ( (digit >= 0x30 && digit <= 0x39) /* 0-9 */
- || (digit >= 0x41 && digit <= 0x46) /* A-F */
- || (digit >= 0x61 && digit <= 0x66) /* a-f */) ? TRUE : FALSE;
-}
-
void Curl_httpchunk_init(struct connectdata *conn)
{
struct Curl_chunker *chunk = &conn->chunk;
diff --git a/src/Makefile.inc b/src/Makefile.inc
index 45b4967f6..d3c7c2bbf 100644
--- a/src/Makefile.inc
+++ b/src/Makefile.inc
@@ -12,13 +12,15 @@
CURLX_CFILES = \
../lib/strtoofft.c \
../lib/nonblock.c \
- ../lib/warnless.c
+ ../lib/warnless.c \
+ ../lib/curl_ctype.c
CURLX_HFILES = \
../lib/curl_setup.h \
../lib/strtoofft.h \
../lib/nonblock.h \
- ../lib/warnless.h
+ ../lib/warnless.h \
+ ../lib/curl_ctype.h
CURL_CFILES = \
slist_wc.c \
diff --git a/tests/server/Makefile.inc b/tests/server/Makefile.inc
index 208aa0fc8..c6233affa 100644
--- a/tests/server/Makefile.inc
+++ b/tests/server/Makefile.inc
@@ -4,13 +4,15 @@ CURLX_SRCS = \
../../lib/mprintf.c \
../../lib/nonblock.c \
../../lib/strtoofft.c \
- ../../lib/warnless.c
+ ../../lib/warnless.c \
+ ../../lib/curl_ctype.c
CURLX_HDRS = \
../../lib/curlx.h \
../../lib/nonblock.h \
../../lib/strtoofft.h \
- ../../lib/warnless.h
+ ../../lib/warnless.h \
+ ../../lib/curl_ctype.h
USEFUL = \
getpart.c \
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 26/150: winbuild: make linker generate proper PDB, (continued)
- [GNUnet-SVN] [gnurl] 26/150: winbuild: make linker generate proper PDB, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 21/150: RELEASE-NOTES: synced with 094647fca, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 45/150: getdate: return -1 for out of range, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 30/150: curlver: next release will be 7.59.0, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 40/150: fnmatch: pattern syntax can no longer fail, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 51/150: build-openssl.bat/build-wolfssl.bat: Build platform is optional, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 25/150: curl: add --proxy-pinnedpubkey, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 31/150: RELEASE-NOTES: synced with 811beab9f, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 55/150: build-openssl.bat: Fixed incorrect move if destination build folder exists, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 78/150: travis: add build with iconv enabled, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 23/150: curl_ctype: private is*() type macros and functions,
gnunet <=
- [GNUnet-SVN] [gnurl] 59/150: get_posix_time: only check for overflows if they can happen!, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 64/150: smtp: fix processing of initial dot in data, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 52/150: fnmatch: optimize processing of consecutive *s and ?s pattern characters, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 47/150: time-cond: fix reading the file modification time on Windows, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 67/150: RELEASE-NOTES: synced with e551910f8, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 43/150: time_t-fixes: remove typecasts to 'long' for info.filetime, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 82/150: TODO: 1.7 Support HTTP/2 for HTTP(S) proxies, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 50/150: openssl: Don't add verify locations when verifypeer==0, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 42/150: curl_setup: move the precautionary define of SIZEOF_TIME_T, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 28/150: time: support > year 2038 time stamps for system with 32bit long, gnunet, 2018/03/30