-/* Copyright (c) 1979 Regents of the University of California */
+static char *sccsid = "@(#)sh.hist.c 4.1 10/9/80";
+
#include "sh.h"
/*
{
freelex(&hp->Hlex);
- xfree(hp);
+ xfree((char *)hp);
}
-dohist()
+dohist(vp)
+ char **vp;
{
+ int n, rflg = 0;
if (getn(value("history")) == 0)
return;
- dohist1(Histlist.Hnext);
+ if (setintr)
+ sigrelse(SIGINT);
+ vp++;
+ if (*vp && eq(*vp, "-r")) {
+ rflg++;
+ vp++;
+ }
+ if (*vp)
+ n = getn(*vp);
+ else
+ n = 1000;
+ dohist1(Histlist.Hnext, &n, rflg);
}
-dohist1(hp)
- register struct Hist *hp;
+dohist1(hp, np, rflg)
+ struct Hist *hp;
+ int *np;
{
-
+ bool print = (*np) > 0;
+top:
if (hp == 0)
return;
+ (*np)--;
hp->Href++;
- dohist1(hp->Hnext);
- phist(hp);
+ if (rflg == 0) {
+ dohist1(hp->Hnext, np, rflg);
+ if (print)
+ phist(hp);
+ return;
+ }
+ if (*np >= 0)
+ phist(hp);
+ hp = hp->Hnext;
+ goto top;
}
phist(hp)