1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Fix the JSON1 extension so that it does not depend on isdigit() and

strtod() from the standard library when compiled into SQLite as part of the
amalgamation.

FossilOrigin-Name: bc9a9a60c31ebf9b11ac89ae5f99a3b66d6efc67
This commit is contained in:
drh
2015-10-16 15:35:39 +00:00
parent b9e8f59b63
commit 49472655d4
3 changed files with 25 additions and 11 deletions

View File

@@ -28,7 +28,6 @@
SQLITE_EXTENSION_INIT1 SQLITE_EXTENSION_INIT1
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include <ctype.h> /* amalgamator: keep */
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
@@ -43,8 +42,17 @@ SQLITE_EXTENSION_INIT1
** Versions of isspace(), isalnum() and isdigit() to which it is safe ** Versions of isspace(), isalnum() and isdigit() to which it is safe
** to pass signed char values. ** to pass signed char values.
*/ */
#define safe_isdigit(x) isdigit((unsigned char)(x)) #ifdef sqlite3Isdigit
#define safe_isalnum(x) isalnum((unsigned char)(x)) /* 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 ** 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 */; int_as_real: /* fall through to real */;
} }
case JSON_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); sqlite3_result_double(pCtx, r);
break; break;
} }

View File

@@ -1,5 +1,5 @@
C Form-feed\sis\snot\svalid\swhitespace\sfor\sjson.\s\s\nFix\sfor\sticket\s[57eec374ae1d0a1d] 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:16:06.127 D 2015-10-16T15:35:39.846
F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 8e42cb55739cd8c12e1fd25401956e2019448f6a F Makefile.msc 8e42cb55739cd8c12e1fd25401956e2019448f6a
@@ -195,7 +195,7 @@ F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2
F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f
F ext/misc/fuzzer.c 4c84635c71c26cfa7c2e5848cf49fe2d2cfcd767 F ext/misc/fuzzer.c 4c84635c71c26cfa7c2e5848cf49fe2d2cfcd767
F ext/misc/ieee754.c b0362167289170627659e84173f5d2e8fee8566e 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/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342
F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63
F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc 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-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 2ad72be12477b0e8e33e56a9a17e29abbd283ec1 P 28957d635961c525f735a52b8ffe3e69ccf31382
R 62f0d8008c01d0defc2c9b4656e1c898 R c52fcc2e6376b553d4a08dc304f342ca
U drh U drh
Z d6a4952373fb13844f78e8a8e4575f90 Z 74777d79c7bc4ee5f8a88ff1109e65fc

View File

@@ -1 +1 @@
28957d635961c525f735a52b8ffe3e69ccf31382 bc9a9a60c31ebf9b11ac89ae5f99a3b66d6efc67