summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2002-06-24 18:21:18 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2002-06-24 18:21:18 +0000
commit03105a5d6e148754606df7e654e98cce07ae00ac (patch)
treea761b20f868a38657d8a715efc44a6fba38c3a30
parent36765a58a66362673e9e0e5f05ba7ba4612c9c1a (diff)
downloadzsh-03105a5d6e148754606df7e654e98cce07ae00ac.tar.gz
zsh-03105a5d6e148754606df7e654e98cce07ae00ac.zip
17360: more lenient accept-line-and-down-history behaviour
17361: more careful about NULL history entries in zle
-rw-r--r--ChangeLog6
-rw-r--r--Src/Zle/zle_hist.c42
2 files changed, 32 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 31ed2fee3..99327d45b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2002-06-24 Peter Stephenson <pws@csr.com>
+ * 17361: Src/zle_hist.c: Be safer about NULL returns from
+ quietgethist() in case the history has been changed under our feet.
+
+ * 17360: Src/zle_hist.c: Allow accept-line-and-down-history to
+ accept the line even if there is no more history.
+
* 17350: Src/zle_params.c, Doc/Zsh/zle.yo: Add $CUTBUFFER and
$killring zle parameters.
diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c
index 5bea98b26..54da51710 100644
--- a/Src/Zle/zle_hist.c
+++ b/Src/Zle/zle_hist.c
@@ -48,7 +48,7 @@ void
remember_edits(void)
{
Histent ent = quietgethist(histline);
- if (metadiffer(ZLETEXT(ent), (char *) line, ll)) {
+ if (ent && metadiffer(ZLETEXT(ent), (char *) line, ll)) {
zsfree(ent->zle_text);
ent->zle_text = metafy((char *) line, ll, META_DUP);
}
@@ -248,13 +248,13 @@ downlineorsearch(char **args)
int
acceptlineanddownhistory(char **args)
{
- Histent he;
+ Histent he = quietgethist(histline);
- if (!(he = movehistent(quietgethist(histline), 1, HIST_FOREIGN)))
- return 1;
- zpushnode(bufstack, ztrdup(he->text));
+ if (he && (he = movehistent(he, 1, HIST_FOREIGN))) {
+ zpushnode(bufstack, ztrdup(he->text));
+ stackhist = he->histnum;
+ }
done = 1;
- stackhist = he->histnum;
return 0;
}
@@ -301,7 +301,8 @@ historysearchbackward(char **args)
str = srch_str;
hp = histpos;
}
- he = quietgethist(histline);
+ if (!(he = quietgethist(histline)))
+ return 1;
while ((he = movehistent(he, -1, hist_skip_flags))) {
if (isset(HISTFINDNODUPS) && he->flags & HIST_DUP)
continue;
@@ -349,7 +350,8 @@ historysearchforward(char **args)
str = srch_str;
hp = histpos;
}
- he = quietgethist(histline);
+ if (!(he = quietgethist(histline)))
+ return 1;
while ((he = movehistent(he, 1, hist_skip_flags))) {
if (isset(HISTFINDNODUPS) && he->flags & HIST_DUP)
continue;
@@ -578,7 +580,9 @@ setlocalhistory(char **args)
int
zle_goto_hist(int ev, int n, int skipdups)
{
- Histent he = movehistent(quietgethist(ev), n, hist_skip_flags);
+ Histent he = quietgethist(ev);
+ if (!he || !(he = movehistent(he, n, hist_skip_flags)))
+ return 1;
if (skipdups && n) {
n = n < 0? -1 : 1;
while (he && !metadiffer(ZLETEXT(he), (char *) line, ll))
@@ -752,11 +756,14 @@ doisearch(char **args, int dir)
int odir = dir, sens = zmult == 1 ? 3 : 1;
int hl = histline, savekeys = -1, feep = 0;
Thingy cmd;
- char *okeymap = ztrdup(curkeymapname);
+ char *okeymap;
static char *previous_search = NULL;
static int previous_search_len = 0;
Histent he;
+ if (!(he = quietgethist(hl)))
+ return;
+
clearlist = 1;
if (*args) {
@@ -770,7 +777,7 @@ doisearch(char **args, int dir)
strcpy(ibuf, ISEARCH_PROMPT);
memcpy(ibuf + NORM_PROMPT_POS, (dir == 1) ? "fwd" : "bck", 3);
remember_edits();
- he = quietgethist(hl);
+ okeymap = ztrdup(curkeymapname);
s = ZLETEXT(he);
selectkeymap("main", 1);
pos = metalen(s, cs);
@@ -1014,9 +1021,9 @@ acceptandinfernexthistory(char **args)
int
infernexthistory(char **args)
{
- Histent he;
+ Histent he = quietgethist(histline);
- if (!(he = infernexthist(quietgethist(histline), args)))
+ if (!he || !(he = infernexthist(he, args)))
return 1;
zle_setline(he);
return 0;
@@ -1200,7 +1207,8 @@ virepeatsearch(char **args)
visrchsense = -visrchsense;
}
t0 = strlen(visrchstr);
- he = quietgethist(histline);
+ if (!(he = quietgethist(histline)))
+ return 1;
while ((he = movehistent(he, visrchsense, hist_skip_flags))) {
if (isset(HISTFINDNODUPS) && he->flags & HIST_DUP)
continue;
@@ -1248,7 +1256,8 @@ historybeginningsearchbackward(char **args)
zmult = n;
return ret;
}
- he = quietgethist(histline);
+ if (!(he = quietgethist(histline)))
+ return 1;
while ((he = movehistent(he, -1, hist_skip_flags))) {
if (isset(HISTFINDNODUPS) && he->flags & HIST_DUP)
continue;
@@ -1284,7 +1293,8 @@ historybeginningsearchforward(char **args)
zmult = n;
return ret;
}
- he = quietgethist(histline);
+ if (!(he = quietgethist(histline)))
+ return 1;
while ((he = movehistent(he, 1, hist_skip_flags))) {
if (isset(HISTFINDNODUPS) && he->flags & HIST_DUP)
continue;