Commit c29f3eb184eb4c3cb1a3c61628058ab43144ace6
1 parent
b4325503
Exists in
master
and in
5 other branches
Biblioteca de versao 5 precisa trabalhar toda em latin-1 igual ao windows deixan…
…do a conversao para UTF-8 por conta do gtk para manter um unico mecanismo de conversao
Showing
5 changed files
with
96 additions
and
74 deletions
Show diff stats
src/lib3270/charset.c
... | ... | @@ -44,19 +44,27 @@ |
44 | 44 | #include "charsetc.h" |
45 | 45 | #include "kybdc.h" |
46 | 46 | #include "popupsc.h" |
47 | -#if defined(X3270_DISPLAY) || (defined(C3270) && !defined(_WIN32)) /*[*/ | |
47 | + | |
48 | +/* | |
49 | +#if defined(X3270_DISPLAY) || (defined(C3270) && !defined(_WIN32)) | |
48 | 50 | #include "screenc.h" |
49 | -#endif /*]*/ | |
51 | +#endif | |
52 | +*/ | |
53 | + | |
50 | 54 | #include "tablesc.h" |
51 | 55 | #include "utf8c.h" |
52 | 56 | #include "utilc.h" |
53 | 57 | #include "widec.h" |
54 | 58 | |
55 | 59 | #include <errno.h> |
56 | -#include <locale.h> | |
57 | -#if !defined(_WIN32) /*[*/ | |
60 | + | |
61 | +//#include <locale.h> | |
62 | + | |
63 | +/* | |
64 | +#if !defined(_WIN32) | |
58 | 65 | #include <langinfo.h> |
59 | -#endif /*]*/ | |
66 | +#endif | |
67 | +*/ | |
60 | 68 | |
61 | 69 | // #include <lib3270/api.h> |
62 | 70 | |
... | ... | @@ -72,9 +80,13 @@ unsigned long cgcsgid_dbcs = 0L; |
72 | 80 | char *default_display_charset = "3270cg-1a,3270cg-1,iso8859-1"; |
73 | 81 | char *converter_names; |
74 | 82 | char *encoding; |
75 | -#if defined(X3270_DISPLAY) /*[*/ | |
83 | + | |
84 | +/* | |
85 | +#if defined(X3270_DISPLAY) | |
76 | 86 | unsigned char xk_selector = 0; |
77 | 87 | #endif |
88 | +*/ | |
89 | + | |
78 | 90 | unsigned char auto_keymap = 0; |
79 | 91 | |
80 | 92 | /* Statics. */ |
... | ... | @@ -82,12 +94,13 @@ static enum cs_result resource_charset(char *csname, char *cs, char *ftcs); |
82 | 94 | typedef enum { CS_ONLY, FT_ONLY, BOTH } remap_scope; |
83 | 95 | static enum cs_result remap_chars(char *csname, char *spec, remap_scope scope, |
84 | 96 | int *ne); |
85 | -static void remap_one(unsigned char ebc, KeySym iso, remap_scope scope, | |
86 | - Boolean one_way); | |
97 | +static void remap_one(unsigned char ebc, KeySym iso, remap_scope scope,Boolean one_way); | |
98 | + | |
87 | 99 | #if defined(DEBUG_CHARSET) /*[*/ |
88 | 100 | static enum cs_result check_charset(void); |
89 | 101 | static char *char_if_ascii7(unsigned long l); |
90 | 102 | #endif /*]*/ |
103 | + | |
91 | 104 | static void set_cgcsgids(char *spec); |
92 | 105 | static int set_cgcsgid(char *spec, unsigned long *idp); |
93 | 106 | |
... | ... | @@ -113,6 +126,7 @@ static unsigned char save_ebc2cg[256]; |
113 | 126 | static unsigned char save_cg2ebc[256]; |
114 | 127 | static unsigned char save_ebc2asc[256]; |
115 | 128 | static unsigned char save_asc2ebc[256]; |
129 | + | |
116 | 130 | #if defined(X3270_FT) /*[*/ |
117 | 131 | static unsigned char save_ft2asc[256]; |
118 | 132 | static unsigned char save_asc2ft[256]; |
... | ... | @@ -145,8 +159,7 @@ restore_charset(void) |
145 | 159 | } |
146 | 160 | |
147 | 161 | /* Get a character set definition. */ |
148 | -static char * | |
149 | -get_charset_def(const char *csname) | |
162 | +static char * get_charset_def(const char *csname) | |
150 | 163 | { |
151 | 164 | return get_fresource("%s.%s", ResCharset, csname); |
152 | 165 | } |
... | ... | @@ -183,9 +196,11 @@ enum cs_result charset_init(H3270 *session, char *csname) |
183 | 196 | char *cs, *ftcs; |
184 | 197 | enum cs_result rc; |
185 | 198 | char *ccs, *cftcs; |
186 | -#if defined(X3270_DISPLAY) /*[*/ | |
199 | +/* | |
200 | +#if defined(X3270_DISPLAY) | |
187 | 201 | char *xks; |
188 | -#endif /*]*/ | |
202 | +#endif | |
203 | +*/ | |
189 | 204 | char *ak; |
190 | 205 | |
191 | 206 | /* | ... | ... |
src/lib3270/print.c
... | ... | @@ -85,15 +85,15 @@ static char *print_window_command = CN; |
85 | 85 | |
86 | 86 | /* |
87 | 87 | * Map default 3279 colors. This code is duplicated three times. ;-( |
88 | - */ | |
88 | + */ /* | |
89 | 89 | static int |
90 | 90 | color_from_fa(unsigned char fa) |
91 | 91 | { |
92 | 92 | static int field_colors[4] = { |
93 | - COLOR_GREEN, /* default */ | |
94 | - COLOR_RED, /* intensified */ | |
95 | - COLOR_BLUE, /* protected */ | |
96 | - COLOR_WHITE /* protected, intensified */ | |
93 | + COLOR_GREEN, // default | |
94 | + COLOR_RED, // intensified | |
95 | + COLOR_BLUE, // protected | |
96 | + COLOR_WHITE // protected, intensified | |
97 | 97 | # define DEFCOLOR_MAP(f) \ |
98 | 98 | ((((f) & FA_PROTECT) >> 4) | (((f) & FA_INT_HIGH_SEL) >> 3)) |
99 | 99 | }; |
... | ... | @@ -103,10 +103,10 @@ color_from_fa(unsigned char fa) |
103 | 103 | else |
104 | 104 | return COLOR_GREEN; |
105 | 105 | } |
106 | - | |
106 | +*/ | |
107 | 107 | /* |
108 | 108 | * Map 3279 colors onto HTML colors. |
109 | - */ | |
109 | + */ /* | |
110 | 110 | static char * |
111 | 111 | html_color(int color) |
112 | 112 | { |
... | ... | @@ -133,7 +133,7 @@ html_color(int color) |
133 | 133 | else |
134 | 134 | return "black"; |
135 | 135 | } |
136 | - | |
136 | +*/ | |
137 | 137 | |
138 | 138 | /* |
139 | 139 | * Print the ASCIIfied contents of the screen onto a stream. |
... | ... | @@ -145,6 +145,9 @@ html_color(int color) |
145 | 145 | Boolean |
146 | 146 | fprint_screen(FILE *f, Boolean even_if_empty, Boolean use_html) |
147 | 147 | { |
148 | + return False; | |
149 | + | |
150 | +/* | |
148 | 151 | register int i; |
149 | 152 | char c; |
150 | 153 | int ns = 0; |
... | ... | @@ -172,10 +175,10 @@ fprint_screen(FILE *f, Boolean even_if_empty, Boolean use_html) |
172 | 175 | current_high = fa_high; |
173 | 176 | |
174 | 177 | for (i = 0; i < h3270.rows*h3270.cols; i++) { |
175 | -#if defined(X3270_DBCS) /*[*/ | |
178 | +#if defined(X3270_DBCS) | |
176 | 179 | char mb[16]; |
177 | 180 | Boolean is_dbcs = False; |
178 | -#endif /*]*/ | |
181 | +#endif | |
179 | 182 | |
180 | 183 | if (i && !(i % h3270.cols)) { |
181 | 184 | nr++; |
... | ... | @@ -195,9 +198,9 @@ fprint_screen(FILE *f, Boolean even_if_empty, Boolean use_html) |
195 | 198 | } |
196 | 199 | if (FA_IS_ZERO(fa)) |
197 | 200 | c = ' '; |
198 | -#if defined(X3270_DBCS) /*[*/ | |
201 | +#if defined(X3270_DBCS) | |
199 | 202 | else { |
200 | - /* XXX: DBCS/html interactions are not done */ | |
203 | + // XXX: DBCS/html interactions are not done | |
201 | 204 | switch (ctlr_dbcs_state(i)) { |
202 | 205 | case DBCS_NONE: |
203 | 206 | case DBCS_SB: |
... | ... | @@ -213,10 +216,10 @@ fprint_screen(FILE *f, Boolean even_if_empty, Boolean use_html) |
213 | 216 | break; |
214 | 217 | } |
215 | 218 | } |
216 | -#else /*][*/ | |
219 | +#else | |
217 | 220 | else |
218 | 221 | c = ebc2asc[h3270.ea_buf[i].cc]; |
219 | -#endif /*]*/ | |
222 | +#endif | |
220 | 223 | if (c == ' ') |
221 | 224 | ns++; |
222 | 225 | else { |
... | ... | @@ -270,13 +273,13 @@ fprint_screen(FILE *f, Boolean even_if_empty, Boolean use_html) |
270 | 273 | } |
271 | 274 | } |
272 | 275 | any = True; |
273 | -#if defined(X3270_DBCS) /*[*/ | |
276 | +#if defined(X3270_DBCS) | |
274 | 277 | if (is_dbcs) { |
275 | 278 | (void) fputs(mb, f); |
276 | 279 | i++; |
277 | 280 | } |
278 | 281 | else |
279 | -#endif /*]*/ | |
282 | +#endif | |
280 | 283 | { |
281 | 284 | if (use_html && c == '<') |
282 | 285 | fprintf(f, "<"); |
... | ... | @@ -300,6 +303,7 @@ fprint_screen(FILE *f, Boolean even_if_empty, Boolean use_html) |
300 | 303 | current_high? "</b>": ""); |
301 | 304 | } |
302 | 305 | return True; |
306 | +*/ | |
303 | 307 | } |
304 | 308 | |
305 | 309 | /* Termination code for print text process. */ /* | ... | ... |
src/lib3270/trace_ds.c
... | ... | @@ -793,11 +793,13 @@ do_screentrace(void) |
793 | 793 | { |
794 | 794 | register int i; |
795 | 795 | |
796 | +/* | |
796 | 797 | if (fprint_screen(screentracef, False, False)) { |
797 | 798 | for (i = 0; i < h3270.cols; i++) |
798 | 799 | (void) fputc('=', screentracef); |
799 | 800 | (void) fputc('\n', screentracef); |
800 | 801 | } |
802 | +*/ | |
801 | 803 | } |
802 | 804 | |
803 | 805 | void | ... | ... |
src/lib3270/utf8.c
... | ... | @@ -45,7 +45,7 @@ |
45 | 45 | char *locale_codeset = CN; |
46 | 46 | |
47 | 47 | static int utf8_ix = -1; |
48 | -static Boolean is_utf8 = False; | |
48 | +// static Boolean is_utf8 = False; | |
49 | 49 | #if defined(X3270_DBCS) /*[*/ |
50 | 50 | static Boolean is_gb18030 = False; |
51 | 51 | #endif /*]*/ |
... | ... | @@ -73,8 +73,8 @@ enum UTF_IX { |
73 | 73 | /* |
74 | 74 | * Names of the above (real) character sets. These are the names used in |
75 | 75 | * displayCharset resources. |
76 | - */ | |
77 | -static char *dcs[] = { /* same order as enum UTF_IX and utf8_tab[] */ | |
76 | + */ /* | |
77 | +static char *dcs[] = { // same order as enum UTF_IX and utf8_tab[] | |
78 | 78 | "iso8859-1", |
79 | 79 | "iso8859-2", |
80 | 80 | "iso8859-7", |
... | ... | @@ -85,6 +85,7 @@ static char *dcs[] = { /* same order as enum UTF_IX and utf8_tab[] */ |
85 | 85 | "koi8-r", |
86 | 86 | CN |
87 | 87 | }; |
88 | +*/ | |
88 | 89 | |
89 | 90 | /* |
90 | 91 | * UTF-8 translation tables. |
... | ... | @@ -336,33 +337,34 @@ static char *utf8_tab[U_MAX][96] = { |
336 | 337 | |
337 | 338 | /* |
338 | 339 | * Save the codeset from the locale, and set globals based on known values. |
339 | - */ | |
340 | + */ /* | |
340 | 341 | void |
341 | 342 | set_codeset(char *codeset_name) |
342 | 343 | { |
343 | 344 | char *new_codeset; |
344 | 345 | |
345 | -#if defined(X3270_DBCS) /*[*/ | |
346 | +#if defined(X3270_DBCS) | |
346 | 347 | is_gb18030 = !strcasecmp(codeset_name, "gb18030"); |
347 | -#endif /*]*/ | |
348 | +#endif | |
348 | 349 | |
349 | -#if !defined(TCL3270) /*[*/ | |
350 | +#if !defined(TCL3270) | |
350 | 351 | is_utf8 = (!strcasecmp(codeset_name, "utf-8") || |
351 | 352 | !strcasecmp(codeset_name, "utf8") || |
352 | 353 | !strcasecmp(codeset_name, "utf_8")); |
353 | -#else /*][*/ | |
354 | - /* | |
355 | - * tcl3270 is always in UTF-8 mode, because it needs to | |
356 | - * supply UTF-8 strings to libtcl. | |
357 | - */ | |
354 | +#else | |
355 | + // | |
356 | + // tcl3270 is always in UTF-8 mode, because it needs to | |
357 | + // supply UTF-8 strings to libtcl. | |
358 | + // | |
358 | 359 | is_utf8 = 1; |
359 | -#endif /*]*/ | |
360 | +#endif | |
360 | 361 | |
361 | 362 | Trace("%s locale_codeset: %p new_codeset: %p (%s)",__FUNCTION__,locale_codeset,codeset_name,codeset_name); |
362 | 363 | new_codeset = NewString(codeset_name); |
363 | 364 | Replace(locale_codeset, new_codeset); |
364 | 365 | Trace("%s",__FUNCTION__); |
365 | 366 | } |
367 | +*/ | |
366 | 368 | |
367 | 369 | /* |
368 | 370 | * Set globals based on an x3270 character set list. |
... | ... | @@ -371,7 +373,7 @@ set_codeset(char *codeset_name) |
371 | 373 | * used by utf8_expand() below. |
372 | 374 | * |
373 | 375 | * set_codeset, above, must be called _before_ this function. |
374 | - */ | |
376 | + */ /* | |
375 | 377 | Boolean |
376 | 378 | utf8_set_display_charsets(char *cslist, char *csname) |
377 | 379 | { |
... | ... | @@ -382,44 +384,44 @@ utf8_set_display_charsets(char *cslist, char *csname) |
382 | 384 | |
383 | 385 | utf8_ix = -1; |
384 | 386 | |
385 | -#if defined(X3270_DBCS) /*[*/ | |
387 | +#if defined(X3270_DBCS) | |
386 | 388 | if (strchr(cslist, '+') != CN) |
387 | 389 | dbcs = True; |
388 | -#endif /*]*/ | |
390 | +#endif | |
389 | 391 | |
390 | 392 | if (!is_utf8) { |
391 | -#if defined(X3270_DBCS) /*[*/ | |
393 | +#if defined(X3270_DBCS) | |
392 | 394 | if (is_gb18030) { |
393 | - /* | |
394 | - * A convenient lie. | |
395 | - * If the locale is GB18030, use the UTF-8 | |
396 | - * expansion mechanism to translate 0xa0 through | |
397 | - * 0xff, using a table entry that expands to GB18030 | |
398 | - * multi-byte sequences rather than UTF-8. | |
399 | - * | |
400 | - * Note that there appears to be a bug in ncursesw | |
401 | - * (or something it depends on) that turns these | |
402 | - * characters into garbage. Hopefully this bug will | |
403 | - * be fixed and this code will start working properly. | |
404 | - * | |
405 | - * As a workarond, everything works properly in a | |
406 | - * Chinese UTF-8 locale. | |
407 | - */ | |
395 | + // | |
396 | + // A convenient lie. | |
397 | + // If the locale is GB18030, use the UTF-8 | |
398 | + // expansion mechanism to translate 0xa0 through | |
399 | + // 0xff, using a table entry that expands to GB18030 | |
400 | + // multi-byte sequences rather than UTF-8. | |
401 | + // | |
402 | + // Note that there appears to be a bug in ncursesw | |
403 | + // (or something it depends on) that turns these | |
404 | + // characters into garbage. Hopefully this bug will | |
405 | + // be fixed and this code will start working properly. | |
406 | + // | |
407 | + // As a workarond, everything works properly in a | |
408 | + // Chinese UTF-8 locale. | |
409 | + // | |
408 | 410 | utf8_ix = PSEUDO_GB18030; |
409 | 411 | } |
410 | -#endif /*]*/ | |
412 | +#endif | |
411 | 413 | return True; |
412 | 414 | } |
413 | 415 | |
414 | -#if defined(X3270_DBCS) /*[*/ | |
415 | - /* For DBCS, map 0xa0..0xff as Latin-1. */ | |
416 | +#if defined(X3270_DBCS) | |
417 | + // For DBCS, map 0xa0..0xff as Latin-1. | |
416 | 418 | if (dbcs) { |
417 | 419 | utf8_ix = U_ISO8859_1; |
418 | 420 | return True; |
419 | 421 | } |
420 | -#endif /*]*/ | |
422 | +#endif | |
421 | 423 | |
422 | - /* Skip 3270cg sets. */ | |
424 | + // Skip 3270cg sets. | |
423 | 425 | ptr = dup = NewString(cslist); |
424 | 426 | while ((tok = strtok(ptr, ",")) != CN) { |
425 | 427 | ptr = NULL; |
... | ... | @@ -433,7 +435,7 @@ utf8_set_display_charsets(char *cslist, char *csname) |
433 | 435 | return False; |
434 | 436 | } |
435 | 437 | |
436 | - /* Look up the charset. */ | |
438 | + // Look up the charset. | |
437 | 439 | for (i = 0; dcs[i] != CN; i++) { |
438 | 440 | if (!strcasecmp(dcs[i], tok)) |
439 | 441 | break; |
... | ... | @@ -448,7 +450,7 @@ utf8_set_display_charsets(char *cslist, char *csname) |
448 | 450 | Free(dup); |
449 | 451 | return True; |
450 | 452 | } |
451 | - | |
453 | +*/ | |
452 | 454 | /* Expand an 8-bit character in the 'implied' character set. */ |
453 | 455 | char * |
454 | 456 | utf8_expand(unsigned char c) |
... | ... | @@ -483,8 +485,7 @@ utf8_expand(unsigned char c) |
483 | 485 | * character set. |
484 | 486 | * Returns 0 if the lookup fails. |
485 | 487 | */ |
486 | -unsigned char | |
487 | -utf8_lookup(char *mbs, enum ulfail *fail, int *consumed) | |
488 | +unsigned char utf8_lookup(char *mbs, enum ulfail *fail, int *consumed) | |
488 | 489 | { |
489 | 490 | int i; |
490 | 491 | int mblen = strlen(mbs); | ... | ... |
src/lib3270/utf8c.h
... | ... | @@ -24,9 +24,9 @@ enum ulfail { |
24 | 24 | ULFAIL_INVALID /* invalid sequence */ |
25 | 25 | }; |
26 | 26 | |
27 | -LIB3270_INTERNAL char *locale_codeset; | |
27 | +// LIB3270_INTERNAL char *locale_codeset; | |
28 | 28 | |
29 | -LIB3270_INTERNAL void set_codeset(char *codeset_name); | |
30 | -LIB3270_INTERNAL Boolean utf8_set_display_charsets(char *cslist, char *csname); | |
31 | -LIB3270_INTERNAL char *utf8_expand(unsigned char c); | |
32 | -LIB3270_INTERNAL unsigned char utf8_lookup(char *mbs, enum ulfail *fail, int *consumed); | |
29 | +// LIB3270_INTERNAL void set_codeset(char *codeset_name); | |
30 | +// LIB3270_INTERNAL Boolean utf8_set_display_charsets(char *cslist, char *csname); | |
31 | + LIB3270_INTERNAL char *utf8_expand(unsigned char c); | |
32 | + LIB3270_INTERNAL unsigned char utf8_lookup(char *mbs, enum ulfail *fail, int *consumed); | ... | ... |