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

📄 ci.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 3 页
字号:
        }        if (newdnumlength<=2) {                /* add new head per given number */                if(newdnumlength==1) {                    /* make a two-field number out of it*/		    if (cmpnumfld(newdelnum.string,Head->num,1)==0)			incnum(Head->num, &newdelnum);		    else			bufscat(&newdelnum, ".1");                }		if (cmpnum(newdelnum.string,Head->num) <= 0) {                    error("deltanumber %s too low; must be higher than %s",			  newdelnum.string, Head->num);		    return -1;                }		targetdelta = Head;		if (0 <= (removedlock = removelock(Head))) {		    if (!genrevs(Head->num,(char*)0,(char*)0,(char*)0,&gendeltas))			return -1;		    newdelta.next = Head;		    Head = &newdelta;		}		return removedlock;        } else {                /* put new revision on side branch */                /*first, get branch point */		tp = newdelnum.string;		for (i = newdnumlength - (newdnumlength&1 ^ 1);  (--i);  )			while (*tp++ != '.')				;		*--tp = 0; /* Kill final dot to get old delta temporarily. */		if (!(targetdelta=genrevs(newdelnum.string,(char*)nil,(char*)nil,(char*)nil,&gendeltas)))		    return -1;		if (cmpnum(targetdelta->num, newdelnum.string) != 0) {		    error("can't find branchpoint %s", newdelnum.string);		    return -1;                }		*tp = '.'; /* Restore final dot. */		return addbranch(targetdelta,&newdelnum);        }}	static intaddbranch(branchpoint,num)	struct hshentry *branchpoint;	struct buf *num;/* adds a new branch and branch delta at branchpoint. * If num is the null string, appends the new branch, incrementing * the highest branch number (initially 1), and setting the level number to 1. * the new delta and branchhead are in globals newdelta and newbranch, resp. * the new number is placed into num. * Return -1 on error, 1 if a lock is removed, 0 otherwise. */{	struct branchhead *bhead, **btrail;	struct buf branchnum;	int removedlock, result;	unsigned field, numlength;	static struct branchhead newbranch;  /* new branch to be inserted */	numlength = countnumflds(num->string);        if (branchpoint->branches==nil) {                /* start first branch */                branchpoint->branches = &newbranch;                if (numlength==0) {			bufscpy(num, branchpoint->num);			bufscat(num, ".1.1");		} else if (numlength&1)			bufscat(num, ".1");                newbranch.nextbranch=nil;	} else if (numlength==0) {                /* append new branch to the end */                bhead=branchpoint->branches;                while (bhead->nextbranch) bhead=bhead->nextbranch;                bhead->nextbranch = &newbranch;		bufautobegin(&branchnum);		getbranchno(bhead->hsh->num, &branchnum);		incnum(branchnum.string, num);		bufautoend(&branchnum);		bufscat(num, ".1");                newbranch.nextbranch=nil;        } else {                /* place the branch properly */		field = numlength - (numlength&1 ^ 1);                /* field of branch number */		btrail = &branchpoint->branches;		while (0 < (result=cmpnumfld(num->string,(*btrail)->hsh->num,field))) {			btrail = &(*btrail)->nextbranch;			if (!*btrail) {				result = -1;				break;			}                }		if (result < 0) {                        /* insert/append new branchhead */			newbranch.nextbranch = *btrail;			*btrail = &newbranch;			if (numlength&1) bufscat(num, ".1");                } else {                        /* branch exists; append to end */			bufautobegin(&branchnum);			getbranchno(num->string, &branchnum);			targetdelta=genrevs(branchnum.string,(char*)nil,					    (char*)nil,(char*)nil,&gendeltas);			bufautoend(&branchnum);			if (!targetdelta)			    return -1;			if (cmpnum(num->string,targetdelta->num) <= 0) {                                error("deltanumber %s too low; must be higher than %s",				      num->string,targetdelta->num);				return -1;                        }			if (0 <= (removedlock = removelock(targetdelta))) {			    if (numlength&1)				incnum(targetdelta->num,num);			    targetdelta->next = &newdelta;			    newdelta.next = 0;			}			return removedlock;			/* Don't do anything to newbranch.  */                }        }        newbranch.hsh = &newdelta;        newdelta.next=nil;	return 0;}	static intaddsyms(num)	char const *num;{	register struct Symrev *p;	for (p = assoclst;  p;  p = p->nextsym)		if (!addsymbol(num, p->ssymbol, p->override))			return false;	return true;}	static voidincnum(onum,nnum)	char const *onum;	struct buf *nnum;/* Increment the last field of revision number onum by one and * place the result into nnum. */{	register char *tp, *np;	register size_t l;	l = strlen(onum);	bufalloc(nnum, l+2);	np = tp = nnum->string;	VOID strcpy(np, onum);	for (tp = np + l;  np != tp;  )		if (isdigit(*--tp)) {			if (*tp != '9') {				++*tp;				return;			}			*tp = '0';		} else {			tp++;			break;		}	/* We changed 999 to 000; now change it to 1000.  */	*tp = '1';	tp = np + l;	*tp++ = '0';	*tp = 0;}	static intremovelock(delta)struct hshentry * delta;/* function: Finds the lock held by caller on delta, * removes it, and returns nonzero if successful. * Print an error message and return -1 if there is no such lock. * An exception is if !StrictLocks, and caller is the owner of * the RCS file. If caller does not have a lock in this case, * return 0; return 1 if a lock is actually removed. */{	register struct lock *next, **trail;	char const *num;        num=delta->num;	for (trail = &Locks;  (next = *trail);  trail = &next->nextlock)	    if (next->delta == delta)		if (strcmp(getcaller(), next->login) == 0) {		    /* We found a lock on delta by caller; delete it.  */		    *trail = next->nextlock;		    delta->lockedby = 0;		    return 1;		} else {                    error("revision %s locked by %s",num,next->login);		    return -1;                }	if (!StrictLocks && myself(RCSstat.st_uid))	    return 0;	error("no lock set by %s for revision %s", getcaller(), num);	return -1;}	static char const *getcurdate()/* Return a pointer to the current date.  */{	static char buffer[datesize]; /* date buffer */	time_t t;	if (!buffer[0]) {		t = time((time_t *)0);		if (t == -1)			faterror("time not available");		time2date(t, buffer);	}        return buffer;}	static int#if has_prototypesfixwork(mode_t newworkmode, char const *mtime)  /* The `#if has_prototypes' is needed because mode_t might promote to int.  */#else  fixwork(newworkmode, mtime)	mode_t newworkmode;	char const *mtime;#endif{	int r;	return			1 < workstat.st_nlink		    ||	newworkmode&S_IWUSR && !myself(workstat.st_uid)		?   -1	    :			workstat.st_mode != newworkmode		    &&			(r =#			    if has_fchmod				fchmod(Ifileno(workptr), newworkmode)#			    else				chmod(workfilename, newworkmode)#			    endif			) != 0		?   r	    :		setfiledate(workfilename, mtime);}	static intxpandfile(unexfile, dir, delta, exfilename)	RILE *unexfile;	char const *dir;	struct hshentry const *delta;	char const **exfilename;/* * Read unexfile and copy it to a * file in dir, performing keyword substitution with data from delta. * Return -1 if unsuccessful, 1 if expansion occurred, 0 otherwise. * If successful, stores the stream descriptor into *EXFILEP * and its name into *EXFILENAME. */{	char const *targetfname;	int e, r;	targetfname = makedirtemp(dir, 1);	if (!(exfile = fopen(targetfname, FOPEN_W_WORK))) {		eerror(targetfname);		error("can't expand working file");		return -1;        }	r = 0;	if (Expand == OLD_EXPAND)		fastcopy(unexfile,exfile);	else {		for (;;) {			e = expandline(unexfile,exfile,delta,false,(FILE*)nil);			if (e < 0)				break;			r |= e;			if (e <= 1)				break;		}	}	*exfilename = targetfname;	aflush(exfile);	return r & 1;}/* --------------------- G E T L O G M S G --------------------------------*/	static struct cbufgetlogmsg()/* Obtain and yield a log message. * If a log message is given with -m, yield that message. * If this is the initial revision, yield a standard log message. * Otherwise, reads a character string from the terminal. * Stops after reading EOF or a single '.' on a * line. getlogmsg prompts the first time it is called for the * log message; during all later calls it asks whether the previous * log message can be reused. */{	static char const		emptych[] = EMPTYLOG,		initialch[] = "Initial revision";	static struct cbuf const		emptylog = { emptych, sizeof(emptych)-sizeof(char) },		initiallog = { initialch, sizeof(initialch)-sizeof(char) };	static struct buf logbuf;	static struct cbuf logmsg;	register char *tp;	register size_t i;	char const *caller;	if (msg.size) return msg;	if (keepflag) {		/* generate std. log message */		caller = getcaller();		i = sizeof(ciklog)+strlen(caller)+3;		bufalloc(&logbuf, i+datesize);		tp = logbuf.string;		VOID sprintf(tp, "%s%s at ", ciklog, caller);		VOID date2str(getcurdate(), tp+i);		logmsg.string = tp;		logmsg.size = strlen(tp);		return logmsg;	}	if (!targetdelta && (		cmpnum(newdelnum.string,"1.1")==0 ||		cmpnum(newdelnum.string,"1.0")==0	))		return initiallog;	if (logmsg.size) {                /*previous log available*/	    if (yesorno(true, "reuse log message of previous file? [yn](y): "))		return logmsg;        }        /* now read string from stdin */	logmsg = getsstdin("m", "log message", "", &logbuf);        /* now check whether the log message is not empty */	if (logmsg.size)		return logmsg;	return emptylog;}/*  Make a linked list of Symbolic names  */        static voidaddassoclst(flag, sp)int  flag;char * sp;{        struct Symrev *pt;		pt = talloc(struct Symrev);	pt->ssymbol = sp;	pt->override = flag;	pt->nextsym = nil;	if (lastassoc)	        lastassoc->nextsym = pt;	else	        assoclst = pt;	lastassoc = pt;	return;}

⌨️ 快捷键说明

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