Fossil SCM
Tested now on win32 and cygwin (with some fixes, please evaluate!). I cannot test it on OSX, but I think this should function as intended.
Commit
a0148eac539221cd05e0ff4958d2e96d06321416
Parent
0ff5b5ed0f6a393…
2 files changed
+5
-5
+2
-2
+5
-5
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -655,18 +655,18 @@ | ||
| 655 | 655 | int i; |
| 656 | 656 | wchar_t zPwd[2000]; |
| 657 | 657 | if( _wgetcwd(zPwd, sizeof(zPwd)/sizeof(zPwd[0])-1)==0 ){ |
| 658 | 658 | fossil_fatal("cannot find the current working directory."); |
| 659 | 659 | } |
| 660 | - zPwdUtf8 = fossil_unicode_to_utf8(zPwd); | |
| 660 | + zPwdUtf8 = fossil_filename_to_utf8(zPwd); | |
| 661 | 661 | nPwd = strlen(zPwdUtf8); |
| 662 | 662 | if( nPwd > nBuf-1 ){ |
| 663 | 663 | fossil_fatal("pwd too big: max %d\n", nBuf-1); |
| 664 | 664 | } |
| 665 | 665 | for(i=0; zPwdUtf8[i]; i++) if( zPwdUtf8[i]=='\\' ) zPwdUtf8[i] = '/'; |
| 666 | 666 | memcpy(zBuf, zPwdUtf8, nPwd+1); |
| 667 | - fossil_unicode_free(zPwdUtf8); | |
| 667 | + fossil_filename_free(zPwdUtf8); | |
| 668 | 668 | #else |
| 669 | 669 | if( getcwd(zBuf, nBuf-1)==0 ){ |
| 670 | 670 | if( errno==ERANGE ){ |
| 671 | 671 | fossil_fatal("pwd too big: max %d\n", nBuf-1); |
| 672 | 672 | }else{ |
| @@ -1012,11 +1012,11 @@ | ||
| 1012 | 1012 | |
| 1013 | 1013 | #if defined(_WIN32) |
| 1014 | 1014 | wchar_t zTmpPath[MAX_PATH]; |
| 1015 | 1015 | |
| 1016 | 1016 | if( GetTempPathW(MAX_PATH, zTmpPath) ){ |
| 1017 | - azDirs[0] = fossil_unicode_to_utf8(zTmpPath); | |
| 1017 | + azDirs[0] = fossil_filename_to_utf8(zTmpPath); | |
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | 1020 | azDirs[1] = fossil_getenv("TEMP"); |
| 1021 | 1021 | azDirs[2] = fossil_getenv("TMP"); |
| 1022 | 1022 | #endif |
| @@ -1093,18 +1093,18 @@ | ||
| 1093 | 1093 | |
| 1094 | 1094 | #endif /* INTERFACE */ |
| 1095 | 1095 | |
| 1096 | 1096 | /* |
| 1097 | 1097 | ** Return the value of an environment variable as UTF8. |
| 1098 | -** Use fossil_unicode_free() to release resources. | |
| 1098 | +** Use fossil_filename_free() to release resources. | |
| 1099 | 1099 | */ |
| 1100 | 1100 | char *fossil_getenv(const char *zName){ |
| 1101 | 1101 | #ifdef _WIN32 |
| 1102 | 1102 | wchar_t *uName = fossil_utf8_to_unicode(zName); |
| 1103 | 1103 | void *zValue = _wgetenv(uName); |
| 1104 | 1104 | fossil_unicode_free(uName); |
| 1105 | - if( zValue ) zValue = fossil_unicode_to_utf8(zValue); | |
| 1105 | + if( zValue ) zValue = fossil_filename_to_utf8(zValue); | |
| 1106 | 1106 | #else |
| 1107 | 1107 | char *zValue = getenv(zName); |
| 1108 | 1108 | #endif |
| 1109 | 1109 | return zValue; |
| 1110 | 1110 | } |
| 1111 | 1111 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -655,18 +655,18 @@ | |
| 655 | int i; |
| 656 | wchar_t zPwd[2000]; |
| 657 | if( _wgetcwd(zPwd, sizeof(zPwd)/sizeof(zPwd[0])-1)==0 ){ |
| 658 | fossil_fatal("cannot find the current working directory."); |
| 659 | } |
| 660 | zPwdUtf8 = fossil_unicode_to_utf8(zPwd); |
| 661 | nPwd = strlen(zPwdUtf8); |
| 662 | if( nPwd > nBuf-1 ){ |
| 663 | fossil_fatal("pwd too big: max %d\n", nBuf-1); |
| 664 | } |
| 665 | for(i=0; zPwdUtf8[i]; i++) if( zPwdUtf8[i]=='\\' ) zPwdUtf8[i] = '/'; |
| 666 | memcpy(zBuf, zPwdUtf8, nPwd+1); |
| 667 | fossil_unicode_free(zPwdUtf8); |
| 668 | #else |
| 669 | if( getcwd(zBuf, nBuf-1)==0 ){ |
| 670 | if( errno==ERANGE ){ |
| 671 | fossil_fatal("pwd too big: max %d\n", nBuf-1); |
| 672 | }else{ |
| @@ -1012,11 +1012,11 @@ | |
| 1012 | |
| 1013 | #if defined(_WIN32) |
| 1014 | wchar_t zTmpPath[MAX_PATH]; |
| 1015 | |
| 1016 | if( GetTempPathW(MAX_PATH, zTmpPath) ){ |
| 1017 | azDirs[0] = fossil_unicode_to_utf8(zTmpPath); |
| 1018 | } |
| 1019 | |
| 1020 | azDirs[1] = fossil_getenv("TEMP"); |
| 1021 | azDirs[2] = fossil_getenv("TMP"); |
| 1022 | #endif |
| @@ -1093,18 +1093,18 @@ | |
| 1093 | |
| 1094 | #endif /* INTERFACE */ |
| 1095 | |
| 1096 | /* |
| 1097 | ** Return the value of an environment variable as UTF8. |
| 1098 | ** Use fossil_unicode_free() to release resources. |
| 1099 | */ |
| 1100 | char *fossil_getenv(const char *zName){ |
| 1101 | #ifdef _WIN32 |
| 1102 | wchar_t *uName = fossil_utf8_to_unicode(zName); |
| 1103 | void *zValue = _wgetenv(uName); |
| 1104 | fossil_unicode_free(uName); |
| 1105 | if( zValue ) zValue = fossil_unicode_to_utf8(zValue); |
| 1106 | #else |
| 1107 | char *zValue = getenv(zName); |
| 1108 | #endif |
| 1109 | return zValue; |
| 1110 | } |
| 1111 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -655,18 +655,18 @@ | |
| 655 | int i; |
| 656 | wchar_t zPwd[2000]; |
| 657 | if( _wgetcwd(zPwd, sizeof(zPwd)/sizeof(zPwd[0])-1)==0 ){ |
| 658 | fossil_fatal("cannot find the current working directory."); |
| 659 | } |
| 660 | zPwdUtf8 = fossil_filename_to_utf8(zPwd); |
| 661 | nPwd = strlen(zPwdUtf8); |
| 662 | if( nPwd > nBuf-1 ){ |
| 663 | fossil_fatal("pwd too big: max %d\n", nBuf-1); |
| 664 | } |
| 665 | for(i=0; zPwdUtf8[i]; i++) if( zPwdUtf8[i]=='\\' ) zPwdUtf8[i] = '/'; |
| 666 | memcpy(zBuf, zPwdUtf8, nPwd+1); |
| 667 | fossil_filename_free(zPwdUtf8); |
| 668 | #else |
| 669 | if( getcwd(zBuf, nBuf-1)==0 ){ |
| 670 | if( errno==ERANGE ){ |
| 671 | fossil_fatal("pwd too big: max %d\n", nBuf-1); |
| 672 | }else{ |
| @@ -1012,11 +1012,11 @@ | |
| 1012 | |
| 1013 | #if defined(_WIN32) |
| 1014 | wchar_t zTmpPath[MAX_PATH]; |
| 1015 | |
| 1016 | if( GetTempPathW(MAX_PATH, zTmpPath) ){ |
| 1017 | azDirs[0] = fossil_filename_to_utf8(zTmpPath); |
| 1018 | } |
| 1019 | |
| 1020 | azDirs[1] = fossil_getenv("TEMP"); |
| 1021 | azDirs[2] = fossil_getenv("TMP"); |
| 1022 | #endif |
| @@ -1093,18 +1093,18 @@ | |
| 1093 | |
| 1094 | #endif /* INTERFACE */ |
| 1095 | |
| 1096 | /* |
| 1097 | ** Return the value of an environment variable as UTF8. |
| 1098 | ** Use fossil_filename_free() to release resources. |
| 1099 | */ |
| 1100 | char *fossil_getenv(const char *zName){ |
| 1101 | #ifdef _WIN32 |
| 1102 | wchar_t *uName = fossil_utf8_to_unicode(zName); |
| 1103 | void *zValue = _wgetenv(uName); |
| 1104 | fossil_unicode_free(uName); |
| 1105 | if( zValue ) zValue = fossil_filename_to_utf8(zValue); |
| 1106 | #else |
| 1107 | char *zValue = getenv(zName); |
| 1108 | #endif |
| 1109 | return zValue; |
| 1110 | } |
| 1111 |
+2
-2
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -491,15 +491,15 @@ | ||
| 491 | 491 | g.argc = argc; |
| 492 | 492 | g.argv = argv; |
| 493 | 493 | #if defined(_WIN32) && !defined(__MINGW32__) |
| 494 | 494 | parse_windows_command_line(&g.argc, &g.argv); |
| 495 | 495 | GetModuleFileNameW(NULL, buf, MAX_PATH); |
| 496 | - g.nameOfExe = fossil_unicode_to_utf8(buf); | |
| 497 | - for(i=0; i<g.argc; i++) g.argv[i] = fossil_filename_to_utf8(g.argv[i]); | |
| 496 | + g.nameOfExe = fossil_filename_to_utf8(buf); | |
| 498 | 497 | #else |
| 499 | 498 | g.nameOfExe = g.argv[0]; |
| 500 | 499 | #endif |
| 500 | + for(i=0; i<g.argc; i++) g.argv[i] = fossil_filename_to_utf8(g.argv[i]); | |
| 501 | 501 | for(i=1; i<g.argc-1; i++){ |
| 502 | 502 | z = g.argv[i]; |
| 503 | 503 | if( z[0]!='-' ) continue; |
| 504 | 504 | z++; |
| 505 | 505 | if( z[0]=='-' ) z++; |
| 506 | 506 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -491,15 +491,15 @@ | |
| 491 | g.argc = argc; |
| 492 | g.argv = argv; |
| 493 | #if defined(_WIN32) && !defined(__MINGW32__) |
| 494 | parse_windows_command_line(&g.argc, &g.argv); |
| 495 | GetModuleFileNameW(NULL, buf, MAX_PATH); |
| 496 | g.nameOfExe = fossil_unicode_to_utf8(buf); |
| 497 | for(i=0; i<g.argc; i++) g.argv[i] = fossil_filename_to_utf8(g.argv[i]); |
| 498 | #else |
| 499 | g.nameOfExe = g.argv[0]; |
| 500 | #endif |
| 501 | for(i=1; i<g.argc-1; i++){ |
| 502 | z = g.argv[i]; |
| 503 | if( z[0]!='-' ) continue; |
| 504 | z++; |
| 505 | if( z[0]=='-' ) z++; |
| 506 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -491,15 +491,15 @@ | |
| 491 | g.argc = argc; |
| 492 | g.argv = argv; |
| 493 | #if defined(_WIN32) && !defined(__MINGW32__) |
| 494 | parse_windows_command_line(&g.argc, &g.argv); |
| 495 | GetModuleFileNameW(NULL, buf, MAX_PATH); |
| 496 | g.nameOfExe = fossil_filename_to_utf8(buf); |
| 497 | #else |
| 498 | g.nameOfExe = g.argv[0]; |
| 499 | #endif |
| 500 | for(i=0; i<g.argc; i++) g.argv[i] = fossil_filename_to_utf8(g.argv[i]); |
| 501 | for(i=1; i<g.argc-1; i++){ |
| 502 | z = g.argv[i]; |
| 503 | if( z[0]!='-' ) continue; |
| 504 | z++; |
| 505 | if( z[0]=='-' ) z++; |
| 506 |