[hackers] [sbase] sort: simplify linecmp, rename curr => tail || Jakob Kramer
commit 9366f48b1fc5fcb2971334189e43b6050cc1e58c
Author: Jakob Kramer <jakob.kramer_AT_gmx.de>
Date: Tue May 6 18:47:02 2014 +0200
sort: simplify linecmp, rename curr => tail
diff --git a/sort.c b/sort.c
index 203490b..a00e902 100644
--- a/sort.c
+++ b/sort.c
_AT_@ -29,7 +29,7 @@ struct kdlist {
};
static struct kdlist *head = NULL;
-static struct kdlist *curr = NULL;
+static struct kdlist *tail = NULL;
static void addkeydef(char *, int);
static void freelist(void);
_AT_@ -118,10 +118,10 @@ addkeydef(char *def, int flags)
head = node;
if(parse_keydef(&node->keydef, def, flags))
enprintf(2, "faulty key definition
");
- if(curr)
- curr->next = node;
+ if(tail)
+ tail->next = node;
node->next = NULL;
- curr = node;
+ tail = node;
}
static void
_AT_@ -147,13 +147,10 @@ linecmp(const char **a, const char **b)
s1 = columns((char *)*a, &node->keydef);
s2 = columns((char *)*b, &node->keydef);
- /* don't consider modifiers if it's the default key
- * definition that was implicitly added */
- /* if -u is given, don't use default */
- if(uflag && !(node == head) && !node->next)
+ /* if -u is given, don't use default key definition
+ * unless it is the only one */
+ if(uflag && node == tail && head != tail)
res = 0;
- else if(!(node == head) && !node->next)
- res = strcmp(s1, s2);
else if(node->keydef.flags & MOD_N)
res = strtol(s1, 0, 10) - strtol(s2, 0, 10);
else
Received on Tue May 06 2014 - 19:01:48 CEST
This archive was generated by hypermail 2.3.0
: Tue May 06 2014 - 19:12:07 CEST