From: larrybr Date: Fri, 20 Sep 2024 17:38:35 +0000 (+0000) Subject: Passing shell tests on Linux and Windows. A number of FILE* API content transfer... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fwin-dupe-crt-fio;p=thirdparty%2Fsqlite.git Passing shell tests on Linux and Windows. A number of FILE* API content transfer calls are diverted to the consio library via macros. FossilOrigin-Name: 15465462872d22028f5e954e399c2431854e4ec56436061c74250ed73c1980f7 --- diff --git a/ext/consio/console_io.c b/ext/consio/console_io.c index d059a02674..503d479b71 100755 --- a/ext/consio/console_io.c +++ b/ext/consio/console_io.c @@ -779,6 +779,23 @@ SQLITE_INTERNAL_LINKAGE char* fGetsUtf8(char *cBuf, int ncMax, FILE *pfIn){ return fgets(cBuf, ncMax, pfIn); # endif } + +# if CIO_WIN_WC_XLATE && !defined(SQLITE_CIO_NO_FGETC) +SQLITE_INTERNAL_LINKAGE int fGetCh(FILE *pfIn){ + struct FileAltIds fai = altIdsOfFile(pfIn); + int fmode = _setmode(fai.fd, _O_BINARY); + BOOL eatCR = (fmode & _O_TEXT)!=0; + _setmode(fai.fd, fmode); + while( 1 ){ + DWORD nr, rf; + char ci; + rf = ReadFile(fai.fh, &ci, 1, &nr, 0); + if( !rf || nr<1 ) return -1; + if( !eatCR || ci!='\r' ) return (int)(unsigned char)ci; + } +} +# endif + #endif /* !defined(SQLITE_CIO_NO_TRANSLATE) */ #if defined(_MSC_VER) diff --git a/ext/consio/console_io.h b/ext/consio/console_io.h index 7950be8a5a..412db69fd4 100644 --- a/ext/consio/console_io.h +++ b/ext/consio/console_io.h @@ -283,5 +283,48 @@ shellGetLine(FILE *pfIn, char *zBufPrior, int nLen, */ SQLITE_INTERNAL_LINKAGE const char* zSkipValidUtf8(const char *z, int nAccept, long ccm); +#endif + +#if !defined(SQLITE_CIO_NO_TRANSLATE) \ + && (defined(_WIN32) || defined(WIN32)) && !SQLITE_OS_WINRT +/* For Win32 builds, block most FILE* API content transfers. */ +# define getc() assert(0) +# define fputc(c,fp) assert(0) +# define putc(c,fp) assert(0) +# define getchar() assert(0) +# define gets() assert(0) +# define putchar(c) assert(0) +# define ungetc(c,fp) assert(0) +# define scanf assert(0) +# define fscanf assert(0) +# define vscanf assert(0) +# define vfscanf assert(0) + +/* Leave ftell, fgetpos, fseek, fsetpos, rewind, fread and fwrite alone. + * They are used in the ext/misc/fileio.c extension embedded in the CLI. + */ + +/* Block feof because we do not trust it mixed with Win32 file I/O. */ +# define feof(fp) assert(0) + +/* Divert a few FILE* content transfers which have good substitutes. */ +# define fflush(fp) fFlushBuffer(fp) +# define fgets(b,n,fp) fGetsUtf8(b,n,fp) +# define fputs fPutsUtf8 +# define puts(z) oPutsUtf8(z) +# define printf oPrintfUtf8 +# define fprintf fPrintfUtf8 + +# ifndef SQLITE_CIO_NO_FGETC +/* As a dispensation for .import's char-at-a-time parsing, provide an + * equivalent which gets them via ReadFile(), without UTF-8 translation. + * They could (conceivably) come from the console, with odd results. + */ +SQLITE_INTERNAL_LINKAGE int fGetCh(FILE *pfIn); +# define fgetc(fp) fGetCh(fp) +# else +# define fgetc(fp) assert(0),0 +# endif + #endif diff --git a/manifest b/manifest index 3937d344e1..ce84f7ff0b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sflub\sin\scfWrite().\s(for\sWin32) -D 2024-09-20T14:18:36.348 +C Passing\sshell\stests\son\sLinux\sand\sWindows.\sA\snumber\sof\sFILE*\sAPI\scontent\stransfer\scalls\sare\sdiverted\sto\sthe\sconsio\slibrary\svia\smacros. +D 2024-09-20T17:38:35.583 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -53,8 +53,8 @@ F ext/README.md fd5f78013b0a2bc6f0067afb19e6ad040e89a10179b4f6f03eee58fac5f169bd F ext/async/README.txt e12275968f6fde133a80e04387d0e839b0c51f91 F ext/async/sqlite3async.c 6f247666b495c477628dd19364d279c78ea48cd90c72d9f9b98ad1aff3294f94 F ext/async/sqlite3async.h 46b47c79357b97ad85d20d2795942c0020dc20c532114a49808287f04aa5309a -F ext/consio/console_io.c 056c5617c7aabdddf10dcb7483d354671131577574c6a06da4832ac78c3c5000 x -F ext/consio/console_io.h 6212909529c4ab3deeeee29db2d0b2b9cd5c881cc9dd51dede079273ce91db3d +F ext/consio/console_io.c 378fb431bf8b5c6a53907f0bd894d6a089dd74660af47ca395bfb465d8e9775a x +F ext/consio/console_io.h 0dd700d9082162470dc841647fbffef991a04664fa27d1f04577934b0003a98f F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3 F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4 F ext/expert/expert1.test 661f873fd451127edf822ef0d520088faa319135f6a15bd10be6801ac284ac9b @@ -768,7 +768,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 2c127880c0634962837f16f2f48a295e514357af959330cc038de73015d5b5e8 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe -F src/shell.c.in 375f8a183126be96ec73db4e42c57917ff10a0900846b1b722dd4f8cef537812 +F src/shell.c.in 110e3977c521d952f123ee1e0f9fc0c73835a56d637c98426e4264cd54d52a36 F src/sqlite.h.in 77f55bd1978a04a14db211732f0a609077cf60ba4ccf9baf39988f508945419c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2213,8 +2213,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 187f1d0a1c375db4bbf5bbdb29295578c891b9cb25e890e1f9bed364f2938055 -R 75ec56560f3199f8903e5143b2f08961 +P 3884ddb4dce9ab44ba43d5fcbd3552c0012b99916d004c35d234d7976d366422 +R 64c5054ee107f171cc96fb9d4cc87bfa U larrybr -Z 049f72b085c539c3c77e6149a5b2d84e +Z dead5ee45b381ba006427d581799756f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a182b9ac45..286359605b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3884ddb4dce9ab44ba43d5fcbd3552c0012b99916d004c35d234d7976d366422 +15465462872d22028f5e954e399c2431854e4ec56436061c74250ed73c1980f7 diff --git a/src/shell.c.in b/src/shell.c.in index 2b0e506ed8..88089e1be9 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -253,8 +253,6 @@ INCLUDE ../ext/consio/console_io.c #ifndef SQLITE_SHELL_FIDDLE -/* From here onward, fgets() is redirected to the console_io library. */ -# define fgets(b,n,f) fGetsUtf8(b,n,f) /* * Define macros for emitting output text in various ways: * sputz(s, z) => emit 0-terminated string z to given stream s @@ -280,7 +278,6 @@ INCLUDE ../ext/consio/console_io.c # define eputz(z) ePutsUtf8(z) # define eputf ePrintfUtf8 # define oputb(buf,na) oPutbUtf8(buf,na) -# define fflush(s) fFlushBuffer(s); #else /* For Fiddle, all console handling and emit redirection is omitted. */