diff options
author | fielding <fielding@13f79535-47bb-0310-9956-ffa450edef68> | 2001-01-28 08:59:15 +0000 |
---|---|---|
committer | fielding <fielding@13f79535-47bb-0310-9956-ffa450edef68> | 2001-01-28 08:59:15 +0000 |
commit | 2e41957ecaa7ef1b7037f4862d31870a67416e49 (patch) | |
tree | b7c9414161bde561bc73cb0b338515f3f30e5b1e /misc/unix/getopt.c | |
parent | f99c9d8877b4c046f045d26e17288d02b22a1906 (diff) | |
download | libapr-2e41957ecaa7ef1b7037f4862d31870a67416e49.tar.gz |
Eliminate warning and redundant exit conditions.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@61147 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'misc/unix/getopt.c')
-rw-r--r-- | misc/unix/getopt.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/misc/unix/getopt.c b/misc/unix/getopt.c index b3b065b97..7d8e11275 100644 --- a/misc/unix/getopt.c +++ b/misc/unix/getopt.c @@ -209,7 +209,7 @@ APR_DECLARE(apr_status_t) apr_getopt_long(apr_getopt_t *os, int *optch, const char **optarg) { const char *p; - int i, len; + int i; /* Let the calling program reset option processing. */ if (os->reset) { @@ -239,15 +239,17 @@ APR_DECLARE(apr_status_t) apr_getopt_long(apr_getopt_t *os, p = os->argv[os->ind++] + 1; if (*p == '-' && p[1] != '\0') { /* Long option */ /* Search for the long option name in the caller's table. */ + int len = 0; + p++; - for (i = 0; opts[i].optch != 0; i++) { + for (i = 0; ; i++) { + if (opts[i].optch == 0) /* No match */ + return serr(os, "invalid option", p - 2, APR_BADCH); len = strlen(opts[i].name); if (strncmp(p, opts[i].name, len) == 0 && (p[len] == '\0' || p[len] == '=')) break; } - if (opts[i].optch == 0) /* No match */ - return serr(os, "invalid option", p - 2, APR_BADCH); *optch = opts[i].optch; if (opts[i].has_arg) { @@ -277,12 +279,12 @@ APR_DECLARE(apr_status_t) apr_getopt_long(apr_getopt_t *os, * Now we're in a run of short options, and *p is the next one. * Look for it in the caller's table. */ - for (i = 0; opts[i].optch != 0; i++) { + for (i = 0; ; i++) { + if (opts[i].optch == 0) /* No match */ + return cerr(os, "invalid option character", *p, APR_BADCH); if (*p == opts[i].optch) break; } - if (opts[i].optch == 0) /* No match */ - return cerr(os, "invalid option character", *p, APR_BADCH); *optch = *p++; if (opts[i].has_arg) { |