llist_add_to(&tar_handle->accept, argv[optind]);
optind++;
}
- tar_handle->accept = rev_llist(tar_handle->accept);
+ tar_handle->accept = llist_rev(tar_handle->accept);
if (tar_handle->accept || tar_handle->reject)
tar_handle->filter = filter_accept_reject_list;
{
FILE *fp, *outfile = stdout;
char *line, **lines = NULL;
- char *str_ignored, *str_o, *str_k, *str_t;
+ char *str_ignored, *str_o, *str_t;
+ llist_t *lst_k = NULL;
int i, flag;
int linecount = 0;
/* Parse command line options */
/* -o and -t can be given at most once */
- opt_complementary = "?:o--o:t--t";
- getopt32(argc, argv, OPT_STR, &str_ignored, &str_ignored, &str_o, &str_k, &str_t);
+ opt_complementary = "?:o--o:t--t:" /* -t, -o: maximum one of each */
+ "k::"; /* -k takes list */
+ getopt32(argc, argv, OPT_STR, &str_ignored, &str_ignored, &str_o, &lst_k, &str_t);
#if ENABLE_FEATURE_SORT_BIG
if (option_mask32 & FLAG_o) outfile = xfopen(str_o, "w");
if (option_mask32 & FLAG_t) {
key_separator = str_t[0];
}
/* parse sort key */
- if (option_mask32 & FLAG_k) {
+ lst_k = llist_rev(lst_k);
+ while (lst_k) {
enum {
FLAG_allowed_for_k =
FLAG_n | /* Numeric sort */
0
};
struct sort_key *key = add_key();
+ char *str_k = lst_k->data;
const char *temp2;
i = 0; /* i==0 before comma, 1 after (-k3,6) */
str_k++;
}
}
+ /* leaking lst_k... */
+ lst_k = lst_k->link;
}
#endif
/* global b strips leading and trailing spaces */
extern void llist_add_to_end(llist_t **list_head, void *data);
extern void *llist_pop(llist_t **elm);
extern void llist_free(llist_t *elm, void (*freeit)(void *data));
-extern llist_t* rev_llist(llist_t *list);
+extern llist_t* llist_rev(llist_t *list);
enum {
LOGMODE_NONE = 0,