Fossil SCM
Back out the [ab934c6b09fd1d5] change. Do not change the console output mode using SetConsoleOutputCP(). Go back to converting UTF8 into MBCS upon output.
Commit
b33032ae401a8d6cfdc6d27f1699d28386710364
Parent
2278ef0ffae6c9c…
2 files changed
-6
+16
-6
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -23,13 +23,10 @@ | ||
| 23 | 23 | #include <string.h> |
| 24 | 24 | #include <time.h> |
| 25 | 25 | #include <fcntl.h> |
| 26 | 26 | #include <sys/types.h> |
| 27 | 27 | #include <sys/stat.h> |
| 28 | -#ifdef _WIN32 | |
| 29 | -#include <windows.h> | |
| 30 | -#endif | |
| 31 | 28 | |
| 32 | 29 | |
| 33 | 30 | #if INTERFACE |
| 34 | 31 | |
| 35 | 32 | /* |
| @@ -236,14 +233,11 @@ | ||
| 236 | 233 | |
| 237 | 234 | sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0); |
| 238 | 235 | g.now = time(0); |
| 239 | 236 | g.argc = argc; |
| 240 | 237 | g.argv = argv; |
| 241 | -#if defined(_WIN32) | |
| 242 | 238 | for(i=0; i<argc; i++) g.argv[i] = fossil_mbcs_to_utf8(argv[i]); |
| 243 | - SetConsoleOutputCP(65001); | |
| 244 | -#endif | |
| 245 | 239 | if( getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){ |
| 246 | 240 | zCmdName = "cgi"; |
| 247 | 241 | }else if( argc<2 ){ |
| 248 | 242 | fossil_fatal("Usage: %s COMMAND ...\n" |
| 249 | 243 | "\"%s help\" for a list of available commands\n" |
| 250 | 244 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -23,13 +23,10 @@ | |
| 23 | #include <string.h> |
| 24 | #include <time.h> |
| 25 | #include <fcntl.h> |
| 26 | #include <sys/types.h> |
| 27 | #include <sys/stat.h> |
| 28 | #ifdef _WIN32 |
| 29 | #include <windows.h> |
| 30 | #endif |
| 31 | |
| 32 | |
| 33 | #if INTERFACE |
| 34 | |
| 35 | /* |
| @@ -236,14 +233,11 @@ | |
| 236 | |
| 237 | sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0); |
| 238 | g.now = time(0); |
| 239 | g.argc = argc; |
| 240 | g.argv = argv; |
| 241 | #if defined(_WIN32) |
| 242 | for(i=0; i<argc; i++) g.argv[i] = fossil_mbcs_to_utf8(argv[i]); |
| 243 | SetConsoleOutputCP(65001); |
| 244 | #endif |
| 245 | if( getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){ |
| 246 | zCmdName = "cgi"; |
| 247 | }else if( argc<2 ){ |
| 248 | fossil_fatal("Usage: %s COMMAND ...\n" |
| 249 | "\"%s help\" for a list of available commands\n" |
| 250 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -23,13 +23,10 @@ | |
| 23 | #include <string.h> |
| 24 | #include <time.h> |
| 25 | #include <fcntl.h> |
| 26 | #include <sys/types.h> |
| 27 | #include <sys/stat.h> |
| 28 | |
| 29 | |
| 30 | #if INTERFACE |
| 31 | |
| 32 | /* |
| @@ -236,14 +233,11 @@ | |
| 233 | |
| 234 | sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0); |
| 235 | g.now = time(0); |
| 236 | g.argc = argc; |
| 237 | g.argv = argv; |
| 238 | for(i=0; i<argc; i++) g.argv[i] = fossil_mbcs_to_utf8(argv[i]); |
| 239 | if( getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){ |
| 240 | zCmdName = "cgi"; |
| 241 | }else if( argc<2 ){ |
| 242 | fossil_fatal("Usage: %s COMMAND ...\n" |
| 243 | "\"%s help\" for a list of available commands\n" |
| 244 |
+16
| --- src/printf.c | ||
| +++ src/printf.c | ||
| @@ -806,11 +806,27 @@ | ||
| 806 | 806 | ** On windows, transform the output into the current terminal encoding |
| 807 | 807 | ** if the output is going to the screen. If output is redirected into |
| 808 | 808 | ** a file, no translation occurs. No translation ever occurs on unix. |
| 809 | 809 | */ |
| 810 | 810 | void fossil_puts(const char *z, int toStdErr){ |
| 811 | +#if defined(_WIN32) | |
| 812 | + extern char *sqlite3_win32_utf8_to_mbcs(const char*); | |
| 813 | + static int once = 1; | |
| 814 | + static int istty[2]; | |
| 815 | + char *zToFree = 0; | |
| 816 | + if( once ){ | |
| 817 | + istty[0] = _isatty(fileno(stdout)); | |
| 818 | + istty[1] = _isatty(fileno(stderr)); | |
| 819 | + once = 0; | |
| 820 | + } | |
| 821 | + assert( toStdErr==0 || toStdErr==1 ); | |
| 822 | + if( istty[toStdErr] ) z = zToFree = sqlite3_win32_utf8_to_mbcs(z); | |
| 823 | + fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout); | |
| 824 | + free(zToFree); | |
| 825 | +#else | |
| 811 | 826 | fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout); |
| 827 | +#endif | |
| 812 | 828 | } |
| 813 | 829 | |
| 814 | 830 | /* |
| 815 | 831 | ** Write output for user consumption. If g.cgiOutput is enabled, then |
| 816 | 832 | ** send the output as part of the CGI reply. If g.cgiOutput is false, |
| 817 | 833 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -806,11 +806,27 @@ | |
| 806 | ** On windows, transform the output into the current terminal encoding |
| 807 | ** if the output is going to the screen. If output is redirected into |
| 808 | ** a file, no translation occurs. No translation ever occurs on unix. |
| 809 | */ |
| 810 | void fossil_puts(const char *z, int toStdErr){ |
| 811 | fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout); |
| 812 | } |
| 813 | |
| 814 | /* |
| 815 | ** Write output for user consumption. If g.cgiOutput is enabled, then |
| 816 | ** send the output as part of the CGI reply. If g.cgiOutput is false, |
| 817 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -806,11 +806,27 @@ | |
| 806 | ** On windows, transform the output into the current terminal encoding |
| 807 | ** if the output is going to the screen. If output is redirected into |
| 808 | ** a file, no translation occurs. No translation ever occurs on unix. |
| 809 | */ |
| 810 | void fossil_puts(const char *z, int toStdErr){ |
| 811 | #if defined(_WIN32) |
| 812 | extern char *sqlite3_win32_utf8_to_mbcs(const char*); |
| 813 | static int once = 1; |
| 814 | static int istty[2]; |
| 815 | char *zToFree = 0; |
| 816 | if( once ){ |
| 817 | istty[0] = _isatty(fileno(stdout)); |
| 818 | istty[1] = _isatty(fileno(stderr)); |
| 819 | once = 0; |
| 820 | } |
| 821 | assert( toStdErr==0 || toStdErr==1 ); |
| 822 | if( istty[toStdErr] ) z = zToFree = sqlite3_win32_utf8_to_mbcs(z); |
| 823 | fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout); |
| 824 | free(zToFree); |
| 825 | #else |
| 826 | fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout); |
| 827 | #endif |
| 828 | } |
| 829 | |
| 830 | /* |
| 831 | ** Write output for user consumption. If g.cgiOutput is enabled, then |
| 832 | ** send the output as part of the CGI reply. If g.cgiOutput is false, |
| 833 |