Translate JSON5-only string literal escape sequences into the JSON equivalents.

FossilOrigin-Name: 14e82f36eed31af1237898728bf353b968523c62b1f8d1d90dbbabd92d0c2834
This commit is contained in:
drh 2023-04-27 12:24:00 +00:00
parent c5ee2d8e80
commit f59c01e24c
3 changed files with 42 additions and 8 deletions

View File

@ -1,5 +1,5 @@
C Implement\ssome\sof\sthe\sJSON5\senhancements\sto\sstring\sand\snumeric\sliterals.\nThis\sis\san\sincremental\scheck-in\sof\swork\sin\sprogress.
D 2023-04-26T20:26:14.388
C Translate\sJSON5-only\sstring\sliteral\sescape\ssequences\sinto\sthe\sJSON\sequivalents.
D 2023-04-27T12:24:00.195
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -592,7 +592,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
F src/hwtime.h b638809e083b601b618df877b2e89cb87c2a47a01f4def10be4c4ebb54664ac7
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
F src/insert.c a8de1db43335fc4946370a7a7e47d89975ad678ddb15078a150e993ba2fb37d4
F src/json.c f82b86599b220a2c60731eba883bbea92ee4d6e61aaa56740179e8aa5e6ec596
F src/json.c e872bb2ba63296c21dd62f83557d504bfb94f299a6591ec735cd4a9aed4e321b
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
F src/loadext.c be5af440f3192c58681b5d43167dbca3ccbfce394d89faa22378a14264781136
F src/main.c 09bc5191f75dc48fc4dfddda143cb864c0c3dbc3297eb9a9c8e01fea58ff847d
@ -2063,8 +2063,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 78404dc37024cad5fe7eacf78ea85b56f08b129a1b9a046c3e1b11275068a485
R e7aefca3f1ce2ae26f999bdfb414a2b2
P 9508efa9d61c0ff0eb73100dd52889dadc5fa2a2091b944a9b8a74e8a5c50e82
R 672753aa30f1f89635383bf8b5e62624
U drh
Z b316d61c8d04f67716fa9ffd06cd770b
Z aa11f958e9e420359b5624437ca5455e
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
9508efa9d61c0ff0eb73100dd52889dadc5fa2a2091b944a9b8a74e8a5c50e82
14e82f36eed31af1237898728bf353b968523c62b1f8d1d90dbbabd92d0c2834

View File

@ -302,8 +302,42 @@ static void jsonAppendString(JsonString *p, const char *zIn, u32 N){
** features.
*/
static void jsonAppendNormalizedString(JsonString *p, const char *zIn, u32 N){
int i;
jsonAppendChar(p, '"');
jsonAppendRaw(p, &zIn[1], N-2); /* TODO: translate JSON5 escapes */
zIn++;
N -= 2;
while( N>0 ){
for(i=0; i<N && zIn[i]!='\\'; i++){}
if( i>0 ){
jsonAppendRaw(p, zIn, i);
zIn += i;
N -= i;
if( N==0 ) break;
}
assert( zIn[0]=='\\' );
switch( zIn[1] ){
case '\'':
jsonAppendChar(p, '\'');
break;
case 'v':
jsonAppendRaw(p, "\\u0009", 6);
break;
case 'x':
jsonAppendRaw(p, "\\u00", 4);
jsonAppendRaw(p, &zIn[2], 2);
zIn += 2;
N -= 2;
break;
case '0':
jsonAppendRaw(p, "\\u0000", 6);
break;
default:
jsonAppendRaw(p, zIn, 2);
break;
}
zIn += 2;
N -= 2;
}
jsonAppendChar(p, '"');
}