Fossil SCM

merge trunk

jan.nijtmans 2013-02-27 10:03 improve_commit_warning merge
Commit dbf96517f26e073f3966aa01b376aa0e2be5b7de
+2 -2
--- src/add.c
+++ src/add.c
@@ -262,11 +262,11 @@
262262
if( vid==0 ){
263263
fossil_panic("no checkout to add to");
264264
}
265265
db_begin_transaction();
266266
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
267
-#if defined(_WIN32)
267
+#if defined(_WIN32) || defined(__CYGWIN__)
268268
db_multi_exec(
269269
"CREATE INDEX IF NOT EXISTS vfile_pathname "
270270
" ON vfile(pathname COLLATE nocase)"
271271
);
272272
#endif
@@ -388,11 +388,11 @@
388388
if( once ){
389389
once = 0;
390390
if( zCaseSensitive ){
391391
caseSensitive = is_truth(zCaseSensitive);
392392
}else{
393
-#if !defined(_WIN32) && !defined(__DARWIN__) && !defined(__APPLE__)
393
+#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__DARWIN__) && !defined(__APPLE__)
394394
caseSensitive = 1; /* Unix */
395395
#else
396396
caseSensitive = 0; /* Windows and Mac */
397397
#endif
398398
caseSensitive = db_get_boolean("case-sensitive",caseSensitive);
399399
--- 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
+16 -3
--- src/db.c
+++ src/db.c
@@ -29,10 +29,13 @@
2929
**
3030
*/
3131
#include "config.h"
3232
#if ! defined(_WIN32)
3333
# include <pwd.h>
34
+# if defined(__CYGWIN__)
35
+# include <sys/cygwin.h>
36
+# endif
3437
#endif
3538
#include <sqlite3.h>
3639
#include <sys/types.h>
3740
#include <sys/stat.h>
3841
#include <unistd.h>
@@ -793,20 +796,29 @@
793796
*/
794797
void db_open_config(int useAttach){
795798
char *zDbName;
796799
const char *zHome;
797800
if( g.configOpen ) return;
798
-#if defined(_WIN32)
801
+#if defined(_WIN32) || defined(__CYGWIN__)
799802
zHome = fossil_getenv("LOCALAPPDATA");
800803
if( zHome==0 ){
801804
zHome = fossil_getenv("APPDATA");
802805
if( zHome==0 ){
803806
char *zDrive = fossil_getenv("HOMEDRIVE");
804807
zHome = fossil_getenv("HOMEPATH");
805808
if( zDrive && zHome ) zHome = mprintf("%s%s", zDrive, zHome);
806809
}
807810
}
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
808820
if( zHome==0 ){
809821
fossil_fatal("cannot locate home directory - "
810822
"please set the LOCALAPPDATA or APPDATA or HOMEPATH "
811823
"environment variables");
812824
}
@@ -824,11 +836,11 @@
824836
if( access(zHome, W_OK) ){
825837
fossil_fatal("home directory %s must be writeable", zHome);
826838
}
827839
#endif
828840
g.zHome = mprintf("%/", zHome);
829
-#if defined(_WIN32)
841
+#if defined(_WIN32) || defined(__CYGWIN__)
830842
/* . filenames give some window systems problems and many apps problems */
831843
zDbName = mprintf("%//_fossil", zHome);
832844
#else
833845
zDbName = mprintf("%s/.fossil", zHome);
834846
#endif
@@ -882,10 +894,11 @@
882894
lsize = file_size(zDbName);
883895
if( lsize%1024!=0 || lsize<4096 ) return 0;
884896
db_open_or_attach(zDbName, "localdb", 0);
885897
zVFileDef = db_text(0, "SELECT sql FROM %s.sqlite_master"
886898
" WHERE name=='vfile'", db_name("localdb"));
899
+ if( zVFileDef==0 ) return 0;
887900
888901
/* If the "isexe" column is missing from the vfile table, then
889902
** add it now. This code added on 2010-03-06. After all users have
890903
** upgraded, this code can be safely deleted.
891904
*/
@@ -1980,11 +1993,11 @@
19801993
if( !allowNested && db_open_local() ){
19811994
fossil_panic("already within an open tree rooted at %s", g.zLocalRoot);
19821995
}
19831996
file_canonical_name(g.argv[2], &path, 0);
19841997
db_open_repository(blob_str(&path));
1985
-#if defined(_WIN32)
1998
+#if defined(_WIN32) || defined(__CYGWIN__)
19861999
# define LOCALDB_NAME "./_FOSSIL_"
19872000
#else
19882001
# define LOCALDB_NAME "./.fslckout"
19892002
#endif
19902003
db_init_database(LOCALDB_NAME, zLocalSchema,
19912004
--- 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 @@
593593
*/
594594
int file_simplify_name(char *z, int n, int slash){
595595
int i, j;
596596
if( n<0 ) n = strlen(z);
597597
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__)
600600
for(i=0; i<n; i++){
601601
if( z[i]=='\\' ) z[i] = '/';
602602
}
603603
#endif
604604
@@ -846,11 +846,11 @@
846846
char zBuf[2000];
847847
zPwd = zBuf;
848848
file_getcwd(zBuf, sizeof(zBuf)-20);
849849
zPwd = file_without_drive_letter(zBuf);
850850
i = 1;
851
-#ifdef _WIN32
851
+#if defined(_WIN32) || defined(__CYGWIN__)
852852
while( zPath[i] && fossil_tolower(zPwd[i])==fossil_tolower(zPath[i]) ) i++;
853853
#else
854854
while( zPath[i] && zPwd[i]==zPath[i] ) i++;
855855
#endif
856856
if( zPath[i]==0 ){
857857
--- 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
--- src/rebuild.c
+++ src/rebuild.c
@@ -785,10 +785,12 @@
785785
int bVerily = find_option("verily",0,0)!=0;
786786
int bForce = find_option("force", "f", 0)!=0;
787787
int privateOnly = find_option("private",0,0)!=0;
788788
int bNeedRebuild = 0;
789789
db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
790
+ db_close(1);
791
+ db_open_repository(g.zRepositoryName);
790792
if( !bForce ){
791793
Blob ans;
792794
char cReply;
793795
blob_zero(&ans);
794796
prompt_user(
795797
--- 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 @@
104104
/*
105105
** Translate text from the filename character set into UTF-8.
106106
** Return a pointer to the translated text.
107107
** Call fossil_filename_free() to deallocate any memory used to store the
108108
** 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().
109113
*/
110114
char *fossil_filename_to_utf8(const void *zFilename){
111115
#if defined(_WIN32)
112116
int nByte = WideCharToMultiByte(CP_UTF8, 0, zFilename, -1, 0, 0, 0, 0);
113117
char *zUtf = sqlite3_malloc( nByte );
@@ -154,14 +158,21 @@
154158
*/
155159
void *fossil_utf8_to_filename(const char *zUtf8){
156160
#ifdef _WIN32
157161
int nByte = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, 0, 0);
158162
wchar_t *zUnicode = sqlite3_malloc( nByte * 2 );
163
+ wchar_t *wUnicode = zUnicode;
159164
if( zUnicode==0 ){
160165
return 0;
161166
}
162167
MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nByte);
168
+ while( *wUnicode != '\0' ){
169
+ if( *wUnicode == '/' ){
170
+ *wUnicode = '\\';
171
+ }
172
+ ++wUnicode;
173
+ }
163174
return zUnicode;
164175
#elif defined(__APPLE__) && !defined(WITHOUT_ICONV)
165176
return fossil_strdup(zUtf8);
166177
#else
167178
return (void *)zUtf8; /* No-op on unix */
@@ -188,11 +199,11 @@
188199
** to a file, -1 is returned and nothing is written
189200
** to the console.
190201
*/
191202
int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){
192203
#ifdef _WIN32
193
- int nChar;
204
+ int nChar, written = 0;
194205
wchar_t *zUnicode; /* Unicode version of zUtf8 */
195206
DWORD dummy;
196207
197208
static int istty[2] = { -1, -1 };
198209
if( istty[toStdErr] == -1 ){
@@ -207,17 +218,20 @@
207218
zUnicode = malloc( (nChar + 1) *sizeof(zUnicode[0]) );
208219
if( zUnicode==0 ){
209220
return 0;
210221
}
211222
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;
215231
}
216
- zUnicode[nChar] = '\0';
217
- WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode, nChar,
218
- &dummy, 0);
232
+ free(zUnicode);
219233
return nChar;
220234
#else
221235
return -1; /* No-op on unix */
222236
#endif
223237
}
224238
--- 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
--- www/fossil_prompt.wiki
+++ www/fossil_prompt.wiki
@@ -17,7 +17,7 @@
1717
</pre></blockquote>
1818
1919
For a permanent installation, you can graft the code into your
2020
<tt>.bashrc</tt> file in your home directory.
2121
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)
2323
and hence easy to customized.
2424
--- 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

Keyboard Shortcuts

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