[PATCH v2] ld: Make library member file suffix comparisons case insensitive when cross compiling too

Martin Storsjö martin@martin.st
Tue Aug 23 14:19:02 GMT 2022


On Tue, 23 Aug 2022, Nick Clifton wrote:

> Hi Martin,
>
>> +/* Hardcoded case insensitive comparison. filename_cmp is insensitive
>> + * when running on Windows, but when cross compiling to Windows, we
>> + * also want similar comparisons to be case insensitive. */
>> +static int stricmp (const char *s1, const char *s2)
>> +{
>> +  for (;;)
>> +    {
>> +      int c1 = TOLOWER (*s1++);
>> +      int c2 = TOLOWER (*s2++);
>> +
>> +      if (c1 != c2)
>> +        return (c1 - c2);
>> +
>> +      if (c1 == '\0')
>> +        return 0;
>> +    }
>> +}
>
> The implementation of filename_cmp() in libiberty also treats forward
> slashes and backward slashes as the same, on DOS based filesystems.
> Shouldn't this be carried over to stricmp() as well ?

Oh, right - in general I guess that could be useful too, but all the 
occurrances I switched to use this only ever compared against filename 
suffixes, no full pathnames. So for the usecases changed here, stricmp as 
such is enough - but I guess I can extend it into a filename_dos_cmp 
instead, if that's preferred.

// Martin



More information about the Binutils mailing list