mirror of
https://github.com/jarun/nnn.git
synced 2025-02-26 03:01:32 +00:00
Add check to defer name to number conversion
This commit is contained in:
parent
e671dcd092
commit
3243a3082a
1 changed files with 20 additions and 4 deletions
24
nnn.c
24
nnn.c
|
@ -378,15 +378,31 @@ xgetenv(char *name, char *fallback)
|
||||||
* If the absolute numeric values are same, we fallback to alphasort.
|
* If the absolute numeric values are same, we fallback to alphasort.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
xstricmp(const char *s1, const char *s2)
|
xstricmp(char *s1, char *s2)
|
||||||
{
|
{
|
||||||
static char *c1, *c2;
|
static char *c1, *c2;
|
||||||
static long long num1, num2;
|
|
||||||
|
|
||||||
num1 = strtoll(s1, &c1, 10);
|
c1 = s1;
|
||||||
num2 = strtoll(s2, &c2, 10);
|
while (isspace(*c1))
|
||||||
|
c1++;
|
||||||
|
if (*c1 == '-' || *c1 == '+')
|
||||||
|
c1++;
|
||||||
|
while(*c1 >= '0' && *c1 <= '9')
|
||||||
|
c1++;
|
||||||
|
|
||||||
|
c2 = s2;
|
||||||
|
while (isspace(*c2))
|
||||||
|
c2++;
|
||||||
|
if (*c2 == '-' || *c2 == '+')
|
||||||
|
c2++;
|
||||||
|
while(*c2 >= '0' && *c2 <= '9')
|
||||||
|
c2++;
|
||||||
|
|
||||||
if (*c1 == '\0' && *c2 == '\0') {
|
if (*c1 == '\0' && *c2 == '\0') {
|
||||||
|
static long long num1, num2;
|
||||||
|
|
||||||
|
num1 = strtoll(s1, &c1, 10);
|
||||||
|
num2 = strtoll(s2, &c2, 10);
|
||||||
if (num1 != num2) {
|
if (num1 != num2) {
|
||||||
if (num1 > num2)
|
if (num1 > num2)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue