diff options
Diffstat (limited to 'contrib/less')
-rw-r--r-- | contrib/less/command.c | 17 | ||||
-rw-r--r-- | contrib/less/forwback.c | 14 | ||||
-rw-r--r-- | contrib/less/less.h | 17 | ||||
-rw-r--r-- | contrib/less/main.c | 19 | ||||
-rw-r--r-- | contrib/less/prompt.c | 3 | ||||
-rw-r--r-- | contrib/less/screen.c | 15 | ||||
-rw-r--r-- | contrib/less/search.c | 8 | ||||
-rw-r--r-- | contrib/less/signal.c | 4 |
8 files changed, 62 insertions, 35 deletions
diff --git a/contrib/less/command.c b/contrib/less/command.c index d898ed1..b3fbedb 100644 --- a/contrib/less/command.c +++ b/contrib/less/command.c @@ -1,3 +1,4 @@ +/* $FreeBSD$ */ /* * Copyright (C) 1984-2000 Mark Nudelman * @@ -35,6 +36,7 @@ extern int ignore_eoi; extern int secure; extern int hshift; extern int show_attn; +extern int more_mode; extern char *every_first_cmd; extern char *curr_altfilename; extern char version[]; @@ -50,7 +52,6 @@ extern char *editor; extern char *editproto; #endif extern int screen_trashed; /* The screen has been overwritten */ -extern int shift_count; static char ungot[UNGOT_SIZE]; static char *ungotp = NULL; @@ -469,12 +470,16 @@ mca_char(c) flag = 0; switch (c) { - case CONTROL('E'): /* ignore END of file */ case '*': + if (more_mode) + break; + case CONTROL('E'): /* ignore END of file */ flag = SRCH_PAST_EOF; break; - case CONTROL('F'): /* FIRST file */ case '@': + if (more_mode) + break; + case CONTROL('F'): /* FIRST file */ flag = SRCH_FIRST_FILE; break; case CONTROL('K'): /* KEEP position */ @@ -1503,8 +1508,7 @@ commands() case A_LSHIFT: if (number <= 0) - number = (shift_count > 0) ? - shift_count : sc_width / 2; + number = 8; if (number > hshift) number = hshift; hshift -= number; @@ -1513,8 +1517,7 @@ commands() case A_RSHIFT: if (number <= 0) - number = (shift_count > 0) ? - shift_count : sc_width / 2; + number = 8; hshift += number; screen_trashed = 1; break; diff --git a/contrib/less/forwback.c b/contrib/less/forwback.c index 722bce55..e110507 100644 --- a/contrib/less/forwback.c +++ b/contrib/less/forwback.c @@ -1,3 +1,4 @@ +/* $FreeBSD$ */ /* * Copyright (C) 1984-2000 Mark Nudelman * @@ -27,6 +28,7 @@ extern int top_scroll; extern int quiet; extern int sc_width, sc_height; extern int quit_at_eof; +extern int more_mode; extern int plusoption; extern int forw_scroll; extern int back_scroll; @@ -142,9 +144,12 @@ forw(n, pos, force, only_last, nblank) pos_clear(); add_forw_pos(pos); force = 1; - if (top_scroll == OPT_ONPLUS || first_time) - clear(); - home(); + if (more_mode == 0) + { + if (top_scroll == OPT_ONPLUS || first_time) + clear(); + home(); + } } else { clear_bot(); @@ -228,7 +233,8 @@ forw(n, pos, force, only_last, nblank) * start the display after the beginning of the file, * and it is not appropriate to squish in that case. */ - if (first_time && pos == NULL_POSITION && !top_scroll && + if ((first_time || more_mode) && + pos == NULL_POSITION && !top_scroll && #if TAGS tagoption == NULL && #endif diff --git a/contrib/less/less.h b/contrib/less/less.h index 2063558..1b446b5 100644 --- a/contrib/less/less.h +++ b/contrib/less/less.h @@ -1,3 +1,4 @@ +/* $FreeBSD$ */ /* * Copyright (C) 1984-2000 Mark Nudelman * @@ -140,7 +141,7 @@ void free(); * Special types and constants. */ typedef off_t POSITION; -#define PR_POSITION "%ld" +#define PR_POSITION "%lld" #define MAX_PRINT_POSITION 20 #define MAX_PRINT_INT 10 @@ -359,20 +360,6 @@ struct textlist #define LSIGNAL(sig,func) signal(sig,func) #endif -#if HAVE_SIGPROCMASK -#if HAVE_SIGSET_T -#else -#undef HAVE_SIGPROCMASK -#endif -#endif -#if HAVE_SIGPROCMASK -#if HAVE_SIGEMPTYSET -#else -#undef sigemptyset -#define sigemptyset(mp) *(mp) = 0 -#endif -#endif - #define S_INTERRUPT 01 #define S_STOP 02 #define S_WINCH 04 diff --git a/contrib/less/main.c b/contrib/less/main.c index 2c69d87..9f5e1c3 100644 --- a/contrib/less/main.c +++ b/contrib/less/main.c @@ -1,3 +1,4 @@ +/* $FreeBSD$ */ /* * Copyright (C) 1984-2000 Mark Nudelman * @@ -29,6 +30,7 @@ public char * progname; public int quitting; public int secure; public int dohelp; +public int more_mode = 0; #if LOGFILE public int logfile = -1; @@ -60,6 +62,7 @@ main(argc, argv) { IFILE ifile; char *s; + extern char *__progname; #ifdef __EMX__ _response(&argc, &argv); @@ -99,6 +102,9 @@ main(argc, argv) * Process command line arguments and LESS environment arguments. * Command line arguments override environment arguments. */ + if (strcmp(__progname, "more") == 0) + more_mode = 1; + is_tty = isatty(1); get_term(); init_cmds(); @@ -106,7 +112,16 @@ main(argc, argv) init_charset(); init_line(); init_option(); - s = lgetenv("LESS"); + + if (more_mode) { + scan_option("-E"); + scan_option("-m"); + scan_option("-G"); + scan_option("-f"); + s = lgetenv("MORE"); + } else { + s = lgetenv("LESS"); + } if (s != NULL) scan_option(save(s)); @@ -197,7 +212,7 @@ main(argc, argv) quit(QUIT_OK); } - if (missing_cap && !know_dumb) + if (missing_cap && !know_dumb && !more_mode) error("WARNING: terminal is not fully functional", NULL_PARG); init_mark(); raw_mode(1); diff --git a/contrib/less/prompt.c b/contrib/less/prompt.c index 1448021..14f8ac4 100644 --- a/contrib/less/prompt.c +++ b/contrib/less/prompt.c @@ -1,3 +1,4 @@ +/* $FreeBSD$ */ /* * Copyright (C) 1984-2000 Mark Nudelman * @@ -111,7 +112,7 @@ ap_pos(pos) { char buf[MAX_PRINT_POSITION]; - sprintf(buf, PR_POSITION, pos); + sprintf(buf, PR_POSITION, (long long)pos); ap_str(buf); } diff --git a/contrib/less/screen.c b/contrib/less/screen.c index 20aa81a..cd3d885 100644 --- a/contrib/less/screen.c +++ b/contrib/less/screen.c @@ -1,3 +1,4 @@ +/* $FreeBSD$ */ /* * Copyright (C) 1984-2000 Mark Nudelman * @@ -223,6 +224,8 @@ extern int quiet; /* If VERY_QUIET, use visual bell for bell */ extern int no_back_scroll; extern int swindow; extern int no_init; +extern int quit_at_eof; +extern int more_mode; extern int sigs; extern int wscroll; extern int screen_trashed; @@ -1108,11 +1111,19 @@ get_term() if (sc_e_keypad == NULL) sc_e_keypad = ""; - sc_init = ltgetstr("ti", &sp); + /* + * This loses for terminals with termcap entries with ti/te strings + * that switch to/from an alternate screen, and we're in quit_at_eof + * (eg, more(1)). + */ + if (!quit_at_eof && !more_mode) { + sc_init = ltgetstr("ti", &sp); + sc_deinit = ltgetstr("te", &sp); + } + if (sc_init == NULL) sc_init = ""; - sc_deinit= ltgetstr("te", &sp); if (sc_deinit == NULL) sc_deinit = ""; diff --git a/contrib/less/search.c b/contrib/less/search.c index 1aff4df..030bdab 100644 --- a/contrib/less/search.c +++ b/contrib/less/search.c @@ -1,3 +1,4 @@ +/* $FreeBSD$ */ /* * Copyright (C) 1984-2000 Mark Nudelman * @@ -22,7 +23,7 @@ #if HAVE_POSIX_REGCOMP #include <regex.h> #ifdef REG_EXTENDED -#define REGCOMP_FLAG REG_EXTENDED +#define REGCOMP_FLAG (more_mode ? 0 : REG_EXTENDED) #else #define REGCOMP_FLAG 0 #endif @@ -52,7 +53,7 @@ extern int linenums; extern int sc_height; extern int jump_sline; extern int bs_mode; -extern int status_col; +extern int more_mode; extern POSITION start_attnpos; extern POSITION end_attnpos; #if HILITE_SEARCH @@ -510,8 +511,7 @@ is_hilited(pos, epos, nohide) { struct hilite *hl; - if (!status_col && - start_attnpos != NULL_POSITION && + if (start_attnpos != NULL_POSITION && pos < end_attnpos && (epos == NULL_POSITION || epos > start_attnpos)) /* diff --git a/contrib/less/signal.c b/contrib/less/signal.c index f044980..708f212 100644 --- a/contrib/less/signal.c +++ b/contrib/less/signal.c @@ -8,6 +8,7 @@ * contact the author, see the README file. */ +/* $FreeBSD$ */ /* * Routines dealing with signals. @@ -33,6 +34,7 @@ extern int lnloop; extern int linenums; extern int wscroll; extern int reading; +extern int more_mode; /* * Interrupt signal handler. @@ -56,6 +58,8 @@ u_interrupt(type) if (kbhit()) getkey(); #endif + if (more_mode) + quit(0); if (reading) intread(); } |