⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rlog.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 3 页
字号:
                Locks = plocked;            }            plocked = nextlocked;        }}	static voidrecentdate(root, pd)	struct hshentry const *root;	struct Datepairs *pd;/*  function:  Finds the delta that is closest to the cutoff date given by   *//*             pd among the revisions selected by exttree.                   *//*             Successively narrows down the interval given by pd,           *//*             and sets the strtdate of pd to the date of the selected delta */{	struct branchhead const *newbranch;	if ( root == nil) return;	if (root->selector) {             if ( cmpnum(root->date, pd->strtdate) >= 0 &&                  cmpnum(root->date, pd->enddate) <= 0)		VOID strcpy(pd->strtdate, root->date);        }        recentdate(root->next, pd);        newbranch = root->branches;        while( newbranch) {           recentdate(newbranch->hsh, pd);           newbranch = newbranch->nextbranch;	}}	static unsignedextdate(root)struct  hshentry        * root;/*  function:  select revisions which are in the date range specified     *//*             in duelst  and datelist, start at root                     *//* Yield number of revisions selected, including those already selected.  */{	struct branchhead const *newbranch;	struct Datepairs const *pdate;	unsigned revno;	if (!root)	    return 0;        if ( datelist || duelst) {            pdate = datelist;            while( pdate ) {                if ( (pdate->strtdate)[0] == '\0' || cmpnum(root->date,pdate->strtdate) >= 0){                   if ((pdate->enddate)[0] == '\0' || cmpnum(pdate->enddate,root->date) >= 0)                        break;                }                pdate = pdate->dnext;            }            if ( pdate == nil) {                pdate = duelst;		for (;;) {		   if (!pdate) {			root->selector = false;			break;		   }                   if ( cmpnum(root->date, pdate->strtdate) == 0)                      break;                   pdate = pdate->dnext;                }            }        }	revno = root->selector + extdate(root->next);        newbranch = root->branches;        while( newbranch ) {	   revno += extdate(newbranch->hsh);           newbranch = newbranch->nextbranch;        }	return revno;}	static charextractdelta(pdelta)	struct hshentry const *pdelta;/*  function:  compare information of pdelta to the authorlist, lockerlist,*//*             statelist, revlist and yield true if pdelta is selected.    */{	struct lock const *plock;	struct stateattri const *pstate;	struct authors const *pauthor;	struct Revpairs const *prevision;	unsigned length;	if ((pauthor = authorlist)) /* only certain authors wanted */	    while (strcmp(pauthor->login, pdelta->author) != 0)		if (!(pauthor = pauthor->nextauthor))		    return false;	if ((pstate = statelist)) /* only certain states wanted */	    while (strcmp(pstate->status, pdelta->state) != 0)		if (!(pstate = pstate->nextstate))		    return false;	if (lockflag) /* only locked revisions wanted */	    for (plock = Locks;  ;  plock = plock->nextlock)		if (!plock)		    return false;		else if (plock->delta == pdelta)		    break;	if ((prevision = Revlst)) /* only certain revs or branches wanted */	    for (;;) {                length = prevision->numfld;		if (		    countnumflds(pdelta->num) == length+(length&1) &&		    0 <= compartial(pdelta->num, prevision->strtrev, length) &&		    0 <= compartial(prevision->endrev, pdelta->num, length)		)		     break;		if (!(prevision = prevision->rnext))		    return false;            }	return true;}	static voidgetdatepair(argv)   char   * argv;/*  function:  get time range from command line and store in datelist if    *//*             a time range specified or in duelst if a time spot specified */{        register   char         c;        struct     Datepairs    * nextdate;	char const		* rawdate;	int                     switchflag;        argv--;        while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' ||                 c == '\n' || c == ';')  ;        if ( c == '\0' ) {	    warn("missing date/time after -d");            return;        }        while( c != '\0' )  {	    switchflag = false;	    nextdate = talloc(struct Datepairs);            if ( c == '<' ) {   /*   case: -d <date   */                c = *++argv;                (nextdate->strtdate)[0] = '\0';	    } else if (c == '>') { /* case: -d'>date' */		c = *++argv;		(nextdate->enddate)[0] = '\0';		switchflag = true;	    } else {                rawdate = argv;		while( c != '<' && c != '>' && c != ';' && c != '\0')		     c = *++argv;                *argv = '\0';		if ( c == '>' ) switchflag=true;		str2date(rawdate,			 switchflag ? nextdate->enddate : nextdate->strtdate);		if ( c == ';' || c == '\0') {  /*  case: -d date  */		    VOID strcpy(nextdate->enddate,nextdate->strtdate);                    nextdate->dnext = duelst;                    duelst = nextdate;		    goto end;		} else {		    /*   case:   -d date<  or -d  date>; see switchflag */		    while ( (c= *++argv) == ' ' || c=='\t' || c=='\n');		    if ( c == ';' || c == '\0') {			/* second date missing */			if (switchflag)			    *nextdate->strtdate= '\0';			else			    *nextdate->enddate= '\0';			nextdate->dnext = datelist;			datelist = nextdate;			goto end;		    }                }            }            rawdate = argv;	    while( c != '>' && c != '<' && c != ';' && c != '\0') 		c = *++argv;            *argv = '\0';	    str2date(rawdate,		     switchflag ? nextdate->strtdate : nextdate->enddate);            nextdate->dnext = datelist;	    datelist = nextdate;     end:	    if ( c == '\0')  return;            while( (c = *++argv) == ';' || c == ' ' || c == '\t' || c =='\n');        }}	static voidgetnumericrev()/*  function:  get the numeric name of revisions which stored in revlist  *//*             and then stored the numeric names in Revlst                *//*             if branchflag, also add default branch                     */{        struct  Revpairs        * ptr, *pt;	unsigned n;	struct buf s, e;	char const *lrev;	struct buf const *rstart, *rend;        Revlst = nil;        ptr = revlist;	bufautobegin(&s);	bufautobegin(&e);        while( ptr ) {	    n = 0;	    rstart = &s;	    rend = &e;	    switch (ptr->numfld) {	      case 1: /* -r rev */		if (expandsym(ptr->strtrev, &s)) {		    rend = &s;		    n = countnumflds(s.string);		    if (!n  &&  (lrev = tiprev())) {			bufscpy(&s, lrev);			n = countnumflds(lrev);		    }                }		break;	      case 2: /* -r rev- */		if (expandsym(ptr->strtrev, &s)) {		    bufscpy(&e, s.string);		    n = countnumflds(s.string);		    (n<2 ? e.string : strrchr(e.string,'.'))[0]  =  0;                }		break;	      case 3: /* -r -rev */		if (expandsym(ptr->endrev, &e)) {		    if ((n = countnumflds(e.string)) < 2)			bufscpy(&s, ".1");		    else {			bufscpy(&s, e.string);			VOID strcpy(strrchr(s.string,'.'), ".1");		    }                }		break;	      default: /* -r rev1-rev2 */		if (			expandsym(ptr->strtrev, &s)		    &&	expandsym(ptr->endrev, &e)		    &&	checkrevpair(s.string, e.string)		) {		    n = countnumflds(s.string);		    /* Swap if out of order.  */		    if (compartial(s.string,e.string,n) > 0) {			rstart = &e;			rend = &s;		    }		}		break;	    }	    if (n) {		pt = ftalloc(struct Revpairs);		pt->numfld = n;		pt->strtrev = fstr_save(rstart->string);		pt->endrev = fstr_save(rend->string);                pt->rnext = Revlst;                Revlst = pt;	    }	    ptr = ptr->rnext;        }        /* Now take care of branchflag */	if (branchflag && (Dbranch||Head)) {	    pt = ftalloc(struct Revpairs);	    pt->strtrev = pt->endrev =		Dbranch ? Dbranch : fstr_save(partialno(&s,Head->num,1));	    pt->rnext=Revlst; Revlst=pt;	    pt->numfld = countnumflds(pt->strtrev);        }	bufautoend(&s);	bufautoend(&e);}	static intcheckrevpair(num1,num2)	char const *num1, *num2;/*  function:  check whether num1, num2 are legal pair,i.e.    only the last field are different and have same number of    fields( if length <= 2, may be different if first field)   */{	unsigned length = countnumflds(num1);	if (			countnumflds(num2) != length		||	2 < length  &&  compartial(num1, num2, length-1) != 0	) {	    error("invalid branch or revision pair %s : %s", num1, num2);            return false;        }        return true;}	static voidgetrevpairs(argv)register     char    * argv;/*  function:  get revision or branch range from command line, and   *//*             store in revlist                                      */{        register    char    c;        struct      Revpairs  * nextrevpair;	int separator;	c = *argv;	/* Support old ambiguous '-' syntax; this will go away.  */	if (strchr(argv,':'))	    separator = ':';	else {	    if (strchr(argv,'-')  &&  VERSION(5) <= RCSversion)		warn("`-' is obsolete in `-r%s'; use `:' instead", argv);	    separator = '-';	}	for (;;) {	    while (c==' ' || c=='\t' || c=='\n')		c = *++argv;	    nextrevpair = talloc(struct Revpairs);            nextrevpair->rnext = revlist;            revlist = nextrevpair;	    nextrevpair->numfld = 1;	    nextrevpair->strtrev = argv;	    for (;;  c = *++argv) {		switch (c) {		    default:			continue;		    case '\0': case ' ': case '\t': case '\n':		    case ',': case ';':			break;		    case ':': case '-':			if (c == separator)			    break;			continue;		}		break;	    }	    *argv = '\0';	    while (c==' ' || c=='\t' || c=='\n')		c = *++argv;	    if (c == separator) {                while( (c =(*++argv)) == ' ' || c == '\t' || c =='\n') ;		nextrevpair->endrev = argv;		for (;;  c = *++argv) {		    switch (c) {			default:			    continue;			case '\0': case ' ': case '\t': case '\n':			case ',': case ';':			    break;			case ':': case '-':			    if (c == separator)				continue;			    break;		    }		    break;		}		*argv = '\0';		while (c==' ' || c=='\t' || c =='\n')		    c = *++argv;		nextrevpair->numfld =		    !nextrevpair->endrev[0] ? 2 /* -rrev- */ :		    !nextrevpair->strtrev[0] ? 3 /* -r-rev */ :		    4 /* -rrev1-rev2 */;            }	    if (!c)		break;	    if (c!=',' && c!=';')		error("missing `,' near `%c%s'", c, argv+1);	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -