diff options
Diffstat (limited to 'lib/uniconv')
| -rw-r--r-- | lib/uniconv/u-conv-from-enc.h | 20 | ||||
| -rw-r--r-- | lib/uniconv/u-conv-to-enc.h | 43 | ||||
| -rw-r--r-- | lib/uniconv/u-strconv-from-enc.h | 6 | ||||
| -rw-r--r-- | lib/uniconv/u-strconv-to-enc.h | 9 | ||||
| -rw-r--r-- | lib/uniconv/u16-conv-from-enc.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u16-conv-to-enc.c | 22 | ||||
| -rw-r--r-- | lib/uniconv/u16-strconv-from-enc.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u16-strconv-from-locale.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u16-strconv-to-enc.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u16-strconv-to-locale.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u32-conv-from-enc.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u32-conv-to-enc.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u32-strconv-from-enc.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u32-strconv-from-locale.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u32-strconv-to-enc.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u32-strconv-to-locale.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u8-conv-from-enc.c | 30 | ||||
| -rw-r--r-- | lib/uniconv/u8-conv-to-enc.c | 5 | ||||
| -rw-r--r-- | lib/uniconv/u8-strconv-from-enc.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u8-strconv-from-locale.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u8-strconv-to-enc.c | 13 | ||||
| -rw-r--r-- | lib/uniconv/u8-strconv-to-locale.c | 2 |
22 files changed, 70 insertions, 106 deletions
diff --git a/lib/uniconv/u-conv-from-enc.h b/lib/uniconv/u-conv-from-enc.h index 32251c5e..4371d2b1 100644 --- a/lib/uniconv/u-conv-from-enc.h +++ b/lib/uniconv/u-conv-from-enc.h @@ -1,5 +1,5 @@ /* Conversion to UTF-16/UTF-32 from legacy encodings. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". @@ -40,9 +40,8 @@ FUNC (const char *fromcode, { /* Convert 'char *' offsets to 'UNIT *' offsets. */ size_t *offsets_end = offsets + srclen; - size_t *o; - for (o = offsets; o < offsets_end; o++) + for (size_t *o = offsets; o < offsets_end; o++) if (*o != (size_t)(-1)) *o = *o / sizeof (UNIT); } @@ -51,16 +50,14 @@ FUNC (const char *fromcode, *lengthp = length / sizeof (UNIT); return (UNIT *) result; #else - uint8_t *utf8_string; size_t utf8_length; - UNIT *result; - - utf8_string = + uint8_t *utf8_string = u8_conv_from_encoding (fromcode, handler, src, srclen, offsets, NULL, &utf8_length); if (utf8_string == NULL) return NULL; - result = U8_TO_U (utf8_string, utf8_length, resultbuf, lengthp); + + UNIT *result = U8_TO_U (utf8_string, utf8_length, resultbuf, lengthp); if (result == NULL) { int saved_errno = errno; @@ -72,11 +69,10 @@ FUNC (const char *fromcode, { size_t length = *lengthp; size_t *offsets_end = offsets + srclen; - size_t *o; - size_t off8 = 0; /* offset into utf8_string */ - size_t offunit = 0; /* offset into result */ - for (o = offsets; o < offsets_end; o++) + size_t off8 = 0; /* offset into utf8_string */ + size_t offunit = 0; /* offset into result */ + for (size_t *o = offsets; o < offsets_end; o++) if (*o != (size_t)(-1)) { while (off8 < *o) diff --git a/lib/uniconv/u-conv-to-enc.h b/lib/uniconv/u-conv-to-enc.h index e1a85324..1ab900cc 100644 --- a/lib/uniconv/u-conv-to-enc.h +++ b/lib/uniconv/u-conv-to-enc.h @@ -1,5 +1,5 @@ /* Conversion from UTF-16/UTF-32 to legacy encodings. - Copyright (C) 2002, 2006-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". @@ -31,9 +31,6 @@ FUNC (const char *tocode, { #if HAVE_UTF_NAME size_t *scaled_offsets; - char *result; - size_t length; - if (offsets != NULL && srclen > 0) { scaled_offsets = @@ -47,8 +44,8 @@ FUNC (const char *tocode, else scaled_offsets = NULL; - result = resultbuf; - length = *lengthp; + char *result = resultbuf; + size_t length = *lengthp; if (mem_iconveha ((const char *) src, srclen * sizeof (UNIT), UTF_NAME, tocode, handler == iconveh_question_mark, handler, @@ -64,9 +61,7 @@ FUNC (const char *tocode, { /* Convert scaled_offsets[srclen * sizeof (UNIT)] to offsets[srclen]. */ - size_t i; - - for (i = 0; i < srclen; i++) + for (size_t i = 0; i < srclen; i++) offsets[i] = scaled_offsets[i * sizeof (UNIT)]; free (scaled_offsets); } @@ -85,16 +80,12 @@ FUNC (const char *tocode, #else uint8_t tmpbuf[4096]; size_t tmpbufsize = SIZEOF (tmpbuf); - uint8_t *utf8_src; - size_t utf8_srclen; - size_t *scaled_offsets; - char *result; - - utf8_src = U_TO_U8 (src, srclen, tmpbuf, &tmpbufsize); + uint8_t *utf8_src = U_TO_U8 (src, srclen, tmpbuf, &tmpbufsize); if (utf8_src == NULL) return NULL; - utf8_srclen = tmpbufsize; + size_t utf8_srclen = tmpbufsize; + size_t *scaled_offsets; if (offsets != NULL && utf8_srclen > 0) { scaled_offsets = (size_t *) malloc (utf8_srclen * sizeof (size_t)); @@ -109,8 +100,8 @@ FUNC (const char *tocode, else scaled_offsets = NULL; - result = u8_conv_to_encoding (tocode, handler, utf8_src, utf8_srclen, - scaled_offsets, resultbuf, lengthp); + char *result = u8_conv_to_encoding (tocode, handler, utf8_src, utf8_srclen, + scaled_offsets, resultbuf, lengthp); if (result == NULL) { int saved_errno = errno; @@ -122,23 +113,17 @@ FUNC (const char *tocode, } if (offsets != NULL) { - size_t iunit; /* offset into src */ - size_t i8; /* offset into utf8_src */ - - for (iunit = 0; iunit < srclen; iunit++) + for (size_t iunit = 0; iunit < srclen; iunit++) offsets[iunit] = (size_t)(-1); - iunit = 0; - i8 = 0; + size_t iunit = 0; /* offset into src */ + size_t i8 = 0; /* offset into utf8_src */ while (iunit < srclen && i8 < utf8_srclen) { - int countunit; - int count8; - offsets[iunit] = scaled_offsets[i8]; - countunit = U_MBLEN (src + iunit, srclen - iunit); - count8 = u8_mblen (utf8_src + i8, utf8_srclen - i8); + int countunit = U_MBLEN (src + iunit, srclen - iunit); + int count8 = u8_mblen (utf8_src + i8, utf8_srclen - i8); if (countunit < 0 || count8 < 0) abort (); iunit += countunit; diff --git a/lib/uniconv/u-strconv-from-enc.h b/lib/uniconv/u-strconv-from-enc.h index 2d1e4ce6..034be44c 100644 --- a/lib/uniconv/u-strconv-from-enc.h +++ b/lib/uniconv/u-strconv-from-enc.h @@ -1,5 +1,5 @@ /* Conversion to UTF-8/UTF-16/UTF-32 from legacy encodings. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -19,10 +19,8 @@ FUNC (const char *string, const char *fromcode, enum iconv_ilseq_handler handler) { - UNIT *result; size_t length; - - result = + UNIT *result = U_CONV_FROM_ENCODING (fromcode, handler, string, strlen (string) + 1, NULL, NULL, &length); diff --git a/lib/uniconv/u-strconv-to-enc.h b/lib/uniconv/u-strconv-to-enc.h index 91b8e1a9..175aac20 100644 --- a/lib/uniconv/u-strconv-to-enc.h +++ b/lib/uniconv/u-strconv-to-enc.h @@ -1,5 +1,5 @@ /* Conversion from UTF-16/UTF-32 to legacy encodings. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". @@ -47,13 +47,10 @@ FUNC (const UNIT *string, #else uint8_t tmpbuf[4096]; size_t tmpbufsize = SIZEOF (tmpbuf); - uint8_t *utf8_string; - char *result; - - utf8_string = U_TO_U8 (string, U_STRLEN (string) + 1, tmpbuf, &tmpbufsize); + uint8_t *utf8_string = U_TO_U8 (string, U_STRLEN (string) + 1, tmpbuf, &tmpbufsize); if (utf8_string == NULL) return NULL; - result = u8_strconv_to_encoding (utf8_string, tocode, handler); + char *result = u8_strconv_to_encoding (utf8_string, tocode, handler); if (result == NULL) { if (utf8_string != tmpbuf) diff --git a/lib/uniconv/u16-conv-from-enc.c b/lib/uniconv/u16-conv-from-enc.c index f2c3dfa1..7c5e1f15 100644 --- a/lib/uniconv/u16-conv-from-enc.c +++ b/lib/uniconv/u16-conv-from-enc.c @@ -1,5 +1,5 @@ /* Conversion to UTF-16 from legacy encodings. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". diff --git a/lib/uniconv/u16-conv-to-enc.c b/lib/uniconv/u16-conv-to-enc.c index f44e90f0..1214e671 100644 --- a/lib/uniconv/u16-conv-to-enc.c +++ b/lib/uniconv/u16-conv-to-enc.c @@ -1,5 +1,5 @@ /* Conversion from UTF-16 to legacy encodings. - Copyright (C) 2002, 2006-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". @@ -62,11 +62,10 @@ static DST_UNIT * FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp) { const SRC_UNIT *s_end = s + n; + /* Output string accumulator. */ DST_UNIT *result; size_t allocated; - size_t length; - if (resultbuf != NULL) { result = resultbuf; @@ -77,18 +76,16 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp) result = NULL; allocated = 0; } - length = 0; + size_t length = 0; /* Invariants: result is either == resultbuf or == NULL or malloc-allocated. If length > 0, then result != NULL. */ while (s < s_end) { - ucs4_t uc; - int count; - /* Fetch a Unicode character from the input string. */ - count = u16_mbtoucr (&uc, s, s_end - s); + ucs4_t uc; + int count = u16_mbtoucr (&uc, s, s_end - s); if (count < 0) { if (count == -2) @@ -112,11 +109,11 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp) } if (count == -2) { - DST_UNIT *memory; - allocated = (allocated > 0 ? 2 * allocated : 12); if (length + 6 > allocated) allocated = length + 6; + + DST_UNIT *memory; if (result == resultbuf || result == NULL) memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT)); else @@ -157,9 +154,8 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp) else if (result != resultbuf && length < allocated) { /* Shrink the allocated memory if possible. */ - DST_UNIT *memory; - - memory = (DST_UNIT *) realloc (result, length * sizeof (DST_UNIT)); + DST_UNIT *memory = + (DST_UNIT *) realloc (result, length * sizeof (DST_UNIT)); if (memory != NULL) result = memory; } diff --git a/lib/uniconv/u16-strconv-from-enc.c b/lib/uniconv/u16-strconv-from-enc.c index 19ead042..efb3a9c3 100644 --- a/lib/uniconv/u16-strconv-from-enc.c +++ b/lib/uniconv/u16-strconv-from-enc.c @@ -1,5 +1,5 @@ /* Conversion to UTF-16 from legacy encodings. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". diff --git a/lib/uniconv/u16-strconv-from-locale.c b/lib/uniconv/u16-strconv-from-locale.c index bc9e5175..6f670255 100644 --- a/lib/uniconv/u16-strconv-from-locale.c +++ b/lib/uniconv/u16-strconv-from-locale.c @@ -1,5 +1,5 @@ /* Conversion to UTF-16 from the locale encoding. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". diff --git a/lib/uniconv/u16-strconv-to-enc.c b/lib/uniconv/u16-strconv-to-enc.c index 85ca8a6d..83d5f090 100644 --- a/lib/uniconv/u16-strconv-to-enc.c +++ b/lib/uniconv/u16-strconv-to-enc.c @@ -1,5 +1,5 @@ /* Conversion from UTF-16 to legacy encodings. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". diff --git a/lib/uniconv/u16-strconv-to-locale.c b/lib/uniconv/u16-strconv-to-locale.c index 697023a8..cdf8cc9b 100644 --- a/lib/uniconv/u16-strconv-to-locale.c +++ b/lib/uniconv/u16-strconv-to-locale.c @@ -1,5 +1,5 @@ /* Conversion from UTF-16 to the locale encoding. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". diff --git a/lib/uniconv/u32-conv-from-enc.c b/lib/uniconv/u32-conv-from-enc.c index 33cefb7f..a18ca18a 100644 --- a/lib/uniconv/u32-conv-from-enc.c +++ b/lib/uniconv/u32-conv-from-enc.c @@ -1,5 +1,5 @@ /* Conversion to UTF-32 from legacy encodings. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". diff --git a/lib/uniconv/u32-conv-to-enc.c b/lib/uniconv/u32-conv-to-enc.c index a96f16de..e0504f46 100644 --- a/lib/uniconv/u32-conv-to-enc.c +++ b/lib/uniconv/u32-conv-to-enc.c @@ -1,5 +1,5 @@ /* Conversion from UTF-32 to legacy encodings. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". diff --git a/lib/uniconv/u32-strconv-from-enc.c b/lib/uniconv/u32-strconv-from-enc.c index 18adfe00..e6095da4 100644 --- a/lib/uniconv/u32-strconv-from-enc.c +++ b/lib/uniconv/u32-strconv-from-enc.c @@ -1,5 +1,5 @@ /* Conversion to UTF-32 from legacy encodings. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". diff --git a/lib/uniconv/u32-strconv-from-locale.c b/lib/uniconv/u32-strconv-from-locale.c index 896c3fd7..6e16662b 100644 --- a/lib/uniconv/u32-strconv-from-locale.c +++ b/lib/uniconv/u32-strconv-from-locale.c @@ -1,5 +1,5 @@ /* Conversion to UTF-32 from the locale encoding. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". diff --git a/lib/uniconv/u32-strconv-to-enc.c b/lib/uniconv/u32-strconv-to-enc.c index f63ced59..31c2354b 100644 --- a/lib/uniconv/u32-strconv-to-enc.c +++ b/lib/uniconv/u32-strconv-to-enc.c @@ -1,5 +1,5 @@ /* Conversion from UTF-32 to legacy encodings. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". diff --git a/lib/uniconv/u32-strconv-to-locale.c b/lib/uniconv/u32-strconv-to-locale.c index d19f3760..578fd0d2 100644 --- a/lib/uniconv/u32-strconv-to-locale.c +++ b/lib/uniconv/u32-strconv-to-locale.c @@ -1,5 +1,5 @@ /* Conversion from UTF-32 to the locale encoding. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". diff --git a/lib/uniconv/u8-conv-from-enc.c b/lib/uniconv/u8-conv-from-enc.c index e292e954..fa2bb59c 100644 --- a/lib/uniconv/u8-conv-from-enc.c +++ b/lib/uniconv/u8-conv-from-enc.c @@ -1,5 +1,5 @@ /* Conversion to UTF-8 from legacy encodings. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -39,7 +39,6 @@ u8_conv_from_encoding (const char *fromcode, if (STRCASEEQ (fromcode, "UTF-8", 'U','T','F','-','8',0,0,0,0)) { /* Conversion from UTF-8 to UTF-8. No need to go through iconv(). */ - uint8_t *result; if (u8_check ((const uint8_t *) src, srclen)) { @@ -48,23 +47,20 @@ u8_conv_from_encoding (const char *fromcode, } if (offsets != NULL) - { - size_t i; - - for (i = 0; i < srclen; ) - { - int count = u8_mblen ((const uint8_t *) src + i, srclen - i); - /* We can rely on count > 0 because of the previous u8_check. */ - if (count <= 0) - abort (); - offsets[i] = i; - i++; - while (--count > 0) - offsets[i++] = (size_t)(-1); - } - } + for (size_t i = 0; i < srclen; ) + { + int count = u8_mblen ((const uint8_t *) src + i, srclen - i); + /* We can rely on count > 0 because of the previous u8_check. */ + if (count <= 0) + abort (); + offsets[i] = i; + i++; + while (--count > 0) + offsets[i++] = (size_t)(-1); + } /* Memory allocation. */ + uint8_t *result; if (resultbuf != NULL && *lengthp >= srclen) result = resultbuf; else diff --git a/lib/uniconv/u8-conv-to-enc.c b/lib/uniconv/u8-conv-to-enc.c index bd6c150c..90b1825d 100644 --- a/lib/uniconv/u8-conv-to-enc.c +++ b/lib/uniconv/u8-conv-to-enc.c @@ -1,5 +1,5 @@ /* Conversion from UTF-8 to legacy encodings. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". @@ -46,8 +46,6 @@ u8_conv_to_encoding (const char *tocode, { if (STRCASEEQ (tocode, "UTF-8", 'U','T','F','-','8',0,0,0,0)) { - char *result; - /* Conversion from UTF-8 to UTF-8. No need to go through iconv(). */ if (u8_check (src, srclen)) { @@ -56,6 +54,7 @@ u8_conv_to_encoding (const char *tocode, } /* Memory allocation. */ + char *result; if (resultbuf != NULL && *lengthp >= srclen) result = resultbuf; else diff --git a/lib/uniconv/u8-strconv-from-enc.c b/lib/uniconv/u8-strconv-from-enc.c index 2e16689c..2b17f59e 100644 --- a/lib/uniconv/u8-strconv-from-enc.c +++ b/lib/uniconv/u8-strconv-from-enc.c @@ -1,5 +1,5 @@ /* Conversion to UTF-8 from legacy encodings. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/lib/uniconv/u8-strconv-from-locale.c b/lib/uniconv/u8-strconv-from-locale.c index f5ea013b..3c1462ee 100644 --- a/lib/uniconv/u8-strconv-from-locale.c +++ b/lib/uniconv/u8-strconv-from-locale.c @@ -1,5 +1,5 @@ /* Conversion to UTF-8 from the locale encoding. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as diff --git a/lib/uniconv/u8-strconv-to-enc.c b/lib/uniconv/u8-strconv-to-enc.c index d346c482..35bd5813 100644 --- a/lib/uniconv/u8-strconv-to-enc.c +++ b/lib/uniconv/u8-strconv-to-enc.c @@ -1,5 +1,5 @@ /* Conversion from UTF-8 to legacy encodings. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". @@ -42,19 +42,16 @@ u8_strconv_to_encoding (const uint8_t *string, const char *tocode, enum iconv_ilseq_handler handler) { - char *result; - size_t length; - if (STRCASEEQ (tocode, "UTF-8", 'U','T','F','-','8',0,0,0,0)) { /* Conversion from UTF-8 to UTF-8. No need to go through iconv(). */ - length = u8_strlen (string) + 1; + size_t length = u8_strlen (string) + 1; if (u8_check (string, length)) { errno = EILSEQ; return NULL; } - result = (char *) malloc (length); + char *result = (char *) malloc (length); if (result == NULL) { errno = ENOMEM; @@ -65,8 +62,8 @@ u8_strconv_to_encoding (const uint8_t *string, } else { - result = NULL; - length = 0; + char *result = NULL; + size_t length = 0; if (mem_iconveha ((const char *) string, u8_strlen (string) + 1, "UTF-8", tocode, handler == iconveh_question_mark, handler, diff --git a/lib/uniconv/u8-strconv-to-locale.c b/lib/uniconv/u8-strconv-to-locale.c index ce9f2513..923f348d 100644 --- a/lib/uniconv/u8-strconv-to-locale.c +++ b/lib/uniconv/u8-strconv-to-locale.c @@ -1,5 +1,5 @@ /* Conversion from UTF-8 to the locale encoding. - Copyright (C) 2002, 2006-2007, 2009-2025 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2026 Free Software Foundation, Inc. This file is free software. It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". |
