Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Use Win32 APIs to read/write the console in Windows unless the SQLITE_USE_STDIO_FOR_CONSOLE option is defined. This is an attempt to get the build working on MinGW. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
abfe488ed67e2e3510c230e656ecf203 |
User & Date: | drh 2024-11-11 17:02:29 |
References
2025-01-28
| ||
01:10 | Apparently I got the logic of [abfe488ed67e2e35] confused, even backwards. Change it so that the SQLITE_USE_W32_FOR_CONSOLE_IO macro causes Win32 APIs to be used for console I/O and for stdio to be used otherwise. This is reported to be necessary for builds that use a C-language runtime other than the one provided by Microsoft. This changes if for Windows only. It is a bug fix, though we don't have a test case that will demonstrate a malfunction. (check-in: 925e97e6 user: drh tags: trunk) | |
2025-01-17
| ||
10:39 | Fix a potential one-byte buffer overrun when reading from the Windows console in the CLI. Forum post 95e17b8f5c. This problem was introduced by check-in [abfe488ed67e2e35], which was an attempt to get the Windows build working on MingGW. (check-in: 4d967596 user: drh tags: trunk) | |
Context
2024-11-11
| ||
18:15 | Wrap some exceptionally long lines in main.mk. Add option to override LDFLAGS on the sqlite3.dll target. Audit: all targets for which it is hypothetically relevant can now inherit user-supplied LDFLAGS, but only those provided to the configure script, not at make-time, in order to mimic the historical build's restriction in that regard. (check-in: 073080ca user: stephan tags: trunk) | |
17:02 | Use Win32 APIs to read/write the console in Windows unless the SQLITE_USE_STDIO_FOR_CONSOLE option is defined. This is an attempt to get the build working on MinGW. (check-in: abfe488e user: drh tags: trunk) | |
09:53 | Doc update to account for [05073350087b]. (check-in: b81976c5 user: stephan tags: trunk) | |
Changes
Changes to ext/misc/sqlite3_stdio.c.
︙ | ︙ | |||
144 145 146 147 148 149 150 | /* 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 ** into '?'. */ wchar_t *b1 = sqlite3_malloc( sz*sizeof(wchar_t) ); if( b1==0 ) return 0; | > > > > > > > > > | | | | > | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | /* 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 ** into '?'. */ wchar_t *b1 = sqlite3_malloc( sz*sizeof(wchar_t) ); if( b1==0 ) return 0; #ifndef SQLITE_USE_STDIO_FOR_CONSOLE DWORD nRead = 0; if( IsConsole(in) && ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz, &nRead, 0) ){ b1[nRead] = 0; }else #endif { _setmode(_fileno(in), IsConsole(in) ? _O_WTEXT : _O_U8TEXT); if( fgetws(b1, sz/4, in)==0 ){ sqlite3_free(b1); return 0; } } WideCharToMultiByte(CP_UTF8, 0, b1, -1, buf, sz, 0, 0); sqlite3_free(b1); return buf; }else{ /* Reading from a file or other input source, just read bytes without ** any translation. */ |
︙ | ︙ | |||
203 204 205 206 207 208 209 | */ int sqlite3_fputs(const char *z, FILE *out){ if( !UseWtextForOutput(out) ){ /* Writing to a file or other destination, just write bytes without ** any translation. */ return fputs(z, out); }else{ | | | < > > > > > > > > > > > > > | | | | | > | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | */ int sqlite3_fputs(const char *z, FILE *out){ if( !UseWtextForOutput(out) ){ /* Writing to a file or other destination, just write bytes without ** any translation. */ return fputs(z, out); }else{ /* One must use UTF16 in order to get unicode support when writing ** to the console on Windows. */ int sz = (int)strlen(z); wchar_t *b1 = sqlite3_malloc( (sz+1)*sizeof(wchar_t) ); if( b1==0 ) return 0; sz = MultiByteToWideChar(CP_UTF8, 0, z, sz, b1, sz); b1[sz] = 0; #ifndef SQLITE_STDIO_FOR_CONSOLE DWORD nWr = 0; if( IsConsole(out) && WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE),b1,sz,&nWr,0) ){ /* If writing to the console, then the WriteConsoleW() is all we ** need to do. */ }else #endif { /* For non-console I/O, or if SQLITE_USE_STDIO_FOR_CONSOLE is defined ** then write using the standard library. */ _setmode(_fileno(out), _O_U8TEXT); if( UseBinaryWText(out) ){ piecemealOutput(b1, sz, out); }else{ fputws(b1, out); } } sqlite3_free(b1); return 0; } } |
︙ | ︙ |