- Copyright (C) 2002, 2005, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005, 2007, 2009-2013 Free Software Foundation, Inc.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
- {
- size_t len = strlen (try_in_order[i]) + 1;
- memcpy (memory, try_in_order[i], len);
- new_try_in_order[i] = (const char *) memory;
- memory += len;
- }
+ {
+ size_t len = strlen (try_in_order[i]) + 1;
+ memcpy (memory, try_in_order[i], len);
+ new_try_in_order[i] = (const char *) memory;
+ memory += len;
+ }
/* Like mem_iconveha, except no handling of transliteration. */
static int
mem_iconveha_notranslit (const char *src, size_t srclen,
/* Like mem_iconveha, except no handling of transliteration. */
static int
mem_iconveha_notranslit (const char *src, size_t srclen,
- const char *from_codeset, const char *to_codeset,
- enum iconv_ilseq_handler handler,
- size_t *offsets,
- char **resultp, size_t *lengthp)
+ const char *from_codeset, const char *to_codeset,
+ enum iconv_ilseq_handler handler,
+ size_t *offsets,
+ char **resultp, size_t *lengthp)
{
int retval = mem_iconveh (src, srclen, from_codeset, to_codeset, handler,
{
int retval = mem_iconveh (src, srclen, from_codeset, to_codeset, handler,
- if (strcmp (from_codeset, alias->name) == 0)
- {
- const char * const *encodings;
-
- if (handler != iconveh_error)
- {
- /* First try all encodings without any forgiving. */
- encodings = alias->encodings_to_try;
- do
- {
- retval = mem_iconveha_notranslit (src, srclen,
- *encodings, to_codeset,
- iconveh_error, offsets,
- resultp, lengthp);
- if (!(retval < 0 && errno == EILSEQ))
- return retval;
- encodings++;
- }
- while (*encodings != NULL);
- }
-
- encodings = alias->encodings_to_try;
- do
- {
- retval = mem_iconveha_notranslit (src, srclen,
- *encodings, to_codeset,
- handler, offsets,
- resultp, lengthp);
- if (!(retval < 0 && errno == EILSEQ))
- return retval;
- encodings++;
- }
- while (*encodings != NULL);
-
- /* Return the last call's result. */
- return -1;
- }
+ if (strcmp (from_codeset, alias->name) == 0)
+ {
+ const char * const *encodings;
+
+ if (handler != iconveh_error)
+ {
+ /* First try all encodings without any forgiving. */
+ encodings = alias->encodings_to_try;
+ do
+ {
+ retval = mem_iconveha_notranslit (src, srclen,
+ *encodings, to_codeset,
+ iconveh_error, offsets,
+ resultp, lengthp);
+ if (!(retval < 0 && errno == EILSEQ))
+ return retval;
+ encodings++;
+ }
+ while (*encodings != NULL);
+ }
+
+ encodings = alias->encodings_to_try;
+ do
+ {
+ retval = mem_iconveha_notranslit (src, srclen,
+ *encodings, to_codeset,
+ handler, offsets,
+ resultp, lengthp);
+ if (!(retval < 0 && errno == EILSEQ))
+ return retval;
+ encodings++;
+ }
+ while (*encodings != NULL);
+
+ /* Return the last call's result. */
+ return -1;
+ }
- const char *from_codeset, const char *to_codeset,
- bool transliterate,
- enum iconv_ilseq_handler handler,
- size_t *offsets,
- char **resultp, size_t *lengthp)
+ const char *from_codeset, const char *to_codeset,
+ bool transliterate,
+ enum iconv_ilseq_handler handler,
+ size_t *offsets,
+ char **resultp, size_t *lengthp)
/* When using GNU libc >= 2.2 or GNU libiconv >= 1.5,
we want to use transliteration. */
/* When using GNU libc >= 2.2 or GNU libiconv >= 1.5,
we want to use transliteration. */
memcpy (to_codeset_suffixed + len, "//TRANSLIT", 10 + 1);
retval = mem_iconveha_notranslit (src, srclen,
memcpy (to_codeset_suffixed + len, "//TRANSLIT", 10 + 1);
retval = mem_iconveha_notranslit (src, srclen,
- from_codeset, to_codeset_suffixed,
- handler, offsets, resultp, lengthp);
+ from_codeset, to_codeset_suffixed,
+ handler, offsets, resultp, lengthp);
- from_codeset, to_codeset,
- handler, offsets, resultp, lengthp);
+ from_codeset, to_codeset,
+ handler, offsets, resultp, lengthp);
}
/* Like str_iconveha, except no handling of transliteration. */
static char *
str_iconveha_notranslit (const char *src,
}
/* Like str_iconveha, except no handling of transliteration. */
static char *
str_iconveha_notranslit (const char *src,
- const char *from_codeset, const char *to_codeset,
- enum iconv_ilseq_handler handler)
+ const char *from_codeset, const char *to_codeset,
+ enum iconv_ilseq_handler handler)
- if (strcmp (from_codeset, alias->name) == 0)
- {
- const char * const *encodings;
-
- if (handler != iconveh_error)
- {
- /* First try all encodings without any forgiving. */
- encodings = alias->encodings_to_try;
- do
- {
- result = str_iconveha_notranslit (src,
- *encodings, to_codeset,
- iconveh_error);
- if (!(result == NULL && errno == EILSEQ))
- return result;
- encodings++;
- }
- while (*encodings != NULL);
- }
-
- encodings = alias->encodings_to_try;
- do
- {
- result = str_iconveha_notranslit (src,
- *encodings, to_codeset,
- handler);
- if (!(result == NULL && errno == EILSEQ))
- return result;
- encodings++;
- }
- while (*encodings != NULL);
-
- /* Return the last call's result. */
- return NULL;
- }
+ if (strcmp (from_codeset, alias->name) == 0)
+ {
+ const char * const *encodings;
+
+ if (handler != iconveh_error)
+ {
+ /* First try all encodings without any forgiving. */
+ encodings = alias->encodings_to_try;
+ do
+ {
+ result = str_iconveha_notranslit (src,
+ *encodings, to_codeset,
+ iconveh_error);
+ if (!(result == NULL && errno == EILSEQ))
+ return result;
+ encodings++;
+ }
+ while (*encodings != NULL);
+ }
+
+ encodings = alias->encodings_to_try;
+ do
+ {
+ result = str_iconveha_notranslit (src,
+ *encodings, to_codeset,
+ handler);
+ if (!(result == NULL && errno == EILSEQ))
+ return result;
+ encodings++;
+ }
+ while (*encodings != NULL);
+
+ /* Return the last call's result. */
+ return NULL;
+ }
- const char *from_codeset, const char *to_codeset,
- bool transliterate,
- enum iconv_ilseq_handler handler)
+ const char *from_codeset, const char *to_codeset,
+ bool transliterate,
+ enum iconv_ilseq_handler handler)
{
if (*src == '\0' || c_strcasecmp (from_codeset, to_codeset) == 0)
{
char *result = strdup (src);
if (result == NULL)
{
if (*src == '\0' || c_strcasecmp (from_codeset, to_codeset) == 0)
{
char *result = strdup (src);
if (result == NULL)
return result;
}
/* When using GNU libc >= 2.2 or GNU libiconv >= 1.5,
we want to use transliteration. */
return result;
}
/* When using GNU libc >= 2.2 or GNU libiconv >= 1.5,
we want to use transliteration. */
memcpy (to_codeset_suffixed + len, "//TRANSLIT", 10 + 1);
result = str_iconveha_notranslit (src, from_codeset, to_codeset_suffixed,
memcpy (to_codeset_suffixed + len, "//TRANSLIT", 10 + 1);
result = str_iconveha_notranslit (src, from_codeset, to_codeset_suffixed,