Skip to content

Commit

Permalink
remove common prefix between strings before comparing them
Browse files Browse the repository at this point in the history
  • Loading branch information
azuline committed Apr 16, 2024
1 parent ad04944 commit d9472cc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/nnn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit d9472cc

Please sign in to comment.