diff options
Diffstat (limited to 'contrib/less/main.c')
-rw-r--r-- | contrib/less/main.c | 85 |
1 files changed, 52 insertions, 33 deletions
diff --git a/contrib/less/main.c b/contrib/less/main.c index 44b217610778..4f8526b69225 100644 --- a/contrib/less/main.c +++ b/contrib/less/main.c @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* - * Copyright (C) 1984-2020 Mark Nudelman + * Copyright (C) 1984-2021 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -19,50 +19,49 @@ #include <windows.h> #endif -public char * every_first_cmd = NULL; -public int new_file; -public int is_tty; -public IFILE curr_ifile = NULL_IFILE; -public IFILE old_ifile = NULL_IFILE; +public char * every_first_cmd = NULL; +public int new_file; +public int is_tty; +public IFILE curr_ifile = NULL_IFILE; +public IFILE old_ifile = NULL_IFILE; public struct scrpos initial_scrpos; -public int any_display = FALSE; -public POSITION start_attnpos = NULL_POSITION; -public POSITION end_attnpos = NULL_POSITION; -public int wscroll; -public char * progname; -public int quitting; -public int secure; -public int dohelp; +public POSITION start_attnpos = NULL_POSITION; +public POSITION end_attnpos = NULL_POSITION; +public int wscroll; +public char * progname; +public int quitting; +public int secure; +public int dohelp; #if LOGFILE -public int logfile = -1; -public int force_logfile = FALSE; -public char * namelogfile = NULL; +public int logfile = -1; +public int force_logfile = FALSE; +public char * namelogfile = NULL; #endif #if EDITOR -public char * editor; -public char * editproto; +public char * editor; +public char * editproto; #endif #if TAGS -extern char * tags; -extern char * tagoption; -extern int jump_sline; +extern char * tags; +extern char * tagoption; +extern int jump_sline; #endif #ifdef WIN32 static char consoleTitle[256]; #endif -public int one_screen; -extern int less_is_more; -extern int missing_cap; -extern int know_dumb; -extern int no_init; -extern int pr_type; -extern int quit_if_one_screen; -extern int no_init; +public int one_screen; +extern int less_is_more; +extern int missing_cap; +extern int know_dumb; +extern int pr_type; +extern int quit_if_one_screen; +extern int no_init; +extern int errmsgs; /* @@ -84,10 +83,14 @@ main(argc, argv) progname = *argv++; argc--; +#if SECURE + secure = 1; +#else secure = 0; s = lgetenv("LESSSECURE"); if (!isnullenv(s)) secure = 1; +#endif #ifdef WIN32 if (getenv("HOME") == NULL) @@ -142,7 +145,7 @@ main(argc, argv) if (s != NULL) scan_option(save(s)); -#define isoptstring(s) less_is_more ? (((s)[0] == '-') && (s)[1] != '\0') : \ +#define isoptstring(s) less_is_more ? (((s)[0] == '-') && (s)[1] != '\0') : \ (((s)[0] == '-' || (s)[0] == '+') && (s)[1] != '\0') while (argc > 0 && (isoptstring(*argv) || isoptpending())) { @@ -228,6 +231,7 @@ main(argc, argv) * Output is not a tty. * Just copy the input file(s) to output. */ + set_output(1); /* write to stdout */ SET_BINARY(1); if (edit_first() == 0) { @@ -291,6 +295,18 @@ main(argc, argv) } } + if (errmsgs > 0) + { + /* + * We displayed some messages on error output + * (file descriptor 2; see flush()). + * Before erasing the screen contents, wait for a keystroke. + */ + less_printf("Press RETURN to continue ", NULL_PARG); + get_return(); + putchr('\n'); + } + set_output(1); init(); commands(); quit(QUIT_OK); @@ -340,7 +356,7 @@ ecalloc(count, size) skipsp(s) char *s; { - while (*s == ' ' || *s == '\t') + while (*s == ' ' || *s == '\t') s++; return (s); } @@ -397,10 +413,13 @@ quit(status) status = save_status; else save_status = status; +#if LESSTEST + rstat('Q'); +#endif /*LESSTEST*/ quitting = 1; edit((char*)NULL); save_cmdhist(); - if (any_display && is_tty) + if (interactive()) clear_bot(); deinit(); flush(); |