From 53dc99a76e73ff086db19e7da266c3b571b3cf87 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 2 Mar 2016 22:10:49 -0600 Subject: Minor cleanup. --- toys/pending/more.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'toys') 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 * - * 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; -- cgit v1.2.3