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.
Commit
7eb5e2319f01c6c2b2847aef8a628904443f8861
Parent
75e483899e28a53…
6 files changed
+12
-12
+12
-12
+2
-2
+36
-20
+36
-20
+2
-2
+12
-12
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -72,13 +72,13 @@ | ||
| 72 | 72 | }else{ |
| 73 | 73 | return stat(zFilename, buf); |
| 74 | 74 | } |
| 75 | 75 | #else |
| 76 | 76 | int rc = 0; |
| 77 | - wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename); | |
| 77 | + wchar_t *zMbcs = fossil_utf8_to_filename(zFilename); | |
| 78 | 78 | rc = _wstati64(zMbcs, buf); |
| 79 | - fossil_unicode_free(zMbcs); | |
| 79 | + fossil_filename_free(zMbcs); | |
| 80 | 80 | return rc; |
| 81 | 81 | #endif |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /* |
| @@ -303,13 +303,13 @@ | ||
| 303 | 303 | /* |
| 304 | 304 | ** Wrapper around the access() system call. |
| 305 | 305 | */ |
| 306 | 306 | int file_access(const char *zFilename, int flags){ |
| 307 | 307 | #ifdef _WIN32 |
| 308 | - wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename); | |
| 308 | + wchar_t *zMbcs = fossil_utf8_to_filename(zFilename); | |
| 309 | 309 | int rc = _waccess(zMbcs, flags); |
| 310 | - fossil_unicode_free(zMbcs); | |
| 310 | + fossil_filename_free(zMbcs); | |
| 311 | 311 | #else |
| 312 | 312 | int rc = access(zFilename, flags); |
| 313 | 313 | #endif |
| 314 | 314 | return rc; |
| 315 | 315 | } |
| @@ -405,15 +405,15 @@ | ||
| 405 | 405 | tv[0].tv_sec = newMTime; |
| 406 | 406 | tv[1].tv_sec = newMTime; |
| 407 | 407 | utimes(zFilename, tv); |
| 408 | 408 | #else |
| 409 | 409 | struct _utimbuf tb; |
| 410 | - wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename); | |
| 410 | + wchar_t *zMbcs = fossil_utf8_to_filename(zFilename); | |
| 411 | 411 | tb.actime = newMTime; |
| 412 | 412 | tb.modtime = newMTime; |
| 413 | 413 | _wutime(zMbcs, &tb); |
| 414 | - fossil_unicode_free(zMbcs); | |
| 414 | + fossil_filename_free(zMbcs); | |
| 415 | 415 | #endif |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | /* |
| 419 | 419 | ** COMMAND: test-set-mtime |
| @@ -441,13 +441,13 @@ | ||
| 441 | 441 | /* |
| 442 | 442 | ** Delete a file. |
| 443 | 443 | */ |
| 444 | 444 | void file_delete(const char *zFilename){ |
| 445 | 445 | #ifdef _WIN32 |
| 446 | - wchar_t *z = fossil_utf8_to_unicode(zFilename); | |
| 446 | + wchar_t *z = fossil_utf8_to_filename(zFilename); | |
| 447 | 447 | _wunlink(z); |
| 448 | - fossil_unicode_free(z); | |
| 448 | + fossil_filename_free(z); | |
| 449 | 449 | #else |
| 450 | 450 | unlink(zFilename); |
| 451 | 451 | #endif |
| 452 | 452 | } |
| 453 | 453 | |
| @@ -465,13 +465,13 @@ | ||
| 465 | 465 | file_delete(zName); |
| 466 | 466 | } |
| 467 | 467 | if( rc!=1 ){ |
| 468 | 468 | #if defined(_WIN32) |
| 469 | 469 | int rc; |
| 470 | - wchar_t *zMbcs = fossil_utf8_to_unicode(zName); | |
| 470 | + wchar_t *zMbcs = fossil_utf8_to_filename(zName); | |
| 471 | 471 | rc = _wmkdir(zMbcs); |
| 472 | - fossil_unicode_free(zMbcs); | |
| 472 | + fossil_filename_free(zMbcs); | |
| 473 | 473 | return rc; |
| 474 | 474 | #else |
| 475 | 475 | return mkdir(zName, 0755); |
| 476 | 476 | #endif |
| 477 | 477 | } |
| @@ -1137,14 +1137,14 @@ | ||
| 1137 | 1137 | ** Like fopen() but always takes a UTF8 argument. |
| 1138 | 1138 | */ |
| 1139 | 1139 | FILE *fossil_fopen(const char *zName, const char *zMode){ |
| 1140 | 1140 | #ifdef _WIN32 |
| 1141 | 1141 | 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); | |
| 1143 | 1143 | FILE *f = _wfopen(uName, uMode); |
| 1144 | - fossil_unicode_free(uName); | |
| 1144 | + fossil_filename_free(uName); | |
| 1145 | 1145 | fossil_unicode_free(uMode); |
| 1146 | 1146 | #else |
| 1147 | 1147 | FILE *f = fopen(zName, zMode); |
| 1148 | 1148 | #endif |
| 1149 | 1149 | return f; |
| 1150 | 1150 | } |
| 1151 | 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_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 @@ | ||
| 72 | 72 | }else{ |
| 73 | 73 | return stat(zFilename, buf); |
| 74 | 74 | } |
| 75 | 75 | #else |
| 76 | 76 | int rc = 0; |
| 77 | - wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename); | |
| 77 | + wchar_t *zMbcs = fossil_utf8_to_filename(zFilename); | |
| 78 | 78 | rc = _wstati64(zMbcs, buf); |
| 79 | - fossil_unicode_free(zMbcs); | |
| 79 | + fossil_filename_free(zMbcs); | |
| 80 | 80 | return rc; |
| 81 | 81 | #endif |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /* |
| @@ -303,13 +303,13 @@ | ||
| 303 | 303 | /* |
| 304 | 304 | ** Wrapper around the access() system call. |
| 305 | 305 | */ |
| 306 | 306 | int file_access(const char *zFilename, int flags){ |
| 307 | 307 | #ifdef _WIN32 |
| 308 | - wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename); | |
| 308 | + wchar_t *zMbcs = fossil_utf8_to_filename(zFilename); | |
| 309 | 309 | int rc = _waccess(zMbcs, flags); |
| 310 | - fossil_unicode_free(zMbcs); | |
| 310 | + fossil_filename_free(zMbcs); | |
| 311 | 311 | #else |
| 312 | 312 | int rc = access(zFilename, flags); |
| 313 | 313 | #endif |
| 314 | 314 | return rc; |
| 315 | 315 | } |
| @@ -405,15 +405,15 @@ | ||
| 405 | 405 | tv[0].tv_sec = newMTime; |
| 406 | 406 | tv[1].tv_sec = newMTime; |
| 407 | 407 | utimes(zFilename, tv); |
| 408 | 408 | #else |
| 409 | 409 | struct _utimbuf tb; |
| 410 | - wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename); | |
| 410 | + wchar_t *zMbcs = fossil_utf8_to_filename(zFilename); | |
| 411 | 411 | tb.actime = newMTime; |
| 412 | 412 | tb.modtime = newMTime; |
| 413 | 413 | _wutime(zMbcs, &tb); |
| 414 | - fossil_unicode_free(zMbcs); | |
| 414 | + fossil_filename_free(zMbcs); | |
| 415 | 415 | #endif |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | /* |
| 419 | 419 | ** COMMAND: test-set-mtime |
| @@ -441,13 +441,13 @@ | ||
| 441 | 441 | /* |
| 442 | 442 | ** Delete a file. |
| 443 | 443 | */ |
| 444 | 444 | void file_delete(const char *zFilename){ |
| 445 | 445 | #ifdef _WIN32 |
| 446 | - wchar_t *z = fossil_utf8_to_unicode(zFilename); | |
| 446 | + wchar_t *z = fossil_utf8_to_filename(zFilename); | |
| 447 | 447 | _wunlink(z); |
| 448 | - fossil_unicode_free(z); | |
| 448 | + fossil_filename_free(z); | |
| 449 | 449 | #else |
| 450 | 450 | unlink(zFilename); |
| 451 | 451 | #endif |
| 452 | 452 | } |
| 453 | 453 | |
| @@ -465,13 +465,13 @@ | ||
| 465 | 465 | file_delete(zName); |
| 466 | 466 | } |
| 467 | 467 | if( rc!=1 ){ |
| 468 | 468 | #if defined(_WIN32) |
| 469 | 469 | int rc; |
| 470 | - wchar_t *zMbcs = fossil_utf8_to_unicode(zName); | |
| 470 | + wchar_t *zMbcs = fossil_utf8_to_filename(zName); | |
| 471 | 471 | rc = _wmkdir(zMbcs); |
| 472 | - fossil_unicode_free(zMbcs); | |
| 472 | + fossil_filename_free(zMbcs); | |
| 473 | 473 | return rc; |
| 474 | 474 | #else |
| 475 | 475 | return mkdir(zName, 0755); |
| 476 | 476 | #endif |
| 477 | 477 | } |
| @@ -1137,14 +1137,14 @@ | ||
| 1137 | 1137 | ** Like fopen() but always takes a UTF8 argument. |
| 1138 | 1138 | */ |
| 1139 | 1139 | FILE *fossil_fopen(const char *zName, const char *zMode){ |
| 1140 | 1140 | #ifdef _WIN32 |
| 1141 | 1141 | 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); | |
| 1143 | 1143 | FILE *f = _wfopen(uName, uMode); |
| 1144 | - fossil_unicode_free(uName); | |
| 1144 | + fossil_filename_free(uName); | |
| 1145 | 1145 | fossil_unicode_free(uMode); |
| 1146 | 1146 | #else |
| 1147 | 1147 | FILE *f = fopen(zName, zMode); |
| 1148 | 1148 | #endif |
| 1149 | 1149 | return f; |
| 1150 | 1150 | } |
| 1151 | 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_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 @@ | ||
| 841 | 841 | Blob aContent; /* content of the just read artifact */ |
| 842 | 842 | static int nFileRead = 0; |
| 843 | 843 | void *zUnicodePath; |
| 844 | 844 | char *zUtf8Name; |
| 845 | 845 | |
| 846 | - zUnicodePath = fossil_utf8_to_unicode(zPath); | |
| 846 | + zUnicodePath = fossil_utf8_to_filename(zPath); | |
| 847 | 847 | d = opendir(zUnicodePath); |
| 848 | 848 | if( d ){ |
| 849 | 849 | while( (pEntry=readdir(d))!=0 ){ |
| 850 | 850 | Blob path; |
| 851 | 851 | char *zSubpath; |
| @@ -875,11 +875,11 @@ | ||
| 875 | 875 | closedir(d); |
| 876 | 876 | }else { |
| 877 | 877 | fossil_panic("encountered error %d while trying to open \"%s\".", |
| 878 | 878 | errno, g.argv[3]); |
| 879 | 879 | } |
| 880 | - fossil_unicode_free(zUnicodePath); | |
| 880 | + fossil_filename_free(zUnicodePath); | |
| 881 | 881 | } |
| 882 | 882 | |
| 883 | 883 | /* |
| 884 | 884 | ** COMMAND: reconstruct* |
| 885 | 885 | ** |
| 886 | 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_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 @@ | ||
| 24 | 24 | #include <sqlite3.h> |
| 25 | 25 | #ifdef _WIN32 |
| 26 | 26 | # include <windows.h> |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | +#ifdef _WIN32 | |
| 29 | 30 | /* |
| 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. | |
| 31 | 32 | ** Call fossil_mbcs_free() to deallocate any memory used to store the |
| 32 | 33 | ** returned pointer when done. |
| 33 | 34 | */ |
| 34 | 35 | char *fossil_mbcs_to_utf8(const char *zMbcs){ |
| 35 | -#ifdef _WIN32 | |
| 36 | 36 | extern char *sqlite3_win32_mbcs_to_utf8(const char*); |
| 37 | 37 | return sqlite3_win32_mbcs_to_utf8(zMbcs); |
| 38 | -#else | |
| 39 | - return (char*)zMbcs; /* No-op on unix */ | |
| 40 | -#endif | |
| 41 | 38 | } |
| 42 | 39 | |
| 43 | 40 | /* |
| 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 | |
| 45 | 42 | ** any memory used to hold the translation |
| 46 | 43 | */ |
| 47 | 44 | void fossil_mbcs_free(char *zOld){ |
| 48 | -#ifdef _WIN32 | |
| 49 | 45 | sqlite3_free(zOld); |
| 50 | -#else | |
| 51 | - /* No-op on unix */ | |
| 52 | -#endif | |
| 53 | 46 | } |
| 54 | 47 | |
| 55 | 48 | /* |
| 56 | -** Translate Unicode text into UTF8. | |
| 49 | +** Translate Unicode text into UTF-8. | |
| 57 | 50 | ** Return a pointer to the translated text. |
| 58 | 51 | ** Call fossil_unicode_free() to deallocate any memory used to store the |
| 59 | 52 | ** returned pointer when done. |
| 60 | 53 | */ |
| 61 | 54 | char *fossil_unicode_to_utf8(const void *zUnicode){ |
| @@ -66,16 +59,16 @@ | ||
| 66 | 59 | return 0; |
| 67 | 60 | } |
| 68 | 61 | WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, zUtf, nByte, 0, 0); |
| 69 | 62 | return zUtf; |
| 70 | 63 | #else |
| 71 | - return (char *)zUnicode; /* No-op on unix */ | |
| 64 | + return fossil_strdup(zUtf8); /* TODO: implement for unix */ | |
| 72 | 65 | #endif |
| 73 | 66 | } |
| 74 | 67 | |
| 75 | 68 | /* |
| 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 | |
| 77 | 70 | ** translated text.. Call fossil_unicode_free() to deallocate any memory |
| 78 | 71 | ** used to store the returned pointer when done. |
| 79 | 72 | */ |
| 80 | 73 | void *fossil_utf8_to_unicode(const char *zUtf8){ |
| 81 | 74 | #ifdef _WIN32 |
| @@ -85,11 +78,11 @@ | ||
| 85 | 78 | return 0; |
| 86 | 79 | } |
| 87 | 80 | MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nByte); |
| 88 | 81 | return zUnicode; |
| 89 | 82 | #else |
| 90 | - return (void *)zUtf8; /* No-op on unix */ | |
| 83 | + return fossil_strdup(zUtf8); /* TODO: implement for unix */ | |
| 91 | 84 | #endif |
| 92 | 85 | } |
| 93 | 86 | |
| 94 | 87 | /* |
| 95 | 88 | ** Deallocate any memory that was previously allocated by |
| @@ -97,21 +90,22 @@ | ||
| 97 | 90 | */ |
| 98 | 91 | void fossil_unicode_free(void *pOld){ |
| 99 | 92 | #ifdef _WIN32 |
| 100 | 93 | sqlite3_free(pOld); |
| 101 | 94 | #else |
| 102 | - /* No-op on unix */ | |
| 95 | + fossil_free(pOld); | |
| 103 | 96 | #endif |
| 104 | 97 | } |
| 98 | +#endif /* _WIN32 */ | |
| 105 | 99 | |
| 106 | 100 | #if defined(__APPLE__) && !defined(WITHOUT_ICONV) |
| 107 | 101 | # include <iconv.h> |
| 108 | 102 | #endif |
| 109 | 103 | |
| 110 | 104 | /* |
| 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. | |
| 113 | 107 | ** Call fossil_filename_free() to deallocate any memory used to store the |
| 114 | 108 | ** returned pointer when done. |
| 115 | 109 | */ |
| 116 | 110 | char *fossil_filename_to_utf8(const void *zFilename){ |
| 117 | 111 | #if defined(_WIN32) |
| @@ -149,16 +143,38 @@ | ||
| 149 | 143 | return zOut; |
| 150 | 144 | #else |
| 151 | 145 | return (char *)zFilename; /* No-op on non-mac unix */ |
| 152 | 146 | #endif |
| 153 | 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 | +} | |
| 154 | 170 | |
| 155 | 171 | /* |
| 156 | 172 | ** Deallocate any memory that was previously allocated by |
| 157 | -** fossil_filename_to_utf8(). | |
| 173 | +** fossil_filename_to_utf8() or fossil_utf8_to_filename(). | |
| 158 | 174 | */ |
| 159 | -void fossil_filename_free(char *pOld){ | |
| 175 | +void fossil_filename_free(void *pOld){ | |
| 160 | 176 | #if defined(_WIN32) |
| 161 | 177 | sqlite3_free(pOld); |
| 162 | 178 | #elif defined(__APPLE__) && !defined(WITHOUT_ICONV) |
| 163 | 179 | fossil_free(pOld); |
| 164 | 180 | #else |
| @@ -165,11 +181,11 @@ | ||
| 165 | 181 | /* No-op on all other unix */ |
| 166 | 182 | #endif |
| 167 | 183 | } |
| 168 | 184 | |
| 169 | 185 | /* |
| 170 | -** Display UTF8 on the console. Return the number of | |
| 186 | +** Display UTF-8 on the console. Return the number of | |
| 171 | 187 | ** Characters written. If stdout or stderr is redirected |
| 172 | 188 | ** to a file, -1 is returned and nothing is written |
| 173 | 189 | ** to the console. |
| 174 | 190 | */ |
| 175 | 191 | int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){ |
| 176 | 192 |
| --- 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 @@ | ||
| 24 | 24 | #include <sqlite3.h> |
| 25 | 25 | #ifdef _WIN32 |
| 26 | 26 | # include <windows.h> |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | +#ifdef _WIN32 | |
| 29 | 30 | /* |
| 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. | |
| 31 | 32 | ** Call fossil_mbcs_free() to deallocate any memory used to store the |
| 32 | 33 | ** returned pointer when done. |
| 33 | 34 | */ |
| 34 | 35 | char *fossil_mbcs_to_utf8(const char *zMbcs){ |
| 35 | -#ifdef _WIN32 | |
| 36 | 36 | extern char *sqlite3_win32_mbcs_to_utf8(const char*); |
| 37 | 37 | return sqlite3_win32_mbcs_to_utf8(zMbcs); |
| 38 | -#else | |
| 39 | - return (char*)zMbcs; /* No-op on unix */ | |
| 40 | -#endif | |
| 41 | 38 | } |
| 42 | 39 | |
| 43 | 40 | /* |
| 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 | |
| 45 | 42 | ** any memory used to hold the translation |
| 46 | 43 | */ |
| 47 | 44 | void fossil_mbcs_free(char *zOld){ |
| 48 | -#ifdef _WIN32 | |
| 49 | 45 | sqlite3_free(zOld); |
| 50 | -#else | |
| 51 | - /* No-op on unix */ | |
| 52 | -#endif | |
| 53 | 46 | } |
| 54 | 47 | |
| 55 | 48 | /* |
| 56 | -** Translate Unicode text into UTF8. | |
| 49 | +** Translate Unicode text into UTF-8. | |
| 57 | 50 | ** Return a pointer to the translated text. |
| 58 | 51 | ** Call fossil_unicode_free() to deallocate any memory used to store the |
| 59 | 52 | ** returned pointer when done. |
| 60 | 53 | */ |
| 61 | 54 | char *fossil_unicode_to_utf8(const void *zUnicode){ |
| @@ -66,16 +59,16 @@ | ||
| 66 | 59 | return 0; |
| 67 | 60 | } |
| 68 | 61 | WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, zUtf, nByte, 0, 0); |
| 69 | 62 | return zUtf; |
| 70 | 63 | #else |
| 71 | - return (char *)zUnicode; /* No-op on unix */ | |
| 64 | + return fossil_strdup(zUtf8); /* TODO: implement for unix */ | |
| 72 | 65 | #endif |
| 73 | 66 | } |
| 74 | 67 | |
| 75 | 68 | /* |
| 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 | |
| 77 | 70 | ** translated text.. Call fossil_unicode_free() to deallocate any memory |
| 78 | 71 | ** used to store the returned pointer when done. |
| 79 | 72 | */ |
| 80 | 73 | void *fossil_utf8_to_unicode(const char *zUtf8){ |
| 81 | 74 | #ifdef _WIN32 |
| @@ -85,11 +78,11 @@ | ||
| 85 | 78 | return 0; |
| 86 | 79 | } |
| 87 | 80 | MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nByte); |
| 88 | 81 | return zUnicode; |
| 89 | 82 | #else |
| 90 | - return (void *)zUtf8; /* No-op on unix */ | |
| 83 | + return fossil_strdup(zUtf8); /* TODO: implement for unix */ | |
| 91 | 84 | #endif |
| 92 | 85 | } |
| 93 | 86 | |
| 94 | 87 | /* |
| 95 | 88 | ** Deallocate any memory that was previously allocated by |
| @@ -97,21 +90,22 @@ | ||
| 97 | 90 | */ |
| 98 | 91 | void fossil_unicode_free(void *pOld){ |
| 99 | 92 | #ifdef _WIN32 |
| 100 | 93 | sqlite3_free(pOld); |
| 101 | 94 | #else |
| 102 | - /* No-op on unix */ | |
| 95 | + fossil_free(pOld); | |
| 103 | 96 | #endif |
| 104 | 97 | } |
| 98 | +#endif /* _WIN32 */ | |
| 105 | 99 | |
| 106 | 100 | #if defined(__APPLE__) && !defined(WITHOUT_ICONV) |
| 107 | 101 | # include <iconv.h> |
| 108 | 102 | #endif |
| 109 | 103 | |
| 110 | 104 | /* |
| 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. | |
| 113 | 107 | ** Call fossil_filename_free() to deallocate any memory used to store the |
| 114 | 108 | ** returned pointer when done. |
| 115 | 109 | */ |
| 116 | 110 | char *fossil_filename_to_utf8(const void *zFilename){ |
| 117 | 111 | #if defined(_WIN32) |
| @@ -149,16 +143,38 @@ | ||
| 149 | 143 | return zOut; |
| 150 | 144 | #else |
| 151 | 145 | return (char *)zFilename; /* No-op on non-mac unix */ |
| 152 | 146 | #endif |
| 153 | 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 | +} | |
| 154 | 170 | |
| 155 | 171 | /* |
| 156 | 172 | ** Deallocate any memory that was previously allocated by |
| 157 | -** fossil_filename_to_utf8(). | |
| 173 | +** fossil_filename_to_utf8() or fossil_utf8_to_filename(). | |
| 158 | 174 | */ |
| 159 | -void fossil_filename_free(char *pOld){ | |
| 175 | +void fossil_filename_free(void *pOld){ | |
| 160 | 176 | #if defined(_WIN32) |
| 161 | 177 | sqlite3_free(pOld); |
| 162 | 178 | #elif defined(__APPLE__) && !defined(WITHOUT_ICONV) |
| 163 | 179 | fossil_free(pOld); |
| 164 | 180 | #else |
| @@ -165,11 +181,11 @@ | ||
| 165 | 181 | /* No-op on all other unix */ |
| 166 | 182 | #endif |
| 167 | 183 | } |
| 168 | 184 | |
| 169 | 185 | /* |
| 170 | -** Display UTF8 on the console. Return the number of | |
| 186 | +** Display UTF-8 on the console. Return the number of | |
| 171 | 187 | ** Characters written. If stdout or stderr is redirected |
| 172 | 188 | ** to a file, -1 is returned and nothing is written |
| 173 | 189 | ** to the console. |
| 174 | 190 | */ |
| 175 | 191 | int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){ |
| 176 | 192 |
| --- 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 @@ | ||
| 459 | 459 | ); |
| 460 | 460 | } |
| 461 | 461 | depth++; |
| 462 | 462 | |
| 463 | 463 | zDir = blob_str(pPath); |
| 464 | - zNative = fossil_utf8_to_unicode(zDir); | |
| 464 | + zNative = fossil_utf8_to_filename(zDir); | |
| 465 | 465 | d = opendir(zNative); |
| 466 | 466 | if( d ){ |
| 467 | 467 | while( (pEntry=readdir(d))!=0 ){ |
| 468 | 468 | char *zPath; |
| 469 | 469 | char *zUtf8; |
| @@ -491,11 +491,11 @@ | ||
| 491 | 491 | fossil_filename_free(zUtf8); |
| 492 | 492 | blob_resize(pPath, origSize); |
| 493 | 493 | } |
| 494 | 494 | closedir(d); |
| 495 | 495 | } |
| 496 | - fossil_unicode_free(zNative); | |
| 496 | + fossil_filename_free(zNative); | |
| 497 | 497 | |
| 498 | 498 | depth--; |
| 499 | 499 | if( depth==0 ){ |
| 500 | 500 | db_finalize(&ins); |
| 501 | 501 | } |
| 502 | 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_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 |