From: Sami Kerola Date: Sat, 22 Jan 2011 21:50:14 +0000 (+0100) Subject: Do not analyze if sort field selector is rubbish. X-Git-Tag: v2.14~9 X-Git-Url: http://git.asbjorn.it/?p=debian%2Fdhcpd-pools.git;a=commitdiff_plain;h=9cc94f1b9fe10aea33295e8baae048c2b201f0e1 Do not analyze if sort field selector is rubbish. Error message also had a bug, it's changed to be over all more helpful. Signed-off-by: Sami Kerola --- diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index ef18faa..7c07170 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -122,6 +122,9 @@ int main(int argc, char **argv) strncpy(config.sort, optarg, (size_t) sorts); } + for (i = 0; i < sorts; i++) { + field_selector(config.sort[i]); + } break; case 'r': /* What ever sort in reverse order */ @@ -181,7 +184,7 @@ int main(int argc, char **argv) output_analysis = output_csv; break; default: - errx(EXIT_FAILURE, "main: unknown ouput format `%c'", + errx(EXIT_FAILURE, "main: unknown output format `%c'", config.output_format[0]); } diff --git a/src/sort.c b/src/sort.c index 40ecad4..8f769e3 100644 --- a/src/sort.c +++ b/src/sort.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "dhcpd-pools.h" @@ -117,9 +118,9 @@ void field_selector(char c) returner = ret_tcperc; break; default: - errx(EXIT_FAILURE, - "field_selector: unknown sort order `%c'", - config.sort[0]); + warnx("field_selector: unknown sort order `%c'", c); + errx(EXIT_FAILURE, "Try `%s --help' for more information.", + program_invocation_short_name); } }