X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/9530ace10a49d62c80c95914601fa9246099501b..78211e93:/uip/new.c?ds=inline diff --git a/uip/new.c b/uip/new.c index 254950b2..e88a0dd7 100644 --- a/uip/new.c +++ b/uip/new.c @@ -21,17 +21,19 @@ #include #include -static struct swit switches[] = { -#define MODESW 0 - { "mode", 1 }, -#define FOLDERSSW 1 - { "folders", 1 }, -#define VERSIONSW 2 - { "version", 1 }, -#define HELPSW 3 - { "help", 1 }, - { NULL, 0 } -}; +#define NEW_SWITCHES \ + X("mode", 1, MODESW) \ + X("folders", 1, FOLDERSSW) \ + X("version", 1, VERSIONSW) \ + X("help", 1, HELPSW) \ + +#define X(sw, minchars, id) id, +DEFINE_SWITCH_ENUM(NEW); +#undef X + +#define X(sw, minchars, id) { sw, minchars, id }, +DEFINE_SWITCH_ARRAY(NEW, switches); +#undef X static enum { NEW, FNEXT, FPREV, UNSEEN } run_mode = NEW; @@ -218,6 +220,8 @@ crawl_callback(char *folder, void *baton) * `cur' points to the name of the current folder, `folders' points to the * name of a .folder (if NULL, crawl all folders), and `sequences' points to * the array of sequences for which to look. + * + * An empty list is returned as first=last=NULL. */ static void check_folders(struct node **first, struct node **last, @@ -229,7 +233,7 @@ check_folders(struct node **first, struct node **last, char *line; size_t len; - *first = *cur_node = NULL; + *first = *last = *cur_node = NULL; *maxlen = 0; b.first = first; @@ -406,6 +410,9 @@ main(int argc, char **argv) char *unseen; struct node *folder; + sequences[0] = NULL; + sequences[1] = NULL; + #ifdef LOCALE setlocale(LC_ALL, ""); #endif @@ -433,10 +440,10 @@ main(int argc, char **argv) snprintf (help, sizeof(help), "%s [switches] [sequences]", invo_name); print_help (help, switches, 1); - done (1); + done (0); case VERSIONSW: print_version(invo_name); - done (1); + done (0); case FOLDERSSW: if (!(folders = *argp++) || *folders == '-') @@ -452,6 +459,7 @@ main(int argc, char **argv) /* have a sequence argument */ if (!seq_in_list(cp, sequences)) { sequences[i++] = cp; + sequences[i] = NULL; } }