Merge remote-tracking branch 'goog/mnc-dev-plus-aosp' into mm
diff --git a/.config b/.config
index 6eb9daa..d32351e 100644
--- a/.config
+++ b/.config
@@ -18,6 +18,7 @@
CONFIG_CAL=y
CONFIG_CAT=y
CONFIG_CAT_V=y
+# CONFIG_CATV is not set
CONFIG_CHGRP=y
CONFIG_CHOWN=y
CONFIG_CHMOD=y
diff --git a/generated/config.h b/generated/config.h
index 9e14105..9127751 100644
--- a/generated/config.h
+++ b/generated/config.h
@@ -20,6 +20,8 @@
#define USE_CAT(...) __VA_ARGS__
#define CFG_CAT_V 1
#define USE_CAT_V(...) __VA_ARGS__
+#define CFG_CATV 0
+#define USE_CATV(...)
#define CFG_CHGRP 1
#define USE_CHGRP(...) __VA_ARGS__
#define CFG_CHOWN 1
diff --git a/generated/flags.h b/generated/flags.h
index c4f1e55..be77bbd 100644
--- a/generated/flags.h
+++ b/generated/flags.h
@@ -143,6 +143,17 @@
#undef FLAG_u
#endif
+// catv vte
+#undef OPTSTR_catv
+#define OPTSTR_catv 0
+#ifdef CLEANUP_catv
+#undef CLEANUP_catv
+#undef FOR_catv
+#undef FLAG_e
+#undef FLAG_t
+#undef FLAG_v
+#endif
+
// cd
#undef OPTSTR_cd
#define OPTSTR_cd 0
@@ -2792,6 +2803,15 @@
#define FLAG_u (1<<3)
#endif
+#ifdef FOR_catv
+#ifndef TT
+#define TT this.catv
+#endif
+#define FLAG_e (FORCED_FLAG<<0)
+#define FLAG_t (FORCED_FLAG<<1)
+#define FLAG_v (FORCED_FLAG<<2)
+#endif
+
#ifdef FOR_cd
#ifndef TT
#define TT this.cd
diff --git a/generated/help.h b/generated/help.h
index 041da12..b3ebf6f 100644
--- a/generated/help.h
+++ b/generated/help.h
@@ -492,6 +492,8 @@
#define help_chgrp "usage: chgrp/chown [-RHLP] [-fvh] group file...\n\nChange group of one or more files.\n\n-f suppress most error messages.\n-h change symlinks instead of what they point to\n-R recurse into subdirectories (implies -h).\n-H with -R change target of symlink, follow command line symlinks\n-L with -R change target of symlink, follow all symlinks\n-P with -R change symlink, do not follow symlinks (default)\n-v verbose output.\n\n"
+#define help_catv "usage: catv [-evt] [filename...]\n\nDisplay nonprinting characters as escape sequences. Use M-x for\nhigh ascii characters (>127), and ^x for other nonprinting chars.\n\n-e Mark each newline with $\n-t Show tabs as ^I\n-v Don't use ^x or M-x escapes.\n\n"
+
#define help_cat "usage: cat [-etuv] [file...]\n\nCopy (concatenate) files to stdout. If no files listed, copy from stdin.\nFilename \"-\" is a synonym for stdin.\n\n-e Mark each newline with $\n-t Show tabs as ^I\n-u Copy one byte at a time (slow).\n-v Display nonprinting characters as escape sequences. Use M-x for\n high ascii characters (>127), and ^x for other nonprinting chars.\n"
#define help_cal "usage: cal [[month] year]\n\nPrint a calendar.\n\nWith one argument, prints all months of the specified year.\nWith two arguments, prints calendar for month and year.\n\n"
diff --git a/generated/newtoys.h b/generated/newtoys.h
index 2636b2b..5302bda 100644
--- a/generated/newtoys.h
+++ b/generated/newtoys.h
@@ -14,6 +14,7 @@
USE_BZCAT(NEWTOY(bzcat, NULL, TOYFLAG_USR|TOYFLAG_BIN))
USE_CAL(NEWTOY(cal, ">2", TOYFLAG_USR|TOYFLAG_BIN))
USE_CAT(NEWTOY(cat, "u"USE_CAT_V("vte"), TOYFLAG_BIN))
+USE_CATV(NEWTOY(catv, USE_CATV("vte"), TOYFLAG_USR|TOYFLAG_BIN))
USE_SH(NEWTOY(cd, NULL, TOYFLAG_NOFORK))
USE_CHATTR(NEWTOY(chattr, NULL, TOYFLAG_BIN))
USE_CHCON(NEWTOY(chcon, "<2hvR", TOYFLAG_USR|TOYFLAG_BIN))
diff --git a/toys/pending/more.c b/toys/pending/more.c
index 59392ff..f0e7907 100644
--- a/toys/pending/more.c
+++ b/toys/pending/more.c
@@ -53,6 +53,7 @@
input_key = tolower(getc(cin));
printf("\33[0m\33[1K\r"); // Reset all attributes, erase to start of line.
if (strchr(" \nrq", input_key)) {
+ fflush(NULL);
return input_key;
}
printf("\33[7m(Enter:Next line Space:Next page Q:Quit R:Show the rest)");
@@ -95,8 +96,8 @@
do {
fp = stdin;
if (*toys.optargs && !(fp = fopen(*toys.optargs, "r"))) {
- perror_msg("'%s'", *toys.optargs);
- continue;
+ perror_msg("%s", *toys.optargs);
+ goto next_file;
}
st.st_size = show_prompt = col = row = 0;
fstat(fileno(fp), &st);
@@ -133,6 +134,7 @@
}
fclose(fp);
+next_file:
if (*toys.optargs && *++toys.optargs) {
input_key = prompt(cin, "--More--(Next file: %s)", *toys.optargs);
if (input_key == 'q') goto stop;
diff --git a/toys/posix/cat.c b/toys/posix/cat.c
index 07de074..01134a7 100644
--- a/toys/posix/cat.c
+++ b/toys/posix/cat.c
@@ -8,7 +8,7 @@
* http://cm.bell-labs.com/cm/cs/doc/84/kp.ps.gz
USE_CAT(NEWTOY(cat, "u"USE_CAT_V("vte"), TOYFLAG_BIN))
-#USE_CATV(NEWTOY(catv, USE_CATV("vte"), TOYFLAG_USR|TOYFLAG_BIN))
+USE_CATV(NEWTOY(catv, USE_CATV("vte"), TOYFLAG_USR|TOYFLAG_BIN))
config CAT
bool "cat"
@@ -23,7 +23,7 @@
config CAT_V
bool "cat -etv"
- default y
+ default n
depends on CAT
help
usage: cat [-evt]
@@ -32,15 +32,10 @@
-t Show tabs as ^I
-v Display nonprinting characters as escape sequences. Use M-x for
high ascii characters (>127), and ^x for other nonprinting chars.
-*/
-
-/*
-todo:
config CATV
bool "catv"
default y
- depends on !CAT_V
help
usage: catv [-evt] [filename...]
@@ -53,6 +48,7 @@
*/
#define FOR_cat
+#define FORCE_FLAGS
#include "toys.h"
static void do_cat(int fd, char *name)
@@ -63,7 +59,7 @@
len = read(fd, toybuf, size);
if (len < 0) toys.exitval = EXIT_FAILURE;
if (len < 1) break;
- if (CFG_CAT_V && (toys.optflags&~FLAG_u)) {
+ if ((CFG_CAT_V || CFG_CATV) && (toys.optflags&~FLAG_u)) {
for (i=0; i<len; i++) {
char c=toybuf[i];
@@ -96,14 +92,8 @@
loopfiles(toys.optargs, do_cat);
}
-//todo:
-//void catv_main(void)
-//{
-// toys.optflags ^= FLAG_v;
-// loopfiles(toys.optargs, do_catv);
-//}
-
-// The common infrastructure is testing FLAG_h which is only defined in cat
-// context (not catv), but catv can't use cat's flag context if cat is disabled
-// and its flags are zero. Need to upgrade flag parsing infrastructure so
-// defining FORCE_FLAGS along with FOR_command doesn't zero unused flag macros.
+void catv_main(void)
+{
+ toys.optflags ^= FLAG_v;
+ loopfiles(toys.optargs, do_cat);
+}