]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ar/objcopy: harmonize .exe suffix stripping
authorJan Beulich <jbeulich@suse.com>
Fri, 4 Apr 2025 08:20:31 +0000 (10:20 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 4 Apr 2025 08:20:31 +0000 (10:20 +0200)
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.

binutils/ar.c
binutils/objcopy.c

index a61d572c0e00e09703a47edcc324df3efc39858a..de41c9e3dd1ace7dc8229ba348be7ad9425bc2f8 100644 (file)
@@ -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
 
index 1cc4fe4876f5d61b7626dfa11b0e35cd9bdbcb36..5b4fa7c6110fe8ecda862dc5f4c9e6762fb12734 100644 (file)
@@ -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)