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

📄 nreq.c

📁 操作系统源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
	}	Error(WARN, LINE, " no macro/string", NULL);}/* * Rename macro or string - "^[.']rn" */static voidnr_rn(line, brk)	unsigned char *line;	int brk;{	int i, j;			/* temporary indexes */	unsigned char nm[4], nm1[4];	/* name buffers */	unsigned char *s1;		/* temporary string pointer */	if ((s1 = Field(2, line, 0)) == NULL ||  Asmname(s1, nm) == 0) {		Error(WARN, LINE, " no name", NULL);		return;	}	if ((s1 = Field(3, line, 0)) == NULL ||  Asmname(s1, nm1) == 0) {		Error(WARN, LINE, " no new name", NULL);		return;	}	if ((i = Findmacro(nm, 0)) >= 0) {		if ((j = Findmacro(nm1, 0)) >= 0)			Delmacro(j);		j = Findmacro(nm1, 1);		Macrotab[j].bx = Macrotab[i].bx;		Macrotab[i].bx = -1;		Macrotab[j].ct = Macrotab[i].ct;		Macrotab[i].ct = 0;		Delmacro(i);		return;	}	(void) Findstr(nm, NULL, 0);	if ((i = Sx) >= 0) {		(void) Findstr(nm1, Str[i].str, 1);		Delstr(i);		return;	}	if (Findmacro(nm1, 0) < 0)		(void) Findmacro(nm1, 1);}/* * Remove register - "^[.']rr" */static voidnr_rr(line, brk)	unsigned char *line;	int brk;{	int i;				/* temporary index */	unsigned char nm[4];		/* name buffer */	if (Asmname(&line[3], nm) == 0) {		Error(WARN, LINE, " no name", NULL);		return;	}	if ((i = Findnum(nm, 0, 0)) < 0) {		Error(WARN, LINE, " no register", NULL);		return;	}	Delnum(i);}/* * Resume space - "^[.']rs" */static voidnr_rs(line, brk)	unsigned char *line;	int brk;{	Pass3(NOBREAK, (unsigned char *)"yesspace", NULL, 0);}/* * Message - "^[.']tm" */static voidnr_tm(line, brk)	unsigned char *line;	int brk;{	Pass3(MESSAGE, Inname, (line[3] == ' ') ? &line[4] : &line[3], NR);}/* * Translate - "^[.']tr abcd..." */static voidnr_tr(line, brk)	unsigned char *line;	int brk;{	unsigned char buf[MAXLINE];	/* temporary buffer */	int i, j;			/* temporary indexes */	unsigned char nm[4], nm1[4];	/* name buffers */	unsigned char *s1, *s2;		/* temporary string pointers */	int trin, trout;		/* types: 0 = char; 1 = named char */	unsigned char xbuf[MAXLINE];	/* temporary buffer */	if (line[3] != ' ') {		Error(WARN, LINE, " unknown translation", NULL);		return;	}	for (s1 = &line[4]; *s1;) {	    nm[1] = nm[2] = '\0';	    s2 = s1 + 1;	/*	 * Assemble the input value.	 */	    if (*s1 == '\\' && (*s2 == '*' || *s2 == '(')) {		if (*s2 == '(') {	    /*	     * Input is named character -- "\(xx".	     */		    trin = 1;		    s1 = s2 + 1;		    if ((nm[0] = *s1) != '\0') {			s1++;			if ((nm[1] = *s1) != '\0')			    s1++;		    }		} else {	    /*	     * Input is interpolated string -- "\*x" or "\*(xx".	     */		    s1 = Asmcode(&s2, nm);		    if (*s1)			s1++;		    s2 = Findstr(nm, NULL, 0);		    if (*s2 != '\0') {			if ((strlen((char *)s2) + strlen((char *)s1) + 1)			>= MAXLINE)			    Error(WARN, LINE, " string too long: ", (char *)nm);			else {			    (void) sprintf((char *)buf, "%s%s",				(char *)s2, (char *)s1);			    (void) strcpy((char *)xbuf, (char *)buf);			    s1 = xbuf;			}		    }		    continue;		}	    } else {	    /*	     * Input is a simple character.	     */		trin = 0;		if ((nm[0] = *s1) != '\0')		    s1++;	    }	/*	 * Assemble the output value.	 */assemble_output:	    nm1[1] = nm1[2] = '\0';	    if (*s1 == '\0') {	    /*	     * Supply a space if there is no output character.	     */		trout = 0;		nm1[0] = ' ';	    } else {		s2 = s1 + 1;		if (*s1 == '\\' && (*s2 == '(' || *s2 == '*')) {		    if (*s2 == '(') {		/*		 * The output is a named character -- "\(xx".		 */			trout = 1;			s1 = s2 + 1;			if ((nm1[0] = *s1) != '\0') {			    s1++;			    if ((nm1[1] = *s1) != '\0')				s1++;			}		    } else {		/*		 * The output is an interpolated string -- * "\*x" or "\*(xx".		 */			s1 = Asmcode(&s2, nm1);			if (*s1)			    s1++;			s2 = Findstr(nm1, NULL, 0);			if (*s2 != '\0') {		    /*		     * Interpolate a string value.		     */			    if ((strlen((char *)s2) + strlen((char *)s1) + 1)			    >= MAXLINE)				Error(WARN, LINE, " string too long: ",				    (char *)nm);			    else {				(void) sprintf((char *)buf, "%s%s", (char *)s2,				    (char *)s1);				(void) strcpy((char *)xbuf, (char *)buf);			        s1 = xbuf;			    }			}			goto assemble_output;		    }		} else {		    trout = 0;		    if ((nm1[0] = *s1) != '0')			s1++;		    else			nm1[0] = ' ';		}	    }	/*	 * Do the translation.	 */	    switch (trin) {	    case 0:			/* simple char */		switch (trout) {		case 0:			/* to simple char */		    Trtbl[(int)nm[0]] = nm1[0];		    break;		case 1:			/* to named char */		    if ((i = Findchar(nm1, 0, NULL, 0)) < 0		    ||  strlen((char *)Schar[i].str) != 1)			Error(WARN, LINE, " bad named character: ",			    (char *)nm1);		    else			Trtbl[(int)nm[0]] = *(Schar[i].str);		    break;		}		break;	    case 1:			/* named char */		if ((i = Findchar(nm, 0, NULL, 0)) < 0)		    Error(WARN, LINE, " unknown named character: ", (char *)nm);		else {		    switch (trout) {		    case 0:		/* to simple char */			Free(&Schar[i].str);			Schar[i].str = Newstr(nm1);			Schar[i].len = 1;			break;		    case 1:		/* to named char */			if ((j = Findchar(nm1, 0, NULL, 0)) < 0)			    Error(WARN, LINE, " unknown named character: ",				(char *)nm1);			else			    (void) Findchar(nm, Schar[j].len, Schar[j].str, 1);			break;		    }		}		break;	    }	}}/* * Initialization - "^[.']\^b (fh|HF|NH) [01]" * * fh = first page header status * HF = header/footer status * NH = initialize number headers */static voidnr_Ub(line, brk)	unsigned char *line;	int brk;{	int i;				/* temporary index */	unsigned char *s1, *s2;		/* temporary string pointers */	if ((s1 = Field(2, line, 0)) == NULL)		return;	if ((s2 = Field(3, line, 0)) == NULL)		i = 0;	else		i = atoi((char *)s2);	if (s1[0] == 'f' && s1[1] == 'h')		Pass3(NOBREAK, (unsigned char *)"fph", NULL, i);	else if (s1[0] == 'H' && s1[1] == 'F')		Hdft = i;	else if (s1[0] == 'N' && s1[1] == 'H') {		for (i = 0; i < MAXNHNR; i++)			Nhnr[i] = 0;	} else		Error(WARN, LINE, " unknown initialization", NULL);}/* * Character definitions - "^[.']\^c" */static voidnr_Uc(line, brk)	unsigned char *line;	int brk;{	unsigned char buf[MAXLINE];	/* temporary buffer */	int i;				/* temporary index */	unsigned char *s1, *s2, *s3,	/* temporary string pointers */		      *s4, *s5;	s2 = Field(2, line, 0);	i = atoi((char *)Field(3, line, 0));	s4 = Field(4, line, 0);	if (i < 0 || i > MAXLINE/2 || *s2 == '\0') {		Error(WARN, LINE, " bad character definition", NULL);		return;	}	if (s4 == NULL)		s4 = (unsigned char *)"";	else if (*s4 == '"')		s4++;	s1 = buf;	while ((s5 = (unsigned char *)strchr((char *)s4, '\\')) != NULL) {		while (s5 > s4)			*s1++ = *s4++;		s4 = ++s5;		if (*s5 == '\\')			*s1++ = '\\';		else if (*s5 == 'b')			*s1++ = '\b';		if (*s4)			s4++;	}	while (*s1++ = *s4++)		;	if (*s2 == 'h' && *(s2+1) == 'y')		(void) Findhy(buf, i, 1);	else		(void) Findchar(s2, i, buf, 1);}/* * Font is OK - "[.']\^f <font_name_character>" */static voidnr_Uf(line, brk)	unsigned char *line;	int brk;{	int i;				/* temporary index */	if (line[3] != '\0' && line[4] != '\0') {		for (i = 0; Fcode[i].nm; i++) {			if (line[4] == Fcode[i].nm) {				Fcode[i].status = '1';				return;			}		}	}	Error(WARN, LINE, " unknown font", NULL);}/* * Resolutions - "[.']\^r cpi horizontal vertical" */static voidnr_Ur(line, brk)	unsigned char *line;	int brk;{	unsigned char buf[MAXLINE];	/* temporary buffer */	int i, j;			/* temporary indexes */	double tval;			/* temporary value */	if ((i = atoi((char *)Field(3, line, 0))) <= 0	||  (j = atoi((char *)Field(4, line, 0))) <= 0) {		Error(WARN, LINE, " bad cpi resolutions", NULL);		return;	}	tval = (double) (240.0 / (double) i);	if (Findscale((int)'m', tval, 1) < 0)		Error(FATAL, LINE, " missing Scal['m']", NULL);	Scalen = tval;	if (Scalen <= 0.0) {		(void) sprintf((char *)buf, " bad Scale['n'] (%f)", Scalen);		Error(FATAL, LINE, (char *)buf, NULL);	}	if (Findscale((int)'n', tval, 1) < 0)		Error(FATAL, LINE, " missing Scale['n']", NULL);	Scalev = (double) (240.0 / (double) j);	if (Scalev <= 0.0) {		(void) sprintf((char *)buf, " bad Scale['v'] (%f)", Scalen);		Error(FATAL, LINE, (char *)buf, NULL);	}	if (Findscale((int)'v', Scalev, 1) < 0)		Error(FATAL, LINE, " missing Scale['v']", NULL);}/* * Set line number and file name - "^[.']\^# <number> <file>" * * Lock line number and file name - "^[.']\^= <number> <file>" */static voidnr_UL(line, brk)	unsigned char *line;	int brk;{	unsigned char *s1;		/* temporary string pointer */	if ((s1 = Field(2, line, 0)) != NULL)		P2il = atoi((char *)s1) - 1;	else		P2il = 0;	Lockil = (line[2] == '#') ? 0 : 1;	Free(&P2name);	if (Field(3, line, 1) != NULL) {		P2name = F;		F = NULL;	} else		P2name = NULL;}

⌨️ 快捷键说明

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