mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Futher simplifications to json1.c. Also an obscure bug-fix in the initial
output of json_tree() when using a path to an object contained within an array. FossilOrigin-Name: fcb1e327a64134e5ac539ec3d52733422d3061fd
This commit is contained in:
@ -156,11 +156,9 @@ static void jsonReset(JsonString *p){
|
|||||||
/* Report an out-of-memory (OOM) condition
|
/* Report an out-of-memory (OOM) condition
|
||||||
*/
|
*/
|
||||||
static void jsonOom(JsonString *p){
|
static void jsonOom(JsonString *p){
|
||||||
if( !p->bErr ){
|
p->bErr = 1;
|
||||||
p->bErr = 1;
|
sqlite3_result_error_nomem(p->pCtx);
|
||||||
sqlite3_result_error_nomem(p->pCtx);
|
jsonReset(p);
|
||||||
jsonReset(p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enlarge pJson->zBuf so that it can hold at least N more bytes.
|
/* Enlarge pJson->zBuf so that it can hold at least N more bytes.
|
||||||
@ -567,10 +565,6 @@ static int jsonParseAddNode(
|
|||||||
JsonNode *pNew;
|
JsonNode *pNew;
|
||||||
if( pParse->oom ) return -1;
|
if( pParse->oom ) return -1;
|
||||||
nNew = pParse->nAlloc*2 + 10;
|
nNew = pParse->nAlloc*2 + 10;
|
||||||
if( nNew<=pParse->nNode ){
|
|
||||||
pParse->oom = 1;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
pNew = sqlite3_realloc(pParse->aNode, sizeof(JsonNode)*nNew);
|
pNew = sqlite3_realloc(pParse->aNode, sizeof(JsonNode)*nNew);
|
||||||
if( pNew==0 ){
|
if( pNew==0 ){
|
||||||
pParse->oom = 1;
|
pParse->oom = 1;
|
||||||
@ -899,16 +893,16 @@ static JsonNode *jsonLookupStep(
|
|||||||
}else if( zPath[0]=='[' && safe_isdigit(zPath[1]) ){
|
}else if( zPath[0]=='[' && safe_isdigit(zPath[1]) ){
|
||||||
if( pRoot->eType!=JSON_ARRAY ) return 0;
|
if( pRoot->eType!=JSON_ARRAY ) return 0;
|
||||||
i = 0;
|
i = 0;
|
||||||
zPath++;
|
j = 1;
|
||||||
while( safe_isdigit(zPath[0]) ){
|
while( safe_isdigit(zPath[j]) ){
|
||||||
i = i*10 + zPath[0] - '0';
|
i = i*10 + zPath[j] - '0';
|
||||||
zPath++;
|
j++;
|
||||||
}
|
}
|
||||||
if( zPath[0]!=']' ){
|
if( zPath[j]!=']' ){
|
||||||
*pzErr = zPath;
|
*pzErr = zPath;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
zPath++;
|
zPath += j + 1;
|
||||||
j = 1;
|
j = 1;
|
||||||
for(;;){
|
for(;;){
|
||||||
while( j<=pRoot->n && (i>0 || (pRoot[j].jnFlags & JNODE_REMOVE)!=0) ){
|
while( j<=pRoot->n && (i>0 || (pRoot[j].jnFlags & JNODE_REMOVE)!=0) ){
|
||||||
@ -936,7 +930,7 @@ static JsonNode *jsonLookupStep(
|
|||||||
}
|
}
|
||||||
return pNode;
|
return pNode;
|
||||||
}
|
}
|
||||||
}else if( zPath[0]!=0 ){
|
}else{
|
||||||
*pzErr = zPath;
|
*pzErr = zPath;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -1696,7 +1690,7 @@ static int jsonEachColumn(
|
|||||||
sqlite3_result_text(ctx, zRoot, -1, SQLITE_STATIC);
|
sqlite3_result_text(ctx, zRoot, -1, SQLITE_STATIC);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
case JEACH_JSON: {
|
||||||
assert( i==JEACH_JSON );
|
assert( i==JEACH_JSON );
|
||||||
sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_STATIC);
|
sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_STATIC);
|
||||||
break;
|
break;
|
||||||
@ -1820,6 +1814,7 @@ static int jsonEachFilter(
|
|||||||
pNode->u.iKey = 0;
|
pNode->u.iKey = 0;
|
||||||
p->iEnd = p->i + pNode->n + 1;
|
p->iEnd = p->i + pNode->n + 1;
|
||||||
if( p->bRecursive ){
|
if( p->bRecursive ){
|
||||||
|
p->eType = p->sParse.aNode[p->sParse.aUp[p->i]].eType;
|
||||||
if( p->i>0 && (p->sParse.aNode[p->i-1].jnFlags & JNODE_LABEL)!=0 ){
|
if( p->i>0 && (p->sParse.aNode[p->i-1].jnFlags & JNODE_LABEL)!=0 ){
|
||||||
p->i--;
|
p->i--;
|
||||||
}
|
}
|
||||||
|
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
|||||||
C Fix\sjson_set()\sso\sthat\sit\scan\soverwrite\sa\svalue\sthat\swas\spreviously\soverwritten\nduring\sthe\ssame\scall.
|
C Futher\ssimplifications\sto\sjson1.c.\s\sAlso\san\sobscure\sbug-fix\sin\sthe\sinitial\noutput\sof\sjson_tree()\swhen\susing\sa\spath\sto\san\sobject\scontained\swithin\san\sarray.
|
||||||
D 2015-09-22T00:21:03.350
|
D 2015-09-22T01:15:49.994
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 2047811644c5bac91ccdfc2720e49b60965a63a7
|
F Makefile.in 2047811644c5bac91ccdfc2720e49b60965a63a7
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@ -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 c5e7018b8fe23ba778a24d918724b5963ecaa689
|
F ext/misc/json1.c 8eefcbdc172e9eff3c613016260c2d82893c12f2
|
||||||
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
|
||||||
@ -1387,7 +1387,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
|||||||
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 737ac3faf4e5fcb5855f5f9a1c1ddfc5424e6292
|
P 0f16041647993975c316203c7e11f06e27640136
|
||||||
R 95f992a7687b0db3b0df98a691005bc0
|
R 062ca531bf3a825489a40d6145bed1f2
|
||||||
U drh
|
U drh
|
||||||
Z 7a61ae480ab77880b942dd9dc8577d84
|
Z 6b7ed4fd95fc512864c2dd577eb1b3dd
|
||||||
|
@ -1 +1 @@
|
|||||||
0f16041647993975c316203c7e11f06e27640136
|
fcb1e327a64134e5ac539ec3d52733422d3061fd
|
Reference in New Issue
Block a user