From a1f1da90fdc9689a6599fce2bfca27f6fc8d7bc0 Mon Sep 17 00:00:00 2001 From: "Steffen (Daode) Nurpmeso" Date: Fri, 4 Jul 2014 17:46:12 +0200 Subject: [PATCH] `un{,save,fwd}{ignore,retain}': let '*' mean 'all fields' --- cmd2.c | 73 ++++++++++++++++++++++++++++++++++++++++----------------------- cmd_tab.h | 6 +++--- nail.1 | 6 ++++++ 3 files changed, 56 insertions(+), 29 deletions(-) diff --git a/cmd2.c b/cmd2.c index c493e69d..3475227a 100644 --- a/cmd2.c +++ b/cmd2.c @@ -67,8 +67,10 @@ static int igshow(struct ignoretab *tab, char const *which); /* Compare two names for sorting ignored field list */ static int igcomp(void const *l, void const *r); -static void unignore_one(char const *name, struct ignoretab *tab); -static int unignore1(char **list, struct ignoretab *tab, char const *which); +/* */ +static int _unignore(char **list, struct ignoretab *tab, char const *which); +static void __unign_all(struct ignoretab *tab); +static void __unign_one(struct ignoretab *tab, char const *name); static int save1(char *str, int domark, char const *cmd, struct ignoretab *ignoret, @@ -402,8 +404,44 @@ igcomp(void const *l, void const *r) return rv; } +static int +_unignore(char **list, struct ignoretab *tab, char const *which) +{ + char *field; + NYD_ENTER; + + if (tab->i_count == 0) + printf(_("No fields currently being %s.\n"), which); + else + while ((field = *list++) != NULL) + if (field[0] == '*' && field[1] == '\0') { + __unign_all(tab); + break; + } else + __unign_one(tab, field); + NYD_LEAVE; + return 0; +} + +static void +__unign_all(struct ignoretab *tab) +{ + size_t i; + struct ignore *n, *x; + NYD_ENTER; + + for (i = 0; i < NELEM(tab->i_head); ++i) + for (n = tab->i_head[i]; n != NULL; n = x) { + x = n->i_link; + free(n->i_field); + free(n); + } + memset(tab, 0, sizeof *tab); + NYD_LEAVE; +} + static void -unignore_one(char const *name, struct ignoretab *tab) +__unign_one(struct ignoretab *tab, char const *name) { struct ignore *ip, *iq; int h; @@ -426,23 +464,6 @@ unignore_one(char const *name, struct ignoretab *tab) NYD_LEAVE; } -static int -unignore1(char **list, struct ignoretab *tab, char const *which) -{ - NYD_ENTER; - - if (tab->i_count == 0) { - printf(_("No fields currently being %s.\n"), which); - goto jleave; - } - - while (*list != NULL) - unignore_one(*list++, tab); -jleave: - NYD_LEAVE; - return 0; -} - FL int c_next(void *v) { @@ -764,7 +785,7 @@ c_unignore(void *v) int rv; NYD_ENTER; - rv = unignore1((char**)v, ignore, "ignored"); + rv = _unignore((char**)v, ignore, "ignored"); NYD_LEAVE; return rv; } @@ -775,7 +796,7 @@ c_unretain(void *v) int rv; NYD_ENTER; - rv = unignore1((char**)v, ignore + 1, "retained"); + rv = _unignore((char**)v, ignore + 1, "retained"); NYD_LEAVE; return rv; } @@ -786,7 +807,7 @@ c_unsaveignore(void *v) int rv; NYD_ENTER; - rv = unignore1((char**)v, saveignore, "ignored"); + rv = _unignore((char**)v, saveignore, "ignored"); NYD_LEAVE; return rv; } @@ -797,7 +818,7 @@ c_unsaveretain(void *v) int rv; NYD_ENTER; - rv = unignore1((char**)v, saveignore + 1, "retained"); + rv = _unignore((char**)v, saveignore + 1, "retained"); NYD_LEAVE; return rv; } @@ -808,7 +829,7 @@ c_unfwdignore(void *v) int rv; NYD_ENTER; - rv = unignore1((char**)v, fwdignore, "ignored"); + rv = _unignore((char**)v, fwdignore, "ignored"); NYD_LEAVE; return rv; } @@ -819,7 +840,7 @@ c_unfwdretain(void *v) int rv; NYD_ENTER; - rv = unignore1((char**)v, fwdignore + 1, "retained"); + rv = _unignore((char**)v, fwdignore + 1, "retained"); NYD_LEAVE; return rv; } diff --git a/cmd_tab.h b/cmd_tab.h index c484b3b6..5628f8aa 100644 --- a/cmd_tab.h +++ b/cmd_tab.h @@ -236,11 +236,11 @@ { "alternates", &c_alternates, (M | RAWLIST), 0, 1000 DS(N_("Show or define an alternate list for the invoking user")) }, { "ignore", &c_igfield, (M | RAWLIST), 0, 1000 - DS(N_("Add header fields to ignored LIST), or show that list")) }, + DS(N_("Add to the ignored LIST, or show that list")) }, { "discard", &c_igfield, (M | RAWLIST), 0, 1000 - DS(N_("Add header fields to ignored LIST), or show that list")) }, + DS(N_("Add to the ignored LIST, or show that list")) }, { "retain", &c_retfield, (M | RAWLIST), 0, 1000 - DS(N_("Add header fields to retained LIST), or show that list")) }, + DS(N_("Add to retained list, or show that list")) }, { "saveignore", &c_saveigfield, (M | RAWLIST), 0, 1000 DS("Is to \"save\" what \"ignore\" is to \"type\"/\"print\"") }, { "savediscard", &c_saveigfield, (M | RAWLIST), 0, 1000 diff --git a/nail.1 b/nail.1 index 00ab2e0b..2d9e005c 100644 --- a/nail.1 +++ b/nail.1 @@ -2274,15 +2274,18 @@ Takes a message list and marks each message as not being Removes the header field names from the list of ignored fields for the .Ic forward command. +The special name `*' will remove all fields. .It Ic unfwdretain Removes the header field names from the list of retained fields for the .Ic forward command. +The special name `*' will remove all fields. .It Ic unghost Remove an existing command .Ic ghost . .It Ic unignore Removes the header field names from the list of ignored fields. +The special name `*' will remove all fields. .It Ic Unread Same as .Ic unread . @@ -2290,12 +2293,15 @@ Same as (U) Takes a message list and marks each message as not having been read. .It Ic unretain Removes the header field names from the list of retained fields. +The special name `*' will remove all fields. .It Ic unsaveignore Removes the header field names from the list of ignored fields for saving. +The special name `*' will remove all fields. .It Ic unsaveretain Removes the header field names from the list of retained fields for saving. +The special name `*' will remove all fields. .It Ic unset Takes a list of option names and discards their remembered values; the inverse of -- 2.11.4.GIT