sort: don't evaluate if clause

this fixes that you could specify a key
definition like "-k 1.2.3", which is incorrect.
This commit is contained in:
Jakob Kramer 2014-05-03 19:06:20 +02:00 committed by sin
parent e535e8d88a
commit a62a2197a8

5
sort.c
View File

@ -103,7 +103,7 @@ addkeydef(char *def)
if(!head) if(!head)
head = node; head = node;
if(parse_keydef(&node->keydef, def)) if(parse_keydef(&node->keydef, def))
enprintf(2, "parse_keydef:"); enprintf(2, "faulty key definition\n");
if(curr) if(curr)
curr->next = node; curr->next = node;
node->next = NULL; node->next = NULL;
@ -155,6 +155,7 @@ static int
parse_keydef(struct keydef *kd, char *s) parse_keydef(struct keydef *kd, char *s)
{ {
char *rest = s; char *rest = s;
kd->start_column = 1; kd->start_column = 1;
kd->start_char = 1; kd->start_char = 1;
/* 0 means end of line */ /* 0 means end of line */
@ -170,9 +171,9 @@ parse_keydef(struct keydef *kd, char *s)
kd->end_column = strtoul(rest+1, &rest, 10); kd->end_column = strtoul(rest+1, &rest, 10);
if(kd->end_column < kd->start_column) if(kd->end_column < kd->start_column)
enprintf(2, ",%u is too small\n", kd->end_column); enprintf(2, ",%u is too small\n", kd->end_column);
}
if(*rest == '.') if(*rest == '.')
kd->end_char = strtoul(rest+1, &rest, 10); kd->end_char = strtoul(rest+1, &rest, 10);
}
if(*rest != '\0') if(*rest != '\0')
return -1; return -1;
return 0; return 0;