From 1d96d74da7f6adccd82e4000efe38900b295467a Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 17 Jun 2000 03:08:26 +0000 Subject: Update. * locale/langinfo.h: Add entries for default_missing information. * locale/C-ctype.c: Add initializers for new fields. * iconv/gconv_trans.c: If nothing matched, try to use default_missing information. * locale/categories.h: Add entries for all LC_CTYPE values. * locale/programs/ld-ctype.c (ctype_output): Write out default_missing information. * localedata/tst-trans.c: Write out an error message if class is not found. --- iconv/gconv_trans.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'iconv') diff --git a/iconv/gconv_trans.c b/iconv/gconv_trans.c index 829ff5f981..0bb5f00c07 100644 --- a/iconv/gconv_trans.c +++ b/iconv/gconv_trans.c @@ -44,12 +44,13 @@ __gconv_transliterate (struct __gconv_step *step, uint32_t *winbufend; uint_fast32_t low; uint_fast32_t high; + uint32_t *default_missing; /* If there is no transliteration information in the locale don't do anything and return the error. */ size = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_TRANSLIT_HASH_SIZE); if (size == 0) - return __GCONV_ILLEGAL_INPUT; + goto no_rules; /* Get the rest of the values. */ layers = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_TRANSLIT_HASH_LAYERS); @@ -141,6 +142,38 @@ __gconv_transliterate (struct __gconv_step *step, high = idx; } + /* One last chance: use the default replacement. */ + no_rules: + default_missing = (uint32_t *) + _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TRANSLIT_DEFAULT_MISSING); + if (default_missing[0] != L'\0') + { + const unsigned char *toinptr = (const unsigned char *) default_missing; + uint32_t len = _NL_CURRENT_WORD (LC_CTYPE, + _NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN); + int res; + + res = DL_CALL_FCT (step->__fct, + (step, step_data, &toinptr, + (const unsigned char *) (default_missing + len), + (unsigned char **) outbufstart, + irreversible, 0, 0)); + + if (res != __GCONV_ILLEGAL_INPUT) + { + /* If the conversion succeeds we have to increment the + input buffer. */ + if (res == __GCONV_EMPTY_INPUT) + { + /* We consuming one character. */ + ++*inbufp; + ++*irreversible; + } + + return res; + } + } + /* Haven't found a match. */ return __GCONV_ILLEGAL_INPUT; } -- cgit v1.2.3