From c29f3eb184eb4c3cb1a3c61628058ab43144ace6 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Tue, 13 Mar 2012 21:55:02 +0000 Subject: [PATCH] Biblioteca de versao 5 precisa trabalhar toda em latin-1 igual ao windows deixando a conversao para UTF-8 por conta do gtk para manter um unico mecanismo de conversao --- src/lib3270/charset.c | 39 +++++++++++++++++++++++++++------------ src/lib3270/print.c | 36 ++++++++++++++++++++---------------- src/lib3270/trace_ds.c | 2 ++ src/lib3270/utf8.c | 83 ++++++++++++++++++++++++++++++++++++++++++----------------------------------------- src/lib3270/utf8c.h | 10 +++++----- 5 files changed, 96 insertions(+), 74 deletions(-) diff --git a/src/lib3270/charset.c b/src/lib3270/charset.c index 436ab54..dc38add 100644 --- a/src/lib3270/charset.c +++ b/src/lib3270/charset.c @@ -44,19 +44,27 @@ #include "charsetc.h" #include "kybdc.h" #include "popupsc.h" -#if defined(X3270_DISPLAY) || (defined(C3270) && !defined(_WIN32)) /*[*/ + +/* +#if defined(X3270_DISPLAY) || (defined(C3270) && !defined(_WIN32)) #include "screenc.h" -#endif /*]*/ +#endif +*/ + #include "tablesc.h" #include "utf8c.h" #include "utilc.h" #include "widec.h" #include -#include -#if !defined(_WIN32) /*[*/ + +//#include + +/* +#if !defined(_WIN32) #include -#endif /*]*/ +#endif +*/ // #include @@ -72,9 +80,13 @@ unsigned long cgcsgid_dbcs = 0L; char *default_display_charset = "3270cg-1a,3270cg-1,iso8859-1"; char *converter_names; char *encoding; -#if defined(X3270_DISPLAY) /*[*/ + +/* +#if defined(X3270_DISPLAY) unsigned char xk_selector = 0; #endif +*/ + unsigned char auto_keymap = 0; /* Statics. */ @@ -82,12 +94,13 @@ static enum cs_result resource_charset(char *csname, char *cs, char *ftcs); typedef enum { CS_ONLY, FT_ONLY, BOTH } remap_scope; static enum cs_result remap_chars(char *csname, char *spec, remap_scope scope, int *ne); -static void remap_one(unsigned char ebc, KeySym iso, remap_scope scope, - Boolean one_way); +static void remap_one(unsigned char ebc, KeySym iso, remap_scope scope,Boolean one_way); + #if defined(DEBUG_CHARSET) /*[*/ static enum cs_result check_charset(void); static char *char_if_ascii7(unsigned long l); #endif /*]*/ + static void set_cgcsgids(char *spec); static int set_cgcsgid(char *spec, unsigned long *idp); @@ -113,6 +126,7 @@ static unsigned char save_ebc2cg[256]; static unsigned char save_cg2ebc[256]; static unsigned char save_ebc2asc[256]; static unsigned char save_asc2ebc[256]; + #if defined(X3270_FT) /*[*/ static unsigned char save_ft2asc[256]; static unsigned char save_asc2ft[256]; @@ -145,8 +159,7 @@ restore_charset(void) } /* Get a character set definition. */ -static char * -get_charset_def(const char *csname) +static char * get_charset_def(const char *csname) { return get_fresource("%s.%s", ResCharset, csname); } @@ -183,9 +196,11 @@ enum cs_result charset_init(H3270 *session, char *csname) char *cs, *ftcs; enum cs_result rc; char *ccs, *cftcs; -#if defined(X3270_DISPLAY) /*[*/ +/* +#if defined(X3270_DISPLAY) char *xks; -#endif /*]*/ +#endif +*/ char *ak; /* diff --git a/src/lib3270/print.c b/src/lib3270/print.c index b2995db..93cb123 100644 --- a/src/lib3270/print.c +++ b/src/lib3270/print.c @@ -85,15 +85,15 @@ static char *print_window_command = CN; /* * Map default 3279 colors. This code is duplicated three times. ;-( - */ + */ /* static int color_from_fa(unsigned char fa) { static int field_colors[4] = { - COLOR_GREEN, /* default */ - COLOR_RED, /* intensified */ - COLOR_BLUE, /* protected */ - COLOR_WHITE /* protected, intensified */ + COLOR_GREEN, // default + COLOR_RED, // intensified + COLOR_BLUE, // protected + COLOR_WHITE // protected, intensified # define DEFCOLOR_MAP(f) \ ((((f) & FA_PROTECT) >> 4) | (((f) & FA_INT_HIGH_SEL) >> 3)) }; @@ -103,10 +103,10 @@ color_from_fa(unsigned char fa) else return COLOR_GREEN; } - +*/ /* * Map 3279 colors onto HTML colors. - */ + */ /* static char * html_color(int color) { @@ -133,7 +133,7 @@ html_color(int color) else return "black"; } - +*/ /* * Print the ASCIIfied contents of the screen onto a stream. @@ -145,6 +145,9 @@ html_color(int color) Boolean fprint_screen(FILE *f, Boolean even_if_empty, Boolean use_html) { + return False; + +/* register int i; char c; int ns = 0; @@ -172,10 +175,10 @@ fprint_screen(FILE *f, Boolean even_if_empty, Boolean use_html) current_high = fa_high; for (i = 0; i < h3270.rows*h3270.cols; i++) { -#if defined(X3270_DBCS) /*[*/ +#if defined(X3270_DBCS) char mb[16]; Boolean is_dbcs = False; -#endif /*]*/ +#endif if (i && !(i % h3270.cols)) { nr++; @@ -195,9 +198,9 @@ fprint_screen(FILE *f, Boolean even_if_empty, Boolean use_html) } if (FA_IS_ZERO(fa)) c = ' '; -#if defined(X3270_DBCS) /*[*/ +#if defined(X3270_DBCS) else { - /* XXX: DBCS/html interactions are not done */ + // XXX: DBCS/html interactions are not done switch (ctlr_dbcs_state(i)) { case DBCS_NONE: case DBCS_SB: @@ -213,10 +216,10 @@ fprint_screen(FILE *f, Boolean even_if_empty, Boolean use_html) break; } } -#else /*][*/ +#else else c = ebc2asc[h3270.ea_buf[i].cc]; -#endif /*]*/ +#endif if (c == ' ') ns++; else { @@ -270,13 +273,13 @@ fprint_screen(FILE *f, Boolean even_if_empty, Boolean use_html) } } any = True; -#if defined(X3270_DBCS) /*[*/ +#if defined(X3270_DBCS) if (is_dbcs) { (void) fputs(mb, f); i++; } else -#endif /*]*/ +#endif { if (use_html && c == '<') fprintf(f, "<"); @@ -300,6 +303,7 @@ fprint_screen(FILE *f, Boolean even_if_empty, Boolean use_html) current_high? "": ""); } return True; +*/ } /* Termination code for print text process. */ /* diff --git a/src/lib3270/trace_ds.c b/src/lib3270/trace_ds.c index c0704ae..83ee48b 100644 --- a/src/lib3270/trace_ds.c +++ b/src/lib3270/trace_ds.c @@ -793,11 +793,13 @@ do_screentrace(void) { register int i; +/* if (fprint_screen(screentracef, False, False)) { for (i = 0; i < h3270.cols; i++) (void) fputc('=', screentracef); (void) fputc('\n', screentracef); } +*/ } void diff --git a/src/lib3270/utf8.c b/src/lib3270/utf8.c index 9faa767..d0f86b4 100644 --- a/src/lib3270/utf8.c +++ b/src/lib3270/utf8.c @@ -45,7 +45,7 @@ char *locale_codeset = CN; static int utf8_ix = -1; -static Boolean is_utf8 = False; +// static Boolean is_utf8 = False; #if defined(X3270_DBCS) /*[*/ static Boolean is_gb18030 = False; #endif /*]*/ @@ -73,8 +73,8 @@ enum UTF_IX { /* * Names of the above (real) character sets. These are the names used in * displayCharset resources. - */ -static char *dcs[] = { /* same order as enum UTF_IX and utf8_tab[] */ + */ /* +static char *dcs[] = { // same order as enum UTF_IX and utf8_tab[] "iso8859-1", "iso8859-2", "iso8859-7", @@ -85,6 +85,7 @@ static char *dcs[] = { /* same order as enum UTF_IX and utf8_tab[] */ "koi8-r", CN }; +*/ /* * UTF-8 translation tables. @@ -336,33 +337,34 @@ static char *utf8_tab[U_MAX][96] = { /* * Save the codeset from the locale, and set globals based on known values. - */ + */ /* void set_codeset(char *codeset_name) { char *new_codeset; -#if defined(X3270_DBCS) /*[*/ +#if defined(X3270_DBCS) is_gb18030 = !strcasecmp(codeset_name, "gb18030"); -#endif /*]*/ +#endif -#if !defined(TCL3270) /*[*/ +#if !defined(TCL3270) is_utf8 = (!strcasecmp(codeset_name, "utf-8") || !strcasecmp(codeset_name, "utf8") || !strcasecmp(codeset_name, "utf_8")); -#else /*][*/ - /* - * tcl3270 is always in UTF-8 mode, because it needs to - * supply UTF-8 strings to libtcl. - */ +#else + // + // tcl3270 is always in UTF-8 mode, because it needs to + // supply UTF-8 strings to libtcl. + // is_utf8 = 1; -#endif /*]*/ +#endif Trace("%s locale_codeset: %p new_codeset: %p (%s)",__FUNCTION__,locale_codeset,codeset_name,codeset_name); new_codeset = NewString(codeset_name); Replace(locale_codeset, new_codeset); Trace("%s",__FUNCTION__); } +*/ /* * Set globals based on an x3270 character set list. @@ -371,7 +373,7 @@ set_codeset(char *codeset_name) * used by utf8_expand() below. * * set_codeset, above, must be called _before_ this function. - */ + */ /* Boolean utf8_set_display_charsets(char *cslist, char *csname) { @@ -382,44 +384,44 @@ utf8_set_display_charsets(char *cslist, char *csname) utf8_ix = -1; -#if defined(X3270_DBCS) /*[*/ +#if defined(X3270_DBCS) if (strchr(cslist, '+') != CN) dbcs = True; -#endif /*]*/ +#endif if (!is_utf8) { -#if defined(X3270_DBCS) /*[*/ +#if defined(X3270_DBCS) if (is_gb18030) { - /* - * A convenient lie. - * If the locale is GB18030, use the UTF-8 - * expansion mechanism to translate 0xa0 through - * 0xff, using a table entry that expands to GB18030 - * multi-byte sequences rather than UTF-8. - * - * Note that there appears to be a bug in ncursesw - * (or something it depends on) that turns these - * characters into garbage. Hopefully this bug will - * be fixed and this code will start working properly. - * - * As a workarond, everything works properly in a - * Chinese UTF-8 locale. - */ + // + // A convenient lie. + // If the locale is GB18030, use the UTF-8 + // expansion mechanism to translate 0xa0 through + // 0xff, using a table entry that expands to GB18030 + // multi-byte sequences rather than UTF-8. + // + // Note that there appears to be a bug in ncursesw + // (or something it depends on) that turns these + // characters into garbage. Hopefully this bug will + // be fixed and this code will start working properly. + // + // As a workarond, everything works properly in a + // Chinese UTF-8 locale. + // utf8_ix = PSEUDO_GB18030; } -#endif /*]*/ +#endif return True; } -#if defined(X3270_DBCS) /*[*/ - /* For DBCS, map 0xa0..0xff as Latin-1. */ +#if defined(X3270_DBCS) + // For DBCS, map 0xa0..0xff as Latin-1. if (dbcs) { utf8_ix = U_ISO8859_1; return True; } -#endif /*]*/ +#endif - /* Skip 3270cg sets. */ + // Skip 3270cg sets. ptr = dup = NewString(cslist); while ((tok = strtok(ptr, ",")) != CN) { ptr = NULL; @@ -433,7 +435,7 @@ utf8_set_display_charsets(char *cslist, char *csname) return False; } - /* Look up the charset. */ + // Look up the charset. for (i = 0; dcs[i] != CN; i++) { if (!strcasecmp(dcs[i], tok)) break; @@ -448,7 +450,7 @@ utf8_set_display_charsets(char *cslist, char *csname) Free(dup); return True; } - +*/ /* Expand an 8-bit character in the 'implied' character set. */ char * utf8_expand(unsigned char c) @@ -483,8 +485,7 @@ utf8_expand(unsigned char c) * character set. * Returns 0 if the lookup fails. */ -unsigned char -utf8_lookup(char *mbs, enum ulfail *fail, int *consumed) +unsigned char utf8_lookup(char *mbs, enum ulfail *fail, int *consumed) { int i; int mblen = strlen(mbs); diff --git a/src/lib3270/utf8c.h b/src/lib3270/utf8c.h index 5a5941a..7f810fb 100644 --- a/src/lib3270/utf8c.h +++ b/src/lib3270/utf8c.h @@ -24,9 +24,9 @@ enum ulfail { ULFAIL_INVALID /* invalid sequence */ }; -LIB3270_INTERNAL char *locale_codeset; +// LIB3270_INTERNAL char *locale_codeset; -LIB3270_INTERNAL void set_codeset(char *codeset_name); -LIB3270_INTERNAL Boolean utf8_set_display_charsets(char *cslist, char *csname); -LIB3270_INTERNAL char *utf8_expand(unsigned char c); -LIB3270_INTERNAL unsigned char utf8_lookup(char *mbs, enum ulfail *fail, int *consumed); +// LIB3270_INTERNAL void set_codeset(char *codeset_name); +// LIB3270_INTERNAL Boolean utf8_set_display_charsets(char *cslist, char *csname); + LIB3270_INTERNAL char *utf8_expand(unsigned char c); + LIB3270_INTERNAL unsigned char utf8_lookup(char *mbs, enum ulfail *fail, int *consumed); -- libgit2 0.21.2