aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-06-17 03:08:26 +0000
committerUlrich Drepper <drepper@redhat.com>2000-06-17 03:08:26 +0000
commit1d96d74da7f6adccd82e4000efe38900b295467a (patch)
treee17bb7feb5740943051034b27028df9e72ed0132
parent323fb88dac799cddfaa33cb80f7fc3395c2297e5 (diff)
downloadglibc-1d96d74da7f6adccd82e4000efe38900b295467a.zip
glibc-1d96d74da7f6adccd82e4000efe38900b295467a.tar.gz
glibc-1d96d74da7f6adccd82e4000efe38900b295467a.tar.bz2
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.
-rw-r--r--ChangeLog11
-rw-r--r--iconv/gconv_trans.c35
-rw-r--r--locale/C-ctype.c6
-rw-r--r--locale/categories.def52
-rw-r--r--locale/langinfo.h2
-rw-r--r--locale/programs/ld-ctype.c24
-rw-r--r--localedata/tst-trans.c7
7 files changed, 130 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index fd3bb20..165f1bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2000-06-16 Ulrich Drepper <drepper@redhat.com>
+ * 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_int.h (norm_add_slashes): Optionally add given suffix.
* iconv/gconv_open.c: Remove error handling specification from `from'
character set name.
diff --git a/iconv/gconv_trans.c b/iconv/gconv_trans.c
index 829ff5f..0bb5f00 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;
}
diff --git a/locale/C-ctype.c b/locale/C-ctype.c
index 4ab3f01..04eb091 100644
--- a/locale/C-ctype.c
+++ b/locale/C-ctype.c
@@ -345,7 +345,7 @@ const struct locale_data _nl_C_LC_CTYPE =
UNDELETABLE,
0,
NULL,
- 62,
+ 64,
{
{ string: _nl_C_LC_CTYPE_class },
{ string: (const char *) _nl_C_LC_CTYPE_toupper },
@@ -422,6 +422,8 @@ const struct locale_data _nl_C_LC_CTYPE =
{ string: "" },
{ string: "" },
{ string: "" },
- { string: "" }
+ { string: "" },
+ { wstr: (uint32_t *) L"?" },
+ { word: 1 }
}
};
diff --git a/locale/categories.def b/locale/categories.def
index 19e0687..e1f3f05 100644
--- a/locale/categories.def
+++ b/locale/categories.def
@@ -82,6 +82,58 @@ DEFINE_CATEGORY
DEFINE_ELEMENT (_NL_CTYPE_WIDTH, "ctype-width", std, bytearray)
DEFINE_ELEMENT (_NL_CTYPE_MB_CUR_MAX, "ctype-mb-cur-max", std, word)
DEFINE_ELEMENT (_NL_CTYPE_CODESET_NAME, "charmap", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_TOUPPER32, "ctype-toupper32", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_TOLOWER32, "ctype-tolower32", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS_MB_LEN, "ctype-indigits_mb-len", std, word)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS0_MB, "ctype-indigits0_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS1_MB, "ctype-indigits1_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS2_MB, "ctype-indigits2_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS3_MB, "ctype-indigits3_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS4_MB, "ctype-indigits4_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS5_MB, "ctype-indigits5_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS6_MB, "ctype-indigits6_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS7_MB, "ctype-indigits7_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS8_MB, "ctype-indigits8_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS9_MB, "ctype-indigits9_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS_WC_LEN, "ctype-indigits_wc-len", std, word)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS0_WC, "ctype-indigits0_wc", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS1_WC, "ctype-indigits1_wc", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS2_WC, "ctype-indigits2_wc", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS3_WC, "ctype-indigits3_wc", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS4_WC, "ctype-indigits4_wc", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS5_WC, "ctype-indigits5_wc", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS6_WC, "ctype-indigits6_wc", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS7_WC, "ctype-indigits7_wc", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS8_WC, "ctype-indigits8_wc", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_INDIGITS9_WC, "ctype-indigits9_wc", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT0_MB, "ctype-outdigit0_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT1_MB, "ctype-outdigit1_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT2_MB, "ctype-outdigit2_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT3_MB, "ctype-outdigit3_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT4_MB, "ctype-outdigit4_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT5_MB, "ctype-outdigit5_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT6_MB, "ctype-outdigit6_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT7_MB, "ctype-outdigit7_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT8_MB, "ctype-outdigit8_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT9_MB, "ctype-outdigit9_mb", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT0_WC, "ctype-outdigit0_wc", std, word)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT1_WC, "ctype-outdigit1_wc", std, word)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT2_WC, "ctype-outdigit2_wc", std, word)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT3_WC, "ctype-outdigit3_wc", std, word)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT4_WC, "ctype-outdigit4_wc", std, word)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT5_WC, "ctype-outdigit5_wc", std, word)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT6_WC, "ctype-outdigit6_wc", std, word)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT7_WC, "ctype-outdigit7_wc", std, word)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT8_WC, "ctype-outdigit8_wc", std, word)
+ DEFINE_ELEMENT (_NL_CTYPE_OUTDIGIT9_WC, "ctype-outdigit9_wc", std, word)
+ DEFINE_ELEMENT (_NL_CTYPE_TRANSLIT_HASH_SIZE, "ctype-translit-hash-size", std, word)
+ DEFINE_ELEMENT (_NL_CTYPE_TRANSLIT_HASH_LAYERS, "ctype-translit-hash-layers", std, word)
+ DEFINE_ELEMENT (_NL_CTYPE_TRANSLIT_FROM_IDX, "ctype-translit-from-idx", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_TRANSLIT_FROM_TBL, "ctype-translit-from-tbl", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_TRANSLIT_TO_IDX, "ctype-translit-to-idx", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_TRANSLIT_TO_TBL, "ctype-translit-to-tbl", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_TRANSLIT_DEFAULT_MISSING, "ctype-translit-default-missing", std, string)
+ DEFINE_ELEMENT (_NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN, "ctype-translit-default-missing-len", std, word)
), _nl_postload_ctype)
diff --git a/locale/langinfo.h b/locale/langinfo.h
index b5ccac6..11ab68e 100644
--- a/locale/langinfo.h
+++ b/locale/langinfo.h
@@ -319,6 +319,8 @@ enum
_NL_CTYPE_TRANSLIT_FROM_TBL,
_NL_CTYPE_TRANSLIT_TO_IDX,
_NL_CTYPE_TRANSLIT_TO_TBL,
+ _NL_CTYPE_TRANSLIT_DEFAULT_MISSING,
+ _NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN,
_NL_NUM_LC_CTYPE,
/* LC_MONETARY category: formatting of monetary quantities.
diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c
index 8839a9e..e899649 100644
--- a/locale/programs/ld-ctype.c
+++ b/locale/programs/ld-ctype.c
@@ -788,6 +788,7 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap,
+ ctype->map_collection_nr];
struct locale_file data;
uint32_t idx[nelems + 1];
+ uint32_t default_missing_len;
size_t elem, cnt, offset, total;
char *cp;
@@ -814,8 +815,7 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap,
case _NL_ITEM_INDEX (name): \
iov[2 + elem + offset].iov_base = (base); \
iov[2 + elem + offset].iov_len = (len); \
- if (elem + 1 < nelems) \
- idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len; \
+ idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len; \
break
CTYPE_DATA (_NL_CTYPE_CLASS,
@@ -1007,6 +1007,26 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap,
idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
break;
+ case _NL_ITEM_INDEX(_NL_CTYPE_TRANSLIT_DEFAULT_MISSING):
+ iov[2 + elem + offset].iov_base =
+ ctype->default_missing ?: (uint32_t *) L"";
+ iov[2 + elem + offset].iov_len =
+ wcslen (iov[2 + elem + offset].iov_base);
+ idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
+ break;
+
+ case _NL_ITEM_INDEX(_NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN):
+ default_missing_len = (ctype->default_missing
+ ? wcslen ((wchar_t *)ctype->default_missing)
+ : 1);
+ iov[2 + elem + offset].iov_base = &default_missing_len;
+ iov[2 + elem + offset].iov_len = sizeof (uint32_t);
+ /* Remove the following line in case a new entry is added
+ after _NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN. */
+ if (elem < nelems)
+ idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
+ break;
+
default:
assert (! "unknown CTYPE element");
}
diff --git a/localedata/tst-trans.c b/localedata/tst-trans.c
index 03a64de..8bc64ce 100644
--- a/localedata/tst-trans.c
+++ b/localedata/tst-trans.c
@@ -1,5 +1,5 @@
/* Test program for user-defined character maps.
- Copyright (C) 1999 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>.
@@ -33,7 +33,10 @@ main (void)
t = wctrans ("test");
if (t == (wctrans_t) 0)
- exit (1);
+ {
+ puts ("locale data files probably not loaded");
+ exit (1);
+ }
wch = towctrans (L'A', t);
printf ("towctrans (L'A', t) = %c\n", wch);