summaryrefslogtreecommitdiffstats
path: root/contrib/less/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/less/command.c')
-rw-r--r--contrib/less/command.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/contrib/less/command.c b/contrib/less/command.c
index 9b059ec..7c0d60b 100644
--- a/contrib/less/command.c
+++ b/contrib/less/command.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2002 Mark Nudelman
+ * Copyright (C) 1984-2005 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.
@@ -21,7 +21,7 @@
#include "option.h"
#include "cmd.h"
-extern int erase_char, kill_char;
+extern int erase_char, erase2_char, kill_char;
extern int sigs;
extern int quit_at_eof;
extern int quit_if_one_screen;
@@ -67,6 +67,7 @@ static char optchar;
static int optflag;
static int optgetname;
static POSITION bottompos;
+static int save_hshift;
#if PIPEC
static char pipec;
#endif
@@ -392,7 +393,9 @@ mca_char(c)
* Already have a match for the name.
* Don't accept anything but erase/kill.
*/
- if (c == erase_char || c == kill_char)
+ if (c == erase_char ||
+ c == erase2_char ||
+ c == kill_char)
return (MCA_DONE);
return (MCA_MORE);
}
@@ -403,7 +406,7 @@ mca_char(c)
if (cmd_char(c) == CC_QUIT)
return (MCA_DONE);
p = get_cmdbuf();
- lc = islower(p[0]);
+ lc = ASCII_IS_LOWER(p[0]);
o = findopt_name(&p, &oname, NULL);
if (o != NULL)
{
@@ -413,15 +416,15 @@ mca_char(c)
* display the full option name.
*/
optchar = o->oletter;
- if (!lc && islower(optchar))
- optchar = toupper(optchar);
+ if (!lc && ASCII_IS_LOWER(optchar))
+ optchar = ASCII_TO_UPPER(optchar);
cmd_reset();
mca_opt_toggle();
for (p = oname; *p != '\0'; p++)
{
c = *p;
- if (!lc && islower(c))
- c = toupper(c);
+ if (!lc && ASCII_IS_LOWER(c))
+ c = ASCII_TO_UPPER(c);
if (cmd_char(c) != CC_OK)
return (MCA_DONE);
}
@@ -430,7 +433,7 @@ mca_char(c)
}
} else
{
- if (c == erase_char || c == kill_char)
+ if (c == erase_char || c == erase2_char || c == kill_char)
break;
if (optchar != '\0')
/* We already have the option letter. */
@@ -598,7 +601,10 @@ prompt()
bottompos = position(BOTTOM_PLUS_ONE);
/*
- * If the -E flag is set and we've hit EOF on the last file, quit.
+ * If we've hit EOF on the last file, and the -E flag is set
+ * (or -F is set and this is the first prompt), then quit.
+ * {{ Relying on "first prompt" to detect a single-screen file
+ * fails if +G is used, for example. }}
*/
if ((quit_at_eof == OPT_ONPLUS || quit_if_one_screen) &&
hit_eof && !(ch_getflags() & CH_HELPFILE) &&
@@ -627,13 +633,13 @@ prompt()
*/
clear_cmd();
p = pr_string();
- if (p == NULL)
+ if (p == NULL || *p == '\0')
putchr(':');
else
{
- so_enter();
+ at_enter(AT_STANDOUT);
putstr(p);
- so_exit();
+ at_exit();
}
}
@@ -826,6 +832,9 @@ multi_search(pattern, n)
* Restore the file we were originally viewing.
*/
reedit_ifile(save_ifile);
+ } else
+ {
+ unsave_ifile(save_ifile);
}
}
@@ -1211,6 +1220,7 @@ commands()
* just means return to viewing the
* previous file.
*/
+ hshift = save_hshift;
if (edit_prev(1) == 0)
break;
}
@@ -1300,6 +1310,8 @@ commands()
if (ch_getflags() & CH_HELPFILE)
break;
cmd_exec();
+ save_hshift = hshift;
+ hshift = 0;
(void) edit(FAKE_HELPFILE);
break;
@@ -1340,9 +1352,8 @@ commands()
}
if (curr_altfilename != NULL)
{
- error("Cannot edit file processed with LESSOPEN",
+ error("WARNING: This file was viewed via LESSOPEN",
NULL_PARG);
- break;
}
start_mca(A_SHELL, "!", ml_shell, 0);
/*
@@ -1524,8 +1535,8 @@ commands()
break;
start_mca(A_SETMARK, "mark: ", (void*)NULL, 0);
c = getcc();
- if (c == erase_char || c == kill_char ||
- c == '\n' || c == '\r')
+ if (c == erase_char || c == erase2_char ||
+ c == kill_char || c == '\n' || c == '\r')
break;
setmark(c);
break;
@@ -1536,8 +1547,8 @@ commands()
*/
start_mca(A_GOMARK, "goto mark: ", (void*)NULL, 0);
c = getcc();
- if (c == erase_char || c == kill_char ||
- c == '\n' || c == '\r')
+ if (c == erase_char || c == erase2_char ||
+ c == kill_char || c == '\n' || c == '\r')
break;
gomark(c);
break;
@@ -1551,7 +1562,7 @@ commands()
}
start_mca(A_PIPE, "|mark: ", (void*)NULL, 0);
c = getcc();
- if (c == erase_char || c == kill_char)
+ if (c == erase_char || c == erase2_char || c == kill_char)
break;
if (c == '\n' || c == '\r')
c = '.';
OpenPOWER on IntegriCloud