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.
This commit is contained in:
Jan Beulich
2025-04-04 10:20:31 +02:00
parent 25a0668a95
commit cc0693d394
2 changed files with 13 additions and 7 deletions

View 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

View 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)