1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-12-24 14:17:58 +03:00

Remove SHELL_LEGACY_CONSOLE_IO PP symbol and code it made active. (It is in the repo if ever needed/wanted, but it is just inferior or dead code now.)

FossilOrigin-Name: 27c5bf6563bc24ba7b47865e8d2f3e2d439666e19038d86dd8445fcdb9abe97a
This commit is contained in:
larrybr
2023-11-11 22:53:55 +00:00
parent 1bcb7c4902
commit ea80462c10
3 changed files with 8 additions and 118 deletions

View File

@@ -36,11 +36,7 @@
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# endif
# ifdef SHELL_LEGACY_CONSOLE_IO
# define SHELL_CON_TRANSLATE 2 /* Use UTF-8/MBCS translation for console I/O */
# else
# define SHELL_CON_TRANSLATE 1 /* Use WCHAR Windows APIs for console I/O */
# endif
# define SHELL_CON_TRANSLATE 1 /* Use WCHAR Windows APIs for console I/O */
#else
# ifndef SHELL_NO_SYSINC
# include <unistd.h>
@@ -152,9 +148,6 @@ static void maybeSetupAsConsole(PerStreamTags *ppst, short odir){
if( pstReachesConsole(ppst) ){
DWORD cm = odir? SHELL_CONO_MODE : SHELL_CONI_MODE;
SetConsoleMode(ppst->hx, cm);
# if SHELL_CON_TRANSLATE == 2
_setmode(_fileno(ppst->pf), _O_TEXT);
# endif
}
#else
(void)ppst;
@@ -186,9 +179,6 @@ consoleClassifySetup( FILE *pfIn, FILE *pfOut, FILE *pfErr ){
}
consoleInfo.pstDesignated[ix] = *ppst;
if( ix > 0 ) fflush(apf[ix]);
#if SHELL_CON_TRANSLATE == 2
_setmode(_fileno(apf[ix]), _O_TEXT);
#endif
}
consoleInfo.sacSetup = rv;
consoleRenewSetup();
@@ -203,15 +193,6 @@ SQLITE_INTERNAL_LINKAGE void SQLITE_CDECL consoleRestore( void ){
for( ix=0; ix<3; ++ix ){
if( pci->sacSetup & (SAC_InConsole<<ix) ){
PerStreamTags *ppst = &pci->pstSetup[ix];
# if SHELL_CON_TRANSLATE == 2
static int tmode = _O_TEXT;
/* Consider: Read this mode in consoleClassifySetup somehow.
** A _get_fmode() call almost works. But not with gcc, yet.
** This has to be done to make the CLI a callable function
** when legacy console I/O is done. (This may never happen.)
*/
_setmode(_fileno(pci->pstSetup[ix].pf), tmode);
# endif
SetConsoleMode(ppst->hx, ppst->consMode);
}
}
@@ -297,15 +278,6 @@ static int conioZstrOut(PerStreamTags *ppst, const char *z){
if( z!=NULL && *z!=0 ){
int nc;
int nwc;
# if SHELL_CON_TRANSLATE == 2
UINT cocp = GetConsoleOutputCP();
FILE *pfO = ppst->pf;
if( cocp == CP_UTF8 ){
/* This is not legacy action. But it can work better,
** when the console putatively can handle UTF-8. */
return fputs(z, pfO)<0 ? 0 : (int)strlen(z);
}
# endif
nc = (int)strlen(z);
nwc = MultiByteToWideChar(CP_UTF8,0, z,nc, 0,0);
if( nwc > 0 ){
@@ -313,24 +285,10 @@ static int conioZstrOut(PerStreamTags *ppst, const char *z){
if( zw!=NULL ){
nwc = MultiByteToWideChar(CP_UTF8,0, z,nc, zw,nwc);
if( nwc > 0 ){
# if SHELL_CON_TRANSLATE == 2
/* Legacy translation to active code page, then MBCS out. */
rv = WideCharToMultiByte(cocp,0, zw,nwc, 0,0, 0,0);
if( rv != 0 ){
char *zmb = sqlite3_malloc64(rv+1);
if( zmb != NULL ){
rv = WideCharToMultiByte(cocp,0, zw,nwc, zmb,rv, 0,0);
zmb[rv] = 0;
if( fputs(zmb, pfO)<0 ) rv = 0;
sqlite3_free(zmb);
}
}
# elif SHELL_CON_TRANSLATE == 1
/* Translation from UTF-8 to UTF-16, then WCHARs out. */
if( WriteConsoleW(ppst->hx, zw,nwc, 0, NULL) ){
rv = nc;
}
# endif
}
sqlite3_free(zw);
}
@@ -531,19 +489,6 @@ SQLITE_INTERNAL_LINKAGE int ePutcUtf8(int ch){
}
#endif
#if SHELL_CON_TRANSLATE==2
static int mbcsToUtf8InPlaceIfValid(char *pc, int nci, int nco, UINT codePage){
WCHAR wcOneCode[2];
int nuo = 0;
int nwConvert = MultiByteToWideChar(codePage, MB_ERR_INVALID_CHARS,
pc, nci, wcOneCode, 2);
if( nwConvert > 0 ){
nuo = WideCharToMultiByte(CP_UTF8, 0, wcOneCode, nwConvert, pc, nco, 0,0);
}
return nuo;
}
#endif
SQLITE_INTERNAL_LINKAGE char* fGetsUtf8(char *cBuf, int ncMax, FILE *pfIn){
if( pfIn==0 ) pfIn = stdin;
#if SHELL_CON_TRANSLATE
@@ -600,61 +545,6 @@ SQLITE_INTERNAL_LINKAGE char* fGetsUtf8(char *cBuf, int ncMax, FILE *pfIn){
cBuf[noc] = 0;
return cBuf;
}else return 0;
# elif SHELL_CON_TRANSLATE==2
/* This is not done efficiently because it may never be used.
** Also, it is interactive input so it need not be fast. */
int nco = 0;
/* For converstion to WCHAR, or pre-test of same. */
UINT cicp = GetConsoleCP(); /* For translation from mbcs. */
/* If input code page is CP_UTF8, must bypass MBCS input
** collection because getc() returns 0 for non-ASCII byte
** Instead, use fgets() which repects character boundaries. */
if( cicp == CP_UTF8 ) return fgets(cBuf, ncMax, pfIn);
while( ncMax-nco >= 5 ){
/* Have space for max UTF-8 group and 0-term. */
int nug = 0;
int c = getc(pfIn);
if( c < 0 ){
if( nco > 0 ) break;
else return 0;
}
cBuf[nco] = (char)c;
if( c < 0x80 ){
++nco;
if( c == '\n' ) break;
continue;
}
/* Deal with possible mbcs lead byte. */
nug = mbcsToUtf8InPlaceIfValid(cBuf+nco, 1, ncMax-nco-1, cicp);
if( nug > 0 ){
nco += nug;
}else{
/* Must have just mbcs lead byte; get the trail byte(s). */
int ntb = 1, ct;
while( ntb <= 3 ){ /* No more under any multi-byte code. */
ct = getc(pfIn);
if( ct < 0 || ct == '\n' ){
/* Just drop whatever garbage preceded the newline or.
** EOF. It's not valid, should not happen, and there
** is no good way to deal with it, short of bailing. */
if( ct > 0 ){
cBuf[nco++] = (int)ct;
}
break;
}
/* Treat ct as bona fide MBCS trailing byte, if valid. */
cBuf[nco+ntb] = ct;
nug = mbcsToUtf8InPlaceIfValid(cBuf+nco, 1+ntb, ncMax-nco-1, cicp);
if( nug > 0 ){
nco += nug;
break;
}
}
if( ct < 0 ) break;
}
}
cBuf[nco] = 0;
return cBuf;
# endif
}else{
#endif

View File

@@ -1,5 +1,5 @@
C Complete\sshell\stransition\sto\susing\s{f,o,e}put{f,z}()\semit\sfunctions.\sThis\sfails\stest\s13.1\sin\sjson501.test,\sbut\sso\sdoes\strunk\sin\sthe\ssame\sway.
D 2023-11-11T20:46:12.670
C Remove\sSHELL_LEGACY_CONSOLE_IO\sPP\ssymbol\sand\scode\sit\smade\sactive.\s(It\sis\sin\sthe\srepo\sif\sever\sneeded/wanted,\sbut\sit\sis\sjust\sinferior\sor\sdead\scode\snow.)
D 2023-11-11T22:53:55.698
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -50,7 +50,7 @@ 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 0b07826bc3cceb10b12f5a3701fc1540154916a845de003d87c447c8a68c5ba7 x
F ext/consio/console_io.c 20cd3ee900facdbe6ef39670b4135ede6822839beb7c858d8d6a3c1618be0012 x
F ext/consio/console_io.h ec611fe8f08645d69cb18d46ab2a09c4653f2fc13ecb04c18e6012d8ea89c463
F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3
F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4
@@ -2141,8 +2141,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 79d1f2c1019964dd154fbdd3f349822cb946a2600883994523ed145047f0a9ea 0832f9a8e9f574b157c791c5cddc73aff7b2ff403509f5d78f310494d4a7f93d
R fd4407aafdd7492d23f3b236cddd5186
P 923c6b8b3a508c715b816c6bcd2ae9ac519bc37a62afc4ef813085c00f1e7cb6
R 0bbf95d43c90eb82b70dc5a47c05dada
U larrybr
Z cce7495ad383169e7382f36018db3c19
Z 6b063716f7dfd90dd364e5381d9a3551
# Remove this line to create a well-formed Fossil manifest.

View File

@@ -1 +1 @@
923c6b8b3a508c715b816c6bcd2ae9ac519bc37a62afc4ef813085c00f1e7cb6
27c5bf6563bc24ba7b47865e8d2f3e2d439666e19038d86dd8445fcdb9abe97a