remove common prefix between strings before comparing them

This commit is contained in:
blissful 2024-04-15 23:05:15 -04:00
parent ad04944bdf
commit d9472cc252
No known key found for this signature in database
GPG Key ID: 3FC5AA97AA6A4D78
1 changed files with 7 additions and 2 deletions

View File

@ -2854,10 +2854,15 @@ static void write_lastdir(const char *curpath, const char *outfile)
*
* If the absolute numeric values are same, we fallback to alphasort.
*/
static int xstricmp(const char * const s1, const char * const s2)
static int xstricmp(const char *s1, const char *s2)
{
char *p1, *p2;
/* Remove the common prefix of both strings. */
while (*s1 && *s2 && *s1 == *s2) {
s1++;
s2++;
}
char *p1, *p2;
long long v1 = strtoll(s1, &p1, 10);
long long v2 = strtoll(s2, &p2, 10);