Fossil SCM

fix [ce73fc2173] <p>Restore Win9x, using unicows eliminate all #ifdef UNICODE

jan.nijtmans 2012-09-17 07:34 UTC trunk
Commit 9cf5056af97e9a76a7160842cb66d0874ab6e04f
-25
--- src/file.c
+++ src/file.c
@@ -1125,16 +1125,11 @@
11251125
*/
11261126
int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){
11271127
#ifdef _WIN32
11281128
int nChar;
11291129
wchar_t *zUnicode; /* Unicode version of zUtf8 */
1130
-#ifdef UNICODE
11311130
DWORD dummy;
1132
-#else
1133
- char *zConsole; /* Console version of zUtf8 */
1134
- int codepage; /* Console code page */
1135
-#endif
11361131
11371132
static int istty[2] = { -1, -1 };
11381133
if( istty[toStdErr] == -1 ){
11391134
istty[toStdErr] = _isatty(toStdErr + 1) != 0;
11401135
}
@@ -1152,31 +1147,11 @@
11521147
if( nChar==0 ){
11531148
free(zUnicode);
11541149
return 0;
11551150
}
11561151
zUnicode[nChar] = '\0';
1157
-#ifdef UNICODE
11581152
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode, nChar, &dummy, 0);
1159
-#else /* !UNICODE */
1160
- codepage = GetConsoleCP();
1161
- nByte = WideCharToMultiByte(codepage, 0, zUnicode, nChar, 0, 0, 0, 0);
1162
- zConsole = malloc( nByte + 1);
1163
- if( zConsole==0 ){
1164
- free(zUnicode);
1165
- return 0;
1166
- }
1167
- nByte = WideCharToMultiByte(codepage, 0, zUnicode, nChar, zConsole, nByte, 0, 0);
1168
- zConsole[nByte] = '\0';
1169
- free(zUnicode);
1170
- if( nByte == 0 ){
1171
- free(zConsole);
1172
- zConsole = 0;
1173
- return 0;
1174
- }
1175
- fwrite(zConsole, 1, nByte, toStdErr ? stderr : stdout);
1176
- fflush(toStdErr ? stderr : stdout);
1177
-#endif /* UNICODE */
11781153
return nChar;
11791154
#else
11801155
return -1; /* No-op on unix */
11811156
#endif
11821157
}
11831158
--- src/file.c
+++ src/file.c
@@ -1125,16 +1125,11 @@
1125 */
1126 int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){
1127 #ifdef _WIN32
1128 int nChar;
1129 wchar_t *zUnicode; /* Unicode version of zUtf8 */
1130 #ifdef UNICODE
1131 DWORD dummy;
1132 #else
1133 char *zConsole; /* Console version of zUtf8 */
1134 int codepage; /* Console code page */
1135 #endif
1136
1137 static int istty[2] = { -1, -1 };
1138 if( istty[toStdErr] == -1 ){
1139 istty[toStdErr] = _isatty(toStdErr + 1) != 0;
1140 }
@@ -1152,31 +1147,11 @@
1152 if( nChar==0 ){
1153 free(zUnicode);
1154 return 0;
1155 }
1156 zUnicode[nChar] = '\0';
1157 #ifdef UNICODE
1158 WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode, nChar, &dummy, 0);
1159 #else /* !UNICODE */
1160 codepage = GetConsoleCP();
1161 nByte = WideCharToMultiByte(codepage, 0, zUnicode, nChar, 0, 0, 0, 0);
1162 zConsole = malloc( nByte + 1);
1163 if( zConsole==0 ){
1164 free(zUnicode);
1165 return 0;
1166 }
1167 nByte = WideCharToMultiByte(codepage, 0, zUnicode, nChar, zConsole, nByte, 0, 0);
1168 zConsole[nByte] = '\0';
1169 free(zUnicode);
1170 if( nByte == 0 ){
1171 free(zConsole);
1172 zConsole = 0;
1173 return 0;
1174 }
1175 fwrite(zConsole, 1, nByte, toStdErr ? stderr : stdout);
1176 fflush(toStdErr ? stderr : stdout);
1177 #endif /* UNICODE */
1178 return nChar;
1179 #else
1180 return -1; /* No-op on unix */
1181 #endif
1182 }
1183
--- src/file.c
+++ src/file.c
@@ -1125,16 +1125,11 @@
1125 */
1126 int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){
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 }
@@ -1152,31 +1147,11 @@
1147 if( nChar==0 ){
1148 free(zUnicode);
1149 return 0;
1150 }
1151 zUnicode[nChar] = '\0';
 
1152 WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode, nChar, &dummy, 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1153 return nChar;
1154 #else
1155 return -1; /* No-op on unix */
1156 #endif
1157 }
1158
+24 -10
--- src/main.c
+++ src/main.c
@@ -197,10 +197,13 @@
197197
const char *azAuxVal[MX_AUX]; /* Value of each aux() or option() value */
198198
const char **azAuxOpt[MX_AUX]; /* Options of each option() value */
199199
int anAuxCols[MX_AUX]; /* Number of columns for option() values */
200200
201201
int allowSymlinks; /* Cached "allow-symlinks" option */
202
+#ifdef _WIN32
203
+ int isNT;
204
+#endif
202205
203206
#ifdef FOSSIL_ENABLE_JSON
204207
struct FossilJsonBits {
205208
int isJsonMode; /* True if running in JSON mode, else
206209
false. This changes how errors are
@@ -470,24 +473,20 @@
470473
char **newArgv; /* New expanded g.argv under construction */
471474
char const * zFileName; /* input file name */
472475
FILE * zInFile; /* input FILE */
473476
int foundBom = -1; /* -1= not searched yet, 0 = no; 1=yes */
474477
#ifdef _WIN32
475
- wchar_t buf[MAX_PATH];
478
+ TCHAR buf[MAX_PATH];
476479
#endif
477480
478481
g.argc = argc;
479482
g.argv = argv;
480483
#ifdef _WIN32
481484
parse_windows_command_line(&g.argc, &g.argv);
482
- GetModuleFileNameW(NULL, buf, MAX_PATH);
485
+ GetModuleFileName(NULL, buf, MAX_PATH);
483486
g.argv[0] = fossil_unicode_to_utf8(buf);
484
-#ifdef UNICODE
485487
for(i=1; i<g.argc; i++) g.argv[i] = fossil_unicode_to_utf8(g.argv[i]);
486
-#else
487
- for(i=1; i<g.argc; i++) g.argv[i] = fossil_mbcs_to_utf8(g.argv[i]);
488
-#endif
489488
#endif
490489
for(i=1; i<g.argc-1; i++){
491490
z = g.argv[i];
492491
if( z[0]!='-' ) continue;
493492
z++;
@@ -557,13 +556,21 @@
557556
int main(int argc, char **argv)
558557
{
559558
const char *zCmdName = "unknown";
560559
int idx;
561560
int rc;
561
+#ifdef _WIN32
562
+ OSVERSIONINFOA sInfo;
563
+#endif
562564
563565
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
564566
memset(&g, 0, sizeof(g));
567
+#ifdef _WIN32
568
+ sInfo.dwOSVersionInfoSize = sizeof(sInfo);
569
+ GetVersionExA(&sInfo);
570
+ g.isNT = sInfo.dwPlatformId==VER_PLATFORM_WIN32_NT;
571
+#endif
565572
g.now = time(0);
566573
#ifdef FOSSIL_ENABLE_JSON
567574
#if defined(NDEBUG)
568575
g.json.errorDetailParanoia = 2 /* FIXME: make configurable
569576
One problem we have here is that this
@@ -834,20 +841,27 @@
834841
int rc;
835842
#if defined(_WIN32)
836843
/* On windows, we have to put double-quotes around the entire command.
837844
** Who knows why - this is just the way windows works.
838845
*/
839
- char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
840
- wchar_t *zUnicode = fossil_utf8_to_unicode(zNewCmd);
846
+ char *zNewCmd;
847
+ TCHAR *zUnicode;
848
+
849
+ if (g.isNT) {
850
+ zNewCmd = mprintf("\"%s\"", zOrigCmd);
851
+ } else {
852
+ zNewCmd = mprintf("%s", zOrigCmd);
853
+ }
854
+ zUnicode = fossil_utf8_to_unicode(zNewCmd);
841855
if( g.fSystemTrace ) {
842856
char *zOut = mprintf("SYSTEM: %s\n", zNewCmd);
843857
fossil_puts(zOut, 1);
844858
fossil_free(zOut);
845859
}
846
- rc = _wsystem(zUnicode);
860
+ rc = _tsystem(zUnicode);
847861
fossil_mbcs_free(zUnicode);
848
- free(zNewCmd);
862
+ fossil_free(zNewCmd);
849863
#else
850864
/* On unix, evaluate the command directly.
851865
*/
852866
if( g.fSystemTrace ) fprintf(stderr, "SYSTEM: %s\n", zOrigCmd);
853867
rc = system(zOrigCmd);
854868
--- src/main.c
+++ src/main.c
@@ -197,10 +197,13 @@
197 const char *azAuxVal[MX_AUX]; /* Value of each aux() or option() value */
198 const char **azAuxOpt[MX_AUX]; /* Options of each option() value */
199 int anAuxCols[MX_AUX]; /* Number of columns for option() values */
200
201 int allowSymlinks; /* Cached "allow-symlinks" option */
 
 
 
202
203 #ifdef FOSSIL_ENABLE_JSON
204 struct FossilJsonBits {
205 int isJsonMode; /* True if running in JSON mode, else
206 false. This changes how errors are
@@ -470,24 +473,20 @@
470 char **newArgv; /* New expanded g.argv under construction */
471 char const * zFileName; /* input file name */
472 FILE * zInFile; /* input FILE */
473 int foundBom = -1; /* -1= not searched yet, 0 = no; 1=yes */
474 #ifdef _WIN32
475 wchar_t buf[MAX_PATH];
476 #endif
477
478 g.argc = argc;
479 g.argv = argv;
480 #ifdef _WIN32
481 parse_windows_command_line(&g.argc, &g.argv);
482 GetModuleFileNameW(NULL, buf, MAX_PATH);
483 g.argv[0] = fossil_unicode_to_utf8(buf);
484 #ifdef UNICODE
485 for(i=1; i<g.argc; i++) g.argv[i] = fossil_unicode_to_utf8(g.argv[i]);
486 #else
487 for(i=1; i<g.argc; i++) g.argv[i] = fossil_mbcs_to_utf8(g.argv[i]);
488 #endif
489 #endif
490 for(i=1; i<g.argc-1; i++){
491 z = g.argv[i];
492 if( z[0]!='-' ) continue;
493 z++;
@@ -557,13 +556,21 @@
557 int main(int argc, char **argv)
558 {
559 const char *zCmdName = "unknown";
560 int idx;
561 int rc;
 
 
 
562
563 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
564 memset(&g, 0, sizeof(g));
 
 
 
 
 
565 g.now = time(0);
566 #ifdef FOSSIL_ENABLE_JSON
567 #if defined(NDEBUG)
568 g.json.errorDetailParanoia = 2 /* FIXME: make configurable
569 One problem we have here is that this
@@ -834,20 +841,27 @@
834 int rc;
835 #if defined(_WIN32)
836 /* On windows, we have to put double-quotes around the entire command.
837 ** Who knows why - this is just the way windows works.
838 */
839 char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
840 wchar_t *zUnicode = fossil_utf8_to_unicode(zNewCmd);
 
 
 
 
 
 
 
841 if( g.fSystemTrace ) {
842 char *zOut = mprintf("SYSTEM: %s\n", zNewCmd);
843 fossil_puts(zOut, 1);
844 fossil_free(zOut);
845 }
846 rc = _wsystem(zUnicode);
847 fossil_mbcs_free(zUnicode);
848 free(zNewCmd);
849 #else
850 /* On unix, evaluate the command directly.
851 */
852 if( g.fSystemTrace ) fprintf(stderr, "SYSTEM: %s\n", zOrigCmd);
853 rc = system(zOrigCmd);
854
--- src/main.c
+++ src/main.c
@@ -197,10 +197,13 @@
197 const char *azAuxVal[MX_AUX]; /* Value of each aux() or option() value */
198 const char **azAuxOpt[MX_AUX]; /* Options of each option() value */
199 int anAuxCols[MX_AUX]; /* Number of columns for option() values */
200
201 int allowSymlinks; /* Cached "allow-symlinks" option */
202 #ifdef _WIN32
203 int isNT;
204 #endif
205
206 #ifdef FOSSIL_ENABLE_JSON
207 struct FossilJsonBits {
208 int isJsonMode; /* True if running in JSON mode, else
209 false. This changes how errors are
@@ -470,24 +473,20 @@
473 char **newArgv; /* New expanded g.argv under construction */
474 char const * zFileName; /* input file name */
475 FILE * zInFile; /* input FILE */
476 int foundBom = -1; /* -1= not searched yet, 0 = no; 1=yes */
477 #ifdef _WIN32
478 TCHAR buf[MAX_PATH];
479 #endif
480
481 g.argc = argc;
482 g.argv = argv;
483 #ifdef _WIN32
484 parse_windows_command_line(&g.argc, &g.argv);
485 GetModuleFileName(NULL, buf, MAX_PATH);
486 g.argv[0] = fossil_unicode_to_utf8(buf);
 
487 for(i=1; i<g.argc; i++) g.argv[i] = fossil_unicode_to_utf8(g.argv[i]);
 
 
 
488 #endif
489 for(i=1; i<g.argc-1; i++){
490 z = g.argv[i];
491 if( z[0]!='-' ) continue;
492 z++;
@@ -557,13 +556,21 @@
556 int main(int argc, char **argv)
557 {
558 const char *zCmdName = "unknown";
559 int idx;
560 int rc;
561 #ifdef _WIN32
562 OSVERSIONINFOA sInfo;
563 #endif
564
565 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
566 memset(&g, 0, sizeof(g));
567 #ifdef _WIN32
568 sInfo.dwOSVersionInfoSize = sizeof(sInfo);
569 GetVersionExA(&sInfo);
570 g.isNT = sInfo.dwPlatformId==VER_PLATFORM_WIN32_NT;
571 #endif
572 g.now = time(0);
573 #ifdef FOSSIL_ENABLE_JSON
574 #if defined(NDEBUG)
575 g.json.errorDetailParanoia = 2 /* FIXME: make configurable
576 One problem we have here is that this
@@ -834,20 +841,27 @@
841 int rc;
842 #if defined(_WIN32)
843 /* On windows, we have to put double-quotes around the entire command.
844 ** Who knows why - this is just the way windows works.
845 */
846 char *zNewCmd;
847 TCHAR *zUnicode;
848
849 if (g.isNT) {
850 zNewCmd = mprintf("\"%s\"", zOrigCmd);
851 } else {
852 zNewCmd = mprintf("%s", zOrigCmd);
853 }
854 zUnicode = fossil_utf8_to_unicode(zNewCmd);
855 if( g.fSystemTrace ) {
856 char *zOut = mprintf("SYSTEM: %s\n", zNewCmd);
857 fossil_puts(zOut, 1);
858 fossil_free(zOut);
859 }
860 rc = _tsystem(zUnicode);
861 fossil_mbcs_free(zUnicode);
862 fossil_free(zNewCmd);
863 #else
864 /* On unix, evaluate the command directly.
865 */
866 if( g.fSystemTrace ) fprintf(stderr, "SYSTEM: %s\n", zOrigCmd);
867 rc = system(zOrigCmd);
868
+5 -5
--- src/winhttp.c
+++ src/winhttp.c
@@ -129,15 +129,10 @@
129129
file_delete(zRequestFName);
130130
file_delete(zReplyFName);
131131
free(p);
132132
}
133133
134
-#if !defined(UNICODE)
135
-# define fossil_unicode_to_utf8 fossil_mbcs_to_utf8
136
-# define fossil_utf8_to_unicode fossil_utf8_to_mbcs
137
-#endif
138
-
139134
/*
140135
** Start a listening socket and process incoming HTTP requests on
141136
** that socket.
142137
*/
143138
void win32_http_server(
@@ -561,10 +556,15 @@
561556
void cmd_win32_service(void){
562557
int n;
563558
const char *zMethod;
564559
const char *zSvcName = "Fossil-DSCM"; /* Default service name */
565560
561
+#ifdef _WIN32
562
+ if( !g.isNT ) {
563
+ fossil_fatal("%s command not support on Windows 9x", g.argv[1]);
564
+ }
565
+#endif
566566
if( g.argc<3 ){
567567
usage("create|delete|show|start|stop ...");
568568
}
569569
zMethod = g.argv[2];
570570
n = strlen(zMethod);
571571
--- src/winhttp.c
+++ src/winhttp.c
@@ -129,15 +129,10 @@
129 file_delete(zRequestFName);
130 file_delete(zReplyFName);
131 free(p);
132 }
133
134 #if !defined(UNICODE)
135 # define fossil_unicode_to_utf8 fossil_mbcs_to_utf8
136 # define fossil_utf8_to_unicode fossil_utf8_to_mbcs
137 #endif
138
139 /*
140 ** Start a listening socket and process incoming HTTP requests on
141 ** that socket.
142 */
143 void win32_http_server(
@@ -561,10 +556,15 @@
561 void cmd_win32_service(void){
562 int n;
563 const char *zMethod;
564 const char *zSvcName = "Fossil-DSCM"; /* Default service name */
565
 
 
 
 
 
566 if( g.argc<3 ){
567 usage("create|delete|show|start|stop ...");
568 }
569 zMethod = g.argv[2];
570 n = strlen(zMethod);
571
--- src/winhttp.c
+++ src/winhttp.c
@@ -129,15 +129,10 @@
129 file_delete(zRequestFName);
130 file_delete(zReplyFName);
131 free(p);
132 }
133
 
 
 
 
 
134 /*
135 ** Start a listening socket and process incoming HTTP requests on
136 ** that socket.
137 */
138 void win32_http_server(
@@ -561,10 +556,15 @@
556 void cmd_win32_service(void){
557 int n;
558 const char *zMethod;
559 const char *zSvcName = "Fossil-DSCM"; /* Default service name */
560
561 #ifdef _WIN32
562 if( !g.isNT ) {
563 fossil_fatal("%s command not support on Windows 9x", g.argv[1]);
564 }
565 #endif
566 if( g.argc<3 ){
567 usage("create|delete|show|start|stop ...");
568 }
569 zMethod = g.argv[2];
570 n = strlen(zMethod);
571
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -149,11 +149,11 @@
149149
endif
150150
151151
#### We add the -static option here so that we can build a static
152152
# executable that will run in a chroot jail.
153153
#
154
-LIB = -static
154
+LIB = -municows -static
155155
156156
# OpenSSL: Add the necessary libraries required, if enabled.
157157
ifdef FOSSIL_ENABLE_SSL
158158
LIB += -lssl -lcrypto -lgdi32
159159
endif
160160
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -149,11 +149,11 @@
149 endif
150
151 #### We add the -static option here so that we can build a static
152 # executable that will run in a chroot jail.
153 #
154 LIB = -static
155
156 # OpenSSL: Add the necessary libraries required, if enabled.
157 ifdef FOSSIL_ENABLE_SSL
158 LIB += -lssl -lcrypto -lgdi32
159 endif
160
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -149,11 +149,11 @@
149 endif
150
151 #### We add the -static option here so that we can build a static
152 # executable that will run in a chroot jail.
153 #
154 LIB = -municows -static
155
156 # OpenSSL: Add the necessary libraries required, if enabled.
157 ifdef FOSSIL_ENABLE_SSL
158 LIB += -lssl -lcrypto -lgdi32
159 endif
160

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button