just sync with sources Reference: /n/atom/patch/applied2013/tr2postsync Date: Tue Jun 18 21:10:44 CES 2013 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/postscript/tr2post/chartab.c Tue Jun 18 21:10:38 2013 +++ /sys/src/cmd/postscript/tr2post/chartab.c Tue Jun 18 21:10:38 2013 @@ -122,18 +122,18 @@ char postroffdirname[] = "/sys/lib/postscript/troff"; /* "/sys/lib/postscript/troff/"; */ char troffmetricdirname[] = "/sys/lib/troff/font"; /* "/sys/lib/troff/font/devutf/"; */ -static int disabled = 1; int readpsfontdesc(char *fontname, int trindex) { + static char *filename = 0; Biobuf *bfd; Biobufhdr *Bfd; - int errorflg = 0, line =1, rv; - int start, end, offset, i; - int startfont, endfont, startchar, endchar, pfid; + int warn = 0, errorflg = 0, line =1, rv; + int start, end, offset; + int startfont, endfont, startchar, endchar, i, pfid; char psfontnam[128]; struct troffont *tp; - static char *filename = 0; + struct charent *cp[]; if (debug) Bprint(Bstderr, "readpsfontdesc(%s,%d)\n", fontname, trindex); filename=galloc(filename, strlen(postroffdirname)+1+strlen(fontname)+1, "readpsfontdesc: cannot allocate memory\n"); @@ -156,7 +156,7 @@ errorflg = 1; error(WARNING, "file %s:%d illegal end value\n", filename, line); } else if (rv < 0) break; - if (Bgetfield(Bfd, 'd', &offset, 0) < 0) { + if ((rv=Bgetfield(Bfd, 'd', &offset, 0)) < 0) { errorflg = 1; error(WARNING, "file %s:%d illegal offset value\n", filename, line); } @@ -174,7 +174,7 @@ pfid = findpfn(psfontnam, 1); if (startfont != endfont) { error(WARNING, "font descriptions must not cross 256 glyph block boundary\n"); - errorflg = 1; USED(errorflg); + errorflg = 1; break; } tp = &(troffontab[trindex]); @@ -190,12 +190,12 @@ Bprint(Bstderr, "\tpsfmap->offset=0x%x\n", offset); Bprint(Bstderr, "\tpsfmap->pfid=0x%x\n", pfid); } - if(!disabled) - for (i=startchar; i<=endchar; i++) { - tp->charent[startfont][i]->postfontid = pfid; - tp->charent[startfont][i]->postcharid = i + offset - startchar; - } - +/* + for (i=startchar; i<=endchar; i++) { + tp->charent[startfont][i].postfontid = pfid; + tp->charent[startfont][i].postcharid = i + offset - startchar; + } + */ if (debug) { Bprint(Bstderr, "%x %x ", start, end); if (offset) Bprint(Bstderr, "%x ", offset); @@ -213,7 +213,8 @@ static char *filename = 0; Biobuf *bfd; Biobufhdr *Bfd; - int errorflg = 0, line =1, rv; + int warn = 0, errorflg = 0, line =1, rv; + struct troffont *tp; struct charent **cp; char stoken[128], *str; int ntoken; @@ -384,7 +385,7 @@ int i, j; if (debug) { - if (fontname==0) fprint(2, "findtfn(%#p,%d)\n", fontname, insflg); + if (fontname==0) fprint(2, "findtfn(0x%x,%d)\n", fontname, insflg); else fprint(2, "findtfn(%s,%d)\n", fontname, insflg); } for (i=0; i= 0) { /* Bprint(Bstderr, "r=<%c>,0x%x\n", r, r); */ /* Bflush(Bstderr); */ --- /sys/src/cmd/postscript/tr2post/devcntl.c Tue Jun 18 21:10:38 2013 +++ /sys/src/cmd/postscript/tr2post/devcntl.c Tue Jun 18 21:10:38 2013 @@ -54,7 +54,7 @@ devcntl(Biobufhdr *inp) { char cmd[50], buf[256], str[MAXTOKENSIZE], *line; - int c, n; + int c, n, linelen; /* * @@ -102,12 +102,12 @@ break; case 'T': /* device name */ - Bgetfield(inp, 's', devname, 16); + Bgetfield(inp, 's', &devname, 16); if (debug) Bprint(Bstderr, "devname=%s\n", devname); break; case 'E': /* input encoding - not in troff yet */ - Bgetfield(inp, 's', str, 100); + Bgetfield(inp, 's', &str, 100); /* if ( strcmp(str, "UTF") == 0 ) reading = UTFENCODING; else reading = ONEBYTE; --- /sys/src/cmd/postscript/tr2post/draw.c Tue Jun 18 21:10:38 2013 +++ /sys/src/cmd/postscript/tr2post/draw.c Tue Jun 18 21:10:38 2013 @@ -9,8 +9,7 @@ BOOLEAN inpath = FALSE; /* TRUE if we're putting pieces together */ void -cover(double, double) -{ +cover(double x, double y) { } void @@ -277,7 +276,7 @@ * a mistake. Suspect I may have to change the double quote delimiters. * */ - p = buf; + for( ; p != nil ; p = q ) { if( q = strchr(p, ' ') ) { *q++ = '\0'; --- /sys/src/cmd/postscript/tr2post/pictures.c Tue Jun 18 21:10:38 2013 +++ /sys/src/cmd/postscript/tr2post/pictures.c Tue Jun 18 21:10:38 2013 @@ -63,7 +63,7 @@ /*****************************************************************************/ void -picture(Biobufhdr*, char *buf) { +picture(Biobufhdr *inp, char *buf) { int poffset; /* page offset */ int indent; /* indent */ int length; /* line length */ --- /sys/src/cmd/postscript/tr2post/tr2post.h Tue Jun 18 21:10:38 2013 +++ /sys/src/cmd/postscript/tr2post/tr2post.h Tue Jun 18 21:10:39 2013 @@ -73,6 +73,7 @@ int findtfn(char *, int); void runeout(Rune); void specialout(char *); +long nametorune(char *); void conv(Biobufhdr *); void hgoto(int); void vgoto(int); @@ -92,7 +93,7 @@ void setpsfont(int, int); void settrfont(void); int hash(char *, int); -int readDESC(void); +BOOLEAN readDESC(void); void finish(void); void ps_include(Biobufhdr *, Biobufhdr *, int, int, int, int, double, double, double, double, --- /sys/src/cmd/postscript/tr2post/utils.c Tue Jun 18 21:10:39 2013 +++ /sys/src/cmd/postscript/tr2post/utils.c Tue Jun 18 21:10:39 2013 @@ -85,13 +85,13 @@ * list of glyphs in bucket. */ void -glyphout(Rune rune, char *stoken) { +glyphout(Rune rune, char *stoken, BOOLEAN specialflag) { struct charent **cp; struct troffont *tfp; struct psfent *psfp; int i, t; int fontid; /* this is the troff font table index, not the mounted font table index */ - int mi, wid; + int mi, fi, wid; Rune r; settrfont(); @@ -102,7 +102,7 @@ cp = findglyph(fontid, rune, stoken); if (*cp != 0) goto foundit; - if (1) { + if (specialflag) { if (expecthmot) hmot(0); /* check special fonts for the special character */ @@ -111,7 +111,7 @@ if (troffontab[fontid].trfontid==0) error(WARNING, "glyphout:troffontab[%d].trfontid=0x%x, botch!\n", fontid, troffontab[fontid].trfontid); if (fontmtab[mi]==0) { - if (debug) fprint(2, "fontmtab[%d]=%#p, fontmnt=%d\n", mi, fontmtab[mi], fontmnt); + if (debug) fprint(2, "fontmtab[%d]=0x%x, fontmnt=%d\n", mi, fontmtab[mi], fontmnt); continue; } if (strcmp(troffontab[fontid].trfontid, fontmtab[mi])==0) break; @@ -119,7 +119,7 @@ if (mi==fontmnt) error(FATAL, "current troff font is not mounted, botch!\n"); for (i=(mi+1)%fontmnt; i!=mi; i=(i+1)%fontmnt) { if (fontmtab[i]==0) { - if (debug) fprint(2, "fontmtab[%d]=%#p, fontmnt=%d\n", i, fontmtab[i], fontmnt); + if (debug) fprint(2, "fontmtab[%d]=0x%x, fontmnt=%d\n", i, fontmtab[i], fontmnt); continue; } fontid = findtfn(fontmtab[i], TRUE); @@ -149,7 +149,7 @@ rune = 'p'; stoken = "pw"; for (i=(mi+1)%fontmnt; i!=mi; i=(i+1)%fontmnt) { if (fontmtab[i]==0) { - if (debug) fprint(2, "fontmtab[%d]=%#p\n", i, fontmtab[i]); + if (debug) fprint(2, "fontmtab[%d]=0x%x\n", i, fontmtab[i]); continue; } fontid = findtfn(fontmtab[i], TRUE); @@ -175,7 +175,6 @@ } tfp = &(troffontab[fontid]); - psfp = tfp->psfmap + 0; /* shut up compiler */ for (i=0; ipsfmapsize; i++) { psfp = &(tfp->psfmap[i]); if(t>=psfp->start && t<=psfp->end) break; @@ -188,6 +187,8 @@ if (t == 0x0001) { /* character is in charlib */ endstring(); if (pageon()) { + struct charent *tcp; + Bprint(Bstdout, "%d %d m ", hpos, vpos); /* if char is unicode character rather than name, clean up for postscript */ wid = chartorune(&r, (*cp)->name); @@ -236,15 +237,25 @@ i = runetochar(stoken, &rune); stoken[i] = '\0'; - glyphout(rune, stoken); + glyphout(rune, stoken, TRUE); } void specialout(char *stoken) { Rune rune; + int i; + + i = chartorune(&rune, stoken); + glyphout(rune, stoken, TRUE); +} + +void +graphfunc(Biobufhdr *bp) { +} - chartorune(&rune, stoken); - glyphout(rune, stoken); +long +nametorune(char *name) { + return(0); } void