Fossil SCM

Fix harmless compiler warnings on windows.

drh 2012-11-29 18:31 trunk
Commit 9eb2df37efece7bc299e1fa87d09f70e986f7a2b
1 file changed +8 -7
+8 -7
--- src/utf8.c
+++ src/utf8.c
@@ -56,11 +56,11 @@
5656
** Translate Unicode text into UTF8.
5757
** Return a pointer to the translated text.
5858
** Call fossil_unicode_free() to deallocate any memory used to store the
5959
** returned pointer when done.
6060
*/
61
-char *fossil_unicode_to_utf8(const char *zUnicode){
61
+char *fossil_unicode_to_utf8(const void *zUnicode){
6262
#ifdef _WIN32
6363
int nByte = WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, 0, 0, 0, 0);
6464
char *zUtf = sqlite3_malloc( nByte );
6565
if( zUtf==0 ){
6666
return 0;
@@ -111,35 +111,36 @@
111111
** Translate text from the filename character set into
112112
** to precomposed UTF8. Return a pointer to the translated text.
113113
** Call fossil_filename_free() to deallocate any memory used to store the
114114
** returned pointer when done.
115115
*/
116
-char *fossil_filename_to_utf8(const char *zFilename){
116
+char *fossil_filename_to_utf8(const void *zFilename){
117117
#if defined(_WIN32)
118118
int nByte = WideCharToMultiByte(CP_UTF8, 0, zFilename, -1, 0, 0, 0, 0);
119119
char *zUtf = sqlite3_malloc( nByte );
120120
if( zUtf==0 ){
121121
return 0;
122122
}
123123
WideCharToMultiByte(CP_UTF8, 0, zFilename, -1, zUtf, nByte, 0, 0);
124124
return zUtf;
125125
#elif defined(__APPLE__)
126
+ char *zIn = (char*)zFilename;
126127
char *zOut;
127128
iconv_t cd;
128129
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 ){
132132
char *zOutx;
133
+ char *zOrig = zIn;
133134
size_t nIn, nOutx;
134
- nIn = n = strlen(zFilename);
135
+ nIn = n = strlen(zIn);
135136
nOutx = nIn+100;
136137
zOutx = zOut = fossil_malloc( nOutx+1 );
137138
x = iconv(cd, &zIn, &nIn, &zOutx, &nOutx);
138139
if( x==(size_t)-1 ){
139140
fossil_free(zOut);
140
- zOut = fossil_strdup(zFilename);
141
+ zOut = fossil_strdup(zOrig);
141142
}else{
142143
zOut[n+100-nOutx] = 0;
143144
}
144145
iconv_close(cd);
145146
}else{
146147
--- 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

Keyboard Shortcuts

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