From 13a53d624c86476d507033a92c3f68a2dc646f72 Mon Sep 17 00:00:00 2001 From: Robert Pengelly Date: Wed, 11 Jun 2025 22:00:25 +0100 Subject: [PATCH] Fix size error on Linux --- ranlib.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ranlib.c b/ranlib.c index 89e349a..6dfdbbf 100644 --- a/ranlib.c +++ b/ranlib.c @@ -408,7 +408,7 @@ void ranlib (FILE *arfp) { FILE *tfp = tmpfile (); struct ar_header header; - long bytes, i, j, len, read, val; + long i, j, len, read, val; unsigned char *object; void *contents; @@ -416,6 +416,12 @@ void ranlib (FILE *arfp) { char temp[16]; long offset = 0; +#if UINT_MAX == 65536 + long bytes; +#else + int bytes; +#endif + for (;;) { struct ar_header hdr; @@ -530,7 +536,11 @@ void ranlib (FILE *arfp) { memcpy (header.group, temp, 6); memcpy (header.mode, temp, 8); +#if UINT_MAX == 65536 len = sprintf (temp, "%ld", bytes + 4); +#else + len = sprintf (temp, "%d", bytes + 4); +#endif temp[len] = ' '; memcpy (header.size, temp, 10); -- 2.34.1