From 9b7cff165247d35005147075719624451905cf29 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Wed, 14 Mar 2012 10:42:01 +0000 Subject: [PATCH] Removendo mais conversões utf-8 da lib, função passa a ser da gui --- src/lib3270/ansi.c | 4 ++-- src/lib3270/see.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------- src/lib3270/utf8.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------- 3 files changed, 107 insertions(+), 82 deletions(-) diff --git a/src/lib3270/ansi.c b/src/lib3270/ansi.c index 218ced9..5530fef 100644 --- a/src/lib3270/ansi.c +++ b/src/lib3270/ansi.c @@ -1215,12 +1215,12 @@ ansi_multibyte(int ig1, int ig2) ch = utf8_lookup(mbs, &fail, NULL); if (ch != 0) { - /* Success! */ + // Success! ansi_ch = ch; return ansi_printing(ig1, ig2); } if (fail == ULFAIL_INCOMPLETE) { - /* Go get more. */ + // Go get more. pending_mbs[pmi++] = (char)ansi_ch; return MBPEND; } diff --git a/src/lib3270/see.c b/src/lib3270/see.c index 42abd0f..af618fc 100644 --- a/src/lib3270/see.c +++ b/src/lib3270/see.c @@ -1,27 +1,27 @@ -/* +/* * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a * aplicativos mainframe. Registro no INPI sob o nome G3270. - * + * * Copyright (C) <2008> - * + * * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela * Free Software Foundation. - * + * * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para * obter mais detalhes. - * + * * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA, 02111-1307, USA - * + * * Este programa está nomeado como see.c e possui 489 linhas de código. - * - * Contatos: - * + * + * Contatos: + * * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) * licinio@bb.com.br (Licínio Luis Branco) @@ -90,16 +90,24 @@ see_ebc(unsigned char ch) case FCORDER_SO: return "SO"; } + + if (ebc2asc[ch]) + (void) sprintf(buf,"%c", ebc2asc[ch]); + else + (void) sprintf(buf, "\\%o", ch); + +/* if (ebc2asc[ch]) (void) sprintf(buf, -#if !defined(PR3287) /*[*/ +#if !defined(PR3287) "%s", utf8_expand(ebc2asc[ch]) -#else /*][*/ +#else "%c", ebc2asc[ch] -#endif /*]*/ +#endif ); else (void) sprintf(buf, "\\%o", ch); +*/ return buf; } @@ -107,77 +115,77 @@ const char * see_aid(unsigned char code) { switch (code) { - case AID_NO: + case AID_NO: return "NoAID"; - case AID_ENTER: + case AID_ENTER: return "Enter"; - case AID_PF1: + case AID_PF1: return "PF1"; - case AID_PF2: + case AID_PF2: return "PF2"; - case AID_PF3: + case AID_PF3: return "PF3"; - case AID_PF4: + case AID_PF4: return "PF4"; - case AID_PF5: + case AID_PF5: return "PF5"; - case AID_PF6: + case AID_PF6: return "PF6"; - case AID_PF7: + case AID_PF7: return "PF7"; - case AID_PF8: + case AID_PF8: return "PF8"; - case AID_PF9: + case AID_PF9: return "PF9"; - case AID_PF10: + case AID_PF10: return "PF10"; - case AID_PF11: + case AID_PF11: return "PF11"; - case AID_PF12: + case AID_PF12: return "PF12"; - case AID_PF13: + case AID_PF13: return "PF13"; - case AID_PF14: + case AID_PF14: return "PF14"; - case AID_PF15: + case AID_PF15: return "PF15"; - case AID_PF16: + case AID_PF16: return "PF16"; - case AID_PF17: + case AID_PF17: return "PF17"; - case AID_PF18: + case AID_PF18: return "PF18"; - case AID_PF19: + case AID_PF19: return "PF19"; - case AID_PF20: + case AID_PF20: return "PF20"; - case AID_PF21: + case AID_PF21: return "PF21"; - case AID_PF22: + case AID_PF22: return "PF22"; - case AID_PF23: + case AID_PF23: return "PF23"; - case AID_PF24: + case AID_PF24: return "PF24"; - case AID_OICR: + case AID_OICR: return "OICR"; - case AID_MSR_MHS: + case AID_MSR_MHS: return "MSR_MHS"; - case AID_SELECT: + case AID_SELECT: return "Select"; - case AID_PA1: + case AID_PA1: return "PA1"; - case AID_PA2: + case AID_PA2: return "PA2"; - case AID_PA3: + case AID_PA3: return "PA3"; - case AID_CLEAR: + case AID_CLEAR: return "Clear"; - case AID_SYSREQ: + case AID_SYSREQ: return "SysReq"; case AID_QREPLY: return "QueryReplyAID"; - default: + default: return unknown(code); } } diff --git a/src/lib3270/utf8.c b/src/lib3270/utf8.c index d0f86b4..44a6f55 100644 --- a/src/lib3270/utf8.c +++ b/src/lib3270/utf8.c @@ -42,9 +42,10 @@ #include "popupsc.h" #include "utf8c.h" -char *locale_codeset = CN; +// char *locale_codeset = CN; + +// static int utf8_ix = -1; -static int utf8_ix = -1; // static Boolean is_utf8 = False; #if defined(X3270_DBCS) /*[*/ static Boolean is_gb18030 = False; @@ -452,33 +453,38 @@ utf8_set_display_charsets(char *cslist, char *csname) } */ /* Expand an 8-bit character in the 'implied' character set. */ -char * -utf8_expand(unsigned char c) +/* +char * utf8_expand(unsigned char c) { - static char nox[2]; + static char nox[2]; - if (c & 0x80) { - if (utf8_ix >= 0) { + if (c & 0x80) + { + if (utf8_ix >= 0) + { if (c >= 0xa0) return utf8_tab[utf8_ix][c - 0xa0]; else return " "; -#if defined(X3270_DBCS) /*[*/ - } else if (dbcs) { - /* - * GB18030 it treated as a special case of UTF-8, - * above. GB2312 does not support these characters. - * Other DBCS encodings will need to be added as they - * are better understood. - */ - return " "; -#endif /*]*/ } +#if defined(X3270_DBCS) + else if (dbcs) + { + // + // GB18030 it treated as a special case of UTF-8, + // above. GB2312 does not support these characters. + // Other DBCS encodings will need to be added as they + // are better understood. + // + return " "; + } +#endif } nox[0] = c; nox[1] = '\0'; return nox; } +*/ /* * Look up a multi-byte UTF-8 string and return its value in the 'implied' @@ -487,34 +493,45 @@ utf8_expand(unsigned char c) */ unsigned char utf8_lookup(char *mbs, enum ulfail *fail, int *consumed) { - int i; + if (fail != NULL) + *fail = ULFAIL_NOUTF8; + +/* + int i; int mblen = strlen(mbs); - if (utf8_ix < 0) { - if (fail != NULL) - *fail = ULFAIL_NOUTF8; - return 0; + if (utf8_ix < 0) + { + if (fail != NULL) + *fail = ULFAIL_NOUTF8; + return 0; } - for (i = 0; i < HI_SIZE; i++) { - int tlen = strlen(utf8_tab[utf8_ix][i]); - /* Check for dummy " " entry. */ + for (i = 0; i < HI_SIZE; i++) + { + int tlen = strlen(utf8_tab[utf8_ix][i]); + + // Check for dummy " " entry. if (tlen == 1) - continue; + continue; - /* Check for incomplete string. */ - if (mblen < tlen) { + // Check for incomplete string. + if (mblen < tlen) + { if (fail != NULL) *fail = ULFAIL_INCOMPLETE; return 0; } - if (!strncmp(mbs, utf8_tab[utf8_ix][i], tlen)) { - if (consumed != NULL) - *consumed = tlen; - return 0xa0 + i; + + if (!strncmp(mbs, utf8_tab[utf8_ix][i], tlen)) + { + if (consumed != NULL) + *consumed = tlen; + return 0xa0 + i; } } if (fail != NULL) - *fail = ULFAIL_INVALID; + *fail = ULFAIL_INVALID; +*/ return 0; } -- libgit2 0.21.2