cut: simplify getopt32 code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
7624077772
commit
d48400d8fb
1 changed files with 10 additions and 13 deletions
|
@ -291,21 +291,18 @@ int cut_main(int argc UNUSED_PARAM, char **argv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ARG "bcf"IF_FEATURE_CUT_REGEX("F")
|
#define ARG "bcf"IF_FEATURE_CUT_REGEX("F")
|
||||||
#if !ENABLE_LONG_OPTS
|
#if ENABLE_LONG_OPTS
|
||||||
opt = getopt32(argv, "^"
|
opt = getopt32long
|
||||||
OPT_STR // = "b:c:f:d:O:sD"IF_FEATURE_CUT_REGEX("F:")"n"
|
|
||||||
"\0" "b--"ARG":c--"ARG":f--"ARG IF_FEATURE_CUT_REGEX("F--"ARG),
|
|
||||||
&sopt, &sopt, &sopt, &delim, &odelim IF_FEATURE_CUT_REGEX(, &sopt)
|
|
||||||
);
|
|
||||||
#else
|
#else
|
||||||
opt = getopt32long(argv, "^"
|
opt = getopt32
|
||||||
OPT_STR // = "b:c:f:d:O:sD"IF_FEATURE_CUT_REGEX("F:")"n"
|
|
||||||
"\0" "b:c:f:"IF_FEATURE_CUT_REGEX("F:") /* one of -bcfF is required */
|
|
||||||
"b--"ARG":c--"ARG":f--"ARG IF_FEATURE_CUT_REGEX(":F--"ARG), /* they are mutually exclusive */
|
|
||||||
cut_longopts,
|
|
||||||
&sopt, &sopt, &sopt, &delim, &odelim IF_FEATURE_CUT_REGEX(, &sopt)
|
|
||||||
);
|
|
||||||
#endif
|
#endif
|
||||||
|
(argv, "^"
|
||||||
|
OPT_STR // = "b:c:f:d:O:sD"IF_FEATURE_CUT_REGEX("F:")"n"
|
||||||
|
"\0" "b:c:f:" IF_FEATURE_CUT_REGEX("F:") /* one of -bcfF is required */
|
||||||
|
"b--"ARG":c--"ARG":f--"ARG IF_FEATURE_CUT_REGEX(":F--"ARG), /* they are mutually exclusive */
|
||||||
|
IF_LONG_OPTS(cut_longopts,)
|
||||||
|
&sopt, &sopt, &sopt, &delim, &odelim IF_FEATURE_CUT_REGEX(, &sopt)
|
||||||
|
);
|
||||||
if (!odelim)
|
if (!odelim)
|
||||||
odelim = (opt & OPT_REGEX) ? " " : delim;
|
odelim = (opt & OPT_REGEX) ? " " : delim;
|
||||||
if (!delim)
|
if (!delim)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue