aboutsummaryrefslogtreecommitdiff
path: root/ext/misc/json1.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/misc/json1.c')
-rw-r--r--ext/misc/json1.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/ext/misc/json1.c b/ext/misc/json1.c
index fa62237b8..61d013ea4 100644
--- a/ext/misc/json1.c
+++ b/ext/misc/json1.c
@@ -28,7 +28,6 @@
SQLITE_EXTENSION_INIT1
#include <assert.h>
#include <string.h>
-#include <ctype.h> /* amalgamator: keep */
#include <stdlib.h>
#include <stdarg.h>
@@ -43,8 +42,17 @@ SQLITE_EXTENSION_INIT1
** Versions of isspace(), isalnum() and isdigit() to which it is safe
** to pass signed char values.
*/
-#define safe_isdigit(x) isdigit((unsigned char)(x))
-#define safe_isalnum(x) isalnum((unsigned char)(x))
+#ifdef sqlite3Isdigit
+ /* Use the SQLite core versions if this routine is part of the
+ ** SQLite amalgamation */
+# define safe_isdigit(x) sqlite3Isdigit(x)
+# define safe_isalnum(x) sqlite3Isalnum(x)
+#else
+ /* Use the standard library for separate compilation */
+#include <ctype.h> /* amalgamator: keep */
+# define safe_isdigit(x) isdigit((unsigned char)(x))
+# define safe_isalnum(x) isalnum((unsigned char)(x))
+#endif
/*
** Growing our own isspace() routine this way is twice as fast as
@@ -514,7 +522,13 @@ static void jsonReturn(
int_as_real: /* fall through to real */;
}
case JSON_REAL: {
- double r = strtod(pNode->u.zJContent, 0);
+ double r;
+#ifdef SQLITE_AMALGAMATION
+ const char *z = pNode->u.zJContent;
+ sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8);
+#else
+ r = strtod(pNode->u.zJContent, 0);
+#endif
sqlite3_result_double(pCtx, r);
break;
}