Quizzer

 view release on metacpan or  search on metacpan

exercises/compile-tcsh/tcsh-6.10.00/sh.hist.c  view on Meta::CPAN

    }
    else {
	np->Hlex.next = lp->next;
	lp->next->prev = &np->Hlex;
	np->Hlex.prev = lp->prev;
	lp->prev->next = &np->Hlex;
	np->histline = NULL;
    }
    if (mflg)
      {
        while ((p = pp->Hnext) && (p->Htime > np->Htime))
	  pp = p;
	while (p && p->Htime == np->Htime)
	  {
	    if (heq(&p->Hlex, &np->Hlex))
	      {
	        eventno--;
		hfree(np);
	        return (p);
	      }
	    pp = p;
	    p = p->Hnext;
	  }
	for (p = Histlist.Hnext; p != pp->Hnext; p = p->Hnext)
	  {
	    n = p->Hnum; r = p->Href;
	    p->Hnum = np->Hnum; p->Href = np->Href;
	    np->Hnum = n; np->Href = r;
	  }
      }
    np->Hnext = pp->Hnext;
    pp->Hnext = np;
    return (np);
}

static void
hfree(hp)
    register struct Hist *hp;
{

    freelex(&hp->Hlex);
    if (hp->histline)
	xfree((ptr_t) hp->histline);
    xfree((ptr_t) hp);
}


/*ARGSUSED*/
void
dohist(vp, c)
    Char  **vp;
    struct command *c;
{
    int     n, hflg = 0;

    USE(c);
    if (getn(varval(STRhistory)) == 0)
	return;
    if (setintr)
#ifdef BSDSIGS
	(void) sigsetmask(sigblock((sigmask_t) 0) & ~sigmask(SIGINT));
#else
	(void) sigrelse(SIGINT);
#endif
    while (*++vp && **vp == '-') {
	Char   *vp2 = *vp;

	while (*++vp2)
	    switch (*vp2) {
	    case 'c':
		hflg |= HIST_CLEAR;
		break;
	    case 'h':
		hflg |= HIST_ONLY;
		break;
	    case 'r':
		hflg |= HIST_REV;
		break;
	    case 'S':
		hflg |= HIST_SAVE;
		break;
	    case 'L':
		hflg |= HIST_LOAD;
		break;
	    case 'M':
	    	hflg |= HIST_MERGE;
		break;
	    case 'T':
	    	hflg |= HIST_TIME;
		break;
	    default:
		stderror(ERR_HISTUS, "chrSLMT");
		break;
	    }
    }

    if (hflg & HIST_CLEAR) {
	struct Hist *np, *hp;
	for (hp = &Histlist; (np = hp->Hnext) != NULL;)
	    hp->Hnext = np->Hnext, hfree(np);
    }

    if (hflg & (HIST_LOAD | HIST_MERGE)) {
	loadhist(*vp, (hflg & HIST_MERGE) ? 1 : 0);
	return;
    }
    else if (hflg & HIST_SAVE) {
	rechist(*vp, 1);
	return;
    }
    if (*vp)
	n = getn(*vp);
    else {
	n = getn(varval(STRhistory));
    }
    dohist1(Histlist.Hnext, &n, hflg);
}

static void
dohist1(hp, np, hflg)
    struct Hist *hp;



( run in 0.758 second using v1.01-cache-2.11-cpan-364913b4093 )