| | @@ -197,10 +197,13 @@ |
| 197 | 197 | const char *azAuxVal[MX_AUX]; /* Value of each aux() or option() value */ |
| 198 | 198 | const char **azAuxOpt[MX_AUX]; /* Options of each option() value */ |
| 199 | 199 | int anAuxCols[MX_AUX]; /* Number of columns for option() values */ |
| 200 | 200 | |
| 201 | 201 | int allowSymlinks; /* Cached "allow-symlinks" option */ |
| 202 | +#ifdef _WIN32 |
| 203 | + int isNT; |
| 204 | +#endif |
| 202 | 205 | |
| 203 | 206 | #ifdef FOSSIL_ENABLE_JSON |
| 204 | 207 | struct FossilJsonBits { |
| 205 | 208 | int isJsonMode; /* True if running in JSON mode, else |
| 206 | 209 | false. This changes how errors are |
| | @@ -470,24 +473,20 @@ |
| 470 | 473 | char **newArgv; /* New expanded g.argv under construction */ |
| 471 | 474 | char const * zFileName; /* input file name */ |
| 472 | 475 | FILE * zInFile; /* input FILE */ |
| 473 | 476 | int foundBom = -1; /* -1= not searched yet, 0 = no; 1=yes */ |
| 474 | 477 | #ifdef _WIN32 |
| 475 | | - wchar_t buf[MAX_PATH]; |
| 478 | + TCHAR buf[MAX_PATH]; |
| 476 | 479 | #endif |
| 477 | 480 | |
| 478 | 481 | g.argc = argc; |
| 479 | 482 | g.argv = argv; |
| 480 | 483 | #ifdef _WIN32 |
| 481 | 484 | parse_windows_command_line(&g.argc, &g.argv); |
| 482 | | - GetModuleFileNameW(NULL, buf, MAX_PATH); |
| 485 | + GetModuleFileName(NULL, buf, MAX_PATH); |
| 483 | 486 | g.argv[0] = fossil_unicode_to_utf8(buf); |
| 484 | | -#ifdef UNICODE |
| 485 | 487 | 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 | 488 | #endif |
| 490 | 489 | for(i=1; i<g.argc-1; i++){ |
| 491 | 490 | z = g.argv[i]; |
| 492 | 491 | if( z[0]!='-' ) continue; |
| 493 | 492 | z++; |
| | @@ -557,13 +556,21 @@ |
| 557 | 556 | int main(int argc, char **argv) |
| 558 | 557 | { |
| 559 | 558 | const char *zCmdName = "unknown"; |
| 560 | 559 | int idx; |
| 561 | 560 | int rc; |
| 561 | +#ifdef _WIN32 |
| 562 | + OSVERSIONINFOA sInfo; |
| 563 | +#endif |
| 562 | 564 | |
| 563 | 565 | sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0); |
| 564 | 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 |
| 565 | 572 | g.now = time(0); |
| 566 | 573 | #ifdef FOSSIL_ENABLE_JSON |
| 567 | 574 | #if defined(NDEBUG) |
| 568 | 575 | g.json.errorDetailParanoia = 2 /* FIXME: make configurable |
| 569 | 576 | One problem we have here is that this |
| | @@ -834,20 +841,27 @@ |
| 834 | 841 | int rc; |
| 835 | 842 | #if defined(_WIN32) |
| 836 | 843 | /* On windows, we have to put double-quotes around the entire command. |
| 837 | 844 | ** Who knows why - this is just the way windows works. |
| 838 | 845 | */ |
| 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); |
| 841 | 855 | if( g.fSystemTrace ) { |
| 842 | 856 | char *zOut = mprintf("SYSTEM: %s\n", zNewCmd); |
| 843 | 857 | fossil_puts(zOut, 1); |
| 844 | 858 | fossil_free(zOut); |
| 845 | 859 | } |
| 846 | | - rc = _wsystem(zUnicode); |
| 860 | + rc = _tsystem(zUnicode); |
| 847 | 861 | fossil_mbcs_free(zUnicode); |
| 848 | | - free(zNewCmd); |
| 862 | + fossil_free(zNewCmd); |
| 849 | 863 | #else |
| 850 | 864 | /* On unix, evaluate the command directly. |
| 851 | 865 | */ |
| 852 | 866 | if( g.fSystemTrace ) fprintf(stderr, "SYSTEM: %s\n", zOrigCmd); |
| 853 | 867 | rc = system(zOrigCmd); |
| 854 | 868 | |