summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7a2cf03)
raw | patch | inline | side by side (parent: 7a2cf03)
author | Max Kellermann <max@duempel.org> | |
Mon, 22 Sep 2008 08:39:01 +0000 (10:39 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Mon, 22 Sep 2008 08:39:01 +0000 (10:39 +0200) |
Instead of checking for the sentinel at the end of the option table,
check the option_table_size constant.
check the option_table_size constant.
src/options.c | patch | blob | history |
diff --git a/src/options.c b/src/options.c
index 2c818279580f1c247df9e47e9e971f58c34deedd..dc0475c4d1be040e61bbd896f70190dcb4ca573f 100644 (file)
--- a/src/options.c
+++ b/src/options.c
{ 'K', "dump-keys", NULL, "Dump key bindings to stdout" },
{ 'D', "debug", NULL, "Enable debug output on stderr" },
#endif
- { 0, NULL, NULL, NULL },
};
+static const unsigned option_table_size = sizeof(option_table) / sizeof(option_table[0]);
+
static const arg_opt_t *
lookup_option(int s, char *l)
{
- int i;
+ unsigned i;
- i=0;
- while (option_table[i].descrition) {
+ for (i = 0; i < option_table_size; ++i) {
if (l && strcmp(l, option_table[i].longopt) == 0)
return &option_table[i];;
if (s && s == option_table[i].shortopt)
return &option_table[i];;
- i++;
}
return NULL;
static void
display_help(void)
{
- int i = 0;
+ unsigned i;
printf("Usage: %s [OPTION]...\n", PACKAGE);
- while (option_table[i].descrition) {
+
+ for (i = 0; i < option_table_size; ++i) {
char tmp[MAX_LONGOPT_LENGTH];
if (option_table[i].argument)