diff --git a/Makefile.in b/Makefile.in index 5abe3bf6d3..6fc821da23 100644 --- a/Makefile.in +++ b/Makefile.in @@ -694,8 +694,8 @@ sqlite3$(TEXE): shell.c sqlite3.c shell.c sqlite3.c \ $(LIBREADLINE) $(TLIBS) -rpath "$(libdir)" -sqldiff$(TEXE): $(TOP)/tool/sqldiff.c sqlite3.lo sqlite3.h - $(LTLINK) -o $@ $(TOP)/tool/sqldiff.c sqlite3.lo $(TLIBS) +sqldiff$(TEXE): $(TOP)/tool/sqldiff.c $(TOP)/ext/misc/sqlite3_stdio.h sqlite3.lo sqlite3.h + $(LTLINK) -I$(TOP)/ext/misc -o $@ $(TOP)/tool/sqldiff.c sqlite3.lo $(TLIBS) dbhash$(TEXE): $(TOP)/tool/dbhash.c sqlite3.lo sqlite3.h $(LTLINK) -o $@ $(TOP)/tool/dbhash.c sqlite3.lo $(TLIBS) diff --git a/Makefile.msc b/Makefile.msc index be6a771639..cc0285bb2c 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1861,8 +1861,8 @@ $(SQLITE3EXE): shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) $(SHELL_CORE_SRC) $(SQLIT /link $(SQLITE3EXEPDB) $(LDFLAGS) $(LTLINKOPTS) $(SHELL_LINK_OPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LIBREADLINE) $(LTLIBS) $(TLIBS) # <> -sqldiff.exe: $(TOP)\tool\sqldiff.c $(TOP)\ext\consio\console_io.h $(TOP)\ext\consio\console_io.c $(SQLITE3C) $(SQLITE3H) $(LIBRESOBJS) - $(LTLINK) $(NO_WARN) -I$(TOP)\ext\consio $(TOP)\tool\sqldiff.c $(TOP)\ext\consio\console_io.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) $(LIBRESOBJS) +sqldiff.exe: $(TOP)\tool\sqldiff.c $(TOP)\ext\misc\sqlite3_stdio.h $(TOP)\ext\misc\sqlite3_stdio.c $(SQLITE3C) $(SQLITE3H) $(LIBRESOBJS) + $(LTLINK) $(NO_WARN) -I$(TOP)\ext\misc $(TOP)\tool\sqldiff.c $(TOP)\ext\misc\sqlite3_stdio.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) $(LIBRESOBJS) dbhash.exe: $(TOP)\tool\dbhash.c $(SQLITE3C) $(SQLITE3H) $(LTLINK) $(NO_WARN) $(TOP)\tool\dbhash.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) diff --git a/ext/misc/sqlite3_stdio.c b/ext/misc/sqlite3_stdio.c index 0cfa26673a..6b7beff4e6 100644 --- a/ext/misc/sqlite3_stdio.c +++ b/ext/misc/sqlite3_stdio.c @@ -14,6 +14,19 @@ ** on Windows. */ #ifdef _WIN32 /* This file is a no-op on all platforms except Windows */ +#include "sqlite3_stdio.h" +#undef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include +#include +#include "sqlite3.h" +#include +#include +#include +#include /* ** Work-alike for the fopen() routine from the standard C library. @@ -68,7 +81,7 @@ FILE *sqlite3_popen(const char *zCommand, const char *zMode){ ** Work-alike for fgets() from the standard C library. */ char *sqlite3_fgets(char *buf, int sz, FILE *in){ - if( isatty(_fileno(in)) ){ + if( _isatty(_fileno(in)) ){ /* When reading from the command-prompt in Windows, it is necessary ** to use _O_WTEXT input mode to read UTF-16 characters, then translate ** that into UTF-8. Otherwise, non-ASCII characters all get translated @@ -95,7 +108,7 @@ char *sqlite3_fgets(char *buf, int sz, FILE *in){ ** Work-alike for fputs() from the standard C library. */ int sqlite3_fputs(const char *z, FILE *out){ - if( isatty(_fileno(out)) ){ + if( _isatty(_fileno(out)) ){ /* When writing to the command-prompt in Windows, it is necessary ** to use _O_WTEXT input mode and write UTF-16 characters. */ @@ -121,7 +134,7 @@ int sqlite3_fputs(const char *z, FILE *out){ */ int sqlite3_fprintf(FILE *out, const char *zFormat, ...){ int rc; - if( isatty(fileno(out)) ){ + if( _isatty(fileno(out)) ){ /* When writing to the command-prompt in Windows, it is necessary ** to use _O_WTEXT input mode and write UTF-16 characters. */ diff --git a/ext/misc/sqlite3_stdio.h b/ext/misc/sqlite3_stdio.h index 3014c1b287..dd0eefad04 100644 --- a/ext/misc/sqlite3_stdio.h +++ b/ext/misc/sqlite3_stdio.h @@ -26,6 +26,8 @@ ** also link in the accompanying sqlite3_stdio.c source file when compiling ** to get compatible interfaces. */ +#ifndef _SQLITE3_STDIO_H_ +#define _SQLITE3_STDIO_H_ 1 #ifdef _WIN32 /**** Definitions For Windows ****/ #include @@ -50,3 +52,4 @@ void sqlite3_fsetmode(FILE *stream, int mode); #define sqlite3_fsetmode(F,X) /*no-op*/ #endif +#endif /* _SQLITE3_STDIO_H_ */ diff --git a/main.mk b/main.mk index 2d616a6167..f0f41736d1 100644 --- a/main.mk +++ b/main.mk @@ -560,8 +560,8 @@ sqlite3$(EXE): sqlite3.h libsqlite3.a shell.c $(TCCX) $(READLINE_FLAGS) -o sqlite3$(EXE) $(SHELL_OPT) \ shell.c libsqlite3.a $(LIBREADLINE) $(TLIBS) $(THREADLIB) -sqldiff$(EXE): $(TOP)/tool/sqldiff.c sqlite3.c sqlite3.h - $(TCCX) -o sqldiff$(EXE) -DSQLITE_THREADSAFE=0 \ +sqldiff$(EXE): $(TOP)/tool/sqldiff.c $(TOP)/ext/misc/sqlite3_stdio.h sqlite3.c sqlite3.h + $(TCCX) -I$(TOP)/ext/misc -o sqldiff$(EXE) -DSQLITE_THREADSAFE=0 \ $(TOP)/tool/sqldiff.c sqlite3.c $(TLIBS) $(THREADLIB) dbhash$(EXE): $(TOP)/tool/dbhash.c sqlite3.c sqlite3.h diff --git a/manifest b/manifest index 5e7518fc0c..728db2c94e 100644 --- a/manifest +++ b/manifest @@ -1,11 +1,11 @@ -C Get\soutput\sredirection\sworking\sagain\sin\sthe\sCLI. -D 2024-09-24T16:09:50.466 +C Port\ssqldiff\sover\sto\suse\ssqlite3_stdio. +D 2024-09-24T17:40:54.086 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 -F Makefile.in a8e1d44a1166b6fb368effb19edc9adf7fede9225e9563352b9bb1989cd0150d +F Makefile.in 6a826facc78c3c8ad38bf00ed588f6aa3665ccd7a9749b891d20582fc290c77e F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6 -F Makefile.msc 1a5234794c9a5a71ba13fb47bcf031814d45b3ed6a56b4cb8e9f63fd32b4febe +F Makefile.msc 10fcf3b1eff1859846878469ffad1ebcd168fa0bd9e8a81f76ce65465b79e35d F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159 F VERSION 0db40f92c04378404eb45bff93e9e42c148c7e54fd3da99469ed21e22411f5a6 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -425,8 +425,8 @@ F ext/misc/shathree.c 1821d90a0040c9accdbe3e3527d378d30569475d758aa70f6848924c0b F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c c0aa7b80d6df45f7da59d912b38752bcac1af53a5766966160e6c5cdd397dbea F ext/misc/sqlar.c a6175790482328171da47095f87608b48a476d4fac78d8a9ff18b03a2454f634 -F ext/misc/sqlite3_stdio.c 4d4190eac193a8ea8fc3f8259e0996cf8e54254b4f4925d71e456e88165401d8 -F ext/misc/sqlite3_stdio.h ddefddeb448eee7fe2d41a828356a0019f813a4ced4ea2e97faa1d6c3e803742 +F ext/misc/sqlite3_stdio.c d9c7b3883788ef6e15134323783d6a3c69d2b453545a2aa60d8a3503bfeadcb7 +F ext/misc/sqlite3_stdio.h f05eaf5e0258f0573910324a789a9586fc360a57678c57a6d63cfaa2245b6176 F ext/misc/stmt.c b090086cd6bd6281c21271d38d576eeffe662f0e6b67536352ce32bbaa438321 F ext/misc/stmtrand.c 59cffa5d8e158943ff1ce078956d8e208e8c04e67307e8f249dece2436dcb7fc F ext/misc/templatevtab.c 10f15b165b95423ddef593bc5dcb915ec4eb5e0f1066d585e5435a368b8bc22b @@ -689,7 +689,7 @@ F ext/wasm/wasmfs.make 8a4955882aaa0783b3f60a9484a1f0f3d8b6f775c0fcd17c082f31966 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 -F main.mk dcb5cbba0ad64bd639b3e05d73d92e27c144a55bab9fca3460699602f4e9f4c2 +F main.mk 0a55ebec3508ca1bdb593d86f3aa19d7fa42a2ddd3220703e6dc0a65f1338a43 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 @@ -2175,7 +2175,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/spellsift.tcl 52b4b04dc4333c7ab024f09d9d66ed6b6f7c6eb00b38497a09f338fa55d40618 x F tool/split-sqlite3c.tcl 5aa60643afca558bc732b1444ae81a522326f91e1dc5665b369c54f09e20de60 -F tool/sqldiff.c 847fc8fcfddf5ce4797b7394cad6372f2f5dc17d8186e2ef8fb44d50fae4f44a +F tool/sqldiff.c 2a0987d183027c795ced13d6749061c1d2f38e24eddb428f56fa64c3a8f51e4b F tool/sqlite3-rsync.c 187b262035c1159b047dbfa1959c168b87b5a153b63465e8c8bd1b54fabf4460 F tool/sqlite3_analyzer.c.in 8da2b08f56eeac331a715036cf707cc20f879f231362be0c22efd682e2b89b4f F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898 @@ -2215,8 +2215,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fcd0ecffc9889f8c855ea340f075ec42cdca482df82d6e67dc9c32613e8d5846 -R bfd2b7dbaf4f82e5e4b17d1ed0ea1a8f +P 086034c3508d95e4f620c5e0580fae770e85410b0c8bd94f600fc0fd25088947 +R d688762d4b1334b98cdf41bc1c1c4c96 U drh -Z 5097f278634497c50b8747316810c634 +Z 9855069890c5f74ec21934036ad0fa9f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index ad785fcbcd..f7119b107e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -086034c3508d95e4f620c5e0580fae770e85410b0c8bd94f600fc0fd25088947 +18f784c47d4252bc3696a7e084a1afb9f51f006cf2021292f2103531b8235226 diff --git a/tool/sqldiff.c b/tool/sqldiff.c index 8b2293cafd..bb26daf139 100644 --- a/tool/sqldiff.c +++ b/tool/sqldiff.c @@ -14,7 +14,7 @@ ** between two SQLite databases. ** ** To compile, simply link against SQLite. (Windows builds must also link -** against ext/consio/console_io.c.) +** against ext/misc/sqlite3_stdio.c.) ** ** See the showHelp() routine below for a brief description of how to ** run the utility. @@ -26,19 +26,7 @@ #include #include #include "sqlite3.h" - -/* Output function substitutions that cause UTF8 characters to be rendered -** correctly on Windows: -** -** fprintf() -> Wfprintf() -** -*/ -#if defined(_WIN32) -# include "console_io.h" -# define Wfprintf fPrintfUtf8 -#else -# define Wfprintf fprintf -#endif +#include "sqlite3_stdio.h" /* ** All global variables are gathered into the "g" singleton. @@ -76,9 +64,9 @@ static void cmdlineError(const char *zFormat, ...){ va_start(ap, zFormat); sqlite3_str_vappendf(pOut, zFormat, ap); va_end(ap); - Wfprintf(stderr, "%s: %s\n", g.zArgv0, sqlite3_str_value(pOut)); + sqlite3_fprintf(stderr, "%s: %s\n", g.zArgv0, sqlite3_str_value(pOut)); strFree(pOut); - Wfprintf(stderr, "\"%s --help\" for more help\n", g.zArgv0); + sqlite3_fprintf(stderr, "\"%s --help\" for more help\n", g.zArgv0); exit(1); } @@ -92,7 +80,7 @@ static void runtimeError(const char *zFormat, ...){ va_start(ap, zFormat); sqlite3_str_vappendf(pOut, zFormat, ap); va_end(ap); - Wfprintf(stderr, "%s: %s\n", g.zArgv0, sqlite3_str_value(pOut)); + sqlite3_fprintf(stderr, "%s: %s\n", g.zArgv0, sqlite3_str_value(pOut)); strFree(pOut); exit(1); } @@ -349,11 +337,11 @@ static void printQuoted(FILE *out, sqlite3_value *X){ char zBuf[50]; r1 = sqlite3_value_double(X); sqlite3_snprintf(sizeof(zBuf), zBuf, "%!.15g", r1); - fprintf(out, "%s", zBuf); + sqlite3_fprintf(out, "%s", zBuf); break; } case SQLITE_INTEGER: { - fprintf(out, "%lld", sqlite3_value_int64(X)); + sqlite3_fprintf(out, "%lld", sqlite3_value_int64(X)); break; } case SQLITE_BLOB: { @@ -361,14 +349,14 @@ static void printQuoted(FILE *out, sqlite3_value *X){ int nBlob = sqlite3_value_bytes(X); if( zBlob ){ int i; - fprintf(out, "x'"); + sqlite3_fprintf(out, "x'"); for(i=0; iinctl ){ inctl = ctl; - fprintf(out, "%.*s'||X'%02x", i-j, &zArg[j], c); + sqlite3_fprintf(out, "%.*s'||X'%02x", i-j, &zArg[j], c); j = i+1; }else if( ctl ){ - fprintf(out, "%02x", c); + sqlite3_fprintf(out, "%02x", c); j = i+1; }else{ if( inctl ){ inctl = 0; - fprintf(out, "'\n||'"); + sqlite3_fprintf(out, "'\n||'"); } if( c=='\'' ){ - fprintf(out, "%.*s'", i-j+1, &zArg[j]); + sqlite3_fprintf(out, "%.*s'", i-j+1, &zArg[j]); j = i+1; } } } - fprintf(out, "%s'", &zArg[j]); + sqlite3_fprintf(out, "%s'", &zArg[j]); } break; } case SQLITE_NULL: { - fprintf(out, "NULL"); + sqlite3_fprintf(out, "NULL"); break; } } @@ -428,7 +416,7 @@ static void dump_table(const char *zTab, FILE *out){ pStmt = db_prepare("SELECT sql FROM aux.sqlite_schema WHERE name=%Q", zTab); if( SQLITE_ROW==sqlite3_step(pStmt) ){ - fprintf(out, "%s;\n", sqlite3_column_text(pStmt,0)); + sqlite3_fprintf(out, "%s;\n", sqlite3_column_text(pStmt,0)); } sqlite3_finalize(pStmt); if( !g.bSchemaOnly ){ @@ -463,14 +451,14 @@ static void dump_table(const char *zTab, FILE *out){ } nCol = sqlite3_column_count(pStmt); while( SQLITE_ROW==sqlite3_step(pStmt) ){ - Wfprintf(out, "%s",sqlite3_str_value(pIns)); + sqlite3_fprintf(out, "%s",sqlite3_str_value(pIns)); zSep = "("; for(i=0; i0 ) fprintf(out, ", "); + if( i>0 ) sqlite3_fprintf(out, ", "); printQuoted(out, sqlite3_column_value(pStmt, i)); } }else{ @@ -1320,9 +1308,9 @@ static void rbudiff_one_table(const char *zTab, FILE *out){ nDelta = rbuDeltaCreate(aSrc, nSrc, aFinal, nFinal, aDelta); if( nDelta