about summary refs log tree commit diff
path: root/Src/builtin.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2001-10-13 21:36:15 +0000
committerWayne Davison <wayned@users.sourceforge.net>2001-10-13 21:36:15 +0000
commit4dca92b451d05d262c70a709c4d7b515bd37d654 (patch)
treeb637911191aa614127c05ff71180d568bbd7c881 /Src/builtin.c
parent66fbad4372d9b33db6529e40fabb6813f7ec21da (diff)
downloadzsh-4dca92b451d05d262c70a709c4d7b515bd37d654.tar.gz
zsh-4dca92b451d05d262c70a709c4d7b515bd37d654.tar.xz
zsh-4dca92b451d05d262c70a709c4d7b515bd37d654.zip
Brought over patches 15806 and 15836 from the trunk.
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 65ff7da99..fa6fd16bd 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -1208,7 +1208,7 @@ printif(char *str, int c)
 int
 bin_fc(char *nam, char **argv, char *ops, int func)
 {
-    int first = -1, last = -1, retval, minflag = 0;
+    int first = -1, last = -1, retval;
     char *s;
     struct asgment *asgf = NULL, *asgl = NULL;
     Patprog pprog = NULL;
@@ -1267,7 +1267,6 @@ bin_fc(char *nam, char **argv, char *ops, int func)
     }
     /* interpret and check first history line specifier */
     if (*argv) {
-	minflag = **argv == '-';
 	first = fcgetcomm(*argv);
 	if (first == -1) {
 	    unqueue_signals();
@@ -1299,9 +1298,9 @@ bin_fc(char *nam, char **argv, char *ops, int func)
     if (last == -1)
 	last = ops['l']? addhistnum(curline.histnum,-1,0) : first;
     if (first < firsthist())
-	first = firsthist();
-    if (last == -1)
-	last = (minflag) ? curhist : first;
+	first = firsthist() - (last < firsthist());
+    if (last > curhist)
+	last = curhist;
     else if (last < first)
 	last = first;
     if (ops['l']) {
@@ -1365,13 +1364,11 @@ fcgetcomm(char *s)
 
     /* First try to match a history number.  Negative *
      * numbers indicate reversed numbering.           */
-    if ((cmd = atoi(s))) {
+    if ((cmd = atoi(s)) != 0 || *s == '0') {
 	if (cmd < 0)
 	    cmd = addhistnum(curline.histnum,cmd,HIST_FOREIGN);
-	if (cmd >= curline.histnum) {
-	    zwarnnam("fc", "bad history number: %d", 0, cmd);
-	    return -1;
-	}
+	if (cmd < 0)
+	    cmd = 0;
 	return cmd;
     }
     /* not a number, so search by string */