Fossil SCM
Fix harmless compiler warnings on windows.
Commit
9eb2df37efece7bc299e1fa87d09f70e986f7a2b
Parent
f1a82cf34f1c89e…
1 file changed
+8
-7
+8
-7
| --- src/utf8.c | ||
| +++ src/utf8.c | ||
| @@ -56,11 +56,11 @@ | ||
| 56 | 56 | ** Translate Unicode text into UTF8. |
| 57 | 57 | ** Return a pointer to the translated text. |
| 58 | 58 | ** Call fossil_unicode_free() to deallocate any memory used to store the |
| 59 | 59 | ** returned pointer when done. |
| 60 | 60 | */ |
| 61 | -char *fossil_unicode_to_utf8(const char *zUnicode){ | |
| 61 | +char *fossil_unicode_to_utf8(const void *zUnicode){ | |
| 62 | 62 | #ifdef _WIN32 |
| 63 | 63 | int nByte = WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, 0, 0, 0, 0); |
| 64 | 64 | char *zUtf = sqlite3_malloc( nByte ); |
| 65 | 65 | if( zUtf==0 ){ |
| 66 | 66 | return 0; |
| @@ -111,35 +111,36 @@ | ||
| 111 | 111 | ** Translate text from the filename character set into |
| 112 | 112 | ** to precomposed UTF8. Return a pointer to the translated text. |
| 113 | 113 | ** Call fossil_filename_free() to deallocate any memory used to store the |
| 114 | 114 | ** returned pointer when done. |
| 115 | 115 | */ |
| 116 | -char *fossil_filename_to_utf8(const char *zFilename){ | |
| 116 | +char *fossil_filename_to_utf8(const void *zFilename){ | |
| 117 | 117 | #if defined(_WIN32) |
| 118 | 118 | int nByte = WideCharToMultiByte(CP_UTF8, 0, zFilename, -1, 0, 0, 0, 0); |
| 119 | 119 | char *zUtf = sqlite3_malloc( nByte ); |
| 120 | 120 | if( zUtf==0 ){ |
| 121 | 121 | return 0; |
| 122 | 122 | } |
| 123 | 123 | WideCharToMultiByte(CP_UTF8, 0, zFilename, -1, zUtf, nByte, 0, 0); |
| 124 | 124 | return zUtf; |
| 125 | 125 | #elif defined(__APPLE__) |
| 126 | + char *zIn = (char*)zFilename; | |
| 126 | 127 | char *zOut; |
| 127 | 128 | iconv_t cd; |
| 128 | 129 | size_t n, x; |
| 129 | - for(n=0; zFilename[n]>0 && zFilename[n]<=0x7f; n++){} | |
| 130 | - if( zFilename[n]!=0 && (cd = iconv_open("UTF-8", "UTF-8-MAC"))!=(iconv_t)-1 ){ | |
| 131 | - char *zIn = (char*)zFilename; | |
| 130 | + for(n=0; zIn[n]>0 && zIn[n]<=0x7f; n++){} | |
| 131 | + if( zIn[n]!=0 && (cd = iconv_open("UTF-8", "UTF-8-MAC"))!=(iconv_t)-1 ){ | |
| 132 | 132 | char *zOutx; |
| 133 | + char *zOrig = zIn; | |
| 133 | 134 | size_t nIn, nOutx; |
| 134 | - nIn = n = strlen(zFilename); | |
| 135 | + nIn = n = strlen(zIn); | |
| 135 | 136 | nOutx = nIn+100; |
| 136 | 137 | zOutx = zOut = fossil_malloc( nOutx+1 ); |
| 137 | 138 | x = iconv(cd, &zIn, &nIn, &zOutx, &nOutx); |
| 138 | 139 | if( x==(size_t)-1 ){ |
| 139 | 140 | fossil_free(zOut); |
| 140 | - zOut = fossil_strdup(zFilename); | |
| 141 | + zOut = fossil_strdup(zOrig); | |
| 141 | 142 | }else{ |
| 142 | 143 | zOut[n+100-nOutx] = 0; |
| 143 | 144 | } |
| 144 | 145 | iconv_close(cd); |
| 145 | 146 | }else{ |
| 146 | 147 |
| --- src/utf8.c | |
| +++ src/utf8.c | |
| @@ -56,11 +56,11 @@ | |
| 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 char *zUnicode){ |
| 62 | #ifdef _WIN32 |
| 63 | int nByte = WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, 0, 0, 0, 0); |
| 64 | char *zUtf = sqlite3_malloc( nByte ); |
| 65 | if( zUtf==0 ){ |
| 66 | return 0; |
| @@ -111,35 +111,36 @@ | |
| 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 char *zFilename){ |
| 117 | #if defined(_WIN32) |
| 118 | int nByte = WideCharToMultiByte(CP_UTF8, 0, zFilename, -1, 0, 0, 0, 0); |
| 119 | char *zUtf = sqlite3_malloc( nByte ); |
| 120 | if( zUtf==0 ){ |
| 121 | return 0; |
| 122 | } |
| 123 | WideCharToMultiByte(CP_UTF8, 0, zFilename, -1, zUtf, nByte, 0, 0); |
| 124 | return zUtf; |
| 125 | #elif defined(__APPLE__) |
| 126 | char *zOut; |
| 127 | iconv_t cd; |
| 128 | size_t n, x; |
| 129 | for(n=0; zFilename[n]>0 && zFilename[n]<=0x7f; n++){} |
| 130 | if( zFilename[n]!=0 && (cd = iconv_open("UTF-8", "UTF-8-MAC"))!=(iconv_t)-1 ){ |
| 131 | char *zIn = (char*)zFilename; |
| 132 | char *zOutx; |
| 133 | size_t nIn, nOutx; |
| 134 | nIn = n = strlen(zFilename); |
| 135 | nOutx = nIn+100; |
| 136 | zOutx = zOut = fossil_malloc( nOutx+1 ); |
| 137 | x = iconv(cd, &zIn, &nIn, &zOutx, &nOutx); |
| 138 | if( x==(size_t)-1 ){ |
| 139 | fossil_free(zOut); |
| 140 | zOut = fossil_strdup(zFilename); |
| 141 | }else{ |
| 142 | zOut[n+100-nOutx] = 0; |
| 143 | } |
| 144 | iconv_close(cd); |
| 145 | }else{ |
| 146 |
| --- src/utf8.c | |
| +++ src/utf8.c | |
| @@ -56,11 +56,11 @@ | |
| 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){ |
| 62 | #ifdef _WIN32 |
| 63 | int nByte = WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, 0, 0, 0, 0); |
| 64 | char *zUtf = sqlite3_malloc( nByte ); |
| 65 | if( zUtf==0 ){ |
| 66 | return 0; |
| @@ -111,35 +111,36 @@ | |
| 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) |
| 118 | int nByte = WideCharToMultiByte(CP_UTF8, 0, zFilename, -1, 0, 0, 0, 0); |
| 119 | char *zUtf = sqlite3_malloc( nByte ); |
| 120 | if( zUtf==0 ){ |
| 121 | return 0; |
| 122 | } |
| 123 | WideCharToMultiByte(CP_UTF8, 0, zFilename, -1, zUtf, nByte, 0, 0); |
| 124 | return zUtf; |
| 125 | #elif defined(__APPLE__) |
| 126 | char *zIn = (char*)zFilename; |
| 127 | char *zOut; |
| 128 | iconv_t cd; |
| 129 | size_t n, x; |
| 130 | for(n=0; zIn[n]>0 && zIn[n]<=0x7f; n++){} |
| 131 | if( zIn[n]!=0 && (cd = iconv_open("UTF-8", "UTF-8-MAC"))!=(iconv_t)-1 ){ |
| 132 | char *zOutx; |
| 133 | char *zOrig = zIn; |
| 134 | size_t nIn, nOutx; |
| 135 | nIn = n = strlen(zIn); |
| 136 | nOutx = nIn+100; |
| 137 | zOutx = zOut = fossil_malloc( nOutx+1 ); |
| 138 | x = iconv(cd, &zIn, &nIn, &zOutx, &nOutx); |
| 139 | if( x==(size_t)-1 ){ |
| 140 | fossil_free(zOut); |
| 141 | zOut = fossil_strdup(zOrig); |
| 142 | }else{ |
| 143 | zOut[n+100-nOutx] = 0; |
| 144 | } |
| 145 | iconv_close(cd); |
| 146 | }else{ |
| 147 |