aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toys/pending/more.c17
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;