[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 8/8] getargs: minor simplification
From: |
Akim Demaille |
Subject: |
[PATCH 8/8] getargs: minor simplification |
Date: |
Thu, 14 Feb 2013 15:11:12 +0100 |
* src/getargs.c (flag_argmatch): Simplify the handling of "none".
---
src/getargs.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/src/getargs.c b/src/getargs.c
index fd96fe1..82c1298 100644
--- a/src/getargs.c
+++ b/src/getargs.c
@@ -84,23 +84,19 @@ flag_argmatch (const char *option,
const char * const keys[], const int values[],
int all, int *flags, char *arg, size_t no)
{
- int value = 0;
- value = XARGMATCH (option, arg + no, keys, values);
+ int value = XARGMATCH (option, arg + no, keys, values);
- if (value)
+ /* -rnone == -rno-all, and -rno-none == -rall. */
+ if (!value)
{
- if (no)
- *flags &= ~value;
- else
- *flags |= value;
+ value = all;
+ no = !no;
}
+
+ if (no)
+ *flags &= ~value;
else
- {
- if (no)
- *flags |= all;
- else
- *flags &= ~all;
- }
+ *flags |= value;
}
/** Decode an option's set of keys.
--
1.8.1.3
- [PATCH 0/8] {master} revamp the handling of -W, Akim Demaille, 2013/02/14
- [PATCH 5/8] options: simplify the handling of -W, Akim Demaille, 2013/02/14
- [PATCH 8/8] getargs: minor simplification,
Akim Demaille <=
- [PATCH 4/8] options: don't accept "error=" for -f and -r, Akim Demaille, 2013/02/14
- [PATCH 2/8] diagnostics: no longer pretty-print rules in error messages, carets suffice, Akim Demaille, 2013/02/14
- [PATCH 6/8] diagnostics: revamp the handling of -Werror, Akim Demaille, 2013/02/14
- [PATCH 7/8] style: more argument handling of -W into the diagnostics module, Akim Demaille, 2013/02/14
- [PATCH 3/8] diagnostics: factor the list of warning names, Akim Demaille, 2013/02/14
- [PATCH 1/8] options: no longer document warnings when diagnosing an invalid -W, Akim Demaille, 2013/02/14
- Re: [PATCH 0/8] {master} revamp the handling of -W, Akim Demaille, 2013/02/16