Fossil

Check-in [ad91647ea7]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:eliminate all #ifdef UNICODE, assuming everthing is compiled with -DUNICODE -D_UNICODE
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ad91647ea761c65a9674bfa3f01c7f8a31828435
User & Date: jan.nijtmans 2012-09-20 20:33:20
Context
2012-09-21
11:24
eliminate the need for <tchar.h> check-in: 1bfa3a0bbf user: jan.nijtmans tags: trunk
09:27
Eliminate usage of TCHAR and the associated Win32 API macros. Closed-Leaf check-in: 4abd4c5d38 user: mistachkin tags: noTCHAR
2012-09-20
20:33
eliminate all #ifdef UNICODE, assuming everthing is compiled with -DUNICODE -D_UNICODE check-in: ad91647ea7 user: jan.nijtmans tags: trunk
2012-09-19
14:48
Updates to the script that generates the "download.html" page. check-in: 9d2216a1f8 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/file.c.

1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
....
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
** to a file, -1 is returned and nothing is written
** to the console.
*/
int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){
#ifdef _WIN32
  int nChar;
  wchar_t *zUnicode; /* Unicode version of zUtf8 */
#ifdef UNICODE
  DWORD dummy;
#else
  char *zConsole;    /* Console version of zUtf8 */
  int codepage;      /* Console code page */
#endif

  static int istty[2] = { -1, -1 };
  if( istty[toStdErr] == -1 ){
    istty[toStdErr] = _isatty(toStdErr + 1) != 0;
  }
  if( !istty[toStdErr] ){
    /* stdout/stderr is not a console. */
................................................................................
  }
  nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, nByte, zUnicode, nChar);
  if( nChar==0 ){
    free(zUnicode);
    return 0;
  }
  zUnicode[nChar] = '\0';
#ifdef UNICODE
  WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode, nChar, &dummy, 0);
#else /* !UNICODE */
  codepage = GetConsoleCP();
  nByte = WideCharToMultiByte(codepage, 0, zUnicode, nChar, 0, 0, 0, 0);
  zConsole = malloc( nByte + 1);
  if( zConsole==0 ){
    free(zUnicode);
    return 0;
  }
  nByte = WideCharToMultiByte(codepage, 0, zUnicode, nChar, zConsole, nByte, 0, 0);
  zConsole[nByte] = '\0';
  free(zUnicode);
  if( nByte == 0 ){
    free(zConsole);
    zConsole = 0;
    return 0;
  }
  fwrite(zConsole, 1, nByte, toStdErr ? stderr : stdout);
  fflush(toStdErr ? stderr : stdout);
#endif /* UNICODE */
  return nChar;
#else
  return -1;  /* No-op on unix */
#endif
}

/*







<

<
<
<
<







 







<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







1123
1124
1125
1126
1127
1128
1129

1130




1131
1132
1133
1134
1135
1136
1137
....
1145
1146
1147
1148
1149
1150
1151

1152



















1153
1154
1155
1156
1157
1158
1159
** to a file, -1 is returned and nothing is written
** to the console.
*/
int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){
#ifdef _WIN32
  int nChar;
  wchar_t *zUnicode; /* Unicode version of zUtf8 */

  DWORD dummy;





  static int istty[2] = { -1, -1 };
  if( istty[toStdErr] == -1 ){
    istty[toStdErr] = _isatty(toStdErr + 1) != 0;
  }
  if( !istty[toStdErr] ){
    /* stdout/stderr is not a console. */
................................................................................
  }
  nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, nByte, zUnicode, nChar);
  if( nChar==0 ){
    free(zUnicode);
    return 0;
  }
  zUnicode[nChar] = '\0';

  WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode, nChar, &dummy, 0);



















  return nChar;
#else
  return -1;  /* No-op on unix */
#endif
}

/*

Changes to src/main.c.

477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495

  g.argc = argc;
  g.argv = argv;
#ifdef _WIN32
  parse_windows_command_line(&g.argc, &g.argv);
  GetModuleFileNameW(NULL, buf, MAX_PATH);
  g.argv[0] = fossil_unicode_to_utf8(buf);
#ifdef UNICODE
  for(i=1; i<g.argc; i++) g.argv[i] = fossil_unicode_to_utf8(g.argv[i]);
#else
  for(i=1; i<g.argc; i++) g.argv[i] = fossil_mbcs_to_utf8(g.argv[i]);
#endif
#endif
  for(i=1; i<g.argc-1; i++){
    z = g.argv[i];
    if( z[0]!='-' ) continue;
    z++;
    if( z[0]=='-' ) z++;
    if( z[0]==0 ) return;   /* Stop searching at "--" */







<

<
<
<







477
478
479
480
481
482
483

484



485
486
487
488
489
490
491

  g.argc = argc;
  g.argv = argv;
#ifdef _WIN32
  parse_windows_command_line(&g.argc, &g.argv);
  GetModuleFileNameW(NULL, buf, MAX_PATH);
  g.argv[0] = fossil_unicode_to_utf8(buf);

  for(i=1; i<g.argc; i++) g.argv[i] = fossil_unicode_to_utf8(g.argv[i]);



#endif
  for(i=1; i<g.argc-1; i++){
    z = g.argv[i];
    if( z[0]!='-' ) continue;
    z++;
    if( z[0]=='-' ) z++;
    if( z[0]==0 ) return;   /* Stop searching at "--" */

Changes to src/winhttp.c.

127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
  if( in ) fclose(in);
  closesocket(p->s);
  file_delete(zRequestFName);
  file_delete(zReplyFName);
  free(p);
}

#if !defined(UNICODE)
#  define fossil_unicode_to_utf8 fossil_mbcs_to_utf8
#  define fossil_utf8_to_unicode fossil_utf8_to_mbcs
#endif

/*
** Start a listening socket and process incoming HTTP requests on
** that socket.
*/
void win32_http_server(
  int mnPort, int mxPort,   /* Range of allowed TCP port numbers */
  const char *zBrowser,     /* Command to launch browser.  (Or NULL) */







<
<
<
<
<







127
128
129
130
131
132
133





134
135
136
137
138
139
140
  if( in ) fclose(in);
  closesocket(p->s);
  file_delete(zRequestFName);
  file_delete(zReplyFName);
  free(p);
}






/*
** Start a listening socket and process incoming HTTP requests on
** that socket.
*/
void win32_http_server(
  int mnPort, int mxPort,   /* Range of allowed TCP port numbers */
  const char *zBrowser,     /* Command to launch browser.  (Or NULL) */