libiconv: bump to version 1.18 (#12510)

This commit is contained in:
Joachim Mairböck
2025-06-20 08:26:28 +02:00
committed by GitHub
parent 61a27b4752
commit c08eb0dd1b
3 changed files with 699 additions and 294 deletions

View File

@@ -94,18 +94,18 @@ activated when \"//TRANSLIT\" is appended to the target encoding name.
libiconv is for you if your application needs to support multiple character \
encodings, but that support lacks from your system."
HOMEPAGE="https://www.gnu.org/software/libiconv/"
COPYRIGHT="2000-2022 Free Software Foundation, Inc."
LICENSE="GNU LGPL v2
COPYRIGHT="2000-2024 Free Software Foundation, Inc."
LICENSE="GNU LGPL v2.1
GNU GPL v3"
REVISION="4"
REVISION="1"
SOURCE_URI="https://ftpmirror.gnu.org/libiconv/libiconv-$portVersion.tar.gz"
CHECKSUM_SHA256="8f74213b56238c85a50a5329f77e06198771e70dd9a739779f4c02f65d971313"
CHECKSUM_SHA256="3b08f5f4f9b4eb82f151a7040bfd6fe6c6fb922efe4b1659c66ea933276965e8"
PATCHES="libiconv-$portVersion.patchset"
ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86"
libiconvVersion="2.6.1"
libiconvVersion="2.7.0"
libcharsetVersion="1.0.0"
portVersionCompat="$portVersion compat >= 1.13"

View File

@@ -1,289 +0,0 @@
From b7c8cfddfcc7f6400c43ee23eda906d190740eb2 Mon Sep 17 00:00:00 2001
From: Robert Kausch <robert.kausch@freac.org>
Date: Thu, 13 Oct 2022 00:05:46 +0000
Subject: gcc2 fixes
diff --git a/srclib/canonicalize-lgpl.c b/srclib/canonicalize-lgpl.c
index a7fa7fe..ad7ffdf 100644
--- a/srclib/canonicalize-lgpl.c
+++ b/srclib/canonicalize-lgpl.c
@@ -225,10 +225,12 @@ realpath_stk (const char *name, char *resolved,
return NULL;
}
+ {
struct scratch_buffer extra_buffer, link_buffer;
scratch_buffer_init (&extra_buffer);
scratch_buffer_init (&link_buffer);
scratch_buffer_init (rname_buf);
+ {
char *rname_on_stack = rname_buf->data;
char *rname = rname_on_stack;
bool end_in_extra_buffer = false;
@@ -271,6 +273,7 @@ realpath_stk (const char *name, char *resolved,
for ( ; *start; start = end)
{
+ idx_t startlen;
/* Skip sequence of multiple file name separators. */
while (ISSLASH (*start))
++start;
@@ -281,7 +284,7 @@ realpath_stk (const char *name, char *resolved,
/* Length of this file name component; it can be zero if a file
name ends in '/'. */
- idx_t startlen = end - start;
+ startlen = end - start;
if (startlen == 0)
break;
@@ -315,13 +318,13 @@ realpath_stk (const char *name, char *resolved,
dest = __mempcpy (dest, start, startlen);
*dest = '\0';
-
+ {
char *buf;
ssize_t n;
while (true)
{
- buf = link_buffer.data;
idx_t bufsize = link_buffer.length;
+ buf = link_buffer.data;
n = __readlink (rname, buf, bufsize - 1);
if (n < bufsize - 1)
break;
@@ -330,6 +333,9 @@ realpath_stk (const char *name, char *resolved,
}
if (0 <= n)
{
+ char *extra_buf = extra_buffer.data;
+ idx_t end_idx IF_LINT (= 0);
+ size_t len;
if (++num_links > __eloop_threshold ())
{
__set_errno (ELOOP);
@@ -338,11 +344,9 @@ realpath_stk (const char *name, char *resolved,
buf[n] = '\0';
- char *extra_buf = extra_buffer.data;
- idx_t end_idx IF_LINT (= 0);
if (end_in_extra_buffer)
end_idx = end - extra_buf;
- size_t len = strlen (end);
+ len = strlen (end);
if (INT_ADD_OVERFLOW (len, n))
{
__set_errno (ENOMEM);
@@ -393,6 +397,7 @@ realpath_stk (const char *name, char *resolved,
? dir_check (rname, dest)
: errno == EINVAL))
goto error;
+ }
}
}
if (dest > rname + prefix_len + 1 && ISSLASH (dest[-1]))
@@ -418,6 +423,7 @@ error_nomem:
}
return scratch_buffer_dupfree (rname_buf, dest - rname);
+ }}
}
/* Return the canonical absolute name of file NAME. A canonical name
diff --git a/srclib/careadlinkat.c b/srclib/careadlinkat.c
index 6ddc35f..9811c41 100644
--- a/srclib/careadlinkat.c
+++ b/srclib/careadlinkat.c
@@ -76,7 +76,7 @@ readlink_stk (int fd, char const *filename,
buffer = stack_buf;
buffer_size = STACK_BUF_SIZE;
}
-
+ {
char *buf = buffer;
idx_t buf_size_max = MIN (IDX_MAX, MIN (SSIZE_MAX, SIZE_MAX));
idx_t buf_size = MIN (buffer_size, buf_size_max);
@@ -85,6 +85,7 @@ readlink_stk (int fd, char const *filename,
{
/* Attempt to read the link into the current buffer. */
idx_t link_length = preadlinkat (fd, filename, buf, buf_size);
+ idx_t link_size = link_length;
if (link_length < 0)
{
if (buf != buffer)
@@ -96,8 +97,6 @@ readlink_stk (int fd, char const *filename,
return NULL;
}
- idx_t link_size = link_length;
-
if (link_size < buf_size)
{
buf[link_size++] = '\0';
@@ -137,6 +136,7 @@ readlink_stk (int fd, char const *filename,
if (alloc->die)
alloc->die (buf_size);
+ }
errno = ENOMEM;
return NULL;
}
diff --git a/srclib/malloc.c b/srclib/malloc.c
index f334dd6..dc13183 100644
--- a/srclib/malloc.c
+++ b/srclib/malloc.c
@@ -31,6 +31,7 @@
void *
rpl_malloc (size_t n)
{
+ void *result;
if (n == 0)
n = 1;
@@ -40,7 +41,7 @@ rpl_malloc (size_t n)
return NULL;
}
- void *result = malloc (n);
+ result = malloc (n);
#if !HAVE_MALLOC_POSIX
if (result == NULL)
diff --git a/srclib/malloc/scratch_buffer_set_array_size.c b/srclib/malloc/scratch_buffer_set_array_size.c
index 89c37a9..43e01ea 100644
--- a/srclib/malloc/scratch_buffer_set_array_size.c
+++ b/srclib/malloc/scratch_buffer_set_array_size.c
@@ -29,6 +29,7 @@ __libc_scratch_buffer_set_array_size (struct scratch_buffer *buffer,
size_t nelem, size_t size)
{
size_t new_length = nelem * size;
+ char *new_ptr;
/* Avoid overflow check if both values are small. */
if ((nelem | size) >> (sizeof (size_t) * CHAR_BIT / 2) != 0
@@ -48,7 +49,7 @@ __libc_scratch_buffer_set_array_size (struct scratch_buffer *buffer,
/* Discard old buffer. */
scratch_buffer_free (buffer);
- char *new_ptr = malloc (new_length);
+ new_ptr = malloc (new_length);
if (new_ptr == NULL)
{
/* Buffer must remain valid to free. */
diff --git a/srclib/malloca.c b/srclib/malloca.c
index e7beaaf..1804e3a 100644
--- a/srclib/malloca.c
+++ b/srclib/malloca.c
@@ -57,14 +57,17 @@ mmalloca (size_t n)
if (mem != NULL)
{
uintptr_t umem = (uintptr_t)mem, umemplus;
+ idx_t offset;
+ void *vp;
+ small_t *p;
/* The INT_ADD_WRAPV avoids signed integer overflow on
theoretical platforms where UINTPTR_MAX <= INT_MAX. */
INT_ADD_WRAPV (umem, sizeof (small_t) + sa_alignment_max - 1,
&umemplus);
- idx_t offset = ((umemplus & ~alignment2_mask)
+ offset = ((umemplus & ~alignment2_mask)
+ sa_alignment_max - umem);
- void *vp = mem + offset;
- small_t *p = vp;
+ vp = mem + offset;
+ p = vp;
/* Here p >= mem + sizeof (small_t),
and p <= mem + sizeof (small_t) + 2 * sa_alignment_max - 1
hence p + n <= mem + nplus.
diff --git a/srclib/rawmemchr.c b/srclib/rawmemchr.c
index ea68c1b..963d5e7 100644
--- a/srclib/rawmemchr.c
+++ b/srclib/rawmemchr.c
@@ -34,12 +34,17 @@ rawmemchr (const void *s, int c_in)
{
/* Change this typedef to experiment with performance. */
typedef uintptr_t longword;
- /* If you change the "uintptr_t", you should change UINTPTR_WIDTH to match.
- This verifies that the type does not have padding bits. */
- verify (UINTPTR_WIDTH == UCHAR_WIDTH * sizeof (longword));
const unsigned char *char_ptr;
unsigned char c = c_in;
+ longword const *longword_ptr;
+ longword repeated_one;
+ longword repeated_c;
+ longword repeated_hibit;
+
+ /* If you change the "uintptr_t", you should change UINTPTR_WIDTH to match.
+ This verifies that the type does not have padding bits. */
+ verify (UINTPTR_WIDTH == UCHAR_WIDTH * sizeof (longword));
/* Handle the first few bytes by reading one byte at a time.
Do this until CHAR_PTR is aligned on a longword boundary. */
@@ -49,14 +54,14 @@ rawmemchr (const void *s, int c_in)
if (*char_ptr == c)
return (void *) char_ptr;
- longword const *longword_ptr = s = char_ptr;
+ longword_ptr = s = char_ptr;
/* Compute auxiliary longword values:
repeated_one is a value which has a 1 in every byte.
repeated_c has c in every byte. */
- longword repeated_one = (longword) -1 / UCHAR_MAX;
- longword repeated_c = repeated_one * c;
- longword repeated_hibit = repeated_one * (UCHAR_MAX / 2 + 1);
+ repeated_one = (longword) -1 / UCHAR_MAX;
+ repeated_c = repeated_one * c;
+ repeated_hibit = repeated_one * (UCHAR_MAX / 2 + 1);
/* Instead of the traditional loop which tests each byte, we will
test a longword at a time. The tricky part is testing if any of
diff --git a/srclib/readlink.c b/srclib/readlink.c
index ed03cc8..458c574 100644
--- a/srclib/readlink.c
+++ b/srclib/readlink.c
@@ -55,6 +55,7 @@ rpl_readlink (char const *file, char *buf, size_t bufsize)
{
# if READLINK_TRAILING_SLASH_BUG
size_t file_len = strlen (file);
+ ssize_t r;
if (file_len && file[file_len - 1] == '/')
{
/* Even if FILE without the slash is a symlink to a directory,
@@ -69,7 +70,7 @@ rpl_readlink (char const *file, char *buf, size_t bufsize)
}
# endif /* READLINK_TRAILING_SLASH_BUG */
- ssize_t r = readlink (file, buf, bufsize);
+ r = readlink (file, buf, bufsize);
# if READLINK_TRUNCATE_BUG
if (r < 0 && errno == ERANGE)
diff --git a/srclib/realloc.c b/srclib/realloc.c
index c878381..87caa86 100644
--- a/srclib/realloc.c
+++ b/srclib/realloc.c
@@ -37,6 +37,7 @@
void *
rpl_realloc (void *p, size_t n)
{
+ void *result;
if (p == NULL)
return malloc (n);
@@ -52,7 +53,7 @@ rpl_realloc (void *p, size_t n)
return NULL;
}
- void *result = realloc (p, n);
+ result = realloc (p, n);
#if !HAVE_MALLOC_POSIX
if (result == NULL)
--
2.37.3

View File

@@ -0,0 +1,694 @@
From 3014ad83f4bc3bb56a0273c4b397b5496370535a Mon Sep 17 00:00:00 2001
From: Robert Kausch <robert.kausch@freac.org>
Date: Thu, 13 Oct 2022 00:05:46 +0000
Subject: gcc2 fixes
diff --git a/srclib/canonicalize-lgpl.c b/srclib/canonicalize-lgpl.c
index efd79ce..b8566d5 100644
--- a/srclib/canonicalize-lgpl.c
+++ b/srclib/canonicalize-lgpl.c
@@ -195,6 +195,10 @@ realpath_stk (const char *name, char *resolved, struct realpath_bufs *bufs)
char const *start;
char const *end;
int num_links = 0;
+ char *rname = bufs->rname.data;
+ bool end_in_extra_buffer = false;
+ bool failed = true;
+ idx_t prefix_len;
if (name == NULL)
{
@@ -214,13 +218,9 @@ realpath_stk (const char *name, char *resolved, struct realpath_bufs *bufs)
return NULL;
}
- char *rname = bufs->rname.data;
- bool end_in_extra_buffer = false;
- bool failed = true;
-
/* This is always zero for Posix hosts, but can be 2 for MS-Windows
and MS-DOS X:/foo/bar file names. */
- idx_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
+ prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
if (!IS_ABSOLUTE_FILE_NAME (name))
{
@@ -255,6 +255,7 @@ realpath_stk (const char *name, char *resolved, struct realpath_bufs *bufs)
for ( ; *start; start = end)
{
+ idx_t startlen;
/* Skip sequence of multiple file name separators. */
while (ISSLASH (*start))
++start;
@@ -265,7 +266,7 @@ realpath_stk (const char *name, char *resolved, struct realpath_bufs *bufs)
/* Length of this file name component; it can be zero if a file
name ends in '/'. */
- idx_t startlen = end - start;
+ startlen = end - start;
if (startlen == 0)
break;
@@ -299,13 +300,13 @@ realpath_stk (const char *name, char *resolved, struct realpath_bufs *bufs)
dest = __mempcpy (dest, start, startlen);
*dest = '\0';
-
+ {
char *buf;
ssize_t n;
while (true)
{
- buf = bufs->link.data;
idx_t bufsize = bufs->link.length;
+ buf = bufs->link.data;
n = __readlink (rname, buf, bufsize - 1);
if (n < bufsize - 1)
break;
@@ -314,6 +315,9 @@ realpath_stk (const char *name, char *resolved, struct realpath_bufs *bufs)
}
if (0 <= n)
{
+ char *extra_buf = bufs->extra.data;
+ idx_t end_idx IF_LINT (= 0);
+ size_t len;
if (++num_links > __eloop_threshold ())
{
__set_errno (ELOOP);
@@ -322,11 +326,9 @@ realpath_stk (const char *name, char *resolved, struct realpath_bufs *bufs)
buf[n] = '\0';
- char *extra_buf = bufs->extra.data;
- idx_t end_idx IF_LINT (= 0);
if (end_in_extra_buffer)
end_idx = end - extra_buf;
- size_t len = strlen (end);
+ len = strlen (end);
if (INT_ADD_OVERFLOW (len, n))
{
__set_errno (ENOMEM);
@@ -377,6 +379,7 @@ realpath_stk (const char *name, char *resolved, struct realpath_bufs *bufs)
? dir_check (rname, dest)
: errno == EINVAL))
goto error;
+ }
}
}
if (dest > rname + prefix_len + 1 && ISSLASH (dest[-1]))
diff --git a/srclib/careadlinkat.c b/srclib/careadlinkat.c
index f308b69..d4a958e 100644
--- a/srclib/careadlinkat.c
+++ b/srclib/careadlinkat.c
@@ -74,7 +74,7 @@ readlink_stk (int fd, char const *filename,
buffer = stack_buf;
buffer_size = STACK_BUF_SIZE;
}
-
+ {
char *buf = buffer;
idx_t buf_size_max = MIN (IDX_MAX, MIN (SSIZE_MAX, SIZE_MAX));
idx_t buf_size = MIN (buffer_size, buf_size_max);
@@ -83,6 +83,7 @@ readlink_stk (int fd, char const *filename,
{
/* Attempt to read the link into the current buffer. */
idx_t link_length = preadlinkat (fd, filename, buf, buf_size);
+ idx_t link_size = link_length;
if (link_length < 0)
{
if (buf != buffer)
@@ -94,8 +95,6 @@ readlink_stk (int fd, char const *filename,
return NULL;
}
- idx_t link_size = link_length;
-
if (link_size < buf_size)
{
buf[link_size++] = '\0';
@@ -135,6 +134,7 @@ readlink_stk (int fd, char const *filename,
if (alloc->die)
alloc->die (buf_size);
+ }
errno = ENOMEM;
return NULL;
}
diff --git a/srclib/malloc.c b/srclib/malloc.c
index 045ff82..ac34963 100644
--- a/srclib/malloc.c
+++ b/srclib/malloc.c
@@ -31,6 +31,7 @@
void *
rpl_malloc (size_t n)
{
+ void *result;
#if !HAVE_MALLOC_0_NONNULL
if (n == 0)
n = 1;
@@ -45,7 +46,7 @@ rpl_malloc (size_t n)
}
#endif
- void *result = malloc (n);
+ result = malloc (n);
#if !HAVE_MALLOC_POSIX
if (result == NULL)
diff --git a/srclib/malloc/scratch_buffer_set_array_size.c b/srclib/malloc/scratch_buffer_set_array_size.c
index 0582bef..65a2945 100644
--- a/srclib/malloc/scratch_buffer_set_array_size.c
+++ b/srclib/malloc/scratch_buffer_set_array_size.c
@@ -29,6 +29,7 @@ __libc_scratch_buffer_set_array_size (struct scratch_buffer *buffer,
size_t nelem, size_t size)
{
size_t new_length = nelem * size;
+ char *new_ptr;
/* Avoid overflow check if both values are small. */
if ((nelem | size) >> (sizeof (size_t) * CHAR_BIT / 2) != 0
@@ -48,7 +49,7 @@ __libc_scratch_buffer_set_array_size (struct scratch_buffer *buffer,
/* Discard old buffer. */
scratch_buffer_free (buffer);
- char *new_ptr = malloc (new_length);
+ new_ptr = malloc (new_length);
if (new_ptr == NULL)
{
/* Buffer must remain valid to free. */
diff --git a/srclib/malloca.c b/srclib/malloca.c
index 2219459..5a031db 100644
--- a/srclib/malloca.c
+++ b/srclib/malloca.c
@@ -68,16 +68,19 @@ mmalloca (size_t n)
/* The ckd_add avoids signed integer overflow on
theoretical platforms where UINTPTR_MAX <= INT_MAX. */
uintptr_t umemplus;
+ idx_t offset;
+ void *p;
+ small_t *sp;
ckd_add (&umemplus, umem, sizeof (small_t) + sa_alignment_max - 1);
- idx_t offset = (umemplus - umemplus % (2 * sa_alignment_max)
+ offset = (umemplus - umemplus % (2 * sa_alignment_max)
+ sa_alignment_max - umem);
- void *p = mem + offset;
+ p = mem + offset;
/* Here p >= mem + sizeof (small_t),
and p <= mem + sizeof (small_t) + 2 * sa_alignment_max - 1
hence p + n <= mem + nplus.
So, the memory range [p, p+n) lies in the allocated memory range
[mem, mem + nplus). */
- small_t *sp = p;
+ sp = p;
# if defined __CHERI_PURE_CAPABILITY__
sp[-1] = umem;
p = (char *) cheri_bounds_set ((char *) p - sizeof (small_t),
diff --git a/srclib/rawmemchr.c b/srclib/rawmemchr.c
index 013e7f8..30aa8ce 100644
--- a/srclib/rawmemchr.c
+++ b/srclib/rawmemchr.c
@@ -43,11 +43,16 @@ rawmemchr (const void *s, int c_in)
/* You can change this typedef to experiment with performance. */
typedef uintptr_t longword;
- /* Verify that the longword type lacks padding bits. */
- static_assert (UINTPTR_WIDTH == UCHAR_WIDTH * sizeof (uintptr_t));
const unsigned char *char_ptr;
unsigned char c = c_in;
+ longword const *longword_ptr;
+ longword repeated_one;
+ longword repeated_c;
+ longword repeated_hibit;
+
+ /* Verify that the longword type lacks padding bits. */
+ static_assert (UINTPTR_WIDTH == UCHAR_WIDTH * sizeof (uintptr_t));
/* Handle the first few bytes by reading one byte at a time.
Do this until CHAR_PTR is aligned on a natural longword boundary,
@@ -58,14 +63,14 @@ rawmemchr (const void *s, int c_in)
if (*char_ptr == c)
return (void *) char_ptr;
- longword const *longword_ptr = s = char_ptr;
+ longword_ptr = s = char_ptr;
/* Compute auxiliary longword values:
repeated_one is a value which has a 1 in every byte.
repeated_c has c in every byte. */
- longword repeated_one = (longword) -1 / UCHAR_MAX;
- longword repeated_c = repeated_one * c;
- longword repeated_hibit = repeated_one * (UCHAR_MAX / 2 + 1);
+ repeated_one = (longword) -1 / UCHAR_MAX;
+ repeated_c = repeated_one * c;
+ repeated_hibit = repeated_one * (UCHAR_MAX / 2 + 1);
/* Instead of the traditional loop which tests each byte, we will
test a longword at a time. The tricky part is testing if any of
diff --git a/srclib/readlink.c b/srclib/readlink.c
index f4af30e..68c45e1 100644
--- a/srclib/readlink.c
+++ b/srclib/readlink.c
@@ -55,6 +55,7 @@ rpl_readlink (char const *file, char *buf, size_t bufsize)
{
# if READLINK_TRAILING_SLASH_BUG
size_t file_len = strlen (file);
+ ssize_t r;
if (file_len && file[file_len - 1] == '/')
{
/* Even if FILE without the slash is a symlink to a directory,
@@ -69,7 +70,7 @@ rpl_readlink (char const *file, char *buf, size_t bufsize)
}
# endif /* READLINK_TRAILING_SLASH_BUG */
- ssize_t r = readlink (file, buf, bufsize);
+ r = readlink (file, buf, bufsize);
# if READLINK_TRUNCATE_BUG
if (r < 0 && errno == ERANGE)
diff --git a/srclib/realloc.c b/srclib/realloc.c
index 5804474..2946a2a 100644
--- a/srclib/realloc.c
+++ b/srclib/realloc.c
@@ -42,6 +42,7 @@ void *
rpl_realloc (void *p, size_t n)
{
size_t n1 = n;
+ void *result;
if (n == 0)
{
@@ -92,7 +93,7 @@ rpl_realloc (void *p, size_t n)
}
# endif
- void *result = realloc (p, n1);
+ result = realloc (p, n1);
# if !HAVE_MALLOC_POSIX
if (result == NULL)
--
2.48.1
From ccc18143b306cdf8161357b5b45279a8cb0f3ed8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joachim=20Mairb=C3=B6ck?= <j.mairboeck@gmail.com>
Date: Thu, 19 Jun 2025 17:28:15 +0200
Subject: more gcc2 fixes
diff --git a/lib/ebcdic1132.h b/lib/ebcdic1132.h
index 7c53dbb..7a3365f 100644
--- a/lib/ebcdic1132.h
+++ b/lib/ebcdic1132.h
@@ -76,9 +76,10 @@ static int
ebcdic1132_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
{
unsigned char c = *s;
+ unsigned short wc;
if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX)
c = swap_x15_x25 (c);
- unsigned short wc = ebcdic1132_2uni[c];
+ wc = ebcdic1132_2uni[c];
if (wc != 0xfffd) {
*pwc = (ucs4_t) wc;
return 1;
diff --git a/lib/ebcdic1137.h b/lib/ebcdic1137.h
index b4b7374..03fdcc2 100644
--- a/lib/ebcdic1137.h
+++ b/lib/ebcdic1137.h
@@ -76,9 +76,10 @@ static int
ebcdic1137_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
{
unsigned char c = *s;
+ unsigned short wc;
if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX)
c = swap_x15_x25 (c);
- unsigned short wc = ebcdic1137_2uni[c];
+ wc = ebcdic1137_2uni[c];
if (wc != 0xfffd) {
*pwc = (ucs4_t) wc;
return 1;
diff --git a/lib/ebcdic12712.h b/lib/ebcdic12712.h
index e7a5650..0879e4b 100644
--- a/lib/ebcdic12712.h
+++ b/lib/ebcdic12712.h
@@ -76,9 +76,10 @@ static int
ebcdic12712_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
{
unsigned char c = *s;
+ unsigned short wc;
if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX)
c = swap_x15_x25 (c);
- unsigned short wc = ebcdic12712_2uni[c];
+ wc = ebcdic12712_2uni[c];
if (wc != 0xfffd) {
*pwc = (ucs4_t) wc;
return 1;
diff --git a/lib/ebcdic16804.h b/lib/ebcdic16804.h
index 57a2031..fff9198 100644
--- a/lib/ebcdic16804.h
+++ b/lib/ebcdic16804.h
@@ -76,9 +76,10 @@ static int
ebcdic16804_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
{
unsigned char c = *s;
+ unsigned short wc;
if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX)
c = swap_x15_x25 (c);
- unsigned short wc = ebcdic16804_2uni[c];
+ wc = ebcdic16804_2uni[c];
if (wc != 0xfffd) {
*pwc = (ucs4_t) wc;
return 1;
diff --git a/lib/ebcdic423.h b/lib/ebcdic423.h
index 7782148..0a91124 100644
--- a/lib/ebcdic423.h
+++ b/lib/ebcdic423.h
@@ -76,9 +76,10 @@ static int
ebcdic423_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
{
unsigned char c = *s;
+ unsigned short wc;
if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX)
c = swap_x15_x25 (c);
- unsigned short wc = ebcdic423_2uni[c];
+ wc = ebcdic423_2uni[c];
if (wc != 0xfffd) {
*pwc = (ucs4_t) wc;
return 1;
diff --git a/lib/ebcdic424.h b/lib/ebcdic424.h
index afcbba9..4e23220 100644
--- a/lib/ebcdic424.h
+++ b/lib/ebcdic424.h
@@ -76,9 +76,10 @@ static int
ebcdic424_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
{
unsigned char c = *s;
+ unsigned short wc;
if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX)
c = swap_x15_x25 (c);
- unsigned short wc = ebcdic424_2uni[c];
+ wc = ebcdic424_2uni[c];
if (wc != 0xfffd) {
*pwc = (ucs4_t) wc;
return 1;
diff --git a/lib/ebcdic425.h b/lib/ebcdic425.h
index de7440b..248931e 100644
--- a/lib/ebcdic425.h
+++ b/lib/ebcdic425.h
@@ -76,9 +76,10 @@ static int
ebcdic425_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
{
unsigned char c = *s;
+ unsigned short wc;
if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX)
c = swap_x15_x25 (c);
- unsigned short wc = ebcdic425_2uni[c];
+ wc = ebcdic425_2uni[c];
if (wc != 0xfffd) {
*pwc = (ucs4_t) wc;
return 1;
diff --git a/lib/ebcdic4971.h b/lib/ebcdic4971.h
index cfef3bb..f9fbaeb 100644
--- a/lib/ebcdic4971.h
+++ b/lib/ebcdic4971.h
@@ -76,9 +76,10 @@ static int
ebcdic4971_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
{
unsigned char c = *s;
+ unsigned short wc;
if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX)
c = swap_x15_x25 (c);
- unsigned short wc = ebcdic4971_2uni[c];
+ wc = ebcdic4971_2uni[c];
if (wc != 0xfffd) {
*pwc = (ucs4_t) wc;
return 1;
diff --git a/lib/ebcdic875.h b/lib/ebcdic875.h
index 759c14e..aea5b93 100644
--- a/lib/ebcdic875.h
+++ b/lib/ebcdic875.h
@@ -76,9 +76,10 @@ static int
ebcdic875_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
{
unsigned char c = *s;
+ unsigned short wc;
if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX)
c = swap_x15_x25 (c);
- unsigned short wc = ebcdic875_2uni[c];
+ wc = ebcdic875_2uni[c];
if (wc != 0xfffd) {
*pwc = (ucs4_t) wc;
return 1;
diff --git a/lib/ebcdic905.h b/lib/ebcdic905.h
index c3cef74..0213d28 100644
--- a/lib/ebcdic905.h
+++ b/lib/ebcdic905.h
@@ -76,9 +76,10 @@ static int
ebcdic905_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
{
unsigned char c = *s;
+ unsigned short wc;
if (conv->isurface & ICONV_SURFACE_EBCDIC_ZOS_UNIX)
c = swap_x15_x25 (c);
- unsigned short wc = ebcdic905_2uni[c];
+ wc = ebcdic905_2uni[c];
if (wc != 0xfffd) {
*pwc = (ucs4_t) wc;
return 1;
diff --git a/src/iconv.c b/src/iconv.c
index d6b68fd..08048a3 100644
--- a/src/iconv.c
+++ b/src/iconv.c
@@ -1017,6 +1017,7 @@ int main (int argc, char* argv[])
iconvlist(print_one,NULL);
status = 0;
} else {
+ const char *envvar_value;
#if O_BINARY
SET_BINARY(fileno(stdout));
#endif
@@ -1052,7 +1053,7 @@ int main (int argc, char* argv[])
}
/* For EBCDIC encodings, determine how to map 0x15 (which encodes the
"newline function", see the Unicode standard, chapter 5). */
- const char *envvar_value = getenv("ICONV_EBCDIC_ZOS_UNIX");
+ envvar_value = getenv("ICONV_EBCDIC_ZOS_UNIX");
if (envvar_value != NULL && envvar_value[0] != '\0') {
unsigned int surface;
iconvctl(cd, ICONV_GET_FROM_SURFACE, &surface);
diff --git a/srclib/canonicalize-lgpl.c b/srclib/canonicalize-lgpl.c
index b8566d5..9b91d01 100644
--- a/srclib/canonicalize-lgpl.c
+++ b/srclib/canonicalize-lgpl.c
@@ -432,10 +432,11 @@ char *
__realpath (const char *name, char *resolved)
{
struct realpath_bufs bufs;
+ char *result;
scratch_buffer_init (&bufs.rname);
scratch_buffer_init (&bufs.extra);
scratch_buffer_init (&bufs.link);
- char *result = realpath_stk (name, resolved, &bufs);
+ result = realpath_stk (name, resolved, &bufs);
scratch_buffer_free (&bufs.link);
scratch_buffer_free (&bufs.extra);
scratch_buffer_free (&bufs.rname);
diff --git a/srclib/realloc.c b/srclib/realloc.c
index 2946a2a..064df02 100644
--- a/srclib/realloc.c
+++ b/srclib/realloc.c
@@ -42,6 +42,9 @@ void *
rpl_realloc (void *p, size_t n)
{
size_t n1 = n;
+# if !HAVE_MALLOC_PTRDIFF
+ ptrdiff_t signed_n;
+# endif
void *result;
if (n == 0)
@@ -85,7 +88,6 @@ rpl_realloc (void *p, size_t n)
}
# if !HAVE_MALLOC_PTRDIFF
- ptrdiff_t signed_n;
if (ckd_add (&signed_n, n, 0))
{
errno = ENOMEM;
--
2.48.1
From 8a5e8fa350a35dbb14a19293b56c9b968eb37660 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joachim=20Mairb=C3=B6ck?= <j.mairboeck@gmail.com>
Date: Thu, 19 Jun 2025 17:41:47 +0200
Subject: gcc2 fixes for tests
diff --git a/tests/test-bom-state.c b/tests/test-bom-state.c
index fa36f43..3d8d946 100644
--- a/tests/test-bom-state.c
+++ b/tests/test-bom-state.c
@@ -47,17 +47,18 @@ static void test_one_input (const char *fromcode,
{
char outbuf1[3];
char outbuf2[3];
+ char *inbuf = (char *) input;
+ size_t inbytesleft = input_size;
+ char *outbuf = outbuf1;
+ size_t outbytesleft = sizeof (outbuf1);
+ size_t ret;
iconv_t cd = iconv_open ("UTF-8", fromcode);
if (cd == (iconv_t)(-1))
abort ();
/* Convert the first character. */
- char *inbuf = (char *) input;
- size_t inbytesleft = input_size;
- char *outbuf = outbuf1;
- size_t outbytesleft = sizeof (outbuf1);
- size_t ret = iconv (cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+ ret = iconv (cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
if (!(ret == (size_t)(-1) && errno == E2BIG && outbytesleft == 0))
abort ();
if (!(memcmp (outbuf1, "\xe2\x94\xa6", 3) == 0)) /* should be U+2526 */
diff --git a/tests/test-discard.c b/tests/test-discard.c
index 296f6ef..a3d6f89 100644
--- a/tests/test-discard.c
+++ b/tests/test-discard.c
@@ -59,6 +59,7 @@ static void test_default (iconv_t cd)
abort ();
}
#ifdef _LIBICONV_VERSION
+ {
int x;
if (iconvctl (cd, ICONV_GET_TRANSLITERATE, &x) != 0)
abort ();
@@ -76,6 +77,7 @@ static void test_default (iconv_t cd)
abort ();
if (x != 0)
abort ();
+ }
#endif
}
@@ -108,6 +110,7 @@ static void test_translit (iconv_t cd)
abort ();
}
#ifdef _LIBICONV_VERSION
+ {
int x;
if (iconvctl (cd, ICONV_GET_TRANSLITERATE, &x) != 0)
abort ();
@@ -125,6 +128,7 @@ static void test_translit (iconv_t cd)
abort ();
if (x != 0)
abort ();
+ }
#endif
}
@@ -167,6 +171,7 @@ static void test_ignore (iconv_t cd)
abort ();
}
#ifdef _LIBICONV_VERSION
+ {
int x;
if (iconvctl (cd, ICONV_GET_TRANSLITERATE, &x) != 0)
abort ();
@@ -184,6 +189,7 @@ static void test_ignore (iconv_t cd)
abort ();
if (x != 1)
abort ();
+ }
#endif
}
@@ -216,6 +222,7 @@ static void test_ignore_translit (iconv_t cd)
abort ();
}
#ifdef _LIBICONV_VERSION
+ {
int x;
if (iconvctl (cd, ICONV_GET_TRANSLITERATE, &x) != 0)
abort ();
@@ -233,6 +240,7 @@ static void test_ignore_translit (iconv_t cd)
abort ();
if (x != 1)
abort ();
+ }
#endif
}
@@ -265,6 +273,7 @@ static void test_nid (iconv_t cd)
abort ();
}
#ifdef _LIBICONV_VERSION
+ {
int x;
if (iconvctl (cd, ICONV_GET_TRANSLITERATE, &x) != 0)
abort ();
@@ -282,6 +291,7 @@ static void test_nid (iconv_t cd)
abort ();
if (x != 0)
abort ();
+ }
#endif
}
@@ -314,6 +324,7 @@ static void test_nid_translit (iconv_t cd)
abort ();
}
#ifdef _LIBICONV_VERSION
+ {
int x;
if (iconvctl (cd, ICONV_GET_TRANSLITERATE, &x) != 0)
abort ();
@@ -331,6 +342,7 @@ static void test_nid_translit (iconv_t cd)
abort ();
if (x != 0)
abort ();
+ }
#endif
}
@@ -363,6 +375,7 @@ static void test_invd (iconv_t cd)
abort ();
}
#ifdef _LIBICONV_VERSION
+ {
int x;
if (iconvctl (cd, ICONV_GET_TRANSLITERATE, &x) != 0)
abort ();
@@ -380,6 +393,7 @@ static void test_invd (iconv_t cd)
abort ();
if (x != 0)
abort ();
+ }
#endif
}
@@ -412,6 +426,7 @@ static void test_invd_translit (iconv_t cd)
abort ();
}
#ifdef _LIBICONV_VERSION
+ {
int x;
if (iconvctl (cd, ICONV_GET_TRANSLITERATE, &x) != 0)
abort ();
@@ -429,6 +444,7 @@ static void test_invd_translit (iconv_t cd)
abort ();
if (x != 0)
abort ();
+ }
#endif
}
--
2.48.1