Skip to content

Commit

Permalink
cut: simplify getopt32 code
Browse files Browse the repository at this point in the history
Signed-off-by: Denys Vlasenko <[email protected]>
  • Loading branch information
Denys Vlasenko committed Dec 13, 2024
1 parent 7624077 commit d48400d
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions coreutils/cut.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,21 +291,18 @@ int cut_main(int argc UNUSED_PARAM, char **argv)
#endif

#define ARG "bcf"IF_FEATURE_CUT_REGEX("F")
#if !ENABLE_LONG_OPTS
opt = getopt32(argv, "^"
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)
);
#if ENABLE_LONG_OPTS
opt = getopt32long
#else
opt = getopt32long(argv, "^"
opt = getopt32
#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 */
"\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,
IF_LONG_OPTS(cut_longopts,)
&sopt, &sopt, &sopt, &delim, &odelim IF_FEATURE_CUT_REGEX(, &sopt)
);
#endif
);
if (!odelim)
odelim = (opt & OPT_REGEX) ? " " : delim;
if (!delim)
Expand Down

0 comments on commit d48400d

Please sign in to comment.