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

📄 rlog.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 3 页
字号:
		putree(Head);	    }	    aputs("=============================================================================\n",out);	} while (cleanup(),		 ++argv, --argc >= 1);	Ofclose(out);	exitmain(exitstatus);}	static voidcleanup(){	if (nerror) exitstatus = EXIT_FAILURE;	Izclose(&finptr);}#if lint#	define exiterr rlogExit#endif	exiting voidexiterr(){	_exit(EXIT_FAILURE);}	static voidputrunk()/*  function:  print revisions chosen, which are in trunk      */{	register struct hshentry const *ptr;	for (ptr = Head;  ptr;  ptr = ptr->next)		putadelta(ptr, ptr->next, true);}	static voidputree(root)	struct hshentry const *root;/*   function: print delta tree (not including trunk) in reverse               order on each branch                                        */{        if ( root == nil ) return;        putree(root->next);        putforest(root->branches);}	static voidputforest(branchroot)	struct branchhead const *branchroot;/*   function:  print branches that has the same direct ancestor    */{        if ( branchroot == nil ) return;        putforest(branchroot->nextbranch);        putabranch(branchroot->hsh);        putree(branchroot->hsh);}	static voidputabranch(root)	struct hshentry const *root;/*   function  :  print one branch     */{        if ( root == nil) return;        putabranch(root->next);        putadelta(root, root, false);}	static voidputadelta(node,editscript,trunk)	register struct hshentry const *node, *editscript;	int trunk;/*  function: Print delta node if node->selector is set.        *//*      editscript indicates where the editscript is stored     *//*      trunk indicated whether this node is in trunk           */{	static char emptych[] = EMPTYLOG;	register FILE *out;	char const *s;	size_t n;	struct branchhead const *newbranch;	struct buf branchnum;	char datebuf[datesize];	if (!node->selector)            return;	out = stdout;	aprintf(out,		"----------------------------\nrevision %s", node->num	);        if ( node->lockedby )	   aprintf(out, "\tlocked by: %s;", node->lockedby);	aprintf(out, "\ndate: %s;  author: %s;  state: %s;",		date2str(node->date, datebuf),		node->author, node->state	);        if ( editscript )           if(trunk)	      aprintf(out, insDelFormat,                             editscript->deletelns, editscript->insertlns);           else	      aprintf(out, insDelFormat,                             editscript->insertlns, editscript->deletelns);        newbranch = node->branches;        if ( newbranch ) {	   bufautobegin(&branchnum);	   aputs("\nbranches:", out);           while( newbranch ) {		getbranchno(newbranch->hsh->num, &branchnum);		aprintf(out, "  %s;", branchnum.string);                newbranch = newbranch->nextbranch;           }	   bufautoend(&branchnum);        }	afputc('\n', out);	s = node->log.string;	if (!(n = node->log.size)) {		s = emptych;		n = sizeof(emptych)-1;	}	awrite(s, n, out);	if (s[n-1] != '\n')		afputc('\n', out);}	static struct hshentry const *readdeltalog()/*  Function : get the log message and skip the text of a deltatext node. *	       Return the delta found. *             Assumes the current lexeme is not yet in nexttok; does not *             advance nexttok. */{        register struct  hshentry  * Delta;	struct buf logbuf;	struct cbuf cb;	if (eoflex())		fatserror("missing delta log");        nextlex();	if (!(Delta = getnum()))		fatserror("delta number corrupted");	getkeystring(Klog);	if (Delta->log.string)		fatserror("duplicate delta log");	bufautobegin(&logbuf);	cb = savestring(&logbuf);	Delta->log = bufremember(&logbuf, cb.size);        nextlex();	while (nexttok==ID && strcmp(NextString,Ktext)!=0)		ignorephrase();	getkeystring(Ktext);        Delta->insertlns = Delta->deletelns = 0;        if ( Delta != Head)                getscript(Delta);        else                readstring();	return Delta;}	static voidgetscript(Delta)struct    hshentry   * Delta;/*   function:  read edit script of Delta and count how many lines added  *//*              and deleted in the script                                 */{        int ed;   /*  editor command  */	declarecache;	register RILE *fin;        register  int   c;	register unsigned long i;	struct diffcmd dc;	fin = finptr;	setupcache(fin);	initdiffcmd(&dc);	while (0  <=  (ed = getdiffcmd(fin,true,(FILE *)0,&dc)))	    if (!ed)                 Delta->deletelns += dc.nlines;	    else {                 /*  skip scripted lines  */		 i = dc.nlines;		 Delta->insertlns += i;		 cache(fin);		 do {		     for (;;) {			cacheget(c);			switch (c) {			    default:				continue;			    case SDELIM:				cacheget(c);				if (c == SDELIM)				    continue;				if (--i)				    fatserror("unexpected end to edit script");				nextc = c;				uncache(fin);				return;			    case '\n':				break;			}			break;		     }		     ++rcsline;		 } while (--i);		 uncache(fin);            }}	static voidexttree(root)struct hshentry  *root;/*  function: select revisions , starting with root             */{	struct branchhead const *newbranch;        if (root == nil) return;	root->selector = extractdelta(root);	root->log.string = nil;        exttree(root->next);        newbranch = root->branches;        while( newbranch ) {            exttree(newbranch->hsh);            newbranch = newbranch->nextbranch;        }}	static voidgetlocker(argv)char    * argv;/*   function : get the login names of lockers from command line   *//*              and store in lockerlist.                           */{        register char c;        struct   lockers   * newlocker;        argv--;        while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' ||                 c == '\n' || c == ';')  ;        if (  c == '\0') {            lockerlist=nil;            return;        }        while( c != '\0' ) {	    newlocker = talloc(struct lockers);            newlocker->lockerlink = lockerlist;            newlocker->login = argv;            lockerlist = newlocker;            while ( ( c = (*++argv)) != ',' && c != '\0' && c != ' '                       && c != '\t' && c != '\n' && c != ';') ;            *argv = '\0';            if ( c == '\0' ) return;            while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' ||                     c == '\n' || c == ';')  ;        }}	static voidgetauthor(argv)char   *argv;/*   function:  get the author's name from command line   *//*              and store in authorlist                   */{        register    c;        struct     authors  * newauthor;        argv--;        while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' ||                 c == '\n' || c == ';')  ;        if ( c == '\0' ) {	    authorlist = talloc(struct authors);	    authorlist->login = getusername(false);            authorlist->nextauthor  = nil;            return;        }        while( c != '\0' ) {	    newauthor = talloc(struct authors);            newauthor->nextauthor = authorlist;            newauthor->login = argv;            authorlist = newauthor;            while( ( c = *++argv) != ',' && c != '\0' && c != ' '                     && c != '\t' && c != '\n' && c != ';') ;            * argv = '\0';            if ( c == '\0') return;            while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' ||                     c == '\n' || c == ';')  ;        }}	static voidgetstate(argv)char   * argv;/*   function :  get the states of revisions from command line  *//*               and store in statelist                         */{        register  char  c;        struct    stateattri    *newstate;        argv--;        while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' ||                 c == '\n' || c == ';')  ;        if ( c == '\0'){	    warn("missing state attributes after -s options");            return;        }        while( c != '\0' ) {	    newstate = talloc(struct stateattri);            newstate->nextstate = statelist;            newstate->status = argv;            statelist = newstate;            while( (c = (*++argv)) != ',' && c != '\0' && c != ' '                    && c != '\t' && c != '\n' && c != ';')  ;            *argv = '\0';            if ( c == '\0' ) return;            while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' ||                     c == '\n' || c == ';')  ;        }}	static voidtrunclocks()/*  Function:  Truncate the list of locks to those that are held by the  *//*             id's on lockerlist. Do not truncate if lockerlist empty.  */{	struct lockers const *plocker;        struct lock     * plocked,  * nextlocked;        if ( (lockerlist == nil) || (Locks == nil)) return;        /* shorten Locks to those contained in lockerlist */        plocked = Locks;        Locks = nil;        while( plocked != nil) {            plocker = lockerlist;            while((plocker != nil) && ( strcmp(plocker->login, plocked->login)!=0))                plocker = plocker->lockerlink;            nextlocked = plocked->nextlock;            if ( plocker != nil) {                plocked->nextlock = Locks;

⌨️ 快捷键说明

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