# if CIO_WIN_WC_XLATE
/* Define console modes for use with the Windows Console API. */
# define SHELL_CONI_MODE \
- (ENABLE_ECHO_INPUT | ENABLE_INSERT_MODE | ENABLE_LINE_INPUT | 0x80 \
+ (ENABLE_ECHO_INPUT | ENABLE_INSERT_MODE | ENABLE_LINE_INPUT \
| ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS | ENABLE_PROCESSED_INPUT)
# define SHELL_CONO_MODE (ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT \
| ENABLE_VIRTUAL_TERMINAL_PROCESSING)
}
# endif /* defined(CONSIO_EPUTB) */
+# if CIO_WIN_WC_XLATE
+
+
+/* Read up to two UTF-16 words.
+** Return 0 at EOF, 1 for ordinary UTF-16, or 2 for UTF-16 surrogate pair.
+** Buffer at *pwc must have at least 2 WCHAR slots remaining.
+*/
+static DWORD readConsoleCharacter(PerStreamTags *ppst, WCHAR *pwc){
+ DWORD ncr = 0;
+ BOOL bRC = ReadConsoleW(ppst->hx, pwc, 1, &ncr, 0);
+ if( !bRC || ncr == 0 ) return 0;
+ assert(ncr==1);
+ if( (pwc[0] & 0xF800)==0xD800 ){
+ DWORD ncrx;
+ /* WHAR just read leads a UTF-16 surrogate pair. Grab its mate. */
+ bRC = ReadConsoleW(ppst->hx, pwc+1, 1, &ncrx, 0);
+ if( !bRC || ncrx == 0 ) return 1;
+ ncr += ncrx;
+ }
+ return ncr;
+}
+# endif
+
SQLITE_INTERNAL_LINKAGE char* fGetsUtf8(char *cBuf, int ncMax, FILE *pfIn){
if( pfIn==0 ) pfIn = stdin;
# if CIO_WIN_WC_XLATE
if( pfIn == consoleInfo.pstSetup[0].pf
&& (consoleInfo.sacSetup & SAC_InConsole)!=0 ){
# if CIO_WIN_WC_XLATE==1
-# define SHELL_GULP 150 /* Count of WCHARS to be gulped at a time */
- WCHAR wcBuf[SHELL_GULP+1];
+ WCHAR wcBuf[2];
int lend = 0, noc = 0;
if( ncMax > 0 ) cBuf[0] = 0;
- while( noc < ncMax-8-1 && !lend ){
- /* There is room for at least 2 more characters and a 0-terminator. */
- int na = (ncMax > SHELL_GULP*4+1 + noc)? SHELL_GULP : (ncMax-1 - noc)/4;
-# undef SHELL_GULP
- DWORD nbr = 0;
- BOOL bRC = ReadConsoleW(consoleInfo.pstSetup[0].hx, wcBuf, na, &nbr, 0);
- if( bRC && nbr>0 && (wcBuf[nbr-1]&0xF800)==0xD800 ){
- /* Last WHAR read is first of a UTF-16 surrogate pair. Grab its mate. */
- DWORD nbrx;
- bRC &= ReadConsoleW(consoleInfo.pstSetup[0].hx, wcBuf+nbr, 1, &nbrx, 0);
- if( bRC ) nbr += nbrx;
+ while( noc < ncMax-4-1 && !lend ){
+ /* Have room for at least 1 more UTF-8 character and a 0-terminator. */
+ DWORD ncr = readConsoleCharacter(&consoleInfo.pstSetup[0], wcBuf);
+ WCHAR wc = wcBuf[0];
+ if( ncr==0 ) break;
+ assert(ncr <= 2);
+ if( wc>=L'\x80' || ncr>1 ){
+ int nmb = WideCharToMultiByte(CP_UTF8, 0, wcBuf,ncr,cBuf+noc,4,0,0);
+ noc += nmb;
+ }else{
+ switch( wc ){
+ case L'\n': lend = 1; break;
+ case L'\x1a': lend = 1; continue;
+ case L'\r': continue;
+ default: break;
+ }
+ cBuf[noc++] = (char)wc;
}
- if( !bRC || (noc==0 && nbr==0) ) return 0;
- if( nbr > 0 ){
- int nmb = WideCharToMultiByte(CP_UTF8, 0, wcBuf,nbr,0,0,0,0);
- if( nmb != 0 && noc+nmb <= ncMax ){
- int iseg = noc;
- nmb = WideCharToMultiByte(CP_UTF8, 0, wcBuf,nbr,cBuf+noc,nmb,0,0);
- noc += nmb;
- /* Fixup line-ends as coded by Windows for CR (or "Enter".)
- ** This is done without regard for any setMode{Text,Binary}()
- ** call that might have been done on the interactive input.
- */
- if( noc > 0 ){
- if( cBuf[noc-1]=='\n' ){
- lend = 1;
- if( noc > 1 && cBuf[noc-2]=='\r' ) cBuf[--noc-1] = '\n';
- }
- }
- /* Check for ^Z (anywhere in line) too, to act as EOF. */
- while( iseg < noc ){
- if( cBuf[iseg]=='\x1a' ){
- noc = iseg; /* Chop ^Z and anything following. */
- lend = 1; /* Counts as end of line too. */
- break;
- }
- ++iseg;
- }
- }else break; /* Drop apparent garbage in. (Could assert.) */
- }else break;
}
/* If got nothing, (after ^Z chop), must be at end-of-file. */
if( noc > 0 ){
-C Get\sall\sCLI\sprint\scalls\swhich\swent\sto\sstdout\sin\s3.44.0\sto\sdo\sso\sagain.
-D 2023-11-24T16:17:54.443
+C Pickup\sstray\soput?()\scalls\sthat\sshould\shave\sgone\sto\sstdout.\sSimplify\sconsole\sline\sreading,\ssacrificing\sspeed\s(which\sdoes\snot\smatter\sthen)\sfor\scode\ssize.
+D 2023-11-27T15:08:50.454
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F ext/async/README.txt e12275968f6fde133a80e04387d0e839b0c51f91
F ext/async/sqlite3async.c 6f247666b495c477628dd19364d279c78ea48cd90c72d9f9b98ad1aff3294f94
F ext/async/sqlite3async.h 46b47c79357b97ad85d20d2795942c0020dc20c532114a49808287f04aa5309a
-F ext/consio/console_io.c 0526efac68e8dda2bbeb3b5be4e68252903f305e001fd954dfd0552dd84048dd x
-F ext/consio/console_io.h d9ba2de923f11348919cccc2ba161ccbf2e417b866d2b7d072329e6c702eb242
+F ext/consio/console_io.c 274bff35fe8dd94c7428393c92e336bf84e693e1dacfd26f4edd55e766c6c11c x
+F ext/consio/console_io.h 030661ee4ed0dae5d3a8309b15a8e81a0f83b2d3d5fdb02b20748a5f1bf50e16
F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3
F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4
F ext/expert/expert1.test 0dd5cb096d66bed593e33053a3b364f6ef52ed72064bf5cf298364636dbf3cd6
F src/resolve.c d017bad7ba8e778617701a0e986fdeb393d67d6afa84fb28ef4e8b8ad2acf916
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
F src/select.c 85857bedd2913d888aa571755b48c54cd2e6e7fcb0087e19b226ee0368cfda1e
-F src/shell.c.in 7bb83293775e1a5586d65212997442bc7acc70a2f1b781745da64ec3c2e4ea97
+F src/shell.c.in a731aa9fe56329a093dae62296e98f0bb2ea8bdb771032238992dd137a865950
F src/sqlite.h.in d93a4821d2f792467a60f7dc81268d1bb8634f40c31694ef254cab4f9921f96a
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 3a8a75bfd20bd819cd4d748a9023edc10c06ec164213cc989b0aad70c6750447
+P d65d9579ee6e1f2270917213d2b6bc25b66182a33176b2df50c691e02e612b0c
Q +e9951ede184ce07cf725152723d795f299922460715ab76225cd3071bf0f18ee
-R 86f87236c92e47405070a2eebda8f546
+R 9e56423e4aab5da81ec6b75e9ca1e2d0
U larrybr
-Z f19122c057a9a6fb73c16943abe8418e
+Z 8a82498f1d45fd5c83b1705256102297
# Remove this line to create a well-formed Fossil manifest.