sort: simplify linecmp, rename curr => tail
This commit is contained in:
		
							
								
								
									
										17
									
								
								sort.c
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								sort.c
									
									
									
									
									
								
							@@ -29,7 +29,7 @@ struct kdlist {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct kdlist *head = NULL;
 | 
					static struct kdlist *head = NULL;
 | 
				
			||||||
static struct kdlist *curr = NULL;
 | 
					static struct kdlist *tail = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void addkeydef(char *, int);
 | 
					static void addkeydef(char *, int);
 | 
				
			||||||
static void freelist(void);
 | 
					static void freelist(void);
 | 
				
			||||||
@@ -118,10 +118,10 @@ addkeydef(char *def, int flags)
 | 
				
			|||||||
		head = node;
 | 
							head = node;
 | 
				
			||||||
	if(parse_keydef(&node->keydef, def, flags))
 | 
						if(parse_keydef(&node->keydef, def, flags))
 | 
				
			||||||
		enprintf(2, "faulty key definition\n");
 | 
							enprintf(2, "faulty key definition\n");
 | 
				
			||||||
	if(curr)
 | 
						if(tail)
 | 
				
			||||||
		curr->next = node;
 | 
							tail->next = node;
 | 
				
			||||||
	node->next = NULL;
 | 
						node->next = NULL;
 | 
				
			||||||
	curr = node;
 | 
						tail = node;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
@@ -147,13 +147,10 @@ linecmp(const char **a, const char **b)
 | 
				
			|||||||
		s1 = columns((char *)*a, &node->keydef);
 | 
							s1 = columns((char *)*a, &node->keydef);
 | 
				
			||||||
		s2 = columns((char *)*b, &node->keydef);
 | 
							s2 = columns((char *)*b, &node->keydef);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* don't consider modifiers if it's the default key
 | 
							/* if -u is given, don't use default key definition
 | 
				
			||||||
		 * definition that was implicitly added */
 | 
							 * unless it is the only one */
 | 
				
			||||||
		/* if -u is given, don't use default */
 | 
							if(uflag && node == tail && head != tail)
 | 
				
			||||||
		if(uflag && !(node == head) && !node->next)
 | 
					 | 
				
			||||||
			res = 0;
 | 
								res = 0;
 | 
				
			||||||
		else if(!(node == head) && !node->next)
 | 
					 | 
				
			||||||
			res = strcmp(s1, s2);
 | 
					 | 
				
			||||||
		else if(node->keydef.flags & MOD_N)
 | 
							else if(node->keydef.flags & MOD_N)
 | 
				
			||||||
			res = strtol(s1, 0, 10) - strtol(s2, 0, 10);
 | 
								res = strtol(s1, 0, 10) - strtol(s2, 0, 10);
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user