Commit 815a26b811dfb1f7f9ff16b19666d6cd6296656b

Authored by Perry Werneck
1 parent 39e75777

Fixing charset update error.

Showing 1 changed file with 18 additions and 3 deletions   Show diff stats
src/core/charset/charset.c
@@ -225,6 +225,8 @@ LIB3270_EXPORT void lib3270_reset_charset(H3270 *hSession, const char * host, co @@ -225,6 +225,8 @@ LIB3270_EXPORT void lib3270_reset_charset(H3270 *hSession, const char * host, co
225 if(!display) 225 if(!display)
226 display = "ISO-8859-1"; 226 display = "ISO-8859-1";
227 227
  228 + debug("%s(%s,%s)",__FUNCTION__,host,display);
  229 +
228 replace_pointer(hSession->charset.host, host); 230 replace_pointer(hSession->charset.host, host);
229 replace_pointer(hSession->charset.display,display); 231 replace_pointer(hSession->charset.display,display);
230 232
@@ -244,14 +246,25 @@ LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name) @@ -244,14 +246,25 @@ LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name)
244 { 246 {
245 int f; 247 int f;
246 248
247 - if(!name) 249 + debug("%s(%s)",__FUNCTION__,name);
  250 +
  251 + if(name && hSession->charset.host && !strcasecmp(name,hSession->charset.host))
248 { 252 {
249 - lib3270_reset_charset(hSession,"us","ISO-8859-1", LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET); 253 + debug("Charset is \"%s\", returning",hSession->charset.host);
250 return 0; 254 return 0;
251 } 255 }
252 256
253 - if(hSession->charset.host && !strcasecmp(name,hSession->charset.host)) 257 + if(!name)
  258 + {
  259 + name = hSession->charset.host;
  260 + debug("Resetting to charset \"%s\"",name);
  261 + }
  262 +
  263 + if(!name)
  264 + {
  265 + lib3270_reset_charset(hSession, NULL, NULL, LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET);
254 return 0; 266 return 0;
  267 + }
255 268
256 for(f=0;charset[f].name != NULL;f++) 269 for(f=0;charset[f].name != NULL;f++)
257 { 270 {
@@ -267,10 +280,12 @@ LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name) @@ -267,10 +280,12 @@ LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name)
267 for(c=0;charset[f].chr[c];c+=2) 280 for(c=0;charset[f].chr[c];c+=2)
268 lib3270_remap_char(hSession,charset[f].chr[c],charset[f].chr[c+1], BOTH, 0); 281 lib3270_remap_char(hSession,charset[f].chr[c],charset[f].chr[c+1], BOTH, 0);
269 282
  283 + debug("Charset is now \"%s\"",charset[f].name);
270 return 0; 284 return 0;
271 } 285 }
272 } 286 }
273 287
  288 + debug("%s: %s",__FUNCTION__,strerror(EINVAL));
274 return errno = EINVAL; 289 return errno = EINVAL;
275 290
276 } 291 }