diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-02-22 01:15:47 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-02-22 01:15:47 +0000 |
commit | 859f41a3da90bf66c5b58864da3407f8a9fd0b67 (patch) | |
tree | d20a5e4a07ec079ffd40ee587b12a0b65fdf2eb4 /utility.c | |
parent | 6f3149cdebebccdb9677afe960bf3a44cd61e27a (diff) | |
download | busybox-w32-859f41a3da90bf66c5b58864da3407f8a9fd0b67.tar.gz busybox-w32-859f41a3da90bf66c5b58864da3407f8a9fd0b67.tar.bz2 busybox-w32-859f41a3da90bf66c5b58864da3407f8a9fd0b67.zip |
Another update to the way usage messages are done by Evin Robertson
<nitfol@my-deja.com>, which makes things just a little bit smaller, but makes
usage.h more readable/maintainable IMHO.
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@1879 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'utility.c')
-rw-r--r-- | utility.c | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -54,7 +54,6 @@ | |||
54 | #define bb_need_full_version | 54 | #define bb_need_full_version |
55 | #define BB_DECLARE_EXTERN | 55 | #define BB_DECLARE_EXTERN |
56 | #include "messages.c" | 56 | #include "messages.c" |
57 | #include "usage.h" | ||
58 | 57 | ||
59 | #include "pwd_grp/pwd.h" | 58 | #include "pwd_grp/pwd.h" |
60 | #include "pwd_grp/grp.h" | 59 | #include "pwd_grp/grp.h" |
@@ -81,21 +80,20 @@ static struct BB_applet *applet_using; | |||
81 | 80 | ||
82 | extern void show_usage(void) | 81 | extern void show_usage(void) |
83 | { | 82 | { |
84 | static const char no_help[] = "No help available.\n"; | 83 | const char *format_string; |
85 | 84 | const char *usage_string = usage_messages; | |
86 | const char *usage_string = no_help; | ||
87 | int i; | 85 | int i; |
88 | 86 | ||
89 | if (applet_using->usage_index >= 0) { | 87 | for (i = applet_using - applets; i > 0; ) { |
90 | usage_string = usage_messages; | 88 | if (!*usage_string++) { |
91 | for (i=applet_using->usage_index ; i>0 ; ) { | 89 | --i; |
92 | if (!*usage_string++) { | ||
93 | --i; | ||
94 | } | ||
95 | } | 90 | } |
96 | } | 91 | } |
97 | fprintf(stderr, "%s\n\nUsage: %s %s\n\n", full_version, | 92 | format_string = "%s\n\nUsage: %s %s\n\n"; |
98 | applet_using->name, usage_string); | 93 | if(*usage_string == 0) |
94 | format_string = "%s\n\nNo help available.\n\n"; | ||
95 | fprintf(stderr, format_string, | ||
96 | full_version, applet_using->name, usage_string); | ||
99 | exit(EXIT_FAILURE); | 97 | exit(EXIT_FAILURE); |
100 | } | 98 | } |
101 | 99 | ||