From: drh Date: Mon, 19 Feb 2018 17:03:23 +0000 (+0000) Subject: In the printf() library, measure width and precision in characters rather X-Git-Tag: version-3.23.0~117^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=62856465f2350ccba3aa95798e6af543e466f521;p=thirdparty%2Fsqlite.git In the printf() library, measure width and precision in characters rather than bytes if the "!" (alternate-form-2) flag is present on a %s or %z substitution. FossilOrigin-Name: ca31c6630422fca70e626dd38aae96296bd8535d491ca52391624a5e7e663636 --- diff --git a/manifest b/manifest index ea203fe2f3..51334ef416 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Only\stry\sto\suse\sthe\sgeteuid()\sinterface\son\sunix\sif\sHAVE_FCHOWN\sis\sdefined.\nThis\sfixes\sthe\sbuild\sfor\svxWorks,\swe\sare\stold. -D 2018-02-19T16:34:31.891 +C In\sthe\sprintf()\slibrary,\smeasure\swidth\sand\sprecision\sin\scharacters\srather\nthan\sbytes\sif\sthe\s"!"\s(alternate-form-2)\sflag\sis\spresent\son\sa\s%s\sor\s%z\nsubstitution. +D 2018-02-19T17:03:23.575 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 7a3f714b4fcf793108042b7b0a5c720b0b310ec84314d61ba7f3f49f27e550ea @@ -484,7 +484,7 @@ F src/pcache1.c 716975564c15eb6679e97f734cec1bfd6c16ac3d4010f05f1f8e509fc7d19880 F src/pragma.c bea56df3ae0637768c0da4fbbb8f2492f780980d95000034a105ff291bf7ca69 F src/pragma.h bb83728944b42f6d409c77f5838a8edbdb0fe83046c5496ffc9602b40340a324 F src/prepare.c 259f4e7960c47082c9653f3d5f0c294abd68bb9c3aab86de7630700cba1c20fb -F src/printf.c 9506b4b96e59c0467047155f09015750cb2878aeda3d39e5610c1192ddc3c41c +F src/printf.c a94897345b3228d97c6aa06297890b7c62bc47acc86e34d3634d125426d78695 F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac @@ -1707,7 +1707,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 88258770adead70fa101c74e266a37bb9aaffac0ba738a4b345617feb8c46477 -R 2e4bdb0c045376ff7154d29ff239bf61 +P 38f654dc117bb11d61407327884b5c913cfaf920547bebc4ce5a4cf983e5c20e +R 07cd50bae7c4080dd411c728ce9cf3a0 +T *branch * printf-enhancement +T *sym-printf-enhancement * +T -sym-trunk * U drh -Z 37b9f8fa92af1d03e78cb9f20faaf7e7 +Z 9d6ee38fe0b61a32cc5a7309de027572 diff --git a/manifest.uuid b/manifest.uuid index f3e38fcfac..29c0e9958e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -38f654dc117bb11d61407327884b5c913cfaf920547bebc4ce5a4cf983e5c20e \ No newline at end of file +ca31c6630422fca70e626dd38aae96296bd8535d491ca52391624a5e7e663636 \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index ca8d26e4f9..f6980c90db 100644 --- a/src/printf.c +++ b/src/printf.c @@ -654,10 +654,25 @@ void sqlite3VXPrintf( zExtra = bufpt; } if( precision>=0 ){ - for(length=0; length 0 && z[0] ){ + SQLITE_SKIP_UTF8(z); + } + length = (int)(z - (unsigned char*)bufpt); + }else{ + for(length=0; length0 ){ + /* Adjust width to account for extra bytes in UTF-8 characters */ + int ii = length - 1; + while( ii>=0 ) if( (bufpt[ii--] & 0xc0)==0x80 ) width++; + } break; case etSQLESCAPE: /* Escape ' characters */ case etSQLESCAPE2: /* Escape ' and enclose in '...' */ @@ -700,7 +715,7 @@ void sqlite3VXPrintf( if( needQuote ) bufpt[j++] = q; bufpt[j] = 0; length = j; - /* The precision in %q and %Q means how many input characters to + /* The precision in %q and %Q means how many input bytes to ** consume, not the length of the output... ** if( precision>=0 && precision0 ){