Commit 7abd52c1 authored by Nalin Dahyabhai's avatar Nalin Dahyabhai

quiet a compiler warning. use KSX-1001 instead of KSC-5601 for Korean, add

* src/vteglyph.c(_vte_glyph_get): quiet a compiler warning.
* src/iso2022.c: use KSX-1001 instead of KSC-5601 for Korean, add maps for
	CNS 11643 planes 3,4,5,6,7 (can't test them, but hey).  Rework so
	that we get the data before it's passed to g_iconv(), and stuff
	gunichars into an array for the caller.
* src/interpret.c: adapt to changes in the iso2022 interfaces.
* src/vte.c: adapt to changes in the iso2022 interfaces.
* src/mkunitables.sh: add snippets for KSX 1001.
* src/iso2022.txt: add iso-2022-cn example text.
parent cfe30db7
2003-04-17 nalin
* src/vteglyph.c(_vte_glyph_get): quiet a compiler warning.
* src/iso2022.c: use KSX-1001 instead of KSC-5601 for Korean, add maps
for CNS 11643 planes 3,4,5,6,7 (can't test them, but hey). Rework
so that we get the data before it's passed to g_iconv(), and return
gunichars.
* src/interpret.c: adapt to changes in the iso2022 interfaces.
* src/vte.c: adapt to changes in the iso2022 interfaces.
* src/mkunitables.sh: add snippets for KSX 1001.
* src/iso2022.txt: add iso-2022-cn example text.
2003-04-17 nalin
* src/vte.c(vte_terminal_process_incoming): invalidate a larger
rectangle to fix behavior wrt openi18n assertion 2.
......
......@@ -17,7 +17,8 @@ EXTRA_DIST = \
unitable.JIS0201 \
unitable.JIS0208 \
unitable.JIS0212 \
unitable.KSC5601
unitable.KSC5601 \
unitable.KSX1001
AM_CFLAGS = @CFLAGS@ @VTE_CFLAGS@ @X_CFLAGS@
AM_LDFLAGS = @LDFLAGS@
......@@ -131,6 +132,8 @@ interpret_LDADD = @LDFLAGS@ @GOBJECT_LIBS@
iso2022_CFLAGS = @CFLAGS@ @GTK_CFLAGS@ -DISO2022_MAIN
iso2022_SOURCES = \
buffer.c \
buffer.h \
debug.c \
debug.h \
iso2022.c \
......
......@@ -41,19 +41,16 @@ main(int argc, char **argv)
char *terminal = NULL;
struct _vte_matcher *matcher = NULL;
struct _vte_termcap *termcap = NULL;
GByteArray *array = NULL;
int i, j;
struct _vte_buffer *buffer = NULL;
GArray *array;
int i, j, l;
char c;
GValue *value;
FILE *infile = NULL;
struct _vte_iso2022 *substitutions, *tmpsubst;
struct _vte_iso2022_state *subst;
const char *tmp;
GQuark quark;
GValueArray *values;
GError *error = NULL;
gunichar *ubuf;
gssize substlen;
gsize ubuflen;
_vte_debug_parse_string(getenv("VTE_DEBUG_FLAGS"));
......@@ -81,7 +78,8 @@ main(int argc, char **argv)
if (termcap == NULL) {
termcap = _vte_termcap_new("/etc/termcap");
}
array = g_byte_array_new();
buffer = _vte_buffer_new();
array = g_array_new(TRUE, TRUE, sizeof(gunichar));
for (i = 0;
_vte_terminal_capability_strings[i].capability != NULL;
......@@ -107,130 +105,85 @@ main(int argc, char **argv)
g_quark_from_static_string(code));
}
substitutions = _vte_iso2022_new();
subst = _vte_iso2022_state_new(NULL, NULL, NULL);
while (fread(&c, 1, 1, infile) == 1) {
g_byte_array_append(array, (guint8*) &c, 1);
for (i = 1; i <= array->len; i++) {
ubuf = (gunichar*) g_convert((const gchar*)array->data,
i,
_vte_matcher_wide_encoding(),
"UTF-8",
NULL, &ubuflen, &error);
if (error != NULL) {
if (error->code ==
G_CONVERT_ERROR_ILLEGAL_SEQUENCE) {
g_print("Munging input byte %02x->?.\n",
array->data[0]);
array->data[0] = '?';
} else
if (error->code !=
G_CONVERT_ERROR_PARTIAL_INPUT) {
g_print("%s\n",
error->message ?
error->message :
"?");
g_print("Data: ");
for (j = 0; j < array->len; j++) {
if (j > 0) {
g_print(", ");
}
g_print("0x%x", array->data[j]);
}
g_print("\n");
}
g_clear_error(&error);
continue;
_vte_buffer_append(buffer, &c, 1);
}
_vte_iso2022_process(subst, buffer, array);
i = 0;
while (i <= array->len) {
tmp = NULL;
values = NULL;
for (j = 1; j < (array->len - i); j++) {
_vte_matcher_match(matcher,
&g_array_index(array, gunichar, i),
j,
&tmp,
NULL,
&quark,
&values);
if ((tmp == NULL) || (strlen(tmp) > 0)) {
break;
}
tmpsubst = _vte_iso2022_copy(substitutions);
substlen = _vte_iso2022_substitute(tmpsubst,
ubuf,
ubuflen / sizeof(gunichar),
ubuf,
matcher);
if (substlen < 0) {
/* Incomplete state-change. */
_vte_iso2022_free(tmpsubst);
g_free(ubuf);
continue;
}
if (i + j == array->len) {
g_print("End of data.\n");
break;
}
if (tmp == NULL) {
gunichar c;
c = g_array_index(array, gunichar, i);
if (VTE_ISO2022_HAS_ENCODED_WIDTH(c)) {
c &= ~VTE_ISO2022_ENCODED_WIDTH_MASK;
}
if (substlen == 0) {
/* State change. (We gave it more than one
* character, so that one's and all of the
* others have been consumed.) */
_vte_iso2022_free(substitutions);
substitutions = tmpsubst;
while (array->len > 0) {
g_byte_array_remove_index(array, 0);
}
g_free(ubuf);
break;
if (c < 32) {
printf("`^%c'\n", c + 64);
} else
if (c < 127) {
printf("`%c'\n", c);
} else {
printf("`0x%x'\n", c);
}
i++;
continue;
}
_vte_matcher_match(matcher, ubuf, substlen,
&tmp, NULL, &quark, &values);
if (tmp != NULL) {
if (strlen(tmp) > 0) {
printf("%s(", g_quark_to_string(quark));
for (j = 0; (values != NULL) && (j < values->n_values); j++) {
if (j > 0) {
printf(", ");
}
value = g_value_array_get_nth(values, j);
if (G_VALUE_HOLDS_LONG(value)) {
printf("%ld",
g_value_get_long(value));
}
if (G_VALUE_HOLDS_STRING(value)) {
printf("`%s'",
g_value_get_string(value));
}
if (G_VALUE_HOLDS_POINTER(value)) {
printf("`%ls'",
(wchar_t*) g_value_get_pointer(value));
}
}
if (values != NULL) {
g_value_array_free(values);
}
for (j = 0; j < i; j++) {
g_byte_array_remove_index(array, 0);
}
printf(")\n");
g_free(ubuf);
break;
} else {
g_free(ubuf);
continue;
}
} else {
while (array->len > 0) {
g_byte_array_remove_index(array, 0);
}
for (j = 0; j < substlen; j++) {
if (VTE_ISO2022_HAS_ENCODED_WIDTH(ubuf[j])) {
ubuf[j] &= ~VTE_ISO2022_ENCODED_WIDTH_MASK;
}
if (ubuf[j] < 32) {
printf("`^%c'\n", ubuf[j] + 64);
} else
if (ubuf[j] < 127) {
printf("`%c'\n", ubuf[j]);
} else {
printf("`0x%x'\n", ubuf[j]);
}
}
l = j;
printf("%s(", g_quark_to_string(quark));
for (j = 0; (values != NULL) && (j < values->n_values); j++) {
if (j > 0) {
printf(", ");
}
value = g_value_array_get_nth(values, j);
if (G_VALUE_HOLDS_LONG(value)) {
printf("%ld", g_value_get_long(value));
}
g_free(ubuf);
if (G_VALUE_HOLDS_STRING(value)) {
printf("`%s'",
g_value_get_string(value));
}
if (G_VALUE_HOLDS_POINTER(value)) {
printf("`%ls'",
(wchar_t*)
g_value_get_pointer(value));
}
}
if (values != NULL) {
g_value_array_free(values);
}
printf(")\n");
i += l;
}
if (infile != stdin) {
fclose(infile);
}
_vte_iso2022_free(substitutions);
g_byte_array_free(array, TRUE);
_vte_iso2022_state_free(subst);
_vte_buffer_free(buffer);
g_array_free(array, TRUE);
_vte_termcap_free(termcap);
_vte_matcher_free(matcher);
return 0;
......
This diff is collapsed.
......@@ -25,24 +25,31 @@
#include <glib.h>
#include <glib-object.h>
#include "buffer.h"
#include "matcher.h"
G_BEGIN_DECLS
struct _vte_iso2022 *_vte_iso2022_new(void);
struct _vte_iso2022 *_vte_iso2022_copy(struct _vte_iso2022 *original);
void _vte_iso2022_free(struct _vte_iso2022 *p);
gunichar _vte_iso2022_substitute_single(gunichar mapname, gunichar c);
gssize _vte_iso2022_substitute(struct _vte_iso2022 *state,
gunichar *instring, gssize length,
gunichar *outstring,
struct _vte_matcher *specials);
struct _vte_iso2022_state;
typedef void (*_vte_iso2022_codeset_changed_cb_fn)(struct _vte_iso2022_state *,
gpointer);
struct _vte_iso2022_state *_vte_iso2022_state_new(const char *native_codeset,
_vte_iso2022_codeset_changed_cb_fn,
gpointer);
void _vte_iso2022_state_set_codeset(struct _vte_iso2022_state *state,
const char *codeset);
const char *_vte_iso2022_state_get_codeset(struct _vte_iso2022_state *state);
void _vte_iso2022_process(struct _vte_iso2022_state *state,
struct _vte_buffer *input, GArray *gunichars);
gunichar _vte_iso2022_process_single(struct _vte_iso2022_state *state,
gunichar c, gunichar map);
void _vte_iso2022_state_free(struct _vte_iso2022_state *);
#define VTE_ISO2022_ENCODED_WIDTH_BIT_OFFSET 28
#define VTE_ISO2022_ENCODED_WIDTH_MASK (3 << VTE_ISO2022_ENCODED_WIDTH_BIT_OFFSET)
#define VTE_ISO2022_HAS_ENCODED_WIDTH(__c) (((__c) & VTE_ISO2022_ENCODED_WIDTH_MASK) != 0)
gssize _vte_iso2022_get_encoded_width(gunichar c);
gboolean _vte_iso2022_is_ambiguous(gunichar c);
gssize _vte_iso2022_unichar_width(gunichar c);
G_END_DECLS
......
......@@ -29,3 +29,5 @@ Swiss: [(=#$@[\]^_{|}~(B] [ù$àéçêîèäöüû]
ISO-2022-JP: [(J~\(B~\] [¥‾~\]
ISO-2022-KR: [$)C>o^-] [억嚬]
ISO-2022-CN(1): [$)G&*&4] [⑩⑽]
ISO-2022-CN(2): [$*HN$&N5~] [怀梩]
......@@ -17,7 +17,7 @@ generate() {
maphome=http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/
encodings="CNS11643 GB12345 GB2312 JIS0201 JIS0208 JIS0212 KSC5601"
encodings="CNS11643 GB12345 GB2312 JIS0201 JIS0208 JIS0212 KSC5601 KSX1001"
if test "$#" != 0 ; then
encodings="$*"
fi
......@@ -29,7 +29,7 @@ for encoding in $encodings ; do
CNS*) wget -qc $maphome/OTHER/$encoding.TXT ;;
GB*) wget -qc $maphome/GB/$encoding.TXT ;;
JIS*) wget -qc $maphome/JIS/$encoding.TXT ;;
KSC*) wget -qc $maphome/KSC/$encoding.TXT ;;
KS*) wget -qc $maphome/KSC/$encoding.TXT ;;
esac
fi
echo -n $encoding
......
This diff is collapsed.
......@@ -563,6 +563,7 @@ _vte_glyph_get(struct _vte_glyph_cache *cache, gunichar c)
default:
g_error("Unknown pixel mode %d.\n",
face->glyph->bitmap.pixel_mode);
r = g = b = 0;
g_assert_not_reached();
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment