summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@fb.com>2013-10-21 07:39:00 -0700
committerJim Meyering <meyering@fb.com>2013-10-24 13:47:46 -0700
commit85e31d5a24018df78b6607dd82d4556936cac8df (patch)
tree8a9d3246f188e273e118e88ce8eb0d63a1e18b53
parenta181ed9a6778c313dda49b7d7921e4d700bb1d52 (diff)
downloadgrep-85e31d5a24018df78b6607dd82d4556936cac8df.tar.gz
maint: clean up an ugly 'while' condition
* src/main.c (get_nondigit_option): Separate a slightly baroque "while" expression into two separate statements, both inside the loop.
-rw-r--r--src/main.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 974cf911..d9c7759f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1746,16 +1746,20 @@ static int
get_nondigit_option (int argc, char *const *argv, intmax_t *default_context)
{
static int prev_digit_optind = -1;
- int opt, this_digit_optind, was_digit;
+ int this_digit_optind, was_digit;
char buf[INT_BUFSIZE_BOUND (intmax_t) + 4];
char *p = buf;
+ int opt;
was_digit = 0;
this_digit_optind = optind;
- while (opt = getopt_long (argc, (char **) argv, short_options, long_options,
- NULL),
- '0' <= opt && opt <= '9')
+ while (1)
{
+ opt = getopt_long (argc, (char **) argv, short_options,
+ long_options, NULL);
+ if ( ! ('0' <= opt && opt <= '9'))
+ break;
+
if (prev_digit_optind != this_digit_optind || !was_digit)
{
/* Reset to start another context length argument. */