Fossil SCM

Cygwin has same filesystem as Windows, so should be case-insensitive and do '/' <-> '\' conversion the same as win32. fossil_utf8_to_filename should do '/' -> '\' conversion on win32, as not all win32 API functions handle '/' correctly.

jan.nijtmans 2013-02-26 09:27 trunk
Commit d4b3e1d86d3d8e4e2a1f1dd3c081414e75230b80
3 files changed +1 -1 +3 -3 +11
+1 -1
--- src/add.c
+++ src/add.c
@@ -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
@@ -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
@@ -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
+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
+11
--- 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 */
168179
--- 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 */
168
--- 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 */
179

Keyboard Shortcuts

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