Ticket #130: iconv.patch
File iconv.patch, 2.7 KB (added by , 14 years ago) |
---|
-
lib/iconv.c
128 128 } 129 129 } 130 130 131 #if def __OS2__132 // i could have done a static variable w/o this function. but i feel it's nicer this way. SCS 133 // the purpose of this function is to save the to_name to get the korean and japanese code set working 134 char * save_toname(char *toname, bool what) 131 #if defined(__OS2__) && defined(__INNOTEK_LIBC__) 132 #include <uconv.h> 133 134 typedef struct os2_iconv_t 135 135 { 136 static char *to_name=NULL; 136 UconvObject from; 137 } os2_iconv_t; 137 138 138 if ( what == 0 ) 139 to_name = SMB_STRDUP(toname); 139 iconv_t os2_iconv_open (const char *tocode, const char *fromcode) 140 { 141 os2_iconv_t *os2_cd = (os2_iconv_t *)iconv_open(tocode, fromcode); 140 142 141 return to_name; 143 if (os2_cd != (iconv_t)(-1)) { 144 /* Assume strings contain pathnames */ 145 uconv_attribute_t attr; 146 147 UniQueryUconvObject(os2_cd->from, &attr, 148 sizeof(uconv_attribute_t), 149 NULL, NULL, NULL ); 150 attr.converttype |= CVTTYPE_PATH; 151 UniSetUconvObject(os2_cd->from, &attr); 142 152 } 153 154 return (iconv_t)os2_cd; 155 } 156 157 #define iconv_open os2_iconv_open 143 158 #endif 144 159 145 160 #ifdef HAVE_NATIVE_ICONV … … 150 165 const char **inbuf, size_t *inbytesleft, 151 166 char **outbuf, size_t *outbytesleft) 152 167 { 153 #ifdef __OS2__154 uint16 *outbuf_uc = ( uint16 * )*outbuf;155 char *to_name = save_toname(NULL, 1);156 #endif157 158 168 size_t ret = iconv((iconv_t)cd, 159 169 (char **)inbuf, inbytesleft, 160 170 outbuf, outbytesleft); … … 163 173 iconv(cd, NULL, NULL, NULL, NULL); 164 174 errno = saved_errno; 165 175 } 166 #ifdef __OS2__167 /* Workaround for path separator on OS/2 */168 else169 {170 if( (strstr(to_name, "949") != NULL) || /* Korean CP */171 (strstr(to_name, "932") != NULL) || /* Japanese CP */172 (strstr(to_name, "942") != NULL) || /* Japanese CP */173 (strstr(to_name, "943") != NULL) ) /* Japanese CP */174 {175 while(( char * )outbuf_uc < *outbuf )176 {177 if( *outbuf_uc == 0x20a9 || /* Korean WON */178 *outbuf_uc == 0x00a5 ) /* Japanese YEN */179 *outbuf_uc = '\\';180 181 outbuf_uc++;182 }183 }184 }185 #endif186 176 return ret; 187 177 } 188 178 #endif … … 201 191 char *bufp = cvtbuf; 202 192 size_t bufsize; 203 193 204 #ifdef __OS2__205 save_toname(cd->to_name, 0);206 #endif207 208 194 /* in many cases we can go direct */ 209 195 if (cd->direct) { 210 196 return cd->direct(cd->cd_direct,