Fossil SCM

Rename fossil_utf8_to_unicode to fossil_utf8_to_filename on UNIX, everywhere where filenames are involved. This enables fossil_utf8_to_unicode/fossil_unicode_to_utf8 to be re-implemented on UNIX to do what the name suggests.

jan.nijtmans 2013-02-21 11:29 trunk merge
Commit 7eb5e2319f01c6c2b2847aef8a628904443f8861
+12 -12
--- src/file.c
+++ src/file.c
@@ -72,13 +72,13 @@
7272
}else{
7373
return stat(zFilename, buf);
7474
}
7575
#else
7676
int rc = 0;
77
- wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename);
77
+ wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
7878
rc = _wstati64(zMbcs, buf);
79
- fossil_unicode_free(zMbcs);
79
+ fossil_filename_free(zMbcs);
8080
return rc;
8181
#endif
8282
}
8383
8484
/*
@@ -303,13 +303,13 @@
303303
/*
304304
** Wrapper around the access() system call.
305305
*/
306306
int file_access(const char *zFilename, int flags){
307307
#ifdef _WIN32
308
- wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename);
308
+ wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
309309
int rc = _waccess(zMbcs, flags);
310
- fossil_unicode_free(zMbcs);
310
+ fossil_filename_free(zMbcs);
311311
#else
312312
int rc = access(zFilename, flags);
313313
#endif
314314
return rc;
315315
}
@@ -405,15 +405,15 @@
405405
tv[0].tv_sec = newMTime;
406406
tv[1].tv_sec = newMTime;
407407
utimes(zFilename, tv);
408408
#else
409409
struct _utimbuf tb;
410
- wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename);
410
+ wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
411411
tb.actime = newMTime;
412412
tb.modtime = newMTime;
413413
_wutime(zMbcs, &tb);
414
- fossil_unicode_free(zMbcs);
414
+ fossil_filename_free(zMbcs);
415415
#endif
416416
}
417417
418418
/*
419419
** COMMAND: test-set-mtime
@@ -441,13 +441,13 @@
441441
/*
442442
** Delete a file.
443443
*/
444444
void file_delete(const char *zFilename){
445445
#ifdef _WIN32
446
- wchar_t *z = fossil_utf8_to_unicode(zFilename);
446
+ wchar_t *z = fossil_utf8_to_filename(zFilename);
447447
_wunlink(z);
448
- fossil_unicode_free(z);
448
+ fossil_filename_free(z);
449449
#else
450450
unlink(zFilename);
451451
#endif
452452
}
453453
@@ -465,13 +465,13 @@
465465
file_delete(zName);
466466
}
467467
if( rc!=1 ){
468468
#if defined(_WIN32)
469469
int rc;
470
- wchar_t *zMbcs = fossil_utf8_to_unicode(zName);
470
+ wchar_t *zMbcs = fossil_utf8_to_filename(zName);
471471
rc = _wmkdir(zMbcs);
472
- fossil_unicode_free(zMbcs);
472
+ fossil_filename_free(zMbcs);
473473
return rc;
474474
#else
475475
return mkdir(zName, 0755);
476476
#endif
477477
}
@@ -1137,14 +1137,14 @@
11371137
** Like fopen() but always takes a UTF8 argument.
11381138
*/
11391139
FILE *fossil_fopen(const char *zName, const char *zMode){
11401140
#ifdef _WIN32
11411141
wchar_t *uMode = fossil_utf8_to_unicode(zMode);
1142
- wchar_t *uName = fossil_utf8_to_unicode(zName);
1142
+ wchar_t *uName = fossil_utf8_to_filename(zName);
11431143
FILE *f = _wfopen(uName, uMode);
1144
- fossil_unicode_free(uName);
1144
+ fossil_filename_free(uName);
11451145
fossil_unicode_free(uMode);
11461146
#else
11471147
FILE *f = fopen(zName, zMode);
11481148
#endif
11491149
return f;
11501150
}
11511151
--- src/file.c
+++ src/file.c
@@ -72,13 +72,13 @@
72 }else{
73 return stat(zFilename, buf);
74 }
75 #else
76 int rc = 0;
77 wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename);
78 rc = _wstati64(zMbcs, buf);
79 fossil_unicode_free(zMbcs);
80 return rc;
81 #endif
82 }
83
84 /*
@@ -303,13 +303,13 @@
303 /*
304 ** Wrapper around the access() system call.
305 */
306 int file_access(const char *zFilename, int flags){
307 #ifdef _WIN32
308 wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename);
309 int rc = _waccess(zMbcs, flags);
310 fossil_unicode_free(zMbcs);
311 #else
312 int rc = access(zFilename, flags);
313 #endif
314 return rc;
315 }
@@ -405,15 +405,15 @@
405 tv[0].tv_sec = newMTime;
406 tv[1].tv_sec = newMTime;
407 utimes(zFilename, tv);
408 #else
409 struct _utimbuf tb;
410 wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename);
411 tb.actime = newMTime;
412 tb.modtime = newMTime;
413 _wutime(zMbcs, &tb);
414 fossil_unicode_free(zMbcs);
415 #endif
416 }
417
418 /*
419 ** COMMAND: test-set-mtime
@@ -441,13 +441,13 @@
441 /*
442 ** Delete a file.
443 */
444 void file_delete(const char *zFilename){
445 #ifdef _WIN32
446 wchar_t *z = fossil_utf8_to_unicode(zFilename);
447 _wunlink(z);
448 fossil_unicode_free(z);
449 #else
450 unlink(zFilename);
451 #endif
452 }
453
@@ -465,13 +465,13 @@
465 file_delete(zName);
466 }
467 if( rc!=1 ){
468 #if defined(_WIN32)
469 int rc;
470 wchar_t *zMbcs = fossil_utf8_to_unicode(zName);
471 rc = _wmkdir(zMbcs);
472 fossil_unicode_free(zMbcs);
473 return rc;
474 #else
475 return mkdir(zName, 0755);
476 #endif
477 }
@@ -1137,14 +1137,14 @@
1137 ** Like fopen() but always takes a UTF8 argument.
1138 */
1139 FILE *fossil_fopen(const char *zName, const char *zMode){
1140 #ifdef _WIN32
1141 wchar_t *uMode = fossil_utf8_to_unicode(zMode);
1142 wchar_t *uName = fossil_utf8_to_unicode(zName);
1143 FILE *f = _wfopen(uName, uMode);
1144 fossil_unicode_free(uName);
1145 fossil_unicode_free(uMode);
1146 #else
1147 FILE *f = fopen(zName, zMode);
1148 #endif
1149 return f;
1150 }
1151
--- src/file.c
+++ src/file.c
@@ -72,13 +72,13 @@
72 }else{
73 return stat(zFilename, buf);
74 }
75 #else
76 int rc = 0;
77 wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
78 rc = _wstati64(zMbcs, buf);
79 fossil_filename_free(zMbcs);
80 return rc;
81 #endif
82 }
83
84 /*
@@ -303,13 +303,13 @@
303 /*
304 ** Wrapper around the access() system call.
305 */
306 int file_access(const char *zFilename, int flags){
307 #ifdef _WIN32
308 wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
309 int rc = _waccess(zMbcs, flags);
310 fossil_filename_free(zMbcs);
311 #else
312 int rc = access(zFilename, flags);
313 #endif
314 return rc;
315 }
@@ -405,15 +405,15 @@
405 tv[0].tv_sec = newMTime;
406 tv[1].tv_sec = newMTime;
407 utimes(zFilename, tv);
408 #else
409 struct _utimbuf tb;
410 wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
411 tb.actime = newMTime;
412 tb.modtime = newMTime;
413 _wutime(zMbcs, &tb);
414 fossil_filename_free(zMbcs);
415 #endif
416 }
417
418 /*
419 ** COMMAND: test-set-mtime
@@ -441,13 +441,13 @@
441 /*
442 ** Delete a file.
443 */
444 void file_delete(const char *zFilename){
445 #ifdef _WIN32
446 wchar_t *z = fossil_utf8_to_filename(zFilename);
447 _wunlink(z);
448 fossil_filename_free(z);
449 #else
450 unlink(zFilename);
451 #endif
452 }
453
@@ -465,13 +465,13 @@
465 file_delete(zName);
466 }
467 if( rc!=1 ){
468 #if defined(_WIN32)
469 int rc;
470 wchar_t *zMbcs = fossil_utf8_to_filename(zName);
471 rc = _wmkdir(zMbcs);
472 fossil_filename_free(zMbcs);
473 return rc;
474 #else
475 return mkdir(zName, 0755);
476 #endif
477 }
@@ -1137,14 +1137,14 @@
1137 ** Like fopen() but always takes a UTF8 argument.
1138 */
1139 FILE *fossil_fopen(const char *zName, const char *zMode){
1140 #ifdef _WIN32
1141 wchar_t *uMode = fossil_utf8_to_unicode(zMode);
1142 wchar_t *uName = fossil_utf8_to_filename(zName);
1143 FILE *f = _wfopen(uName, uMode);
1144 fossil_filename_free(uName);
1145 fossil_unicode_free(uMode);
1146 #else
1147 FILE *f = fopen(zName, zMode);
1148 #endif
1149 return f;
1150 }
1151
+12 -12
--- src/file.c
+++ src/file.c
@@ -72,13 +72,13 @@
7272
}else{
7373
return stat(zFilename, buf);
7474
}
7575
#else
7676
int rc = 0;
77
- wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename);
77
+ wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
7878
rc = _wstati64(zMbcs, buf);
79
- fossil_unicode_free(zMbcs);
79
+ fossil_filename_free(zMbcs);
8080
return rc;
8181
#endif
8282
}
8383
8484
/*
@@ -303,13 +303,13 @@
303303
/*
304304
** Wrapper around the access() system call.
305305
*/
306306
int file_access(const char *zFilename, int flags){
307307
#ifdef _WIN32
308
- wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename);
308
+ wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
309309
int rc = _waccess(zMbcs, flags);
310
- fossil_unicode_free(zMbcs);
310
+ fossil_filename_free(zMbcs);
311311
#else
312312
int rc = access(zFilename, flags);
313313
#endif
314314
return rc;
315315
}
@@ -405,15 +405,15 @@
405405
tv[0].tv_sec = newMTime;
406406
tv[1].tv_sec = newMTime;
407407
utimes(zFilename, tv);
408408
#else
409409
struct _utimbuf tb;
410
- wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename);
410
+ wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
411411
tb.actime = newMTime;
412412
tb.modtime = newMTime;
413413
_wutime(zMbcs, &tb);
414
- fossil_unicode_free(zMbcs);
414
+ fossil_filename_free(zMbcs);
415415
#endif
416416
}
417417
418418
/*
419419
** COMMAND: test-set-mtime
@@ -441,13 +441,13 @@
441441
/*
442442
** Delete a file.
443443
*/
444444
void file_delete(const char *zFilename){
445445
#ifdef _WIN32
446
- wchar_t *z = fossil_utf8_to_unicode(zFilename);
446
+ wchar_t *z = fossil_utf8_to_filename(zFilename);
447447
_wunlink(z);
448
- fossil_unicode_free(z);
448
+ fossil_filename_free(z);
449449
#else
450450
unlink(zFilename);
451451
#endif
452452
}
453453
@@ -465,13 +465,13 @@
465465
file_delete(zName);
466466
}
467467
if( rc!=1 ){
468468
#if defined(_WIN32)
469469
int rc;
470
- wchar_t *zMbcs = fossil_utf8_to_unicode(zName);
470
+ wchar_t *zMbcs = fossil_utf8_to_filename(zName);
471471
rc = _wmkdir(zMbcs);
472
- fossil_unicode_free(zMbcs);
472
+ fossil_filename_free(zMbcs);
473473
return rc;
474474
#else
475475
return mkdir(zName, 0755);
476476
#endif
477477
}
@@ -1137,14 +1137,14 @@
11371137
** Like fopen() but always takes a UTF8 argument.
11381138
*/
11391139
FILE *fossil_fopen(const char *zName, const char *zMode){
11401140
#ifdef _WIN32
11411141
wchar_t *uMode = fossil_utf8_to_unicode(zMode);
1142
- wchar_t *uName = fossil_utf8_to_unicode(zName);
1142
+ wchar_t *uName = fossil_utf8_to_filename(zName);
11431143
FILE *f = _wfopen(uName, uMode);
1144
- fossil_unicode_free(uName);
1144
+ fossil_filename_free(uName);
11451145
fossil_unicode_free(uMode);
11461146
#else
11471147
FILE *f = fopen(zName, zMode);
11481148
#endif
11491149
return f;
11501150
}
11511151
--- src/file.c
+++ src/file.c
@@ -72,13 +72,13 @@
72 }else{
73 return stat(zFilename, buf);
74 }
75 #else
76 int rc = 0;
77 wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename);
78 rc = _wstati64(zMbcs, buf);
79 fossil_unicode_free(zMbcs);
80 return rc;
81 #endif
82 }
83
84 /*
@@ -303,13 +303,13 @@
303 /*
304 ** Wrapper around the access() system call.
305 */
306 int file_access(const char *zFilename, int flags){
307 #ifdef _WIN32
308 wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename);
309 int rc = _waccess(zMbcs, flags);
310 fossil_unicode_free(zMbcs);
311 #else
312 int rc = access(zFilename, flags);
313 #endif
314 return rc;
315 }
@@ -405,15 +405,15 @@
405 tv[0].tv_sec = newMTime;
406 tv[1].tv_sec = newMTime;
407 utimes(zFilename, tv);
408 #else
409 struct _utimbuf tb;
410 wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename);
411 tb.actime = newMTime;
412 tb.modtime = newMTime;
413 _wutime(zMbcs, &tb);
414 fossil_unicode_free(zMbcs);
415 #endif
416 }
417
418 /*
419 ** COMMAND: test-set-mtime
@@ -441,13 +441,13 @@
441 /*
442 ** Delete a file.
443 */
444 void file_delete(const char *zFilename){
445 #ifdef _WIN32
446 wchar_t *z = fossil_utf8_to_unicode(zFilename);
447 _wunlink(z);
448 fossil_unicode_free(z);
449 #else
450 unlink(zFilename);
451 #endif
452 }
453
@@ -465,13 +465,13 @@
465 file_delete(zName);
466 }
467 if( rc!=1 ){
468 #if defined(_WIN32)
469 int rc;
470 wchar_t *zMbcs = fossil_utf8_to_unicode(zName);
471 rc = _wmkdir(zMbcs);
472 fossil_unicode_free(zMbcs);
473 return rc;
474 #else
475 return mkdir(zName, 0755);
476 #endif
477 }
@@ -1137,14 +1137,14 @@
1137 ** Like fopen() but always takes a UTF8 argument.
1138 */
1139 FILE *fossil_fopen(const char *zName, const char *zMode){
1140 #ifdef _WIN32
1141 wchar_t *uMode = fossil_utf8_to_unicode(zMode);
1142 wchar_t *uName = fossil_utf8_to_unicode(zName);
1143 FILE *f = _wfopen(uName, uMode);
1144 fossil_unicode_free(uName);
1145 fossil_unicode_free(uMode);
1146 #else
1147 FILE *f = fopen(zName, zMode);
1148 #endif
1149 return f;
1150 }
1151
--- src/file.c
+++ src/file.c
@@ -72,13 +72,13 @@
72 }else{
73 return stat(zFilename, buf);
74 }
75 #else
76 int rc = 0;
77 wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
78 rc = _wstati64(zMbcs, buf);
79 fossil_filename_free(zMbcs);
80 return rc;
81 #endif
82 }
83
84 /*
@@ -303,13 +303,13 @@
303 /*
304 ** Wrapper around the access() system call.
305 */
306 int file_access(const char *zFilename, int flags){
307 #ifdef _WIN32
308 wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
309 int rc = _waccess(zMbcs, flags);
310 fossil_filename_free(zMbcs);
311 #else
312 int rc = access(zFilename, flags);
313 #endif
314 return rc;
315 }
@@ -405,15 +405,15 @@
405 tv[0].tv_sec = newMTime;
406 tv[1].tv_sec = newMTime;
407 utimes(zFilename, tv);
408 #else
409 struct _utimbuf tb;
410 wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
411 tb.actime = newMTime;
412 tb.modtime = newMTime;
413 _wutime(zMbcs, &tb);
414 fossil_filename_free(zMbcs);
415 #endif
416 }
417
418 /*
419 ** COMMAND: test-set-mtime
@@ -441,13 +441,13 @@
441 /*
442 ** Delete a file.
443 */
444 void file_delete(const char *zFilename){
445 #ifdef _WIN32
446 wchar_t *z = fossil_utf8_to_filename(zFilename);
447 _wunlink(z);
448 fossil_filename_free(z);
449 #else
450 unlink(zFilename);
451 #endif
452 }
453
@@ -465,13 +465,13 @@
465 file_delete(zName);
466 }
467 if( rc!=1 ){
468 #if defined(_WIN32)
469 int rc;
470 wchar_t *zMbcs = fossil_utf8_to_filename(zName);
471 rc = _wmkdir(zMbcs);
472 fossil_filename_free(zMbcs);
473 return rc;
474 #else
475 return mkdir(zName, 0755);
476 #endif
477 }
@@ -1137,14 +1137,14 @@
1137 ** Like fopen() but always takes a UTF8 argument.
1138 */
1139 FILE *fossil_fopen(const char *zName, const char *zMode){
1140 #ifdef _WIN32
1141 wchar_t *uMode = fossil_utf8_to_unicode(zMode);
1142 wchar_t *uName = fossil_utf8_to_filename(zName);
1143 FILE *f = _wfopen(uName, uMode);
1144 fossil_filename_free(uName);
1145 fossil_unicode_free(uMode);
1146 #else
1147 FILE *f = fopen(zName, zMode);
1148 #endif
1149 return f;
1150 }
1151
+2 -2
--- src/rebuild.c
+++ src/rebuild.c
@@ -841,11 +841,11 @@
841841
Blob aContent; /* content of the just read artifact */
842842
static int nFileRead = 0;
843843
void *zUnicodePath;
844844
char *zUtf8Name;
845845
846
- zUnicodePath = fossil_utf8_to_unicode(zPath);
846
+ zUnicodePath = fossil_utf8_to_filename(zPath);
847847
d = opendir(zUnicodePath);
848848
if( d ){
849849
while( (pEntry=readdir(d))!=0 ){
850850
Blob path;
851851
char *zSubpath;
@@ -875,11 +875,11 @@
875875
closedir(d);
876876
}else {
877877
fossil_panic("encountered error %d while trying to open \"%s\".",
878878
errno, g.argv[3]);
879879
}
880
- fossil_unicode_free(zUnicodePath);
880
+ fossil_filename_free(zUnicodePath);
881881
}
882882
883883
/*
884884
** COMMAND: reconstruct*
885885
**
886886
--- src/rebuild.c
+++ src/rebuild.c
@@ -841,11 +841,11 @@
841 Blob aContent; /* content of the just read artifact */
842 static int nFileRead = 0;
843 void *zUnicodePath;
844 char *zUtf8Name;
845
846 zUnicodePath = fossil_utf8_to_unicode(zPath);
847 d = opendir(zUnicodePath);
848 if( d ){
849 while( (pEntry=readdir(d))!=0 ){
850 Blob path;
851 char *zSubpath;
@@ -875,11 +875,11 @@
875 closedir(d);
876 }else {
877 fossil_panic("encountered error %d while trying to open \"%s\".",
878 errno, g.argv[3]);
879 }
880 fossil_unicode_free(zUnicodePath);
881 }
882
883 /*
884 ** COMMAND: reconstruct*
885 **
886
--- src/rebuild.c
+++ src/rebuild.c
@@ -841,11 +841,11 @@
841 Blob aContent; /* content of the just read artifact */
842 static int nFileRead = 0;
843 void *zUnicodePath;
844 char *zUtf8Name;
845
846 zUnicodePath = fossil_utf8_to_filename(zPath);
847 d = opendir(zUnicodePath);
848 if( d ){
849 while( (pEntry=readdir(d))!=0 ){
850 Blob path;
851 char *zSubpath;
@@ -875,11 +875,11 @@
875 closedir(d);
876 }else {
877 fossil_panic("encountered error %d while trying to open \"%s\".",
878 errno, g.argv[3]);
879 }
880 fossil_filename_free(zUnicodePath);
881 }
882
883 /*
884 ** COMMAND: reconstruct*
885 **
886
+36 -20
--- src/utf8.c
+++ src/utf8.c
@@ -24,38 +24,31 @@
2424
#include <sqlite3.h>
2525
#ifdef _WIN32
2626
# include <windows.h>
2727
#endif
2828
29
+#ifdef _WIN32
2930
/*
30
-** Translate MBCS to UTF8. Return a pointer to the translated text.
31
+** Translate MBCS to UTF-8. Return a pointer to the translated text.
3132
** Call fossil_mbcs_free() to deallocate any memory used to store the
3233
** returned pointer when done.
3334
*/
3435
char *fossil_mbcs_to_utf8(const char *zMbcs){
35
-#ifdef _WIN32
3636
extern char *sqlite3_win32_mbcs_to_utf8(const char*);
3737
return sqlite3_win32_mbcs_to_utf8(zMbcs);
38
-#else
39
- return (char*)zMbcs; /* No-op on unix */
40
-#endif
4138
}
4239
4340
/*
44
-** After translating from UTF8 to MBCS, invoke this routine to deallocate
41
+** After translating from UTF-8 to MBCS, invoke this routine to deallocate
4542
** any memory used to hold the translation
4643
*/
4744
void fossil_mbcs_free(char *zOld){
48
-#ifdef _WIN32
4945
sqlite3_free(zOld);
50
-#else
51
- /* No-op on unix */
52
-#endif
5346
}
5447
5548
/*
56
-** Translate Unicode text into UTF8.
49
+** Translate Unicode text into UTF-8.
5750
** Return a pointer to the translated text.
5851
** Call fossil_unicode_free() to deallocate any memory used to store the
5952
** returned pointer when done.
6053
*/
6154
char *fossil_unicode_to_utf8(const void *zUnicode){
@@ -66,16 +59,16 @@
6659
return 0;
6760
}
6861
WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, zUtf, nByte, 0, 0);
6962
return zUtf;
7063
#else
71
- return (char *)zUnicode; /* No-op on unix */
64
+ return fossil_strdup(zUtf8); /* TODO: implement for unix */
7265
#endif
7366
}
7467
7568
/*
76
-** Translate UTF8 to unicode for use in system calls. Return a pointer to the
69
+** Translate UTF-8 to unicode for use in system calls. Return a pointer to the
7770
** translated text.. Call fossil_unicode_free() to deallocate any memory
7871
** used to store the returned pointer when done.
7972
*/
8073
void *fossil_utf8_to_unicode(const char *zUtf8){
8174
#ifdef _WIN32
@@ -85,11 +78,11 @@
8578
return 0;
8679
}
8780
MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nByte);
8881
return zUnicode;
8982
#else
90
- return (void *)zUtf8; /* No-op on unix */
83
+ return fossil_strdup(zUtf8); /* TODO: implement for unix */
9184
#endif
9285
}
9386
9487
/*
9588
** Deallocate any memory that was previously allocated by
@@ -97,21 +90,22 @@
9790
*/
9891
void fossil_unicode_free(void *pOld){
9992
#ifdef _WIN32
10093
sqlite3_free(pOld);
10194
#else
102
- /* No-op on unix */
95
+ fossil_free(pOld);
10396
#endif
10497
}
98
+#endif /* _WIN32 */
10599
106100
#if defined(__APPLE__) && !defined(WITHOUT_ICONV)
107101
# include <iconv.h>
108102
#endif
109103
110104
/*
111
-** Translate text from the filename character set into
112
-** to precomposed UTF8. Return a pointer to the translated text.
105
+** Translate text from the filename character set into UTF-8.
106
+** Return a pointer to the translated text.
113107
** Call fossil_filename_free() to deallocate any memory used to store the
114108
** returned pointer when done.
115109
*/
116110
char *fossil_filename_to_utf8(const void *zFilename){
117111
#if defined(_WIN32)
@@ -149,16 +143,38 @@
149143
return zOut;
150144
#else
151145
return (char *)zFilename; /* No-op on non-mac unix */
152146
#endif
153147
}
148
+
149
+/*
150
+** Translate text from UTF-8 to the filename character set.
151
+** Return a pointer to the translated text.
152
+** Call fossil_filename_free() to deallocate any memory used to store the
153
+** returned pointer when done.
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
+#endif
169
+}
154170
155171
/*
156172
** Deallocate any memory that was previously allocated by
157
-** fossil_filename_to_utf8().
173
+** fossil_filename_to_utf8() or fossil_utf8_to_filename().
158174
*/
159
-void fossil_filename_free(char *pOld){
175
+void fossil_filename_free(void *pOld){
160176
#if defined(_WIN32)
161177
sqlite3_free(pOld);
162178
#elif defined(__APPLE__) && !defined(WITHOUT_ICONV)
163179
fossil_free(pOld);
164180
#else
@@ -165,11 +181,11 @@
165181
/* No-op on all other unix */
166182
#endif
167183
}
168184
169185
/*
170
-** Display UTF8 on the console. Return the number of
186
+** Display UTF-8 on the console. Return the number of
171187
** Characters written. If stdout or stderr is redirected
172188
** to a file, -1 is returned and nothing is written
173189
** to the console.
174190
*/
175191
int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){
176192
--- src/utf8.c
+++ src/utf8.c
@@ -24,38 +24,31 @@
24 #include <sqlite3.h>
25 #ifdef _WIN32
26 # include <windows.h>
27 #endif
28
 
29 /*
30 ** Translate MBCS to UTF8. Return a pointer to the translated text.
31 ** Call fossil_mbcs_free() to deallocate any memory used to store the
32 ** returned pointer when done.
33 */
34 char *fossil_mbcs_to_utf8(const char *zMbcs){
35 #ifdef _WIN32
36 extern char *sqlite3_win32_mbcs_to_utf8(const char*);
37 return sqlite3_win32_mbcs_to_utf8(zMbcs);
38 #else
39 return (char*)zMbcs; /* No-op on unix */
40 #endif
41 }
42
43 /*
44 ** After translating from UTF8 to MBCS, invoke this routine to deallocate
45 ** any memory used to hold the translation
46 */
47 void fossil_mbcs_free(char *zOld){
48 #ifdef _WIN32
49 sqlite3_free(zOld);
50 #else
51 /* No-op on unix */
52 #endif
53 }
54
55 /*
56 ** Translate Unicode text into UTF8.
57 ** Return a pointer to the translated text.
58 ** Call fossil_unicode_free() to deallocate any memory used to store the
59 ** returned pointer when done.
60 */
61 char *fossil_unicode_to_utf8(const void *zUnicode){
@@ -66,16 +59,16 @@
66 return 0;
67 }
68 WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, zUtf, nByte, 0, 0);
69 return zUtf;
70 #else
71 return (char *)zUnicode; /* No-op on unix */
72 #endif
73 }
74
75 /*
76 ** Translate UTF8 to unicode for use in system calls. Return a pointer to the
77 ** translated text.. Call fossil_unicode_free() to deallocate any memory
78 ** used to store the returned pointer when done.
79 */
80 void *fossil_utf8_to_unicode(const char *zUtf8){
81 #ifdef _WIN32
@@ -85,11 +78,11 @@
85 return 0;
86 }
87 MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nByte);
88 return zUnicode;
89 #else
90 return (void *)zUtf8; /* No-op on unix */
91 #endif
92 }
93
94 /*
95 ** Deallocate any memory that was previously allocated by
@@ -97,21 +90,22 @@
97 */
98 void fossil_unicode_free(void *pOld){
99 #ifdef _WIN32
100 sqlite3_free(pOld);
101 #else
102 /* No-op on unix */
103 #endif
104 }
 
105
106 #if defined(__APPLE__) && !defined(WITHOUT_ICONV)
107 # include <iconv.h>
108 #endif
109
110 /*
111 ** Translate text from the filename character set into
112 ** to precomposed UTF8. Return a pointer to the translated text.
113 ** Call fossil_filename_free() to deallocate any memory used to store the
114 ** returned pointer when done.
115 */
116 char *fossil_filename_to_utf8(const void *zFilename){
117 #if defined(_WIN32)
@@ -149,16 +143,38 @@
149 return zOut;
150 #else
151 return (char *)zFilename; /* No-op on non-mac unix */
152 #endif
153 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
155 /*
156 ** Deallocate any memory that was previously allocated by
157 ** fossil_filename_to_utf8().
158 */
159 void fossil_filename_free(char *pOld){
160 #if defined(_WIN32)
161 sqlite3_free(pOld);
162 #elif defined(__APPLE__) && !defined(WITHOUT_ICONV)
163 fossil_free(pOld);
164 #else
@@ -165,11 +181,11 @@
165 /* No-op on all other unix */
166 #endif
167 }
168
169 /*
170 ** Display UTF8 on the console. Return the number of
171 ** Characters written. If stdout or stderr is redirected
172 ** to a file, -1 is returned and nothing is written
173 ** to the console.
174 */
175 int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){
176
--- src/utf8.c
+++ src/utf8.c
@@ -24,38 +24,31 @@
24 #include <sqlite3.h>
25 #ifdef _WIN32
26 # include <windows.h>
27 #endif
28
29 #ifdef _WIN32
30 /*
31 ** Translate MBCS to UTF-8. Return a pointer to the translated text.
32 ** Call fossil_mbcs_free() to deallocate any memory used to store the
33 ** returned pointer when done.
34 */
35 char *fossil_mbcs_to_utf8(const char *zMbcs){
 
36 extern char *sqlite3_win32_mbcs_to_utf8(const char*);
37 return sqlite3_win32_mbcs_to_utf8(zMbcs);
 
 
 
38 }
39
40 /*
41 ** After translating from UTF-8 to MBCS, invoke this routine to deallocate
42 ** any memory used to hold the translation
43 */
44 void fossil_mbcs_free(char *zOld){
 
45 sqlite3_free(zOld);
 
 
 
46 }
47
48 /*
49 ** Translate Unicode text into UTF-8.
50 ** Return a pointer to the translated text.
51 ** Call fossil_unicode_free() to deallocate any memory used to store the
52 ** returned pointer when done.
53 */
54 char *fossil_unicode_to_utf8(const void *zUnicode){
@@ -66,16 +59,16 @@
59 return 0;
60 }
61 WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, zUtf, nByte, 0, 0);
62 return zUtf;
63 #else
64 return fossil_strdup(zUtf8); /* TODO: implement for unix */
65 #endif
66 }
67
68 /*
69 ** Translate UTF-8 to unicode for use in system calls. Return a pointer to the
70 ** translated text.. Call fossil_unicode_free() to deallocate any memory
71 ** used to store the returned pointer when done.
72 */
73 void *fossil_utf8_to_unicode(const char *zUtf8){
74 #ifdef _WIN32
@@ -85,11 +78,11 @@
78 return 0;
79 }
80 MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nByte);
81 return zUnicode;
82 #else
83 return fossil_strdup(zUtf8); /* TODO: implement for unix */
84 #endif
85 }
86
87 /*
88 ** Deallocate any memory that was previously allocated by
@@ -97,21 +90,22 @@
90 */
91 void fossil_unicode_free(void *pOld){
92 #ifdef _WIN32
93 sqlite3_free(pOld);
94 #else
95 fossil_free(pOld);
96 #endif
97 }
98 #endif /* _WIN32 */
99
100 #if defined(__APPLE__) && !defined(WITHOUT_ICONV)
101 # include <iconv.h>
102 #endif
103
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)
@@ -149,16 +143,38 @@
143 return zOut;
144 #else
145 return (char *)zFilename; /* No-op on non-mac unix */
146 #endif
147 }
148
149 /*
150 ** Translate text from UTF-8 to the filename character set.
151 ** Return a pointer to the translated text.
152 ** Call fossil_filename_free() to deallocate any memory used to store the
153 ** returned pointer when done.
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 #endif
169 }
170
171 /*
172 ** Deallocate any memory that was previously allocated by
173 ** fossil_filename_to_utf8() or fossil_utf8_to_filename().
174 */
175 void fossil_filename_free(void *pOld){
176 #if defined(_WIN32)
177 sqlite3_free(pOld);
178 #elif defined(__APPLE__) && !defined(WITHOUT_ICONV)
179 fossil_free(pOld);
180 #else
@@ -165,11 +181,11 @@
181 /* No-op on all other unix */
182 #endif
183 }
184
185 /*
186 ** Display UTF-8 on the console. Return the number of
187 ** Characters written. If stdout or stderr is redirected
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
+36 -20
--- src/utf8.c
+++ src/utf8.c
@@ -24,38 +24,31 @@
2424
#include <sqlite3.h>
2525
#ifdef _WIN32
2626
# include <windows.h>
2727
#endif
2828
29
+#ifdef _WIN32
2930
/*
30
-** Translate MBCS to UTF8. Return a pointer to the translated text.
31
+** Translate MBCS to UTF-8. Return a pointer to the translated text.
3132
** Call fossil_mbcs_free() to deallocate any memory used to store the
3233
** returned pointer when done.
3334
*/
3435
char *fossil_mbcs_to_utf8(const char *zMbcs){
35
-#ifdef _WIN32
3636
extern char *sqlite3_win32_mbcs_to_utf8(const char*);
3737
return sqlite3_win32_mbcs_to_utf8(zMbcs);
38
-#else
39
- return (char*)zMbcs; /* No-op on unix */
40
-#endif
4138
}
4239
4340
/*
44
-** After translating from UTF8 to MBCS, invoke this routine to deallocate
41
+** After translating from UTF-8 to MBCS, invoke this routine to deallocate
4542
** any memory used to hold the translation
4643
*/
4744
void fossil_mbcs_free(char *zOld){
48
-#ifdef _WIN32
4945
sqlite3_free(zOld);
50
-#else
51
- /* No-op on unix */
52
-#endif
5346
}
5447
5548
/*
56
-** Translate Unicode text into UTF8.
49
+** Translate Unicode text into UTF-8.
5750
** Return a pointer to the translated text.
5851
** Call fossil_unicode_free() to deallocate any memory used to store the
5952
** returned pointer when done.
6053
*/
6154
char *fossil_unicode_to_utf8(const void *zUnicode){
@@ -66,16 +59,16 @@
6659
return 0;
6760
}
6861
WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, zUtf, nByte, 0, 0);
6962
return zUtf;
7063
#else
71
- return (char *)zUnicode; /* No-op on unix */
64
+ return fossil_strdup(zUtf8); /* TODO: implement for unix */
7265
#endif
7366
}
7467
7568
/*
76
-** Translate UTF8 to unicode for use in system calls. Return a pointer to the
69
+** Translate UTF-8 to unicode for use in system calls. Return a pointer to the
7770
** translated text.. Call fossil_unicode_free() to deallocate any memory
7871
** used to store the returned pointer when done.
7972
*/
8073
void *fossil_utf8_to_unicode(const char *zUtf8){
8174
#ifdef _WIN32
@@ -85,11 +78,11 @@
8578
return 0;
8679
}
8780
MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nByte);
8881
return zUnicode;
8982
#else
90
- return (void *)zUtf8; /* No-op on unix */
83
+ return fossil_strdup(zUtf8); /* TODO: implement for unix */
9184
#endif
9285
}
9386
9487
/*
9588
** Deallocate any memory that was previously allocated by
@@ -97,21 +90,22 @@
9790
*/
9891
void fossil_unicode_free(void *pOld){
9992
#ifdef _WIN32
10093
sqlite3_free(pOld);
10194
#else
102
- /* No-op on unix */
95
+ fossil_free(pOld);
10396
#endif
10497
}
98
+#endif /* _WIN32 */
10599
106100
#if defined(__APPLE__) && !defined(WITHOUT_ICONV)
107101
# include <iconv.h>
108102
#endif
109103
110104
/*
111
-** Translate text from the filename character set into
112
-** to precomposed UTF8. Return a pointer to the translated text.
105
+** Translate text from the filename character set into UTF-8.
106
+** Return a pointer to the translated text.
113107
** Call fossil_filename_free() to deallocate any memory used to store the
114108
** returned pointer when done.
115109
*/
116110
char *fossil_filename_to_utf8(const void *zFilename){
117111
#if defined(_WIN32)
@@ -149,16 +143,38 @@
149143
return zOut;
150144
#else
151145
return (char *)zFilename; /* No-op on non-mac unix */
152146
#endif
153147
}
148
+
149
+/*
150
+** Translate text from UTF-8 to the filename character set.
151
+** Return a pointer to the translated text.
152
+** Call fossil_filename_free() to deallocate any memory used to store the
153
+** returned pointer when done.
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
+#endif
169
+}
154170
155171
/*
156172
** Deallocate any memory that was previously allocated by
157
-** fossil_filename_to_utf8().
173
+** fossil_filename_to_utf8() or fossil_utf8_to_filename().
158174
*/
159
-void fossil_filename_free(char *pOld){
175
+void fossil_filename_free(void *pOld){
160176
#if defined(_WIN32)
161177
sqlite3_free(pOld);
162178
#elif defined(__APPLE__) && !defined(WITHOUT_ICONV)
163179
fossil_free(pOld);
164180
#else
@@ -165,11 +181,11 @@
165181
/* No-op on all other unix */
166182
#endif
167183
}
168184
169185
/*
170
-** Display UTF8 on the console. Return the number of
186
+** Display UTF-8 on the console. Return the number of
171187
** Characters written. If stdout or stderr is redirected
172188
** to a file, -1 is returned and nothing is written
173189
** to the console.
174190
*/
175191
int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){
176192
--- src/utf8.c
+++ src/utf8.c
@@ -24,38 +24,31 @@
24 #include <sqlite3.h>
25 #ifdef _WIN32
26 # include <windows.h>
27 #endif
28
 
29 /*
30 ** Translate MBCS to UTF8. Return a pointer to the translated text.
31 ** Call fossil_mbcs_free() to deallocate any memory used to store the
32 ** returned pointer when done.
33 */
34 char *fossil_mbcs_to_utf8(const char *zMbcs){
35 #ifdef _WIN32
36 extern char *sqlite3_win32_mbcs_to_utf8(const char*);
37 return sqlite3_win32_mbcs_to_utf8(zMbcs);
38 #else
39 return (char*)zMbcs; /* No-op on unix */
40 #endif
41 }
42
43 /*
44 ** After translating from UTF8 to MBCS, invoke this routine to deallocate
45 ** any memory used to hold the translation
46 */
47 void fossil_mbcs_free(char *zOld){
48 #ifdef _WIN32
49 sqlite3_free(zOld);
50 #else
51 /* No-op on unix */
52 #endif
53 }
54
55 /*
56 ** Translate Unicode text into UTF8.
57 ** Return a pointer to the translated text.
58 ** Call fossil_unicode_free() to deallocate any memory used to store the
59 ** returned pointer when done.
60 */
61 char *fossil_unicode_to_utf8(const void *zUnicode){
@@ -66,16 +59,16 @@
66 return 0;
67 }
68 WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, zUtf, nByte, 0, 0);
69 return zUtf;
70 #else
71 return (char *)zUnicode; /* No-op on unix */
72 #endif
73 }
74
75 /*
76 ** Translate UTF8 to unicode for use in system calls. Return a pointer to the
77 ** translated text.. Call fossil_unicode_free() to deallocate any memory
78 ** used to store the returned pointer when done.
79 */
80 void *fossil_utf8_to_unicode(const char *zUtf8){
81 #ifdef _WIN32
@@ -85,11 +78,11 @@
85 return 0;
86 }
87 MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nByte);
88 return zUnicode;
89 #else
90 return (void *)zUtf8; /* No-op on unix */
91 #endif
92 }
93
94 /*
95 ** Deallocate any memory that was previously allocated by
@@ -97,21 +90,22 @@
97 */
98 void fossil_unicode_free(void *pOld){
99 #ifdef _WIN32
100 sqlite3_free(pOld);
101 #else
102 /* No-op on unix */
103 #endif
104 }
 
105
106 #if defined(__APPLE__) && !defined(WITHOUT_ICONV)
107 # include <iconv.h>
108 #endif
109
110 /*
111 ** Translate text from the filename character set into
112 ** to precomposed UTF8. Return a pointer to the translated text.
113 ** Call fossil_filename_free() to deallocate any memory used to store the
114 ** returned pointer when done.
115 */
116 char *fossil_filename_to_utf8(const void *zFilename){
117 #if defined(_WIN32)
@@ -149,16 +143,38 @@
149 return zOut;
150 #else
151 return (char *)zFilename; /* No-op on non-mac unix */
152 #endif
153 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
155 /*
156 ** Deallocate any memory that was previously allocated by
157 ** fossil_filename_to_utf8().
158 */
159 void fossil_filename_free(char *pOld){
160 #if defined(_WIN32)
161 sqlite3_free(pOld);
162 #elif defined(__APPLE__) && !defined(WITHOUT_ICONV)
163 fossil_free(pOld);
164 #else
@@ -165,11 +181,11 @@
165 /* No-op on all other unix */
166 #endif
167 }
168
169 /*
170 ** Display UTF8 on the console. Return the number of
171 ** Characters written. If stdout or stderr is redirected
172 ** to a file, -1 is returned and nothing is written
173 ** to the console.
174 */
175 int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){
176
--- src/utf8.c
+++ src/utf8.c
@@ -24,38 +24,31 @@
24 #include <sqlite3.h>
25 #ifdef _WIN32
26 # include <windows.h>
27 #endif
28
29 #ifdef _WIN32
30 /*
31 ** Translate MBCS to UTF-8. Return a pointer to the translated text.
32 ** Call fossil_mbcs_free() to deallocate any memory used to store the
33 ** returned pointer when done.
34 */
35 char *fossil_mbcs_to_utf8(const char *zMbcs){
 
36 extern char *sqlite3_win32_mbcs_to_utf8(const char*);
37 return sqlite3_win32_mbcs_to_utf8(zMbcs);
 
 
 
38 }
39
40 /*
41 ** After translating from UTF-8 to MBCS, invoke this routine to deallocate
42 ** any memory used to hold the translation
43 */
44 void fossil_mbcs_free(char *zOld){
 
45 sqlite3_free(zOld);
 
 
 
46 }
47
48 /*
49 ** Translate Unicode text into UTF-8.
50 ** Return a pointer to the translated text.
51 ** Call fossil_unicode_free() to deallocate any memory used to store the
52 ** returned pointer when done.
53 */
54 char *fossil_unicode_to_utf8(const void *zUnicode){
@@ -66,16 +59,16 @@
59 return 0;
60 }
61 WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, zUtf, nByte, 0, 0);
62 return zUtf;
63 #else
64 return fossil_strdup(zUtf8); /* TODO: implement for unix */
65 #endif
66 }
67
68 /*
69 ** Translate UTF-8 to unicode for use in system calls. Return a pointer to the
70 ** translated text.. Call fossil_unicode_free() to deallocate any memory
71 ** used to store the returned pointer when done.
72 */
73 void *fossil_utf8_to_unicode(const char *zUtf8){
74 #ifdef _WIN32
@@ -85,11 +78,11 @@
78 return 0;
79 }
80 MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nByte);
81 return zUnicode;
82 #else
83 return fossil_strdup(zUtf8); /* TODO: implement for unix */
84 #endif
85 }
86
87 /*
88 ** Deallocate any memory that was previously allocated by
@@ -97,21 +90,22 @@
90 */
91 void fossil_unicode_free(void *pOld){
92 #ifdef _WIN32
93 sqlite3_free(pOld);
94 #else
95 fossil_free(pOld);
96 #endif
97 }
98 #endif /* _WIN32 */
99
100 #if defined(__APPLE__) && !defined(WITHOUT_ICONV)
101 # include <iconv.h>
102 #endif
103
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)
@@ -149,16 +143,38 @@
143 return zOut;
144 #else
145 return (char *)zFilename; /* No-op on non-mac unix */
146 #endif
147 }
148
149 /*
150 ** Translate text from UTF-8 to the filename character set.
151 ** Return a pointer to the translated text.
152 ** Call fossil_filename_free() to deallocate any memory used to store the
153 ** returned pointer when done.
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 #endif
169 }
170
171 /*
172 ** Deallocate any memory that was previously allocated by
173 ** fossil_filename_to_utf8() or fossil_utf8_to_filename().
174 */
175 void fossil_filename_free(void *pOld){
176 #if defined(_WIN32)
177 sqlite3_free(pOld);
178 #elif defined(__APPLE__) && !defined(WITHOUT_ICONV)
179 fossil_free(pOld);
180 #else
@@ -165,11 +181,11 @@
181 /* No-op on all other unix */
182 #endif
183 }
184
185 /*
186 ** Display UTF-8 on the console. Return the number of
187 ** Characters written. If stdout or stderr is redirected
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
+2 -2
--- src/vfile.c
+++ src/vfile.c
@@ -459,11 +459,11 @@
459459
);
460460
}
461461
depth++;
462462
463463
zDir = blob_str(pPath);
464
- zNative = fossil_utf8_to_unicode(zDir);
464
+ zNative = fossil_utf8_to_filename(zDir);
465465
d = opendir(zNative);
466466
if( d ){
467467
while( (pEntry=readdir(d))!=0 ){
468468
char *zPath;
469469
char *zUtf8;
@@ -491,11 +491,11 @@
491491
fossil_filename_free(zUtf8);
492492
blob_resize(pPath, origSize);
493493
}
494494
closedir(d);
495495
}
496
- fossil_unicode_free(zNative);
496
+ fossil_filename_free(zNative);
497497
498498
depth--;
499499
if( depth==0 ){
500500
db_finalize(&ins);
501501
}
502502
--- src/vfile.c
+++ src/vfile.c
@@ -459,11 +459,11 @@
459 );
460 }
461 depth++;
462
463 zDir = blob_str(pPath);
464 zNative = fossil_utf8_to_unicode(zDir);
465 d = opendir(zNative);
466 if( d ){
467 while( (pEntry=readdir(d))!=0 ){
468 char *zPath;
469 char *zUtf8;
@@ -491,11 +491,11 @@
491 fossil_filename_free(zUtf8);
492 blob_resize(pPath, origSize);
493 }
494 closedir(d);
495 }
496 fossil_unicode_free(zNative);
497
498 depth--;
499 if( depth==0 ){
500 db_finalize(&ins);
501 }
502
--- src/vfile.c
+++ src/vfile.c
@@ -459,11 +459,11 @@
459 );
460 }
461 depth++;
462
463 zDir = blob_str(pPath);
464 zNative = fossil_utf8_to_filename(zDir);
465 d = opendir(zNative);
466 if( d ){
467 while( (pEntry=readdir(d))!=0 ){
468 char *zPath;
469 char *zUtf8;
@@ -491,11 +491,11 @@
491 fossil_filename_free(zUtf8);
492 blob_resize(pPath, origSize);
493 }
494 closedir(d);
495 }
496 fossil_filename_free(zNative);
497
498 depth--;
499 if( depth==0 ){
500 db_finalize(&ins);
501 }
502

Keyboard Shortcuts

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