]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix the JSON1 extension so that it does not depend on isdigit() and
authordrh <drh@noemail.net>
Fri, 16 Oct 2015 15:35:39 +0000 (15:35 +0000)
committerdrh <drh@noemail.net>
Fri, 16 Oct 2015 15:35:39 +0000 (15:35 +0000)
strtod() from the standard library when compiled into SQLite as part of the
amalgamation.

FossilOrigin-Name: bc9a9a60c31ebf9b11ac89ae5f99a3b66d6efc67

ext/misc/json1.c
manifest
manifest.uuid

index fa62237b89e5711e387b948f03794c1516488ff4..61d013ea4b639fe078053c93cb9b7481f7277d69 100644 (file)
@@ -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;
     }
index 6614404fd30d62f67c49f79f8328a4ee1c37ebc4..a7399e5940fddb7def9f5e83306a635ebd45972e 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Form-feed\sis\snot\svalid\swhitespace\sfor\sjson.\s\s\nFix\sfor\sticket\s[57eec374ae1d0a1d]
-D 2015-10-16T15:16:06.127
+C Fix\sthe\sJSON1\sextension\sso\sthat\sit\sdoes\snot\sdepend\son\sisdigit()\sand\nstrtod()\sfrom\sthe\sstandard\slibrary\swhen\scompiled\sinto\sSQLite\sas\spart\sof\sthe\namalgamation.
+D 2015-10-16T15:35:39.846
 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 8e42cb55739cd8c12e1fd25401956e2019448f6a
@@ -195,7 +195,7 @@ F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2
 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f
 F ext/misc/fuzzer.c 4c84635c71c26cfa7c2e5848cf49fe2d2cfcd767
 F ext/misc/ieee754.c b0362167289170627659e84173f5d2e8fee8566e
-F ext/misc/json1.c d559a00d83766cffc6506ee34ceda24895f13605
+F ext/misc/json1.c 4f45afd9dbcd6feca8c528251efbb7fc09299a09
 F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342
 F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63
 F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc
@@ -1391,7 +1391,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 2ad72be12477b0e8e33e56a9a17e29abbd283ec1
-R 62f0d8008c01d0defc2c9b4656e1c898
+P 28957d635961c525f735a52b8ffe3e69ccf31382
+R c52fcc2e6376b553d4a08dc304f342ca
 U drh
-Z d6a4952373fb13844f78e8a8e4575f90
+Z 74777d79c7bc4ee5f8a88ff1109e65fc
index bf0fd4ab3a585812fc714ff2795104baf960d239..63d0199668f74553ca7117f78f673179abda82f7 100644 (file)
@@ -1 +1 @@
-28957d635961c525f735a52b8ffe3e69ccf31382
\ No newline at end of file
+bc9a9a60c31ebf9b11ac89ae5f99a3b66d6efc67
\ No newline at end of file