//config: bool "cat (5.6 kb)"
//config: default y
//config: help
-//config: cat is used to concatenate files and print them to the standard
-//config: output. Enable this option if you wish to enable the 'cat' utility.
+//config: cat is used to concatenate files and print them to the standard
+//config: output. Enable this option if you wish to enable the 'cat' utility.
//config:
//config:config FEATURE_CATN
//config: bool "Enable -n and -b options"
//config: default y
//config: depends on CAT
//config: help
-//config: -n numbers all output lines while -b numbers nonempty output lines.
+//config: -n numbers all output lines while -b numbers nonempty output lines.
//config:
//config:config FEATURE_CATV
//config: bool "cat -v[etA]"
//config: default y
//config: depends on CAT
//config: help
-//config: Display nonprinting characters as escape sequences
+//config: Display nonprinting characters as escape sequences
//applet:IF_CAT(APPLET(cat, BB_DIR_BIN, BB_SUID_DROP))
int retval = EXIT_SUCCESS;
int fd;
#if ENABLE_FEATURE_CATN
- unsigned lineno = 0;
- unsigned eol_char = (opts & (CAT_OPT_n|CAT_OPT_b)) ? '\n' : 0x100;
+ bool eol_seen = (opts & (CAT_OPT_n|CAT_OPT_b));
+ unsigned eol_char = (eol_seen ? '\n' : 0x100);
unsigned skip_num_on = (opts & CAT_OPT_b) ? '\n' : 0x100;
- bool eol_seen = 1;
+ unsigned lineno = 0;
#endif
BUILD_BUG_ON(CAT_OPT_e != VISIBLE_ENDLINE);
int cat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int cat_main(int argc UNUSED_PARAM, char **argv)
{
+#if ENABLE_FEATURE_CATV || ENABLE_FEATURE_CATN
unsigned opts;
- IF_FEATURE_CATV(opt_complementary = "Aetv"; /* -A == -vet */)
- /* -u is ignored ("unbuffered") */
- opts = getopt32(argv, IF_FEATURE_CATV("etvA") IF_FEATURE_CATN("nb") "u");
+ opts =
+#endif
+ getopt32(argv, IF_FEATURE_CATV("^")
+ /* -u is ignored ("unbuffered") */
+ IF_FEATURE_CATV("etvA")IF_FEATURE_CATN("nb")"u"
+ IF_FEATURE_CATV("\0" "Aetv" /* -A == -vet */)
+ );
argv += optind;
/* Read from stdin if there's nothing else to do. */