Fossil SCM
be smarter about istty static initialization
Commit
5d9f57a72104ffb938088e8ad93cab12fc2bc920
Parent
6f3b0f344510f68…
2 files changed
+3
-6
+6
-4
+3
-6
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -1127,16 +1127,13 @@ | ||
| 1127 | 1127 | #ifdef _WIN32 |
| 1128 | 1128 | int nChar; |
| 1129 | 1129 | wchar_t *zUnicode; /* Unicode version of zUtf8 */ |
| 1130 | 1130 | DWORD dummy; |
| 1131 | 1131 | |
| 1132 | - static int once = 1; | |
| 1133 | - static int istty[2]; | |
| 1134 | - if( once ){ | |
| 1135 | - istty[0] = _isatty(fileno(stdout)); | |
| 1136 | - istty[1] = _isatty(fileno(stderr)); | |
| 1137 | - once = 0; | |
| 1132 | + static int istty[2] = { -1, -1 }; | |
| 1133 | + if( istty[toStdErr] == -1 ){ | |
| 1134 | + istty[toStdErr] = _isatty(toStdErr + 1) != 0; | |
| 1138 | 1135 | } |
| 1139 | 1136 | if( !istty[toStdErr] ){ |
| 1140 | 1137 | /* stdout/stderr is not a console. */ |
| 1141 | 1138 | return -1; |
| 1142 | 1139 | } |
| 1143 | 1140 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1127,16 +1127,13 @@ | |
| 1127 | #ifdef _WIN32 |
| 1128 | int nChar; |
| 1129 | wchar_t *zUnicode; /* Unicode version of zUtf8 */ |
| 1130 | DWORD dummy; |
| 1131 | |
| 1132 | static int once = 1; |
| 1133 | static int istty[2]; |
| 1134 | if( once ){ |
| 1135 | istty[0] = _isatty(fileno(stdout)); |
| 1136 | istty[1] = _isatty(fileno(stderr)); |
| 1137 | once = 0; |
| 1138 | } |
| 1139 | if( !istty[toStdErr] ){ |
| 1140 | /* stdout/stderr is not a console. */ |
| 1141 | return -1; |
| 1142 | } |
| 1143 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1127,16 +1127,13 @@ | |
| 1127 | #ifdef _WIN32 |
| 1128 | int nChar; |
| 1129 | wchar_t *zUnicode; /* Unicode version of zUtf8 */ |
| 1130 | DWORD dummy; |
| 1131 | |
| 1132 | static int istty[2] = { -1, -1 }; |
| 1133 | if( istty[toStdErr] == -1 ){ |
| 1134 | istty[toStdErr] = _isatty(toStdErr + 1) != 0; |
| 1135 | } |
| 1136 | if( !istty[toStdErr] ){ |
| 1137 | /* stdout/stderr is not a console. */ |
| 1138 | return -1; |
| 1139 | } |
| 1140 |
+6
-4
| --- win/Makefile.mingw | ||
| +++ win/Makefile.mingw | ||
| @@ -13,15 +13,15 @@ | ||
| 13 | 13 | # |
| 14 | 14 | |
| 15 | 15 | #### Select one of MinGW, MinGW-64 (32-bit) or MinGW-w64 (64-bit) compilers. |
| 16 | 16 | # By default, this is an empty string (i.e. use the native compiler). |
| 17 | 17 | # |
| 18 | -PREFIX = | |
| 18 | +# PREFIX = | |
| 19 | 19 | # PREFIX = mingw32- |
| 20 | 20 | # PREFIX = i686-pc-mingw32- |
| 21 | 21 | # PREFIX = i686-w64-mingw32- |
| 22 | -# PREFIX = x86_64-w64-mingw32- | |
| 22 | +PREFIX = x86_64-w64-mingw32- | |
| 23 | 23 | |
| 24 | 24 | #### The toplevel directory of the source tree. Fossil can be built |
| 25 | 25 | # in a directory that is separate from the source tree. Just change |
| 26 | 26 | # the following to point from the build directory to the src/ folder. |
| 27 | 27 | # |
| @@ -104,11 +104,11 @@ | ||
| 104 | 104 | # will run on the target platform. This is usually the same |
| 105 | 105 | # as BCC, unless you are cross-compiling. This C compiler builds |
| 106 | 106 | # the finished binary for fossil. The BCC compiler above is used |
| 107 | 107 | # for building intermediate code-generator tools. |
| 108 | 108 | # |
| 109 | -TCC = $(PREFIX)gcc -Os -Wall -L$(ZLIBDIR) -I$(ZINCDIR) | |
| 109 | +TCC = $(PREFIX)gcc -Os -Wall -DUNICODE -D_UNICODE -L$(ZLIBDIR) -I$(ZINCDIR) | |
| 110 | 110 | |
| 111 | 111 | #### Compile resources for use in building executables that will run |
| 112 | 112 | # on the target platform. |
| 113 | 113 | # |
| 114 | 114 | RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR) |
| @@ -175,15 +175,17 @@ | ||
| 175 | 175 | ifdef FOSSIL_ENABLE_TCL |
| 176 | 176 | LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32 |
| 177 | 177 | else |
| 178 | 178 | LIB += -lkernel32 -lws2_32 |
| 179 | 179 | endif |
| 180 | + | |
| 181 | +LIB += -municode | |
| 180 | 182 | |
| 181 | 183 | #### Tcl shell for use in running the fossil test suite. This is only |
| 182 | 184 | # used for testing. |
| 183 | 185 | # |
| 184 | -TCLSH = tclsh | |
| 186 | +TCLSH = tclsh86 | |
| 185 | 187 | |
| 186 | 188 | #### Nullsoft installer MakeNSIS location |
| 187 | 189 | # |
| 188 | 190 | MAKENSIS = "$(ProgramFiles)\NSIS\MakeNSIS.exe" |
| 189 | 191 | |
| 190 | 192 |
| --- win/Makefile.mingw | |
| +++ win/Makefile.mingw | |
| @@ -13,15 +13,15 @@ | |
| 13 | # |
| 14 | |
| 15 | #### Select one of MinGW, MinGW-64 (32-bit) or MinGW-w64 (64-bit) compilers. |
| 16 | # By default, this is an empty string (i.e. use the native compiler). |
| 17 | # |
| 18 | PREFIX = |
| 19 | # PREFIX = mingw32- |
| 20 | # PREFIX = i686-pc-mingw32- |
| 21 | # PREFIX = i686-w64-mingw32- |
| 22 | # PREFIX = x86_64-w64-mingw32- |
| 23 | |
| 24 | #### The toplevel directory of the source tree. Fossil can be built |
| 25 | # in a directory that is separate from the source tree. Just change |
| 26 | # the following to point from the build directory to the src/ folder. |
| 27 | # |
| @@ -104,11 +104,11 @@ | |
| 104 | # will run on the target platform. This is usually the same |
| 105 | # as BCC, unless you are cross-compiling. This C compiler builds |
| 106 | # the finished binary for fossil. The BCC compiler above is used |
| 107 | # for building intermediate code-generator tools. |
| 108 | # |
| 109 | TCC = $(PREFIX)gcc -Os -Wall -L$(ZLIBDIR) -I$(ZINCDIR) |
| 110 | |
| 111 | #### Compile resources for use in building executables that will run |
| 112 | # on the target platform. |
| 113 | # |
| 114 | RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR) |
| @@ -175,15 +175,17 @@ | |
| 175 | ifdef FOSSIL_ENABLE_TCL |
| 176 | LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32 |
| 177 | else |
| 178 | LIB += -lkernel32 -lws2_32 |
| 179 | endif |
| 180 | |
| 181 | #### Tcl shell for use in running the fossil test suite. This is only |
| 182 | # used for testing. |
| 183 | # |
| 184 | TCLSH = tclsh |
| 185 | |
| 186 | #### Nullsoft installer MakeNSIS location |
| 187 | # |
| 188 | MAKENSIS = "$(ProgramFiles)\NSIS\MakeNSIS.exe" |
| 189 | |
| 190 |
| --- win/Makefile.mingw | |
| +++ win/Makefile.mingw | |
| @@ -13,15 +13,15 @@ | |
| 13 | # |
| 14 | |
| 15 | #### Select one of MinGW, MinGW-64 (32-bit) or MinGW-w64 (64-bit) compilers. |
| 16 | # By default, this is an empty string (i.e. use the native compiler). |
| 17 | # |
| 18 | # PREFIX = |
| 19 | # PREFIX = mingw32- |
| 20 | # PREFIX = i686-pc-mingw32- |
| 21 | # PREFIX = i686-w64-mingw32- |
| 22 | PREFIX = x86_64-w64-mingw32- |
| 23 | |
| 24 | #### The toplevel directory of the source tree. Fossil can be built |
| 25 | # in a directory that is separate from the source tree. Just change |
| 26 | # the following to point from the build directory to the src/ folder. |
| 27 | # |
| @@ -104,11 +104,11 @@ | |
| 104 | # will run on the target platform. This is usually the same |
| 105 | # as BCC, unless you are cross-compiling. This C compiler builds |
| 106 | # the finished binary for fossil. The BCC compiler above is used |
| 107 | # for building intermediate code-generator tools. |
| 108 | # |
| 109 | TCC = $(PREFIX)gcc -Os -Wall -DUNICODE -D_UNICODE -L$(ZLIBDIR) -I$(ZINCDIR) |
| 110 | |
| 111 | #### Compile resources for use in building executables that will run |
| 112 | # on the target platform. |
| 113 | # |
| 114 | RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR) |
| @@ -175,15 +175,17 @@ | |
| 175 | ifdef FOSSIL_ENABLE_TCL |
| 176 | LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32 |
| 177 | else |
| 178 | LIB += -lkernel32 -lws2_32 |
| 179 | endif |
| 180 | |
| 181 | LIB += -municode |
| 182 | |
| 183 | #### Tcl shell for use in running the fossil test suite. This is only |
| 184 | # used for testing. |
| 185 | # |
| 186 | TCLSH = tclsh86 |
| 187 | |
| 188 | #### Nullsoft installer MakeNSIS location |
| 189 | # |
| 190 | MAKENSIS = "$(ProgramFiles)\NSIS\MakeNSIS.exe" |
| 191 | |
| 192 |