diff options
author | Rob Landley <rob@landley.net> | 2016-03-02 22:10:49 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2016-03-02 22:10:49 -0600 |
commit | 53dc99a76e73ff086db19e7da266c3b571b3cf87 (patch) | |
tree | bea00c81f2ddfda741781a4fe0e0ff64e7c3a667 /toys | |
parent | 0dfa601b9fec5191269702cdd037adf25814ab19 (diff) | |
download | toybox-53dc99a76e73ff086db19e7da266c3b571b3cf87.tar.gz |
Minor cleanup.
Diffstat (limited to 'toys')
-rw-r--r-- | toys/pending/more.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/toys/pending/more.c b/toys/pending/more.c index f0e79079..55bed363 100644 --- a/toys/pending/more.c +++ b/toys/pending/more.c @@ -2,17 +2,17 @@ * * Copyright 2013 Bilal Qureshi <bilal.jmi@gmail.com> * - * No Standard + * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/more.html -USE_MORE(NEWTOY(more, NULL, TOYFLAG_USR|TOYFLAG_BIN)) +USE_MORE(NEWTOY(more, 0, TOYFLAG_USR|TOYFLAG_BIN)) config MORE bool "more" default n help - usage: more [FILE]... + usage: more [FILE...] - View FILE (or stdin) one screenful at a time. + View FILE(s) (or stdin) one screenful at a time. */ #define FOR_more @@ -62,10 +62,8 @@ static int prompt(FILE *cin, const char* fmt, ...) static void do_cat_operation(int fd, char *name) { - char *buf = NULL; - if (toys.optc > 1) show_file_header(name); - for (; (buf = get_line(fd)); free(buf)) printf("%s\n", buf); + xsendfile(0, 1); } void more_main() @@ -76,7 +74,7 @@ void more_main() struct termios newf; FILE *fp, *cin; - if (!isatty(STDOUT_FILENO) || !(cin = fopen("/dev/tty", "r"))) { + if (!isatty(1) || !(cin = fopen("/dev/tty", "r"))) { loopfiles(toys.optargs, do_cat_operation); return; } @@ -125,7 +123,8 @@ void more_main() } putchar(ch); - if (ch == '\t') col = (col | 0x7) + 1; else col++; + if (ch == '\t') col = (col | 0x7) + 1; + else col++; if (col == cols) putchar(ch = '\n'); if (ch == '\n') { col = 0; |