]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Get precision working on %J, both with and with the ! flag. Width is
authordrh <>
Thu, 7 May 2026 00:02:55 +0000 (00:02 +0000)
committerdrh <>
Thu, 7 May 2026 00:02:55 +0000 (00:02 +0000)
still a no-op, and there are no test cases.  Incremental check-in.

FossilOrigin-Name: 18166bce208c64b7f3afaa88c27a10e0295a89f9c72942dcaa949cf7efb479e6

manifest
manifest.uuid
src/printf.c

index 5559936a02c0bdbbdbdaab048a522de309e8f203..7e7cfa4a43748e5a0e73b4b31512925a4c902e59 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Experimental\sprototype\sof\sthe\s%J\sconversion\sin\sprintf().
-D 2026-05-06T20:48:34.700
+C Get\sprecision\sworking\son\s%J,\sboth\swith\sand\swith\sthe\s!\sflag.\s\sWidth\sis\nstill\sa\sno-op,\sand\sthere\sare\sno\stest\scases.\s\sIncremental\scheck-in.
+D 2026-05-07T00:02:55.078
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -731,7 +731,7 @@ F src/pcache.h 092b758d2c5e4dabb30eae46d8dfad77c0f70b16bf3ff1943f7a232b0fe0d4ba
 F src/pcache1.c 131ca0daf4e66b4608d2945ae76d6ed90de3f60539afbd5ef9ec65667a5f2fcd
 F src/pragma.c 789ef67117b74b5be0a2db6681f7f0c55e6913791b9da309aefd280de2c8a74d
 F src/prepare.c f6a6e28a281bd1d1da12f47d370a81af46159b40f73bf7fa0b276b664f9c8b7d
-F src/printf.c 56069e56e6cf34ce54169ad26621c379e086a64dadf33a17bdb9d7a9350973ab
+F src/printf.c 335f6f468ed6ff0d42e41fac952ab2e69e44e8134af6834589e922b14e080375
 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
 F src/resolve.c fcc406bfb055bee9954ee77c023f4a2a66a24bcdf1573516a72280811a269c20
 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
@@ -2203,11 +2203,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
 F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
 F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
-P 5c6d3e9d83af94234f67b06bd23c4eb0178a80c74c39be4945b3282244630020
-R a21480506f85a37cbc3d8c2a9355b050
-T *branch * format-json
-T *sym-format-json *
-T -sym-trunk *
+P 7f6b1bae0849f0a840b95ae95aa6fdc6d51b72fdd50493649f584ad7829a3060
+R 64fe79042d670f076fa407257d28ae73
 U drh
-Z 3fa145bffe9be1127d94257e2ad01c6e
+Z 9ce0686262e45801ba6d31466b72b666
 # Remove this line to create a well-formed Fossil manifest.
index 7ee69f5912bf8ea40b2430f94d17463d2aa7026d..ae9540d7374b637e9def9f30efb33dc52a7b8210 100644 (file)
@@ -1 +1 @@
-7f6b1bae0849f0a840b95ae95aa6fdc6d51b72fdd50493649f584ad7829a3060
+18166bce208c64b7f3afaa88c27a10e0295a89f9c72942dcaa949cf7efb479e6
index 1ee7ce594537561be1e06bfdd6bf13d60cd2c17c..ccb067dcee0103b96ab25078954678407b7baa1d 100644 (file)
@@ -872,7 +872,7 @@ void sqlite3_str_vappendf(
         break;
       case etJSONSTR: {         /* %J: Generate a JSON string literal */
         char *escarg;
-        int i, j;
+        i64 i, j, px;
         unsigned char ch;
 
         if( bArgList ){
@@ -884,7 +884,17 @@ void sqlite3_str_vappendf(
           sqlite3_str_append(pAccum, "null", 4);
         }else{
           sqlite3_str_append(pAccum, "\"", 1);
-          for(i=j=0; 1; i++){
+          px = precision;
+          if( px<=0 ){
+            px = 0x7fffffff;
+          }else if( flag_altform2 ){
+            /* Convert precision from code-points to bytes */
+            for(i=0; i<px && escarg[i]; i++){
+              if( (escarg[i]&0xc0)==0x80 ) px++;
+            }
+            while( (escarg[px]&0xc0)==0x80 ) px++;
+          }
+          for(i=j=0; i<px; i++){
             if( (ch = ((u8*)escarg)[i])<0x1f || ch=='"' || ch=='\\' ){
               if( j<i-1 ) sqlite3_str_append(pAccum, &escarg[j], i-j);
               j = i+1;
@@ -902,6 +912,7 @@ void sqlite3_str_vappendf(
               }
             }
           }
+          if( j<i-1 ) sqlite3_str_append(pAccum, &escarg[j], i-j);
           sqlite3_str_append(pAccum, "\"", 1);
         }
         length = 0;