summaryrefslogtreecommitdiffstats
path: root/contrib/less
diff options
context:
space:
mode:
authorps <ps@FreeBSD.org>2000-05-23 05:51:17 +0000
committerps <ps@FreeBSD.org>2000-05-23 05:51:17 +0000
commit4f86a08dc712d931c98124b30e0d97d63fc21649 (patch)
tree870fabd51c68a3aec2554ef44a5bd75293c9fbae /contrib/less
parentd00f222c77a8ab0c3c81f9d60defbbec4eb69be7 (diff)
downloadFreeBSD-src-4f86a08dc712d931c98124b30e0d97d63fc21649.zip
FreeBSD-src-4f86a08dc712d931c98124b30e0d97d63fc21649.tar.gz
Make less act like more(1) when it is invoked as more.
Obtained from: NetBSD
Diffstat (limited to 'contrib/less')
-rw-r--r--contrib/less/command.c10
-rw-r--r--contrib/less/forwback.c11
-rw-r--r--contrib/less/main.c19
-rw-r--r--contrib/less/screen.c15
-rw-r--r--contrib/less/search.c4
5 files changed, 49 insertions, 10 deletions
diff --git a/contrib/less/command.c b/contrib/less/command.c
index 95c529f..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[];
@@ -468,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 */
diff --git a/contrib/less/forwback.c b/contrib/less/forwback.c
index 722bce55..d8071aa 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();
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/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 f533527..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,6 +53,7 @@ extern int linenums;
extern int sc_height;
extern int jump_sline;
extern int bs_mode;
+extern int more_mode;
extern POSITION start_attnpos;
extern POSITION end_attnpos;
#if HILITE_SEARCH
OpenPOWER on IntegriCloud