Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch ticket-01a2f3a346 Excluding Merge-Ins
This is equivalent to a diff from ed6adcaf3b to 3e3f34ebcf
2012-08-29
| ||
11:27 | fix for [01a2f3a346] check-in: 0357ed556e user: jan.nijtmans tags: msvc-broken | |
10:44 | Fix a typo on the Ticket Change Details page. check-in: eb82a23827 user: drh tags: trunk | |
08:02 | merge trunk Closed-Leaf check-in: 3e3f34ebcf user: jan.nijtmans tags: ticket-01a2f3a346 | |
2012-08-28
| ||
17:39 | Fixes to hyperlink generation for embedded documentation. check-in: ed6adcaf3b user: drh tags: trunk | |
09:05 | merge trunk into ticket-01a2f3a346 branch check-in: f89bd067c2 user: jan.nijtmans tags: ticket-01a2f3a346 | |
2012-08-27
| ||
22:56 | Make merges a no-op if the pivot is the same as the version being merged. check-in: bf079432fb user: drh tags: trunk | |
Changes to src/file.c.
25 25 #include "config.h" 26 26 #include <sys/types.h> 27 27 #include <sys/stat.h> 28 28 #include <unistd.h> 29 29 #include <string.h> 30 30 #include <errno.h> 31 31 #include "file.h" 32 +#if defined(_WIN32) 33 +#include <direct.h> 34 +#endif 35 + 32 36 33 37 /* 34 38 ** On Windows, include the Platform SDK header file. 35 39 */ 36 40 #ifdef _WIN32 37 41 # include <windows.h> 38 42 #endif ................................................................................ 66 70 if( isWd && g.allowSymlinks ){ 67 71 return lstat(zFilename, buf); 68 72 }else{ 69 73 return stat(zFilename, buf); 70 74 } 71 75 #else 72 76 int rc = 0; 73 - char *zMbcs = fossil_utf8_to_mbcs(zFilename); 74 - rc = stat(zMbcs, buf); 77 + wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename); 78 + rc = _wstati64(zMbcs, buf); 75 79 fossil_mbcs_free(zMbcs); 76 80 return rc; 77 81 #endif 78 82 } 79 83 80 84 /* 81 85 ** Fill in the fileStat variable for the file named zFilename. ................................................................................ 296 300 } 297 301 298 302 299 303 /* 300 304 ** Wrapper around the access() system call. 301 305 */ 302 306 int file_access(const char *zFilename, int flags){ 303 - char *zMbcs = fossil_utf8_to_mbcs(zFilename); 304 - int rc = access(zMbcs, flags); 307 +#ifdef _WIN32 308 + wchar_t *zMbcs = fossil_utf8_to_unicode(zFilename); 309 + int rc = _waccess(zMbcs, flags); 305 310 fossil_mbcs_free(zMbcs); 311 +#else 312 + int rc = access(zFilename, flags); 313 +#endif 306 314 return rc; 307 315 } 308 316 309 317 /* 310 318 ** Find an unused filename similar to zBase with zSuffix appended. 311 319 ** 312 320 ** Make the name relative to the working directory if relFlag is true. ................................................................................ 387 395 return rc; 388 396 } 389 397 390 398 /* 391 399 ** Delete a file. 392 400 */ 393 401 void file_delete(const char *zFilename){ 394 - char *z = fossil_utf8_to_mbcs(zFilename); 395 - unlink(z); 402 +#ifdef _WIN32 403 + wchar_t *z = fossil_utf8_to_unicode(zFilename); 404 + _wunlink(z); 396 405 fossil_mbcs_free(z); 406 +#else 407 + unlink(zFilename); 408 +#endif 397 409 } 398 410 399 411 /* 400 412 ** Create the directory named in the argument, if it does not already 401 413 ** exist. If forceFlag is 1, delete any prior non-directory object 402 414 ** with the same name. 403 415 ** ................................................................................ 408 420 if( rc==2 ){ 409 421 if( !forceFlag ) return 1; 410 422 file_delete(zName); 411 423 } 412 424 if( rc!=1 ){ 413 425 #if defined(_WIN32) 414 426 int rc; 415 - char *zMbcs = fossil_utf8_to_mbcs(zName); 416 - rc = mkdir(zMbcs); 427 + wchar_t *zMbcs = fossil_utf8_to_unicode(zName); 428 + rc = _wmkdir(zMbcs); 417 429 fossil_mbcs_free(zMbcs); 418 430 return rc; 419 431 #else 420 432 return mkdir(zName, 0755); 421 433 #endif 422 434 } 423 435 return 0; ................................................................................ 559 571 fossil_free(z); 560 572 } 561 573 } 562 574 563 575 /* 564 576 ** Get the current working directory. 565 577 ** 566 -** On windows, the name is converted from MBCS to UTF8 and all '\\' 578 +** On windows, the name is converted from unicode to UTF8 and all '\\' 567 579 ** characters are converted to '/'. No conversions are needed on 568 580 ** unix. 569 581 */ 570 582 void file_getcwd(char *zBuf, int nBuf){ 571 583 #ifdef _WIN32 572 584 char *zPwdUtf8; 573 585 int nPwd; 574 586 int i; 575 - char zPwd[2000]; 576 - if( getcwd(zPwd, sizeof(zPwd)-1)==0 ){ 587 + wchar_t zPwd[2000]; 588 + if( _wgetcwd(zPwd, sizeof(zPwd)-1)==0 ){ 577 589 fossil_fatal("cannot find the current working directory."); 578 590 } 579 - zPwdUtf8 = fossil_mbcs_to_utf8(zPwd); 591 + zPwdUtf8 = fossil_unicode_to_utf8(zPwd); 580 592 nPwd = strlen(zPwdUtf8); 581 593 if( nPwd > nBuf-1 ){ 582 594 fossil_fatal("pwd too big: max %d\n", nBuf-1); 583 595 } 584 596 for(i=0; zPwdUtf8[i]; i++) if( zPwdUtf8[i]=='\\' ) zPwdUtf8[i] = '/'; 585 597 memcpy(zBuf, zPwdUtf8, nPwd+1); 586 598 fossil_mbcs_free(zPwdUtf8); ................................................................................ 926 938 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 927 939 "0123456789"; 928 940 unsigned int i, j; 929 941 const char *zDir = "."; 930 942 int cnt = 0; 931 943 932 944 #if defined(_WIN32) 933 - char zTmpPath[MAX_PATH]; 945 + wchar_t zTmpPath[MAX_PATH]; 934 946 935 - if( GetTempPath(sizeof(zTmpPath), zTmpPath) ){ 936 - azDirs[0] = zTmpPath; 947 + if( GetTempPathW(MAX_PATH, zTmpPath) ){ 948 + azDirs[0] = fossil_unicode_to_utf8(zTmpPath); 937 949 } 938 950 939 951 azDirs[1] = fossil_getenv("TEMP"); 940 952 azDirs[2] = fossil_getenv("TMP"); 941 953 #endif 942 954 943 955 ................................................................................ 1012 1024 #ifdef _WIN32 1013 1025 extern char *sqlite3_win32_mbcs_to_utf8(const char*); 1014 1026 return sqlite3_win32_mbcs_to_utf8(zMbcs); 1015 1027 #else 1016 1028 return (char*)zMbcs; /* No-op on unix */ 1017 1029 #endif 1018 1030 } 1031 + 1032 +/* 1033 +** Translate Unicode to UTF8. Return a pointer to the translated text. 1034 +** Call fossil_mbcs_free() to deallocate any memory used to store the 1035 +** returned pointer when done. 1036 +*/ 1037 +char *fossil_unicode_to_utf8(const void *zUnicode){ 1038 +#ifdef _WIN32 1039 + int nByte = WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, 0, 0, 0, 0); 1040 + char *zUtf = sqlite3_malloc( nByte ); 1041 + if( zUtf==0 ){ 1042 + return 0; 1043 + } 1044 + WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, zUtf, nByte, 0, 0); 1045 + return zUtf; 1046 +#else 1047 + return (char *)zUnicode; /* No-op on unix */ 1048 +#endif 1049 +} 1019 1050 1020 1051 /* 1021 1052 ** Translate UTF8 to MBCS for use in system calls. Return a pointer to the 1022 1053 ** translated text.. Call fossil_mbcs_free() to deallocate any memory 1023 1054 ** used to store the returned pointer when done. 1024 1055 */ 1025 1056 char *fossil_utf8_to_mbcs(const char *zUtf8){ ................................................................................ 1026 1057 #ifdef _WIN32 1027 1058 extern char *sqlite3_win32_utf8_to_mbcs(const char*); 1028 1059 return sqlite3_win32_utf8_to_mbcs(zUtf8); 1029 1060 #else 1030 1061 return (char*)zUtf8; /* No-op on unix */ 1031 1062 #endif 1032 1063 } 1064 + 1065 +/* 1066 +** Translate UTF8 to unicode for use in system calls. Return a pointer to the 1067 +** translated text.. Call fossil_mbcs_free() to deallocate any memory 1068 +** used to store the returned pointer when done. 1069 +*/ 1070 +void *fossil_utf8_to_unicode(const char *zUtf8){ 1071 +#ifdef _WIN32 1072 + int nByte = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, 0, 0); 1073 + wchar_t *zUnicode = sqlite3_malloc( nByte * 2 ); 1074 + if( zUnicode==0 ){ 1075 + return 0; 1076 + } 1077 + MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nByte); 1078 + return zUnicode; 1079 +#else 1080 + return (void *)zUtf8; /* No-op on unix */ 1081 +#endif 1082 +} 1033 1083 1034 1084 /* 1035 1085 ** Return the value of an environment variable as UTF8. 1036 1086 */ 1037 1087 char *fossil_getenv(const char *zName){ 1038 - char *zValue = getenv(zName); 1039 1088 #ifdef _WIN32 1040 - if( zValue ) zValue = fossil_mbcs_to_utf8(zValue); 1089 + wchar_t *uName = fossil_utf8_to_unicode(zName); 1090 + void *zValue = _wgetenv(uName); 1091 + fossil_mbcs_free(uName); 1092 + if( zValue ) zValue = fossil_unicode_to_utf8(zValue); 1093 +#else 1094 + char *zValue = getenv(zName); 1041 1095 #endif 1042 1096 return zValue; 1043 1097 } 1044 1098 1045 1099 /* 1046 1100 ** Translate UTF8 to MBCS for display on the console. Return a pointer to the 1047 1101 ** translated text.. Call fossil_mbcs_free() to deallocate any memory ................................................................................ 1083 1137 #endif 1084 1138 } 1085 1139 1086 1140 /* 1087 1141 ** Translate MBCS to UTF8. Return a pointer. Call fossil_mbcs_free() 1088 1142 ** to deallocate any memory used to store the returned pointer when done. 1089 1143 */ 1090 -void fossil_mbcs_free(char *zOld){ 1144 +void fossil_mbcs_free(void *zOld){ 1091 1145 #ifdef _WIN32 1092 1146 extern void sqlite3_free(void*); 1093 1147 sqlite3_free(zOld); 1094 1148 #else 1095 1149 /* No-op on unix */ 1096 1150 #endif 1097 1151 } 1098 1152 1099 1153 /* 1100 1154 ** Like fopen() but always takes a UTF8 argument. 1101 1155 */ 1102 1156 FILE *fossil_fopen(const char *zName, const char *zMode){ 1103 - char *zMbcs = fossil_utf8_to_mbcs(zName); 1104 - FILE *f = fopen(zMbcs, zMode); 1105 - fossil_mbcs_free(zMbcs); 1157 +#ifdef _WIN32 1158 + wchar_t *uMode = fossil_utf8_to_unicode(zMode); 1159 + wchar_t *uName = fossil_utf8_to_unicode(zName); 1160 + FILE *f = _wfopen(uName, uMode); 1161 + fossil_mbcs_free(uName); 1162 + fossil_mbcs_free(uMode); 1163 +#else 1164 + FILE *f = fopen(zName, zMode); 1165 +#endif 1106 1166 return f; 1107 1167 }
Changes to src/rebuild.c.
19 19 */ 20 20 #include "config.h" 21 21 #include "rebuild.h" 22 22 #include <assert.h> 23 23 #include <dirent.h> 24 24 #include <errno.h> 25 25 26 +#ifndef _WIN32 27 +#define _WDIR DIR 28 +#define _wdirent dirent 29 +#define _wopendir opendir 30 +#define _wreaddir readdir 31 +#define _wclosedir closedir 32 +#define wchar_t char 33 +#endif 34 + 26 35 /* 27 36 ** Make changes to the stable part of the schema (the part that is not 28 37 ** simply deleted and reconstructed on a rebuild) to bring the schema 29 38 ** up to the latest. 30 39 */ 31 40 static const char zSchemaUpdates1[] = 32 41 @ -- Index on the delta table ................................................................................ 816 825 } 817 826 818 827 /* 819 828 ** Recursively read all files from the directory zPath and install 820 829 ** every file read as a new artifact in the repository. 821 830 */ 822 831 void recon_read_dir(char *zPath){ 823 - DIR *d; 824 - struct dirent *pEntry; 832 + _WDIR *d; 833 + struct _wdirent *pEntry; 825 834 Blob aContent; /* content of the just read artifact */ 826 835 static int nFileRead = 0; 827 - char *zMbcsPath; 836 + wchar_t *zMbcsPath; 828 837 char *zUtf8Name; 829 838 830 - zMbcsPath = fossil_utf8_to_mbcs(zPath); 831 - d = opendir(zMbcsPath); 839 + zMbcsPath = fossil_utf8_to_unicode(zPath); 840 + d = _wopendir(zMbcsPath); 832 841 if( d ){ 833 - while( (pEntry=readdir(d))!=0 ){ 842 + while( (pEntry=_wreaddir(d))!=0 ){ 834 843 Blob path; 835 844 char *zSubpath; 836 845 837 846 if( pEntry->d_name[0]=='.' ){ 838 847 continue; 839 848 } 840 - zUtf8Name = fossil_mbcs_to_utf8(pEntry->d_name); 849 + zUtf8Name = fossil_unicode_to_utf8(pEntry->d_name); 841 850 zSubpath = mprintf("%s/%s", zPath, zUtf8Name); 842 851 fossil_mbcs_free(zUtf8Name); 843 852 if( file_isdir(zSubpath)==1 ){ 844 853 recon_read_dir(zSubpath); 845 854 } 846 855 blob_init(&path, 0, 0); 847 856 blob_appendf(&path, "%s", zSubpath); ................................................................................ 852 861 content_put(&aContent); 853 862 blob_reset(&path); 854 863 blob_reset(&aContent); 855 864 free(zSubpath); 856 865 fossil_print("\r%d", ++nFileRead); 857 866 fflush(stdout); 858 867 } 859 - closedir(d); 868 + _wclosedir(d); 860 869 }else { 861 870 fossil_panic("encountered error %d while trying to open \"%s\".", 862 871 errno, g.argv[3]); 863 872 } 864 873 fossil_mbcs_free(zMbcsPath); 865 874 } 866 875
Changes to src/vfile.c.
23 23 #include <sys/types.h> 24 24 #if defined(__DMC__) 25 25 #include "dirent.h" 26 26 #else 27 27 #include <dirent.h> 28 28 #endif 29 29 30 +#ifndef _WIN32 31 +#define _WDIR DIR 32 +#define _wdirent dirent 33 +#define _wopendir opendir 34 +#define _wreaddir readdir 35 +#define _wclosedir closedir 36 +#define wchar_t char 37 +#endif 38 + 30 39 /* 31 40 ** The input is guaranteed to be a 40-character well-formed UUID. 32 41 ** Find its rid. 33 42 */ 34 43 int fast_uuid_to_rid(const char *zUuid){ 35 44 static Stmt q; 36 45 int rid; ................................................................................ 379 388 ** Files whose names begin with "." are omitted unless allFlag is true. 380 389 ** 381 390 ** Any files or directories that match the glob pattern pIgnore are 382 391 ** excluded from the scan. Name matching occurs after the first 383 392 ** nPrefix characters are elided from the filename. 384 393 */ 385 394 void vfile_scan(Blob *pPath, int nPrefix, int allFlag, Glob *pIgnore){ 386 - DIR *d; 395 + _WDIR *d; 387 396 int origSize; 388 397 const char *zDir; 389 - struct dirent *pEntry; 398 + struct _wdirent *pEntry; 390 399 int skipAll = 0; 391 400 static Stmt ins; 392 401 static int depth = 0; 393 - char *zMbcs; 402 + wchar_t *zMbcs; 394 403 395 404 origSize = blob_size(pPath); 396 405 if( pIgnore ){ 397 406 blob_appendf(pPath, "/"); 398 407 if( glob_match(pIgnore, &blob_str(pPath)[nPrefix+1]) ) skipAll = 1; 399 408 blob_resize(pPath, origSize); 400 409 } ................................................................................ 405 414 "INSERT OR IGNORE INTO sfile(x) SELECT :file" 406 415 " WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE pathname=:file)" 407 416 ); 408 417 } 409 418 depth++; 410 419 411 420 zDir = blob_str(pPath); 412 - zMbcs = fossil_utf8_to_mbcs(zDir); 413 - d = opendir(zMbcs); 421 + zMbcs = fossil_utf8_to_unicode(zDir); 422 + d = _wopendir(zMbcs); 414 423 if( d ){ 415 - while( (pEntry=readdir(d))!=0 ){ 424 + while( (pEntry=_wreaddir(d))!=0 ){ 416 425 char *zPath; 417 426 char *zUtf8; 418 427 if( pEntry->d_name[0]=='.' ){ 419 428 if( !allFlag ) continue; 420 429 if( pEntry->d_name[1]==0 ) continue; 421 430 if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue; 422 431 } 423 - zUtf8 = fossil_mbcs_to_utf8(pEntry->d_name); 432 + zUtf8 = fossil_unicode_to_utf8(pEntry->d_name); 424 433 blob_appendf(pPath, "/%s", zUtf8); 425 434 fossil_mbcs_free(zUtf8); 426 435 zPath = blob_str(pPath); 427 436 if( glob_match(pIgnore, &zPath[nPrefix+1]) ){ 428 437 /* do nothing */ 429 438 }else if( file_wd_isdir(zPath)==1 ){ 430 439 if( !vfile_top_of_checkout(zPath) ){ ................................................................................ 433 442 }else if( file_wd_isfile_or_link(zPath) ){ 434 443 db_bind_text(&ins, ":file", &zPath[nPrefix+1]); 435 444 db_step(&ins); 436 445 db_reset(&ins); 437 446 } 438 447 blob_resize(pPath, origSize); 439 448 } 440 - closedir(d); 449 + _wclosedir(d); 441 450 } 442 451 fossil_mbcs_free(zMbcs); 443 452 444 453 depth--; 445 454 if( depth==0 ){ 446 455 db_finalize(&ins); 447 456 }