diff options
author | Miles Bader <miles@gnu.org> | 1997-05-15 21:46:13 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1997-05-15 21:46:13 +0000 |
commit | fc3abdaf3b37e721339eb67e02e0fb15dace17b4 (patch) | |
tree | 56eb218464795c0c06bdb71f6a5c55aa93fdeb9e /utils | |
parent | e608af332323a053bea3ee29b6ebfa1ea2b1a09b (diff) |
(_parse_strlist, parse_strlist, parse_numlist):
Functions removed.
Include "parse.h".
Diffstat (limited to 'utils')
-rw-r--r-- | utils/ps.c | 100 |
1 files changed, 1 insertions, 99 deletions
@@ -33,6 +33,7 @@ #include <version.h> #include "psout.h" +#include "parse.h" const char *argp_program_version = STANDARD_HURD_VERSION (ps); @@ -181,105 +182,6 @@ spec_abbrevs[] = { static struct ps_fmt_specs ps_specs = { spec_abbrevs, &ps_std_fmt_specs }; -/* For each string in the comma-separated list in ARG, call ADD_FN; if ARG is - empty and DEFAULT_ADD_FN isn't NULL, then call DEFAULT_ADD_FN instead. */ -static void -_parse_strlist (char *arg, - void (*add_fn)(const char *str), void (*default_add_fn)(), - const char *type_name) -{ - if (arg) - while (isspace(*arg)) - arg++; - - if (arg == NULL || *arg == '\0') - if (default_add_fn) - (*default_add_fn)(); - else - error(7, 0, "Empty %s list", type_name); - else - { - char *end = arg; - - void mark_end() - { - *end++ = '\0'; - while (isspace(*end)) - end++; - } - void parse_element() - { - if (*arg == '\0') - error(7, 0, "Empty element in %s list", type_name); - (*add_fn)(arg); - arg = end; - } - - while (*end != '\0') - switch (*end) - { - case ' ': case '\t': - mark_end(); - if (*end == ',') - mark_end(); - parse_element(); - break; - case ',': - mark_end(); - parse_element(); - break; - default: - end++; - } - - parse_element(); - } -} - -/* For each string in the comma-separated list in ARG, call ADD_FN; if ARG is - empty and DEFAULT_FN isn't NULL, then call ADD_FN on the resutl of calling - DEFAULT_FN instead, otherwise signal an error. */ -static void -parse_strlist (char *arg, - void (*add_fn)(const char *str), - const char *(*default_fn)(), - const char *type_name) -{ - void default_str_add() { (*add_fn)((*default_fn)()); } - _parse_strlist(arg, add_fn, default_str_add, type_name); -} - -/* For each numeric string in the comma-separated list in ARG, call ADD_FN; - if ARG is empty and DEFAULT_FN isn't NULL, then call DEF_FN to get a number, - and call ADD_FN on that, otherwise signal an error. If any member of the - list isn't a number, and LOOKUP_FN isn't NULL, then it is called to return - an integer for the string. LOOKUP_FN should signal an error itself it - there's some problem parsing the string. */ -static void -parse_numlist (char *arg, - void (*add_fn)(unsigned num), - int (*default_fn)(), - int (*lookup_fn)(const char *str), - const char *type_name) -{ - void default_num_add() { (*add_fn)((*default_fn)()); } - void add_num_str(const char *str) - { - const char *p; - for (p = str; *p != '\0'; p++) - if (!isdigit(*p)) - { - if (lookup_fn) - (*add_fn)((*lookup_fn)(str)); - else - error (7, 0, "%s: Invalid %s", p, type_name); - return; - } - (*add_fn)(atoi(str)); - } - _parse_strlist(arg, add_num_str, default_fn ? default_num_add : 0, - type_name); -} static process_t proc_server; |