diff options
author | Arjun Shankar <arjun@redhat.com> | 2020-09-25 14:47:06 +0200 |
---|---|---|
committer | Arjun Shankar <arjun@redhat.com> | 2020-09-25 14:47:06 +0200 |
commit | 7d4ec75e111291851620c6aa2c4460647b7fd50d (patch) | |
tree | 1692804299aa1634e52cd2cf021ab4dbce2b01c6 /iconv/gconv_int.h | |
parent | 06e95b93f0bb5943363ad3dcf0cd0fb9d8613b61 (diff) | |
download | glibc-7d4ec75e111291851620c6aa2c4460647b7fd50d.tar.gz glibc-7d4ec75e111291851620c6aa2c4460647b7fd50d.tar.xz glibc-7d4ec75e111291851620c6aa2c4460647b7fd50d.zip |
intl: Handle translation output codesets with suffixes [BZ #26383]
Commit 91927b7c7643 (Rewrite iconv option parsing [BZ #19519]) did not handle cases where the output codeset for translations (via the `gettext' family of functions) might have a caller specified encoding suffix such as TRANSLIT or IGNORE. This led to a regression where translations did not work when the codeset had a suffix. This commit fixes the above issue by parsing any suffixes passed to __dcigettext and adds two new test-cases to intl/tst-codeset.c to verify correct behaviour. The iconv-internal function __gconv_create_spec and the static iconv-internal function gconv_destroy_spec are now visible internally within glibc and used in intl/dcigettext.c.
Diffstat (limited to 'iconv/gconv_int.h')
-rw-r--r-- | iconv/gconv_int.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/iconv/gconv_int.h b/iconv/gconv_int.h index e86938dae7..f721ce30ff 100644 --- a/iconv/gconv_int.h +++ b/iconv/gconv_int.h @@ -152,6 +152,27 @@ extern int __gconv_open (struct gconv_spec *conv_spec, __gconv_t *handle, int flags); libc_hidden_proto (__gconv_open) +/* This function accepts the charset names of the source and destination of the + conversion and populates *conv_spec with an equivalent conversion + specification that may later be used by __gconv_open. The charset names + might contain options in the form of suffixes that alter the conversion, + e.g. "ISO-10646/UTF-8/TRANSLIT". It processes the charset names, ignoring + and truncating any suffix options in fromcode, and processing and truncating + any suffix options in tocode. Supported suffix options ("TRANSLIT" or + "IGNORE") when found in tocode lead to the corresponding flag in *conv_spec + to be set to true. Unrecognized suffix options are silently discarded. If + the function succeeds, it returns conv_spec back to the caller. It returns + NULL upon failure. */ +extern struct gconv_spec * +__gconv_create_spec (struct gconv_spec *conv_spec, const char *fromcode, + const char *tocode); +libc_hidden_proto (__gconv_create_spec) + +/* This function frees all heap memory allocated by __gconv_create_spec. */ +extern void +__gconv_destroy_spec (struct gconv_spec *conv_spec); +libc_hidden_proto (__gconv_destroy_spec) + /* Free resources associated with transformation descriptor CD. */ extern int __gconv_close (__gconv_t cd) attribute_hidden; |