diff options
author | wkj <devnull@localhost> | 2004-05-16 07:55:57 +0000 |
---|---|---|
committer | wkj <devnull@localhost> | 2004-05-16 07:55:57 +0000 |
commit | c5561c23cf394806cbf6d70a96f2dc0253f93745 (patch) | |
tree | f4a5b99f88454917a5bada0f2a97d1505051968c /src/cmd/troff | |
parent | b855148c9b6d28fedfd083d037bcf246f1913d92 (diff) | |
download | plan9port-c5561c23cf394806cbf6d70a96f2dc0253f93745.tar.gz plan9port-c5561c23cf394806cbf6d70a96f2dc0253f93745.tar.bz2 plan9port-c5561c23cf394806cbf6d70a96f2dc0253f93745.zip |
Checkpoint -- still merging with Taj's version of the world.
Diffstat (limited to 'src/cmd/troff')
-rw-r--r-- | src/cmd/troff/dwbinit.c | 3 | ||||
-rw-r--r-- | src/cmd/troff/ext.h | 2 | ||||
-rw-r--r-- | src/cmd/troff/fns.h | 2 | ||||
-rw-r--r-- | src/cmd/troff/mbwc.c | 2 | ||||
-rw-r--r-- | src/cmd/troff/n1.c | 27 | ||||
-rw-r--r-- | src/cmd/troff/n10.c | 9 | ||||
-rw-r--r-- | src/cmd/troff/n2.c | 1 | ||||
-rw-r--r-- | src/cmd/troff/n3.c | 4 | ||||
-rw-r--r-- | src/cmd/troff/n4.c | 2 | ||||
-rw-r--r-- | src/cmd/troff/n5.c | 13 | ||||
-rw-r--r-- | src/cmd/troff/n6.c | 3 | ||||
-rw-r--r-- | src/cmd/troff/n7.c | 12 | ||||
-rw-r--r-- | src/cmd/troff/n8.c | 24 | ||||
-rw-r--r-- | src/cmd/troff/n9.c | 3 | ||||
-rw-r--r-- | src/cmd/troff/t10.c | 7 | ||||
-rw-r--r-- | src/cmd/troff/t11.c | 11 | ||||
-rw-r--r-- | src/cmd/troff/t6.c | 12 | ||||
-rw-r--r-- | src/cmd/troff/tdef.h | 5 |
18 files changed, 86 insertions, 56 deletions
diff --git a/src/cmd/troff/dwbinit.c b/src/cmd/troff/dwbinit.c index a63e5fde..59f74ec8 100644 --- a/src/cmd/troff/dwbinit.c +++ b/src/cmd/troff/dwbinit.c @@ -143,6 +143,8 @@ void DWBdebug(dwbinit *ptr, int level) /*****************************************************************************/ +extern char *unsharp(char*); + char *DWBhome(void) { @@ -186,6 +188,7 @@ char *DWBhome(void) if ( (home = DWBHOME) == NULL || *home == '\0' || *home == ' ' ) home = NULL; } /* End if */ + home = unsharp(home); } /* End if */ while (home && *home == '/' && *(home +1) == '/') /* remove extra slashes */ diff --git a/src/cmd/troff/ext.h b/src/cmd/troff/ext.h index 42147880..5e187563 100644 --- a/src/cmd/troff/ext.h +++ b/src/cmd/troff/ext.h @@ -1,3 +1,5 @@ +#define devname p9_devname + extern int TROFF; extern int alphabet; diff --git a/src/cmd/troff/fns.h b/src/cmd/troff/fns.h index 6bd94ada..087d4c80 100644 --- a/src/cmd/troff/fns.h +++ b/src/cmd/troff/fns.h @@ -1,6 +1,7 @@ /* * other */ +#ifdef NOTDEF int pclose(FILE*); long filesize(int fd); int open(char *, int); @@ -8,6 +9,7 @@ int read(int, char *, int); int lseek(int, long, int); int close(int); int getpid(void); +#endif /* * c1.c diff --git a/src/cmd/troff/mbwc.c b/src/cmd/troff/mbwc.c index 66a98219..8bc2e944 100644 --- a/src/cmd/troff/mbwc.c +++ b/src/cmd/troff/mbwc.c @@ -130,7 +130,7 @@ mbstowcs(wchar_t *pwcs, const char *s, size_t n) size_t wcstombs(char *s, const wchar_t *pwcs, size_t n) { - int i, d; + int /*i,*/ d; long c; char *p, *pe; char buf[3]; diff --git a/src/cmd/troff/n1.c b/src/cmd/troff/n1.c index d0949fe2..45e99f3f 100644 --- a/src/cmd/troff/n1.c +++ b/src/cmd/troff/n1.c @@ -10,9 +10,6 @@ #include "ext.h" #include "dwbinit.h" -#undef MB_CUR_MAX -#define MB_CUR_MAX 3 - #include <setjmp.h> #include <time.h> @@ -50,6 +47,7 @@ char *progname; /* program name (troff or nroff) */ int trace = 0; /* tracing mode: default off */ int trace1 = 0; +int main(int argc, char *argv[]) { char *p; @@ -57,7 +55,7 @@ main(int argc, char *argv[]) Tchar i; char buf[100]; - ifile = stdin; + ifile = stdin; /* gcc */ ptid = stdout; buf[0] = '\0'; /* make sure it's empty (silly 3b2) */ @@ -279,7 +277,7 @@ void init2(void) void cvtime(void) { - long tt; + time_t tt; struct tm *ltime; time(&tt); @@ -676,7 +674,6 @@ char ifilt[32] = { 0, 001, 002, 003, 0, 005, 006, 007, 010, 011, 012 }; Tchar getch0(void) { - int j; Tchar i; again: @@ -719,7 +716,7 @@ g0: if (ip) goto again; } -g2: +//g2: if (i >= 040) /* zapped: && i < 0177 */ goto g4; i = ifilt[i]; @@ -754,6 +751,7 @@ Tchar get1ch(FILE *fp) /* get one "character" from input, figure out what alphab if ((n = mbtowc(&wc, buf, p-buf)) >= 0) break; } + if (n == 1) /* real ascii, presumably */ return wc; if (n == 0) @@ -830,7 +828,7 @@ n1: if (p[0] == '-' && p[1] == 0) { ifile = stdin; strcpy(cfname[ifi], "stdin"); - } else if ((ifile = fopen(unsharp(p), "r")) == NULL) { + } else if ((ifile = fopen(p, "r")) == NULL) { ERROR "cannot open file %s", p WARN; nfo -= mflg; done(02); @@ -840,7 +838,7 @@ n1: return(0); } - +int popf(void) { --ifi; @@ -874,6 +872,7 @@ void flushi(void) * (internal names), spaces and special cookies (below 040). * Leave STX ETX ENQ ACK and BELL in to maintain compatibility with v7 troff. */ +int getach(void) { Tchar i; @@ -913,11 +912,10 @@ void casenx(void) nxf = frame + 1; } - +int getname(void) { int j, k; - Tchar i; lgf++; for (k = 0; k < NS - 1; k++) { @@ -934,12 +932,11 @@ getname(void) void caseso(void) { - FILE *fp; - char *p, *q; + FILE *fp = 0; lgf++; nextf[0] = 0; - if (skip() || !getname() || (fp = fopen(unsharp(nextf), "r")) == NULL || ifi >= NSO) { + if (skip() || !getname() || (fp = fopen(nextf, "r")) == NULL || ifi >= NSO) { ERROR "can't open file %s", nextf WARN; done(02); } @@ -1008,7 +1005,7 @@ void casecf(void) nextf[0] = 0; if (!skip() && getname()) { if (strncmp("<<", nextf, 2) != 0) { - if ((fd = fopen(unsharp(nextf), "r")) == NULL) { + if ((fd = fopen(nextf, "r")) == NULL) { ERROR "can't open file %s", nextf WARN; done(02); } diff --git a/src/cmd/troff/n10.c b/src/cmd/troff/n10.c index 0183cadc..de2461d8 100644 --- a/src/cmd/troff/n10.c +++ b/src/cmd/troff/n10.c @@ -74,14 +74,13 @@ static char *parse(char *s, int typeit) /* convert \0, etc to nroff driving tabl static int getnrfont(FILE *fp) /* read the nroff description file */ { - FILE *fin; Chwid chtemp[NCHARS]; static Chwid chinit; int i, nw, n, wid, code, type; - char buf[100], ch[100], s1[100], s2[100], cmd[300]; + char buf[100], ch[100], s1[100], s2[100]; wchar_t wc; - + code = 0; chinit.wid = 1; chinit.str = ""; for (i = 0; i < ALPHABET; i++) { @@ -139,7 +138,7 @@ static int getnrfont(FILE *fp) /* read the nroff description file */ void n_ptinit(void) { int i; - char *p, *cp; + char *p; char opt[50], cmd[100]; FILE *fp; @@ -186,7 +185,7 @@ void n_ptinit(void) /* hyphalg = 0; /* for testing */ strcat(termtab, devname); - if ((fp = fopen(unsharp(termtab), "r")) == NULL) { + if ((fp = fopen(termtab, "r")) == NULL) { ERROR "cannot open %s", termtab WARN; exit(-1); } diff --git a/src/cmd/troff/n2.c b/src/cmd/troff/n2.c index 8164c038..22fd1019 100644 --- a/src/cmd/troff/n2.c +++ b/src/cmd/troff/n2.c @@ -137,7 +137,6 @@ void outweird(int k) /* like ptchname() but ascii */ void outascii(Tchar i) /* print i in best-guess ascii */ { - char *p; int j = cbits(i); /* is this ever called with NROFF set? probably doesn't work at all. */ diff --git a/src/cmd/troff/n3.c b/src/cmd/troff/n3.c index 6918d06d..8279d748 100644 --- a/src/cmd/troff/n3.c +++ b/src/cmd/troff/n3.c @@ -64,7 +64,7 @@ void blockinit(void) char *grow(char *ptr, int num, int size) /* make array bigger */ { - char *p, new; + char *p; if (ptr == NULL) p = (char *) calloc(num, size); @@ -307,7 +307,6 @@ void growcontab(void) Offset finds(int mn) { int i; - Tchar j = IMP; Offset savip; oldmn = findmn(mn); @@ -372,6 +371,7 @@ int copyb(void) Offset savoff; Uchar *p; + savoff = 0; if (skip() || !(j = getrq())) j = '.'; req = j; diff --git a/src/cmd/troff/n4.c b/src/cmd/troff/n4.c index 3b3698e4..71162cc3 100644 --- a/src/cmd/troff/n4.c +++ b/src/cmd/troff/n4.c @@ -141,7 +141,7 @@ void setn(void) for( i = 0; tabtab[i] != 0 && i < NTAB; i++) { if (i > 0) buf[j++] = ' '; - sprintf(&buf[j], "%d", tabtab[i] & TABMASK); + sprintf(&buf[j], "%ld", tabtab[i] & TABMASK); j = strlen(buf); if ( tabtab[i] & RTAB) sprintf(&buf[j], "uR"); diff --git a/src/cmd/troff/n5.c b/src/cmd/troff/n5.c index c2801e47..ab5ef2e5 100644 --- a/src/cmd/troff/n5.c +++ b/src/cmd/troff/n5.c @@ -78,11 +78,12 @@ void casens(void) dip->nls++; } - +int chget(int c) { Tchar i; + i = 0; if (skip() || ismot(i = getch()) || cbits(i) == ' ' || cbits(i) == '\n') { ch = i; return(c); @@ -142,7 +143,7 @@ void casenh(void) hyf = 0; } - +int max(int aa, int bb) { if (aa > bb) @@ -333,7 +334,7 @@ void casech(void) nlist[k] = i; } - +int findn(int i) { int k; @@ -408,7 +409,7 @@ void casefm(void) return; } if (fcache[i].fp == NULL) { - if( (fcache[i].fp = fopen(unsharp(nextf), "w")) == NULL) { + if( (fcache[i].fp = fopen(nextf, "w")) == NULL) { ERROR "fm: cannot open %s", nextf WARN; return; } @@ -742,7 +743,7 @@ void eatblk(int inblk) } } - +int cmpstr(Tchar c) { int j, delim; @@ -830,7 +831,7 @@ void caserd(void) pushi(RD_OFFSET, PAIR('r','d')); } - +int rdtty(void) { char onechar; diff --git a/src/cmd/troff/n6.c b/src/cmd/troff/n6.c index e4affa17..2328d6a9 100644 --- a/src/cmd/troff/n6.c +++ b/src/cmd/troff/n6.c @@ -7,6 +7,7 @@ * n6.c -- width functions, sizes and fonts */ +int n_width(Tchar j) { int i, k; @@ -294,7 +295,7 @@ void n_casebd(void) { int i, j, k; - k = 0; + j = k = 0; bd0: if (skip() || !(i = getrq()) || (j = findft(i)) == -1) { if (k) diff --git a/src/cmd/troff/n7.c b/src/cmd/troff/n7.c index c22a485c..bcea354a 100644 --- a/src/cmd/troff/n7.c +++ b/src/cmd/troff/n7.c @@ -354,6 +354,7 @@ void newline(int a) int i, j, nlss; int opn; + nlss = 0; if (a) goto nl1; if (dip != d) { @@ -445,7 +446,7 @@ nl2: } } - +int findn1(int a) { int i, j; @@ -477,7 +478,7 @@ void chkpn(void) } } - +int findt(int a) { int i, j, k; @@ -504,7 +505,7 @@ findt(int a) return(k); } - +int findt1(void) { int i; @@ -539,7 +540,7 @@ e1: goto e1; } - +int movword(void) { int w; @@ -648,7 +649,7 @@ void setnel(void) } } - +int getword(int x) { int j, k; @@ -656,6 +657,7 @@ getword(int x) int noword; int obits; + j = 0; noword = 0; if (x) if (pendw) { diff --git a/src/cmd/troff/n8.c b/src/cmd/troff/n8.c index d1be5080..bace4aae 100644 --- a/src/cmd/troff/n8.c +++ b/src/cmd/troff/n8.c @@ -72,7 +72,7 @@ void hyphen(Tchar *wp) } } -static alpha(Tchar i) /* non-zero if really alphabetic */ +static int alpha(Tchar i) /* non-zero if really alphabetic */ { if (ismot(i)) return 0; @@ -82,7 +82,7 @@ static alpha(Tchar i) /* non-zero if really alphabetic */ return isalpha(cbits(i)); } - +int punct(Tchar i) { if (!i || alpha(i)) @@ -217,7 +217,7 @@ int exword(void) } } - +int suffix(void) { Tchar *w; @@ -269,7 +269,7 @@ mark: goto again; } - +int maplow(int i) { if (isupper(i)) @@ -277,7 +277,7 @@ maplow(int i) return(i); } - +int vowel(int i) { switch (i) { @@ -310,7 +310,7 @@ void digram(void) Tchar *nhyend, *maxw; int maxval; extern char bxh[26][13], bxxh[26][13], xxh[26][13], xhx[26][13], hxx[26][13]; - + maxw = 0; again: if (!(w = chkvow(hyend + 1))) return; @@ -341,7 +341,7 @@ again: goto again; } - +int dilook(int a, int b, char t[26][13]) { int i, j; @@ -461,13 +461,19 @@ static int texit(Tchar *start, Tchar *end) /* hyphenate as in tex, return # foun characters. sigh. */ +extern char *unsharp(char*); + +static char *texhyphens; + static int readpats(void) { FILE *fp; char buf[200], buf1[200]; - if ((fp = fopen(unsharp(TEXHYPHENS), "r")) == NULL - && (fp = fopen(unsharp(DWBalthyphens), "r")) == NULL) { + if(texhyphens == 0) + texhyphens = unsharp(TEXHYPHENS); + if ((fp = fopen(texhyphens, "r")) == NULL + && (fp = fopen(DWBalthyphens, "r")) == NULL) { ERROR "warning: can't find hyphen.tex" WARN; return 0; } diff --git a/src/cmd/troff/n9.c b/src/cmd/troff/n9.c index 5cd70648..3e3ad97f 100644 --- a/src/cmd/troff/n9.c +++ b/src/cmd/troff/n9.c @@ -75,7 +75,7 @@ s1: pushback(linebuf); } - +int eat(int c) { int i; @@ -341,6 +341,7 @@ Tchar setfield(int x) int savepos; static Tchar wbuf[] = { WORDSP, 0}; + rchar = 0; if (x == tabch) rchar = tabc | chbits; else if (x == ldrch) diff --git a/src/cmd/troff/t10.c b/src/cmd/troff/t10.c index 3e8026d1..0022cc79 100644 --- a/src/cmd/troff/t10.c +++ b/src/cmd/troff/t10.c @@ -159,6 +159,7 @@ int ptout0(Tchar *pi) Tchar i; int outsize; /* size of object being printed */ + w = 0; outsize = 1; /* default */ i = *pi; k = cbits(i); @@ -176,11 +177,11 @@ int ptout0(Tchar *pi) xpts = fbits(i); /* sneaky, font bits as size bits */ if (xpts != mpts) ptps(); - OUT "x H %d\n", sbits(i) PUT; + OUT "x H %ld\n", sbits(i) PUT; return(outsize); } if (k == SLANT) { - OUT "x S %d\n", sfbits(i)-180 PUT; + OUT "x S %ld\n", sfbits(i)-180 PUT; return(outsize); } if (k == WORDSP) { @@ -300,7 +301,7 @@ int ptout0(Tchar *pi) pi[1] = '~'; case DRAWSPLINE: /* spline */ default: /* something else; copy it like spline */ - OUT "D%c %d %d", cbits(pi[1]), dx, dy PUT; + OUT "D%ld %d %d", cbits(pi[1]), dx, dy PUT; hpos += dx; vpos += dy; if (cbits(pi[3]) == DRAWFCN || cbits(pi[4]) == DRAWFCN) { diff --git a/src/cmd/troff/t11.c b/src/cmd/troff/t11.c index 5511748c..398d74da 100644 --- a/src/cmd/troff/t11.c +++ b/src/cmd/troff/t11.c @@ -17,13 +17,14 @@ Font fonts[MAXFONTS+1]; /* font info + ptr to width info */ #define eq(s1, s2) (strcmp(s1, s2) == 0) +int getdesc(char *name) { FILE *fin; char cmd[100], s[100]; int i, v; - if ((fin = fopen(unsharp(name), "r")) == NULL) + if ((fin = fopen(name, "r")) == NULL) return -1; while (fscanf(fin, "%s", cmd) != EOF) { if (strcmp(cmd, "res") == 0) { @@ -64,7 +65,7 @@ static int checkfont(char *name) char buf[300], buf2[300]; int i, status = -1; - if ((fp = fopen(unsharp(name), "r")) == NULL) + if ((fp = fopen(name, "r")) == NULL) return -1; for (i = 1; i <= 10; i++) { if (fgets(buf, sizeof buf, fp) == NULL) @@ -85,6 +86,7 @@ static int checkfont(char *name) } +int getfont(char *name, int pos) /* create width tab for font */ { FILE *fin; @@ -94,10 +96,11 @@ getfont(char *name, int pos) /* create width tab for font */ int i, nw, n, wid, kern, code, type; char buf[100], ch[100], s1[100], s2[100], s3[100], cmd[300]; + nw = code = 0; /* fprintf(stderr, "read font %s onto %d\n", name, pos); */ if (checkfont(name) == -1) return -1; - if ((fin = fopen(unsharp(name), "r")) == NULL) + if ((fin = fopen(name, "r")) == NULL) return -1; for (i = 0; i < ALPHABET; i++) chtemp[i] = chinit; /* zero out to begin with */ @@ -189,6 +192,7 @@ getfont(char *name, int pos) /* create width tab for font */ return 1; } +int chadd(char *s, int type, int install) /* add s to global character name table; */ { /* or just look it up */ @@ -231,6 +235,7 @@ char *chname(int n) /* return string for char with index n */ return ""; } +int getlig(FILE *fin) /* pick up ligature list */ { int lig; diff --git a/src/cmd/troff/t6.c b/src/cmd/troff/t6.c index b778916c..583d4aa8 100644 --- a/src/cmd/troff/t6.c +++ b/src/cmd/troff/t6.c @@ -14,6 +14,7 @@ int ccstab[MAXFONTS+1]; int bdtab[MAXFONTS+1]; int sbold = 0; +int t_width(Tchar j) { int i, k; @@ -75,6 +76,7 @@ void zapwcache(int s) widcache[i].fontpts = 0; } +int onfont(int n, int f) /* is char n on font f? */ { int i; @@ -108,6 +110,7 @@ onfont(int n, int f) /* is char n on font f? */ return -1; /* vanilla not found */ } +int getcw(int i) { int k, n, x; @@ -218,6 +221,7 @@ Tchar t_setch(int c) char temp[50]; char *s; + j = 0; s = temp; if (c == '(') { /* \(xx */ if ((*s++ = getach()) == 0 || (*s++ = getach()) == 0) @@ -283,7 +287,7 @@ Tchar t_setabs(void) /* set absolute char from \N'...' */ * returns -1 on error */ - +int t_findft(int i) { int k; @@ -362,7 +366,7 @@ void casps1(int i) mchbits(); } - +int findps(int i) { int j, k; @@ -396,6 +400,7 @@ void t_setps(void) { int i, j; + j = 0; i = cbits(getch()); if (isdigit(i)) { /* \sd or \sdd */ i -= '0'; @@ -703,10 +708,12 @@ char *strdupl(const char *s) /* make a copy of s */ return t; } +int setfp(int pos, int f, char *truename, int print) /* mount font f at position pos[0...nfonts] */ { char pathname[NS], shortname[NS], *sl; + sl = (char*)0; zapwcache(0); if (truename) strcpy(shortname, truename); @@ -780,6 +787,7 @@ void casebd(void) { int i, j, k; + j=0; if (!TROFF) { n_casebd(); return; diff --git a/src/cmd/troff/tdef.h b/src/cmd/troff/tdef.h index e9e1f65c..0b3f2b17 100644 --- a/src/cmd/troff/tdef.h +++ b/src/cmd/troff/tdef.h @@ -3,9 +3,12 @@ #include <limits.h> #include <ctype.h> #include <string.h> +#include <unistd.h> -#define NROFF (!TROFF) +#undef MB_CUR_MAX +#define MB_CUR_MAX 3 +#define NROFF (!TROFF) /* Site dependent definitions */ |