Fossil SCM

eliminate all #ifdef UNICODE, assuming everthing is compiled with -DUNICODE -D_UNICODE

jan.nijtmans 2012-09-20 20:33 trunk
Commit ad91647ea761c65a9674bfa3f01c7f8a31828435
+1 -26
--- 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
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 */
1152
+ WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode, nChar, &dummy, 0);
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 WriteConsole(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
-4
--- src/main.c
+++ src/main.c
@@ -479,15 +479,11 @@
479479
g.argv = argv;
480480
#ifdef _WIN32
481481
parse_windows_command_line(&g.argc, &g.argv);
482482
GetModuleFileNameW(NULL, buf, MAX_PATH);
483483
g.argv[0] = fossil_unicode_to_utf8(buf);
484
-#ifdef UNICODE
485484
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
489485
#endif
490486
for(i=1; i<g.argc-1; i++){
491487
z = g.argv[i];
492488
if( z[0]!='-' ) continue;
493489
z++;
494490
--- src/main.c
+++ src/main.c
@@ -479,15 +479,11 @@
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++;
494
--- src/main.c
+++ src/main.c
@@ -479,15 +479,11 @@
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 for(i=1; i<g.argc; i++) g.argv[i] = fossil_unicode_to_utf8(g.argv[i]);
 
 
 
485 #endif
486 for(i=1; i<g.argc-1; i++){
487 z = g.argv[i];
488 if( z[0]!='-' ) continue;
489 z++;
490
--- 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(
144139
--- 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(
144
--- 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(
139

Keyboard Shortcuts

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