From: larrybr Date: Mon, 26 Jul 2021 18:28:24 +0000 (+0000) Subject: Give sqldiff --visible-controls option to deal with non-graphic text content robustly... X-Git-Tag: version-3.37.0~315 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e40875d21123bcae130570624961109a07b54864;p=thirdparty%2Fsqlite.git Give sqldiff --visible-controls option to deal with non-graphic text content robustly across platforms FossilOrigin-Name: 68d2373f5d578cf3aff9d1ac4b1ab3ac00b466e94e1eb516523fc7660dfc0549 --- diff --git a/manifest b/manifest index 99fe0fda6a..c4f06a0d91 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\sCLI\swith\sthe\s".connection"\scommand\sthat\scan\sswitch\sbetween\nup\sto\sfive\sdifferent\sdatabase\sconnections.\s\sUsed\sfor\smanual\stesting\sof\smultiple\ndatabase\sconnections\sin\sthe\ssame\sprocess. -D 2021-07-23T18:43:58.652 +C Give\ssqldiff\s--visible-controls\soption\sto\sdeal\swith\snon-graphic\stext\scontent\srobustly\sacross\splatforms +D 2021-07-26T18:28:24.001 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1885,7 +1885,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/split-sqlite3c.tcl 3efcd4240b738f6bb2b5af0aea7e1e0ef9bc1c61654f645076cec883030b710c -F tool/sqldiff.c 21226ef092ec1e543b237c5d3d2d32d344a60f2437eadfea04f65b348fbd00e4 +F tool/sqldiff.c b4906b8a88252c94a77f2080f10c2624ba9b11f2577f25c1b29c3324a7a76c83 F tool/sqlite3_analyzer.c.in 7eeaae8b0d7577662acaabbb11107af0659d1b41bc1dfdd4d91422de27127968 F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898 F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848 @@ -1920,7 +1920,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 91bcb9621529b58d28e91a2763eb9eef3951400d5eaef105073258f3dd331872 -R 0cfa2cb9dd20ef662e91de1cc8d85fce -U drh -Z 13547b3fed83ea2295e7d5c9afd10815 +P 54eaf076c05887157179459ab39c2556953f6fef9c1b14f17a8aa74087da3023 +R a514ddb4ecddc8a67fe058834fe110d9 +U larrybr +Z 948d1027dff68e9d9c973736292e2ed9 diff --git a/manifest.uuid b/manifest.uuid index a66844c71c..f8be94e571 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -54eaf076c05887157179459ab39c2556953f6fef9c1b14f17a8aa74087da3023 \ No newline at end of file +68d2373f5d578cf3aff9d1ac4b1ab3ac00b466e94e1eb516523fc7660dfc0549 \ No newline at end of file diff --git a/tool/sqldiff.c b/tool/sqldiff.c index 9844cbadf0..fea40b9fe0 100644 --- a/tool/sqldiff.c +++ b/tool/sqldiff.c @@ -34,6 +34,7 @@ struct GlobalVars { int bSchemaOnly; /* Only show schema differences */ int bSchemaPK; /* Use the schema-defined PK, not the true PK */ int bHandleVtab; /* Handle fts3, fts4, fts5 and rtree vtabs */ + int bDarkCtl; /* Render controls in text as blob literals */ unsigned fDebug; /* Debug flags */ sqlite3 *db; /* The database connection */ } g; @@ -386,13 +387,39 @@ static void printQuoted(FILE *out, sqlite3_value *X){ fprintf(out, "NULL"); }else{ fprintf(out, "'"); - for(i=j=0; zArg[i]; i++){ - if( zArg[i]=='\'' ){ - fprintf(out, "%.*s'", i-j+1, &zArg[j]); - j = i+1; - } - } - fprintf(out, "%s'", &zArg[j]); + if( !g.bDarkCtl ){ + for(i=j=0; zArg[i]; i++){ + if( zArg[i]=='\'' ){ + fprintf(out, "%.*s'", i-j+1, &zArg[j]); + j = i+1; + } + } + fprintf(out, "%s'", &zArg[j]); + }else{ + int inctl = 0; + for(i=j=0; zArg[i]; i++){ + char c = zArg[i]; + int ctl = iscntrl(c); + if( ctl>inctl ){ + inctl = ctl; + fprintf(out, "%.*s'||X'%02x", i-j, &zArg[j], c); + j = i+1; + }else if( ctl ){ + fprintf(out, "%02x", c); + j = i+1; + }else{ + if( inctl ){ + inctl = 0; + fprintf(out, "'\n||'"); + } + if( c=='\'' ){ + fprintf(out, "%.*s'", i-j+1, &zArg[j]); + j = i+1; + } + } + } + fprintf(out, "%s'", &zArg[j]); + } } break; } @@ -1875,6 +1902,7 @@ static void showHelp(void){ " --table TAB Show only differences in table TAB\n" " --transaction Show SQL output inside a transaction\n" " --vtab Handle fts3, fts4, fts5 and rtree tables\n" +" --visible-controls Render controls in text as blob literals\n" ); } @@ -1948,6 +1976,9 @@ int main(int argc, char **argv){ if( strcmp(z,"vtab")==0 ){ g.bHandleVtab = 1; }else + if( strcmp(z, "visible-controls")==0 ){ + g.bDarkCtl = 1; + }else { cmdlineError("unknown option: %s", argv[i]); }