summaryrefslogtreecommitdiff
path: root/gnulib-local
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2021-01-20 22:34:44 +0100
committerAndy Wingo <wingo@pobox.com>2021-01-20 23:03:56 +0100
commit86e7a8b12b4527030962df9fda0162d18ed6877e (patch)
treeebc3a0e500fd83f7c9d34754432ad8a9ebe26f42 /gnulib-local
parenta91b95cca2d397c84f8b9bbd602d40209a7092ce (diff)
downloadguile-86e7a8b12b4527030962df9fda0162d18ed6877e.tar.gz
Update environ_locale_charset gnulib patch
* gnulib-local/lib/localcharset.c.diff: Update to apply to current gnulib. Lots of code duplication now, but oh well. * lib/localcharset.c (environ_locale_charset): Update. * lib/iconv_open-solaris.h: * lib/iconv_open-osf.h: * lib/iconv_open-irix.h: * lib/iconv_open-hpux.h: * lib/iconv_open-aix.h: Regenerate with gperf 3.1.
Diffstat (limited to 'gnulib-local')
-rw-r--r--gnulib-local/lib/localcharset.c.diff63
1 files changed, 55 insertions, 8 deletions
diff --git a/gnulib-local/lib/localcharset.c.diff b/gnulib-local/lib/localcharset.c.diff
index b1c249c19..04865a345 100644
--- a/gnulib-local/lib/localcharset.c.diff
+++ b/gnulib-local/lib/localcharset.c.diff
@@ -5,7 +5,7 @@ rationale.
--- a/lib/localcharset.c
+++ b/lib/localcharset.c
-@@ -544,3 +544,73 @@ locale_charset (void)
+@@ -544,3 +544,120 @@ locale_charset (void)
return codeset;
}
@@ -60,15 +60,62 @@ rationale.
+ codeset = "";
+
+ /* Resolve alias. */
-+ for (aliases = get_charset_aliases ();
-+ *aliases != '\0';
-+ aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
-+ if (strcmp (codeset, aliases) == 0
-+ || (aliases[0] == '*' && aliases[1] == '\0'))
++ {
++# ifdef alias_table_defined
++ /* On some platforms, UTF-8 locales are the most frequently used ones.
++ Speed up the common case and slow down the less common cases by
++ testing for this case first. */
++# if defined __OpenBSD__ || (defined __APPLE__ && defined __MACH__) || defined __sun || defined __CYGWIN__
++ if (strcmp (codeset, "UTF-8") == 0)
++ goto done_table_lookup;
++ else
++# endif
+ {
-+ codeset = aliases + strlen (aliases) + 1;
-+ break;
++ const struct table_entry * const table = alias_table;
++ size_t const table_size =
++ sizeof (alias_table) / sizeof (struct table_entry);
++ /* The table is sorted. Perform a binary search. */
++ size_t hi = table_size;
++ size_t lo = 0;
++ while (lo < hi)
++ {
++ /* Invariant:
++ for i < lo, strcmp (table[i].alias, codeset) < 0,
++ for i >= hi, strcmp (table[i].alias, codeset) > 0. */
++ size_t mid = (hi + lo) >> 1; /* >= lo, < hi */
++ int cmp = strcmp (table[mid].alias, codeset);
++ if (cmp < 0)
++ lo = mid + 1;
++ else if (cmp > 0)
++ hi = mid;
++ else
++ {
++ /* Found an i with
++ strcmp (table[i].alias, codeset) == 0. */
++ codeset = table[mid].canonical;
++ goto done_table_lookup;
++ }
++ }
+ }
++ if (0)
++ done_table_lookup: ;
++ else
++# endif
++ {
++ /* Did not find it in the table. */
++ /* On Mac OS X, all modern locales use the UTF-8 encoding.
++ BeOS and Haiku have a single locale, and it has UTF-8 encoding. */
++# if (defined __APPLE__ && defined __MACH__) || defined __BEOS__ || defined __HAIKU__
++ codeset = "UTF-8";
++# else
++ /* Don't return an empty string. GNU libc and GNU libiconv interpret
++ the empty string as denoting "the locale's character encoding",
++ thus GNU libiconv would call this function a second time. */
++ if (codeset[0] == '\0')
++ codeset = "ASCII";
++# endif
++ }
++ }
+
+ /* Don't return an empty string. GNU libc and GNU libiconv interpret
+ the empty string as denoting "the locale's character encoding",