📄 n1.c
字号:
if (i = vmot()) { return(i); } goto g0; case 'h': /* horiz mot */ numerr.type = numerr.escarg = 0; numerr.esc = k; if (i = hmot()) return(i); goto g0; case '|': /* narrow space */ if (NROFF) goto g0; return(makem((int)(EM)/6)); case '^': /* half narrow space */ if (NROFF) goto g0; return(makem((int)(EM)/12)); case 'w': /* width function */ setwd(); goto g0; case 'p': /* spread */ spread++; goto g0; case 'N': /* absolute character number */ numerr.type = numerr.escarg = 0; numerr.esc = k; if ((i = setabs()) == 0) goto g0; return i; case 'H': /* character height */ numerr.type = numerr.escarg = 0; numerr.esc = k; return(setht()); case 'S': /* slant */ numerr.type = numerr.escarg = 0; numerr.esc = k; return(setslant()); case 'z': /* zero with char */ return(setz()); case 'l': /* hor line */ numerr.type = numerr.escarg = 0; numerr.esc = k; setline(); goto g0; case 'L': /* vert line */ numerr.type = numerr.escarg = 0; numerr.esc = k; setvline(); goto g0; case 'D': /* drawing function */ numerr.type = numerr.escarg = 0; numerr.esc = k; setdraw(); goto g0; case 'X': /* \X'...' for copy through */ setxon(); goto g0; case 'b': /* bracket */ setbra(); goto g0; case 'o': /* overstrike */ setov(); goto g0; case 'k': /* mark hor place */ if ((k = findr(getsn())) != -1) { numtabp[k].val = numtabp[HP].val; } goto g0; case '0': /* number space */ return(makem(width('0' | chbits))); case 'x': /* extra line space */ numerr.type = numerr.escarg = 0; numerr.esc = k; if (i = xlss()) return(i); goto g0; case 'u': /* half em up */ case 'r': /* full em up */ case 'd': /* half em down */ return(sethl(k)); default: return(j); } /* NOTREACHED */}void setxon(void) /* \X'...' for copy through */{ Tchar xbuf[NC]; Tchar *i; Tchar c; int delim, k; if (ismot(c = getch())) return; delim = cbits(c); i = xbuf; *i++ = XON | chbits; while ((k = cbits(c = getch())) != delim && k != '\n' && i < xbuf+NC-1) { if (k == ' ') setcbits(c, WORDSP); *i++ = c | ZBIT; } *i++ = XOFF | chbits; *i = 0; pushback(xbuf);}char ifilt[32] = { 0, 001, 002, 003, 0, 005, 006, 007, 010, 011, 012 };Tchar getch0(void){ int j; Tchar i;again: if (pbp > lastpbp) i = *--pbp; else if (ip) { /* i = rbf(); */ i = rbf0(ip); if (i == 0) i = rbf(); else { ++ip; if (pastend(ip)) { --ip; rbf(); } } } else { if (donef || ndone) done(0); if (nx || 1) { /* BUG: was ibufp >= eibuf, so EOF test is wrong */ if (nfo < 0) ERROR "in getch0, nfo = %d", nfo WARN; if (nfo == 0) {g0: if (nextfile()) { if (ip) goto again; } } nx = 0;#ifdef UNICODE if (MB_CUR_MAX > 1) i = get1ch(ifile); else#endif /*UNICODE*/ i = getc(ifile); if (i == EOF) goto g0; if (ip) goto again; }g2: if (i >= 040) /* zapped: && i < 0177 */ goto g4; i = ifilt[i]; } if (cbits(i) == IMP && !raw) goto again; if (i == 0 && !init && !raw) { /* zapped: || i == 0177 */ goto again; }g4: if (ismot(i)) return i; if (copyf == 0 && sfbits(i) == 0) i |= chbits; if (cbits(i) == eschar && !raw) setcbits(i, ESC); return(i);}#ifdef UNICODETchar get1ch(FILE *fp) /* get one "character" from input, figure out what alphabet */{ wchar_t wc; char buf[100], *p; int i, n, c; for (i = 0, p = buf; i < MB_CUR_MAX; i++) { if ((c = getc(fp)) == EOF) return c; *p++ = c; if ((n = mbtowc(&wc, buf, p-buf)) >= 0) break; } if (n == 1) /* real ascii, presumably */ return wc; if (n == 0) return p[-1]; /* illegal, but what else to do? */ if (c == EOF) return EOF; *p = 0; return chadd(buf, MBchar, Install); /* add name even if haven't seen it */}#endif /*UNICODE*/void pushback(Tchar *b){ Tchar *ob = b; while (*b++) ; b--; while (b > ob && pbp < &pbbuf[NC-3]) *pbp++ = *--b; if (pbp >= &pbbuf[NC-3]) { ERROR "pushback overflow" WARN; done(2); }}void cpushback(char *b){ char *ob = b; while (*b++) ; b--; while (b > ob && pbp < &pbbuf[NC-3]) *pbp++ = *--b; if (pbp >= &pbbuf[NC-3]) { ERROR "cpushback overflow" WARN; done(2); }}int nextfile(void){ char *p;n0: if (ifile != stdin) fclose(ifile); if (ifi > 0 && !nx) { if (popf()) goto n0; /* popf error */ return(1); /* popf ok */ } if (nx || nmfi < mflg) { p = mfiles[nmfi++]; if (*p != 0) goto n1; } if (rargc-- <= 0) { if ((nfo -= mflg) && !stdi) { done(0);} nfo++; numtabp[CD].val = stdi = mflg = 0; ifile = stdin; strcpy(cfname[ifi], "stdin"); return(0); } p = (argp++)[0]; if (rargc >= 0) cfname[ifi][0] = 0;n1: numtabp[CD].val = 0; if (p[0] == '-' && p[1] == 0) { ifile = stdin; strcpy(cfname[ifi], "stdin"); } else if ((ifile = fopen(p, "r")) == NULL) { ERROR "cannot open file %s", p WARN; nfo -= mflg; done(02); } else strcpy(cfname[ifi],p); nfo++; return(0);}popf(void){ --ifi; if (ifi < 0) { ERROR "popf went negative" WARN; return 1; } numtabp[CD].val = cfline[ifi]; /* restore line counter */ ip = ipl[ifi]; /* input pointer */ ifile = ifl[ifi]; /* input FILE * */ return(0);}void flushi(void){ if (nflush) return; ch = 0; copyf++; while (!nlflg) { if (donef && frame == stk) break; getch(); } copyf--;}/* * return 16-bit, ascii/alphabetic character, ignore chars with more bits, * (internal names), spaces and special cookies (below 040). * Leave STX ETX ENQ ACK and BELL in to maintain compatibility with v7 troff. */getach(void){ Tchar i; int j; lgf++; j = cbits(i = getch()); if (ismot(i) || j > SHORTMASK || (j <= 040 && j != 002 /*STX*/ && j != 003 /*ETX*/ && j != 005 /*ENQ*/ && j != 006 /*ACK*/ && j != 007)) { /*BELL*/ ch = i; j = 0; } lgf--; return j;}void casenx(void){ lgf++; skip(); getname(); nx++; if (nmfi > 0) nmfi--; strcpy(mfiles[nmfi], nextf); nextfile(); nlflg++; ip = 0; pendt = 0; frame = stk; nxf = frame + 1;}getname(void){ int j, k; Tchar i; lgf++; for (k = 0; k < NS - 1; k++) { j = getach(); if (!j) break; nextf[k] = j; } nextf[k] = 0; lgf--; return(nextf[0]);}void caseso(void){ FILE *fp; char *p, *q; lgf++; nextf[0] = 0; if (skip() || !getname() || (fp = fopen(nextf, "r")) == NULL || ifi >= NSO) { ERROR "can't open file %s", nextf WARN; done(02); } strcpy(cfname[ifi+1], nextf); cfline[ifi] = numtabp[CD].val; /*hold line counter*/ numtabp[CD].val = 0; flushi(); ifl[ifi] = ifile; ifile = fp; ipl[ifi] = ip; ip = 0; nx++; nflush++; ifi++;}void caself(void) /* set line number and file */{ int n; if (skip()) return; n = atoi0(); if (!nonumb) cfline[ifi] = numtabp[CD].val = n - 1; if (!skip()) if (getname()) { /* eats '\n' ? */ strcpy(cfname[ifi], nextf); if (!nonumb) numtabp[CD].val--; }}void cpout(FILE *fin, char *token){ int n; char buf[1024]; if (token) { /* BUG: There should be no NULL bytes in input */ char *newl = buf; while ((fgets(buf, sizeof buf, fin)) != NULL) { if (newl) { numtabp[CD].val++; /* line number */ if (strcmp(token, buf) == 0) return; } newl = strchr(buf, '\n'); fputs(buf, ptid); } } else { while ((n = fread(buf, sizeof *buf, sizeof buf, fin)) > 0) fwrite(buf, n, 1, ptid); fclose(fin); }}void casecf(void){ /* copy file without change */ FILE *fd; char *eof, *p; extern int hpos, esc, po; /* this may not make much sense in nroff... */ lgf++; nextf[0] = 0; if (!skip() && getname()) { if (strncmp("<<", nextf, 2) != 0) { if ((fd = fopen(nextf, "r")) == NULL) { ERROR "can't open file %s", nextf WARN; done(02); } eof = (char *) NULL; } else { /* current file */ if (pbp > lastpbp || ip) { ERROR "casecf: not reading from file" WARN; done(02); } eof = &nextf[2]; if (!*eof) { ERROR "casecf: missing end of input token" WARN; done(02); } p = eof; while(*++p) ; *p++ = '\n'; *p = 0; fd = ifile; } } else { ERROR "casecf: no argument" WARN; lgf--; return; } lgf--; /* make it into a clean state, be sure that everything is out */ tbreak(); hpos = po; esc = 0; ptesc(); /* to left margin */ esc = un; ptesc(); ptlead(); ptps(); ptfont(); flusho(); cpout(fd, eof); ptps(); ptfont();}void getline(char *s, int n) /* get rest of input line into s */{ int i; lgf++; copyf++; skip(); for (i = 0; i < n-1; i++) if ((s[i] = cbits(getch())) == '\n' || s[i] == RIGHT) break; s[i] = 0; copyf--; lgf--;}void casesy(void) /* call system */{ char sybuf[NTM]; getline(sybuf, NTM); system(sybuf);}void getpn(char *a){ int n, neg; if (*a == 0) return; neg = 0; for ( ; *a; a++) switch (*a) { case '+': case ',': continue; case '-': neg = 1; continue; default: n = 0; if (isdigit(*a)) { do n = 10 * n + *a++ - '0'; while (isdigit(*a)); a--; } else n = 9999; *pnp++ = neg ? -n : n; neg = 0; if (pnp >= &pnlist[NPN-2]) { ERROR "too many page numbers" WARN; done3(-3); } } if (neg) *pnp++ = -9999; *pnp = -INT_MAX; print = 0; pnp = pnlist; if (*pnp != -INT_MAX) chkpn();}void setrpt(void){ Tchar i, j; copyf++; raw++; i = getch0(); copyf--; raw--; if ((long) i < 0 || cbits(j = getch0()) == RPT) return; while (i > 0 && pbp < &pbbuf[NC-3]) { i--; *pbp++ = j; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -