aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2025-04-04 10:20:31 +0200
committerJan Beulich <jbeulich@suse.com>2025-04-04 10:20:31 +0200
commitcc0693d394692261e03651325c9ae986ae579296 (patch)
treecd8191936325853a301a09b479e7211f74a152b6
parent25a0668a95ea5fac9393149205aa8f137da1c362 (diff)
downloadbinutils-cc0693d394692261e03651325c9ae986ae579296.zip
binutils-cc0693d394692261e03651325c9ae986ae579296.tar.gz
binutils-cc0693d394692261e03651325c9ae986ae579296.tar.bz2
ar/objcopy: harmonize .exe suffix stripping
With it only being the tail of the name which wants checking, using lbasename() isn't helpful. Mirror what objcopy.c:main() does to ar.c, merely chaning the plain int of the local variable to size_t.
-rw-r--r--binutils/ar.c17
-rw-r--r--binutils/objcopy.c3
2 files changed, 13 insertions, 7 deletions
diff --git a/binutils/ar.c b/binutils/ar.c
index a61d572..de41c9e 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -740,13 +740,18 @@ main (int argc, char **argv)
#ifndef is_ranlib
if (is_ranlib < 0)
{
- const char *temp = lbasename (program_name);
+ size_t l = strlen (program_name);
- if (strlen (temp) >= 6
- && FILENAME_CMP (temp + strlen (temp) - 6, "ranlib") == 0)
- is_ranlib = 1;
- else
- is_ranlib = 0;
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+ /* Drop the .exe suffix, if any. */
+ if (l > 4 && FILENAME_CMP (program_name + l - 4, ".exe") == 0)
+ {
+ l -= 4;
+ program_name[l] = '\0';
+ }
+#endif
+ is_ranlib = (l >= 6 &&
+ FILENAME_CMP (program_name + l - 6, "ranlib") == 0);
}
#endif
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 1cc4fe4..5b4fa7c 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -6227,7 +6227,8 @@ main (int argc, char *argv[])
#ifndef is_strip
if (is_strip < 0)
{
- int i = strlen (program_name);
+ size_t i = strlen (program_name);
+
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
/* Drop the .exe suffix, if any. */
if (i > 4 && FILENAME_CMP (program_name + i - 4, ".exe") == 0)