Fossil SCM
merge trunk
Commit
dbf96517f26e073f3966aa01b376aa0e2be5b7de
Parent
eeb0231b9b3ff94…
6 files changed
+2
-2
+16
-3
+3
-3
+2
+21
-7
+1
-1
+2
-2
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -262,11 +262,11 @@ | ||
| 262 | 262 | if( vid==0 ){ |
| 263 | 263 | fossil_panic("no checkout to add to"); |
| 264 | 264 | } |
| 265 | 265 | db_begin_transaction(); |
| 266 | 266 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 267 | -#if defined(_WIN32) | |
| 267 | +#if defined(_WIN32) || defined(__CYGWIN__) | |
| 268 | 268 | db_multi_exec( |
| 269 | 269 | "CREATE INDEX IF NOT EXISTS vfile_pathname " |
| 270 | 270 | " ON vfile(pathname COLLATE nocase)" |
| 271 | 271 | ); |
| 272 | 272 | #endif |
| @@ -388,11 +388,11 @@ | ||
| 388 | 388 | if( once ){ |
| 389 | 389 | once = 0; |
| 390 | 390 | if( zCaseSensitive ){ |
| 391 | 391 | caseSensitive = is_truth(zCaseSensitive); |
| 392 | 392 | }else{ |
| 393 | -#if !defined(_WIN32) && !defined(__DARWIN__) && !defined(__APPLE__) | |
| 393 | +#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__DARWIN__) && !defined(__APPLE__) | |
| 394 | 394 | caseSensitive = 1; /* Unix */ |
| 395 | 395 | #else |
| 396 | 396 | caseSensitive = 0; /* Windows and Mac */ |
| 397 | 397 | #endif |
| 398 | 398 | caseSensitive = db_get_boolean("case-sensitive",caseSensitive); |
| 399 | 399 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -262,11 +262,11 @@ | |
| 262 | if( vid==0 ){ |
| 263 | fossil_panic("no checkout to add to"); |
| 264 | } |
| 265 | db_begin_transaction(); |
| 266 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 267 | #if defined(_WIN32) |
| 268 | db_multi_exec( |
| 269 | "CREATE INDEX IF NOT EXISTS vfile_pathname " |
| 270 | " ON vfile(pathname COLLATE nocase)" |
| 271 | ); |
| 272 | #endif |
| @@ -388,11 +388,11 @@ | |
| 388 | if( once ){ |
| 389 | once = 0; |
| 390 | if( zCaseSensitive ){ |
| 391 | caseSensitive = is_truth(zCaseSensitive); |
| 392 | }else{ |
| 393 | #if !defined(_WIN32) && !defined(__DARWIN__) && !defined(__APPLE__) |
| 394 | caseSensitive = 1; /* Unix */ |
| 395 | #else |
| 396 | caseSensitive = 0; /* Windows and Mac */ |
| 397 | #endif |
| 398 | caseSensitive = db_get_boolean("case-sensitive",caseSensitive); |
| 399 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -262,11 +262,11 @@ | |
| 262 | if( vid==0 ){ |
| 263 | fossil_panic("no checkout to add to"); |
| 264 | } |
| 265 | db_begin_transaction(); |
| 266 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 267 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 268 | db_multi_exec( |
| 269 | "CREATE INDEX IF NOT EXISTS vfile_pathname " |
| 270 | " ON vfile(pathname COLLATE nocase)" |
| 271 | ); |
| 272 | #endif |
| @@ -388,11 +388,11 @@ | |
| 388 | if( once ){ |
| 389 | once = 0; |
| 390 | if( zCaseSensitive ){ |
| 391 | caseSensitive = is_truth(zCaseSensitive); |
| 392 | }else{ |
| 393 | #if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__DARWIN__) && !defined(__APPLE__) |
| 394 | caseSensitive = 1; /* Unix */ |
| 395 | #else |
| 396 | caseSensitive = 0; /* Windows and Mac */ |
| 397 | #endif |
| 398 | caseSensitive = db_get_boolean("case-sensitive",caseSensitive); |
| 399 |
M
src/db.c
+16
-3
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -29,10 +29,13 @@ | ||
| 29 | 29 | ** |
| 30 | 30 | */ |
| 31 | 31 | #include "config.h" |
| 32 | 32 | #if ! defined(_WIN32) |
| 33 | 33 | # include <pwd.h> |
| 34 | +# if defined(__CYGWIN__) | |
| 35 | +# include <sys/cygwin.h> | |
| 36 | +# endif | |
| 34 | 37 | #endif |
| 35 | 38 | #include <sqlite3.h> |
| 36 | 39 | #include <sys/types.h> |
| 37 | 40 | #include <sys/stat.h> |
| 38 | 41 | #include <unistd.h> |
| @@ -793,20 +796,29 @@ | ||
| 793 | 796 | */ |
| 794 | 797 | void db_open_config(int useAttach){ |
| 795 | 798 | char *zDbName; |
| 796 | 799 | const char *zHome; |
| 797 | 800 | if( g.configOpen ) return; |
| 798 | -#if defined(_WIN32) | |
| 801 | +#if defined(_WIN32) || defined(__CYGWIN__) | |
| 799 | 802 | zHome = fossil_getenv("LOCALAPPDATA"); |
| 800 | 803 | if( zHome==0 ){ |
| 801 | 804 | zHome = fossil_getenv("APPDATA"); |
| 802 | 805 | if( zHome==0 ){ |
| 803 | 806 | char *zDrive = fossil_getenv("HOMEDRIVE"); |
| 804 | 807 | zHome = fossil_getenv("HOMEPATH"); |
| 805 | 808 | if( zDrive && zHome ) zHome = mprintf("%s%s", zDrive, zHome); |
| 806 | 809 | } |
| 807 | 810 | } |
| 811 | +#if defined(__CYGWIN__) | |
| 812 | + if( zHome!=0 ){ | |
| 813 | + /* We now have the win32 path, but we need the Cygwin equivalent */ | |
| 814 | + ssize_t size = cygwin_conv_path(CCP_WIN_A_TO_POSIX, zHome, 0, 0); | |
| 815 | + char *converted = fossil_malloc(size); | |
| 816 | + cygwin_conv_path(CCP_WIN_A_TO_POSIX, zHome, converted, size); | |
| 817 | + zHome = converted; | |
| 818 | + } | |
| 819 | +#endif | |
| 808 | 820 | if( zHome==0 ){ |
| 809 | 821 | fossil_fatal("cannot locate home directory - " |
| 810 | 822 | "please set the LOCALAPPDATA or APPDATA or HOMEPATH " |
| 811 | 823 | "environment variables"); |
| 812 | 824 | } |
| @@ -824,11 +836,11 @@ | ||
| 824 | 836 | if( access(zHome, W_OK) ){ |
| 825 | 837 | fossil_fatal("home directory %s must be writeable", zHome); |
| 826 | 838 | } |
| 827 | 839 | #endif |
| 828 | 840 | g.zHome = mprintf("%/", zHome); |
| 829 | -#if defined(_WIN32) | |
| 841 | +#if defined(_WIN32) || defined(__CYGWIN__) | |
| 830 | 842 | /* . filenames give some window systems problems and many apps problems */ |
| 831 | 843 | zDbName = mprintf("%//_fossil", zHome); |
| 832 | 844 | #else |
| 833 | 845 | zDbName = mprintf("%s/.fossil", zHome); |
| 834 | 846 | #endif |
| @@ -882,10 +894,11 @@ | ||
| 882 | 894 | lsize = file_size(zDbName); |
| 883 | 895 | if( lsize%1024!=0 || lsize<4096 ) return 0; |
| 884 | 896 | db_open_or_attach(zDbName, "localdb", 0); |
| 885 | 897 | zVFileDef = db_text(0, "SELECT sql FROM %s.sqlite_master" |
| 886 | 898 | " WHERE name=='vfile'", db_name("localdb")); |
| 899 | + if( zVFileDef==0 ) return 0; | |
| 887 | 900 | |
| 888 | 901 | /* If the "isexe" column is missing from the vfile table, then |
| 889 | 902 | ** add it now. This code added on 2010-03-06. After all users have |
| 890 | 903 | ** upgraded, this code can be safely deleted. |
| 891 | 904 | */ |
| @@ -1980,11 +1993,11 @@ | ||
| 1980 | 1993 | if( !allowNested && db_open_local() ){ |
| 1981 | 1994 | fossil_panic("already within an open tree rooted at %s", g.zLocalRoot); |
| 1982 | 1995 | } |
| 1983 | 1996 | file_canonical_name(g.argv[2], &path, 0); |
| 1984 | 1997 | db_open_repository(blob_str(&path)); |
| 1985 | -#if defined(_WIN32) | |
| 1998 | +#if defined(_WIN32) || defined(__CYGWIN__) | |
| 1986 | 1999 | # define LOCALDB_NAME "./_FOSSIL_" |
| 1987 | 2000 | #else |
| 1988 | 2001 | # define LOCALDB_NAME "./.fslckout" |
| 1989 | 2002 | #endif |
| 1990 | 2003 | db_init_database(LOCALDB_NAME, zLocalSchema, |
| 1991 | 2004 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -29,10 +29,13 @@ | |
| 29 | ** |
| 30 | */ |
| 31 | #include "config.h" |
| 32 | #if ! defined(_WIN32) |
| 33 | # include <pwd.h> |
| 34 | #endif |
| 35 | #include <sqlite3.h> |
| 36 | #include <sys/types.h> |
| 37 | #include <sys/stat.h> |
| 38 | #include <unistd.h> |
| @@ -793,20 +796,29 @@ | |
| 793 | */ |
| 794 | void db_open_config(int useAttach){ |
| 795 | char *zDbName; |
| 796 | const char *zHome; |
| 797 | if( g.configOpen ) return; |
| 798 | #if defined(_WIN32) |
| 799 | zHome = fossil_getenv("LOCALAPPDATA"); |
| 800 | if( zHome==0 ){ |
| 801 | zHome = fossil_getenv("APPDATA"); |
| 802 | if( zHome==0 ){ |
| 803 | char *zDrive = fossil_getenv("HOMEDRIVE"); |
| 804 | zHome = fossil_getenv("HOMEPATH"); |
| 805 | if( zDrive && zHome ) zHome = mprintf("%s%s", zDrive, zHome); |
| 806 | } |
| 807 | } |
| 808 | if( zHome==0 ){ |
| 809 | fossil_fatal("cannot locate home directory - " |
| 810 | "please set the LOCALAPPDATA or APPDATA or HOMEPATH " |
| 811 | "environment variables"); |
| 812 | } |
| @@ -824,11 +836,11 @@ | |
| 824 | if( access(zHome, W_OK) ){ |
| 825 | fossil_fatal("home directory %s must be writeable", zHome); |
| 826 | } |
| 827 | #endif |
| 828 | g.zHome = mprintf("%/", zHome); |
| 829 | #if defined(_WIN32) |
| 830 | /* . filenames give some window systems problems and many apps problems */ |
| 831 | zDbName = mprintf("%//_fossil", zHome); |
| 832 | #else |
| 833 | zDbName = mprintf("%s/.fossil", zHome); |
| 834 | #endif |
| @@ -882,10 +894,11 @@ | |
| 882 | lsize = file_size(zDbName); |
| 883 | if( lsize%1024!=0 || lsize<4096 ) return 0; |
| 884 | db_open_or_attach(zDbName, "localdb", 0); |
| 885 | zVFileDef = db_text(0, "SELECT sql FROM %s.sqlite_master" |
| 886 | " WHERE name=='vfile'", db_name("localdb")); |
| 887 | |
| 888 | /* If the "isexe" column is missing from the vfile table, then |
| 889 | ** add it now. This code added on 2010-03-06. After all users have |
| 890 | ** upgraded, this code can be safely deleted. |
| 891 | */ |
| @@ -1980,11 +1993,11 @@ | |
| 1980 | if( !allowNested && db_open_local() ){ |
| 1981 | fossil_panic("already within an open tree rooted at %s", g.zLocalRoot); |
| 1982 | } |
| 1983 | file_canonical_name(g.argv[2], &path, 0); |
| 1984 | db_open_repository(blob_str(&path)); |
| 1985 | #if defined(_WIN32) |
| 1986 | # define LOCALDB_NAME "./_FOSSIL_" |
| 1987 | #else |
| 1988 | # define LOCALDB_NAME "./.fslckout" |
| 1989 | #endif |
| 1990 | db_init_database(LOCALDB_NAME, zLocalSchema, |
| 1991 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -29,10 +29,13 @@ | |
| 29 | ** |
| 30 | */ |
| 31 | #include "config.h" |
| 32 | #if ! defined(_WIN32) |
| 33 | # include <pwd.h> |
| 34 | # if defined(__CYGWIN__) |
| 35 | # include <sys/cygwin.h> |
| 36 | # endif |
| 37 | #endif |
| 38 | #include <sqlite3.h> |
| 39 | #include <sys/types.h> |
| 40 | #include <sys/stat.h> |
| 41 | #include <unistd.h> |
| @@ -793,20 +796,29 @@ | |
| 796 | */ |
| 797 | void db_open_config(int useAttach){ |
| 798 | char *zDbName; |
| 799 | const char *zHome; |
| 800 | if( g.configOpen ) return; |
| 801 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 802 | zHome = fossil_getenv("LOCALAPPDATA"); |
| 803 | if( zHome==0 ){ |
| 804 | zHome = fossil_getenv("APPDATA"); |
| 805 | if( zHome==0 ){ |
| 806 | char *zDrive = fossil_getenv("HOMEDRIVE"); |
| 807 | zHome = fossil_getenv("HOMEPATH"); |
| 808 | if( zDrive && zHome ) zHome = mprintf("%s%s", zDrive, zHome); |
| 809 | } |
| 810 | } |
| 811 | #if defined(__CYGWIN__) |
| 812 | if( zHome!=0 ){ |
| 813 | /* We now have the win32 path, but we need the Cygwin equivalent */ |
| 814 | ssize_t size = cygwin_conv_path(CCP_WIN_A_TO_POSIX, zHome, 0, 0); |
| 815 | char *converted = fossil_malloc(size); |
| 816 | cygwin_conv_path(CCP_WIN_A_TO_POSIX, zHome, converted, size); |
| 817 | zHome = converted; |
| 818 | } |
| 819 | #endif |
| 820 | if( zHome==0 ){ |
| 821 | fossil_fatal("cannot locate home directory - " |
| 822 | "please set the LOCALAPPDATA or APPDATA or HOMEPATH " |
| 823 | "environment variables"); |
| 824 | } |
| @@ -824,11 +836,11 @@ | |
| 836 | if( access(zHome, W_OK) ){ |
| 837 | fossil_fatal("home directory %s must be writeable", zHome); |
| 838 | } |
| 839 | #endif |
| 840 | g.zHome = mprintf("%/", zHome); |
| 841 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 842 | /* . filenames give some window systems problems and many apps problems */ |
| 843 | zDbName = mprintf("%//_fossil", zHome); |
| 844 | #else |
| 845 | zDbName = mprintf("%s/.fossil", zHome); |
| 846 | #endif |
| @@ -882,10 +894,11 @@ | |
| 894 | lsize = file_size(zDbName); |
| 895 | if( lsize%1024!=0 || lsize<4096 ) return 0; |
| 896 | db_open_or_attach(zDbName, "localdb", 0); |
| 897 | zVFileDef = db_text(0, "SELECT sql FROM %s.sqlite_master" |
| 898 | " WHERE name=='vfile'", db_name("localdb")); |
| 899 | if( zVFileDef==0 ) return 0; |
| 900 | |
| 901 | /* If the "isexe" column is missing from the vfile table, then |
| 902 | ** add it now. This code added on 2010-03-06. After all users have |
| 903 | ** upgraded, this code can be safely deleted. |
| 904 | */ |
| @@ -1980,11 +1993,11 @@ | |
| 1993 | if( !allowNested && db_open_local() ){ |
| 1994 | fossil_panic("already within an open tree rooted at %s", g.zLocalRoot); |
| 1995 | } |
| 1996 | file_canonical_name(g.argv[2], &path, 0); |
| 1997 | db_open_repository(blob_str(&path)); |
| 1998 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 1999 | # define LOCALDB_NAME "./_FOSSIL_" |
| 2000 | #else |
| 2001 | # define LOCALDB_NAME "./.fslckout" |
| 2002 | #endif |
| 2003 | db_init_database(LOCALDB_NAME, zLocalSchema, |
| 2004 |
+3
-3
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -593,12 +593,12 @@ | ||
| 593 | 593 | */ |
| 594 | 594 | int file_simplify_name(char *z, int n, int slash){ |
| 595 | 595 | int i, j; |
| 596 | 596 | if( n<0 ) n = strlen(z); |
| 597 | 597 | |
| 598 | - /* On windows convert all \ characters to / */ | |
| 599 | -#if defined(_WIN32) | |
| 598 | + /* On windows and cygwin convert all \ characters to / */ | |
| 599 | +#if defined(_WIN32) || defined(__CYGWIN__) | |
| 600 | 600 | for(i=0; i<n; i++){ |
| 601 | 601 | if( z[i]=='\\' ) z[i] = '/'; |
| 602 | 602 | } |
| 603 | 603 | #endif |
| 604 | 604 | |
| @@ -846,11 +846,11 @@ | ||
| 846 | 846 | char zBuf[2000]; |
| 847 | 847 | zPwd = zBuf; |
| 848 | 848 | file_getcwd(zBuf, sizeof(zBuf)-20); |
| 849 | 849 | zPwd = file_without_drive_letter(zBuf); |
| 850 | 850 | i = 1; |
| 851 | -#ifdef _WIN32 | |
| 851 | +#if defined(_WIN32) || defined(__CYGWIN__) | |
| 852 | 852 | while( zPath[i] && fossil_tolower(zPwd[i])==fossil_tolower(zPath[i]) ) i++; |
| 853 | 853 | #else |
| 854 | 854 | while( zPath[i] && zPwd[i]==zPath[i] ) i++; |
| 855 | 855 | #endif |
| 856 | 856 | if( zPath[i]==0 ){ |
| 857 | 857 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -593,12 +593,12 @@ | |
| 593 | */ |
| 594 | int file_simplify_name(char *z, int n, int slash){ |
| 595 | int i, j; |
| 596 | if( n<0 ) n = strlen(z); |
| 597 | |
| 598 | /* On windows convert all \ characters to / */ |
| 599 | #if defined(_WIN32) |
| 600 | for(i=0; i<n; i++){ |
| 601 | if( z[i]=='\\' ) z[i] = '/'; |
| 602 | } |
| 603 | #endif |
| 604 | |
| @@ -846,11 +846,11 @@ | |
| 846 | char zBuf[2000]; |
| 847 | zPwd = zBuf; |
| 848 | file_getcwd(zBuf, sizeof(zBuf)-20); |
| 849 | zPwd = file_without_drive_letter(zBuf); |
| 850 | i = 1; |
| 851 | #ifdef _WIN32 |
| 852 | while( zPath[i] && fossil_tolower(zPwd[i])==fossil_tolower(zPath[i]) ) i++; |
| 853 | #else |
| 854 | while( zPath[i] && zPwd[i]==zPath[i] ) i++; |
| 855 | #endif |
| 856 | if( zPath[i]==0 ){ |
| 857 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -593,12 +593,12 @@ | |
| 593 | */ |
| 594 | int file_simplify_name(char *z, int n, int slash){ |
| 595 | int i, j; |
| 596 | if( n<0 ) n = strlen(z); |
| 597 | |
| 598 | /* On windows and cygwin convert all \ characters to / */ |
| 599 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 600 | for(i=0; i<n; i++){ |
| 601 | if( z[i]=='\\' ) z[i] = '/'; |
| 602 | } |
| 603 | #endif |
| 604 | |
| @@ -846,11 +846,11 @@ | |
| 846 | char zBuf[2000]; |
| 847 | zPwd = zBuf; |
| 848 | file_getcwd(zBuf, sizeof(zBuf)-20); |
| 849 | zPwd = file_without_drive_letter(zBuf); |
| 850 | i = 1; |
| 851 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 852 | while( zPath[i] && fossil_tolower(zPwd[i])==fossil_tolower(zPath[i]) ) i++; |
| 853 | #else |
| 854 | while( zPath[i] && zPwd[i]==zPath[i] ) i++; |
| 855 | #endif |
| 856 | if( zPath[i]==0 ){ |
| 857 |
+2
| --- src/rebuild.c | ||
| +++ src/rebuild.c | ||
| @@ -785,10 +785,12 @@ | ||
| 785 | 785 | int bVerily = find_option("verily",0,0)!=0; |
| 786 | 786 | int bForce = find_option("force", "f", 0)!=0; |
| 787 | 787 | int privateOnly = find_option("private",0,0)!=0; |
| 788 | 788 | int bNeedRebuild = 0; |
| 789 | 789 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 2); |
| 790 | + db_close(1); | |
| 791 | + db_open_repository(g.zRepositoryName); | |
| 790 | 792 | if( !bForce ){ |
| 791 | 793 | Blob ans; |
| 792 | 794 | char cReply; |
| 793 | 795 | blob_zero(&ans); |
| 794 | 796 | prompt_user( |
| 795 | 797 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -785,10 +785,12 @@ | |
| 785 | int bVerily = find_option("verily",0,0)!=0; |
| 786 | int bForce = find_option("force", "f", 0)!=0; |
| 787 | int privateOnly = find_option("private",0,0)!=0; |
| 788 | int bNeedRebuild = 0; |
| 789 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 2); |
| 790 | if( !bForce ){ |
| 791 | Blob ans; |
| 792 | char cReply; |
| 793 | blob_zero(&ans); |
| 794 | prompt_user( |
| 795 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -785,10 +785,12 @@ | |
| 785 | int bVerily = find_option("verily",0,0)!=0; |
| 786 | int bForce = find_option("force", "f", 0)!=0; |
| 787 | int privateOnly = find_option("private",0,0)!=0; |
| 788 | int bNeedRebuild = 0; |
| 789 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 2); |
| 790 | db_close(1); |
| 791 | db_open_repository(g.zRepositoryName); |
| 792 | if( !bForce ){ |
| 793 | Blob ans; |
| 794 | char cReply; |
| 795 | blob_zero(&ans); |
| 796 | prompt_user( |
| 797 |
+21
-7
| --- src/utf8.c | ||
| +++ src/utf8.c | ||
| @@ -104,10 +104,14 @@ | ||
| 104 | 104 | /* |
| 105 | 105 | ** Translate text from the filename character set into UTF-8. |
| 106 | 106 | ** Return a pointer to the translated text. |
| 107 | 107 | ** Call fossil_filename_free() to deallocate any memory used to store the |
| 108 | 108 | ** returned pointer when done. |
| 109 | +** | |
| 110 | +** This function must not convert '\' to '/' on windows/cygwin, as it is | |
| 111 | +** used in places where we are not sure it's really filenames we are handling, | |
| 112 | +** e.g. fossil_getenv() or handling the argv arguments from main(). | |
| 109 | 113 | */ |
| 110 | 114 | char *fossil_filename_to_utf8(const void *zFilename){ |
| 111 | 115 | #if defined(_WIN32) |
| 112 | 116 | int nByte = WideCharToMultiByte(CP_UTF8, 0, zFilename, -1, 0, 0, 0, 0); |
| 113 | 117 | char *zUtf = sqlite3_malloc( nByte ); |
| @@ -154,14 +158,21 @@ | ||
| 154 | 158 | */ |
| 155 | 159 | void *fossil_utf8_to_filename(const char *zUtf8){ |
| 156 | 160 | #ifdef _WIN32 |
| 157 | 161 | int nByte = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, 0, 0); |
| 158 | 162 | wchar_t *zUnicode = sqlite3_malloc( nByte * 2 ); |
| 163 | + wchar_t *wUnicode = zUnicode; | |
| 159 | 164 | if( zUnicode==0 ){ |
| 160 | 165 | return 0; |
| 161 | 166 | } |
| 162 | 167 | MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nByte); |
| 168 | + while( *wUnicode != '\0' ){ | |
| 169 | + if( *wUnicode == '/' ){ | |
| 170 | + *wUnicode = '\\'; | |
| 171 | + } | |
| 172 | + ++wUnicode; | |
| 173 | + } | |
| 163 | 174 | return zUnicode; |
| 164 | 175 | #elif defined(__APPLE__) && !defined(WITHOUT_ICONV) |
| 165 | 176 | return fossil_strdup(zUtf8); |
| 166 | 177 | #else |
| 167 | 178 | return (void *)zUtf8; /* No-op on unix */ |
| @@ -188,11 +199,11 @@ | ||
| 188 | 199 | ** to a file, -1 is returned and nothing is written |
| 189 | 200 | ** to the console. |
| 190 | 201 | */ |
| 191 | 202 | int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){ |
| 192 | 203 | #ifdef _WIN32 |
| 193 | - int nChar; | |
| 204 | + int nChar, written = 0; | |
| 194 | 205 | wchar_t *zUnicode; /* Unicode version of zUtf8 */ |
| 195 | 206 | DWORD dummy; |
| 196 | 207 | |
| 197 | 208 | static int istty[2] = { -1, -1 }; |
| 198 | 209 | if( istty[toStdErr] == -1 ){ |
| @@ -207,17 +218,20 @@ | ||
| 207 | 218 | zUnicode = malloc( (nChar + 1) *sizeof(zUnicode[0]) ); |
| 208 | 219 | if( zUnicode==0 ){ |
| 209 | 220 | return 0; |
| 210 | 221 | } |
| 211 | 222 | nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, nByte, zUnicode, nChar); |
| 212 | - if( nChar==0 ){ | |
| 213 | - free(zUnicode); | |
| 214 | - return 0; | |
| 223 | + /* Split WriteConsoleW call into multiple chunks, if necessary. See: | |
| 224 | + * <https://connect.microsoft.com/VisualStudio/feedback/details/635230> */ | |
| 225 | + while( written < nChar ){ | |
| 226 | + int size = nChar-written; | |
| 227 | + if (size > 26000) size = 26000; | |
| 228 | + WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode+written, | |
| 229 | + size, &dummy, 0); | |
| 230 | + written += size; | |
| 215 | 231 | } |
| 216 | - zUnicode[nChar] = '\0'; | |
| 217 | - WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode, nChar, | |
| 218 | - &dummy, 0); | |
| 232 | + free(zUnicode); | |
| 219 | 233 | return nChar; |
| 220 | 234 | #else |
| 221 | 235 | return -1; /* No-op on unix */ |
| 222 | 236 | #endif |
| 223 | 237 | } |
| 224 | 238 |
| --- src/utf8.c | |
| +++ src/utf8.c | |
| @@ -104,10 +104,14 @@ | |
| 104 | /* |
| 105 | ** Translate text from the filename character set into UTF-8. |
| 106 | ** Return a pointer to the translated text. |
| 107 | ** Call fossil_filename_free() to deallocate any memory used to store the |
| 108 | ** returned pointer when done. |
| 109 | */ |
| 110 | char *fossil_filename_to_utf8(const void *zFilename){ |
| 111 | #if defined(_WIN32) |
| 112 | int nByte = WideCharToMultiByte(CP_UTF8, 0, zFilename, -1, 0, 0, 0, 0); |
| 113 | char *zUtf = sqlite3_malloc( nByte ); |
| @@ -154,14 +158,21 @@ | |
| 154 | */ |
| 155 | void *fossil_utf8_to_filename(const char *zUtf8){ |
| 156 | #ifdef _WIN32 |
| 157 | int nByte = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, 0, 0); |
| 158 | wchar_t *zUnicode = sqlite3_malloc( nByte * 2 ); |
| 159 | if( zUnicode==0 ){ |
| 160 | return 0; |
| 161 | } |
| 162 | MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nByte); |
| 163 | return zUnicode; |
| 164 | #elif defined(__APPLE__) && !defined(WITHOUT_ICONV) |
| 165 | return fossil_strdup(zUtf8); |
| 166 | #else |
| 167 | return (void *)zUtf8; /* No-op on unix */ |
| @@ -188,11 +199,11 @@ | |
| 188 | ** to a file, -1 is returned and nothing is written |
| 189 | ** to the console. |
| 190 | */ |
| 191 | int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){ |
| 192 | #ifdef _WIN32 |
| 193 | int nChar; |
| 194 | wchar_t *zUnicode; /* Unicode version of zUtf8 */ |
| 195 | DWORD dummy; |
| 196 | |
| 197 | static int istty[2] = { -1, -1 }; |
| 198 | if( istty[toStdErr] == -1 ){ |
| @@ -207,17 +218,20 @@ | |
| 207 | zUnicode = malloc( (nChar + 1) *sizeof(zUnicode[0]) ); |
| 208 | if( zUnicode==0 ){ |
| 209 | return 0; |
| 210 | } |
| 211 | nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, nByte, zUnicode, nChar); |
| 212 | if( nChar==0 ){ |
| 213 | free(zUnicode); |
| 214 | return 0; |
| 215 | } |
| 216 | zUnicode[nChar] = '\0'; |
| 217 | WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode, nChar, |
| 218 | &dummy, 0); |
| 219 | return nChar; |
| 220 | #else |
| 221 | return -1; /* No-op on unix */ |
| 222 | #endif |
| 223 | } |
| 224 |
| --- src/utf8.c | |
| +++ src/utf8.c | |
| @@ -104,10 +104,14 @@ | |
| 104 | /* |
| 105 | ** Translate text from the filename character set into UTF-8. |
| 106 | ** Return a pointer to the translated text. |
| 107 | ** Call fossil_filename_free() to deallocate any memory used to store the |
| 108 | ** returned pointer when done. |
| 109 | ** |
| 110 | ** This function must not convert '\' to '/' on windows/cygwin, as it is |
| 111 | ** used in places where we are not sure it's really filenames we are handling, |
| 112 | ** e.g. fossil_getenv() or handling the argv arguments from main(). |
| 113 | */ |
| 114 | char *fossil_filename_to_utf8(const void *zFilename){ |
| 115 | #if defined(_WIN32) |
| 116 | int nByte = WideCharToMultiByte(CP_UTF8, 0, zFilename, -1, 0, 0, 0, 0); |
| 117 | char *zUtf = sqlite3_malloc( nByte ); |
| @@ -154,14 +158,21 @@ | |
| 158 | */ |
| 159 | void *fossil_utf8_to_filename(const char *zUtf8){ |
| 160 | #ifdef _WIN32 |
| 161 | int nByte = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, 0, 0); |
| 162 | wchar_t *zUnicode = sqlite3_malloc( nByte * 2 ); |
| 163 | wchar_t *wUnicode = zUnicode; |
| 164 | if( zUnicode==0 ){ |
| 165 | return 0; |
| 166 | } |
| 167 | MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nByte); |
| 168 | while( *wUnicode != '\0' ){ |
| 169 | if( *wUnicode == '/' ){ |
| 170 | *wUnicode = '\\'; |
| 171 | } |
| 172 | ++wUnicode; |
| 173 | } |
| 174 | return zUnicode; |
| 175 | #elif defined(__APPLE__) && !defined(WITHOUT_ICONV) |
| 176 | return fossil_strdup(zUtf8); |
| 177 | #else |
| 178 | return (void *)zUtf8; /* No-op on unix */ |
| @@ -188,11 +199,11 @@ | |
| 199 | ** to a file, -1 is returned and nothing is written |
| 200 | ** to the console. |
| 201 | */ |
| 202 | int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){ |
| 203 | #ifdef _WIN32 |
| 204 | int nChar, written = 0; |
| 205 | wchar_t *zUnicode; /* Unicode version of zUtf8 */ |
| 206 | DWORD dummy; |
| 207 | |
| 208 | static int istty[2] = { -1, -1 }; |
| 209 | if( istty[toStdErr] == -1 ){ |
| @@ -207,17 +218,20 @@ | |
| 218 | zUnicode = malloc( (nChar + 1) *sizeof(zUnicode[0]) ); |
| 219 | if( zUnicode==0 ){ |
| 220 | return 0; |
| 221 | } |
| 222 | nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, nByte, zUnicode, nChar); |
| 223 | /* Split WriteConsoleW call into multiple chunks, if necessary. See: |
| 224 | * <https://connect.microsoft.com/VisualStudio/feedback/details/635230> */ |
| 225 | while( written < nChar ){ |
| 226 | int size = nChar-written; |
| 227 | if (size > 26000) size = 26000; |
| 228 | WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode+written, |
| 229 | size, &dummy, 0); |
| 230 | written += size; |
| 231 | } |
| 232 | free(zUnicode); |
| 233 | return nChar; |
| 234 | #else |
| 235 | return -1; /* No-op on unix */ |
| 236 | #endif |
| 237 | } |
| 238 |
+1
-1
| --- www/fossil_prompt.wiki | ||
| +++ www/fossil_prompt.wiki | ||
| @@ -17,7 +17,7 @@ | ||
| 17 | 17 | </pre></blockquote> |
| 18 | 18 | |
| 19 | 19 | For a permanent installation, you can graft the code into your |
| 20 | 20 | <tt>.bashrc</tt> file in your home directory. |
| 21 | 21 | |
| 22 | -The code is very simply (only 32 non-comment lines, as of this writing) | |
| 22 | +The code is very simple (only 32 non-comment lines, as of this writing) | |
| 23 | 23 | and hence easy to customized. |
| 24 | 24 |
| --- www/fossil_prompt.wiki | |
| +++ www/fossil_prompt.wiki | |
| @@ -17,7 +17,7 @@ | |
| 17 | </pre></blockquote> |
| 18 | |
| 19 | For a permanent installation, you can graft the code into your |
| 20 | <tt>.bashrc</tt> file in your home directory. |
| 21 | |
| 22 | The code is very simply (only 32 non-comment lines, as of this writing) |
| 23 | and hence easy to customized. |
| 24 |
| --- www/fossil_prompt.wiki | |
| +++ www/fossil_prompt.wiki | |
| @@ -17,7 +17,7 @@ | |
| 17 | </pre></blockquote> |
| 18 | |
| 19 | For a permanent installation, you can graft the code into your |
| 20 | <tt>.bashrc</tt> file in your home directory. |
| 21 | |
| 22 | The code is very simple (only 32 non-comment lines, as of this writing) |
| 23 | and hence easy to customized. |
| 24 |