Introduction
Introduction Statistics Contact Development Disclaimer Help
do not depend on C library locale for ctype functions/macros - json2tsv - JSON …
git clone git://git.codemadness.org/json2tsv
Log
Files
Refs
README
LICENSE
---
commit 47732754f1217ac0808253b8c531428d82ec3a18
parent 1ebc23030bb37e0f9399328ec3a6968e35758351
Author: Hiltjo Posthuma <[email protected]>
Date: Tue, 29 Mar 2022 23:50:44 +0200
do not depend on C library locale for ctype functions/macros
Diffstat:
M json.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/json.c b/json.c
@@ -1,4 +1,3 @@
-#include <ctype.h>
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
@@ -11,6 +10,9 @@
#include "json.h"
+#define ISDIGIT(c) (((unsigned)c) - '0' < 10)
+#define ISXDIGIT(c) ((((unsigned)c) - '0' < 10) || ((unsigned)c | 32) - 'a' < …
+
static int
codepointtoutf8(long r, char *s)
{
@@ -149,7 +151,7 @@ escchr:
if (capacity(&str, &sz, len, 4…
goto end;
for (i = 12, cp = 0; i >= 0; i…
- if ((c = GETNEXT()) ==…
+ if ((c = GETNEXT()) ==…
JSON_INVALID()…
cp |= (hexdigit(c) << …
}
@@ -165,7 +167,7 @@ escchr:
goto escchr;
}
for (hi = cp, i = 12, …
- if ((c = GETNE…
+ if ((c = GETNE…
JSON_I…
lo |= (hexdigi…
}
@@ -292,7 +294,7 @@ escchr:
while (1) {
c = GETNEXT();
if (c == EOF ||
- (!isdigit(c) && c != 'e' && c != 'E' &&
+ (!ISDIGIT(c) && c != 'e' && c != 'E' &&
c != '+' && c != '-' && c != '.') ||
p + 1 >= sizeof(pri)) {
pri[p] = '\0';
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.