[tex-k] dvipsk
Peter Breitenlohner
peb at mppmu.mpg.de
Wed Jan 19 12:10:50 CET 2005
Hi Karl, Tom, Sebastian, Thomas,
attached are 5 patches
patch-01-make
patch-02-make
patch-03-fnt_num
patch-04-tfmopen
patch-05-Omega
with my (not yet finished) attempts to unify dvipsk and odvipsk with a
command line switch "-noomega".
The patches are to be applied, one after the other, to dvipsk as found
in tetex-src-2.99.5.20041207-beta.tar.gz. The program(s) should compile
and run after each step.
The patches 02, 03, and 05 start with a comment explaining what is done.
patch-01-make: should already be in the CVS
patch-02-make: more Makefile changes (mainly for running "make check")
patch-03-fnt_num: mainly handling of DVI and VF font numbers
patch-04-tfmopen: a (fairly trivial) rearrangement of tfmopen
patch-05-Omega: The bulk of the changes
The comment of this patch reads:
This patch prepares for the unification of dvipsk/odvipsk
At the moment there are still a few instances on "#if(n)def Omega":
1. dvips.c: Define noomega as 0 for Omega, 1 for !Omega
Program name in helparr
2. dvips.h: Progam name in BANNER
3. t1part.c: Size of grid/tmpgrid array (Why?)
Are there T1 fonts with >256 chars?
And if so are they in any way Omega-specific?
BTW: there is a statement (t1part.c:1888)
for(i=0;i<=255;i++)
grid[i]=tmpgrid[i];
and there is (t1part.c:2624)
fprintf(stderr,
"Found %d chars instead 256\n", max(index_grid,CharCount));
I have the very strong suspicion that the grid arrays dimensions
should be 256 for !Omega as well as for Omega
In addition there is code in dvips.c for the "-noomega" command
line switch, at present deactivated via "#if 0"
The program should still be functionally equivalent with the present
dvipsk when compiled without "-DOmega" resp. odvipsk with "-DOmega"
with the following exceptions:
1. There are lots of additional checks in order not to violate
array bounds
2. I have removed the function nscalewidth, since scalewidth
already handles negative arguments in exactly the same way
3. Stricter checks for valid characters in tfm/ofm files
4. There was a bug in the bbox computation ("-E") for Omega fonts
5. I have modified the bbox computation for slant<0
6. The manpage already mentions "-noomega", although this is not
yet valid
Apart from the size of the grid arrays, where I just don't know what
is needed, the final transition to a unified program should be
a triviality.
I have done some basic tests, but nothing thorough.
I think it would be very helpful if one or more people could
1. Look at the code. The changes are fairly extensive but mostly
well localized
2. Do extensive tests with both versions
It would be nice if some of you could have a look at this and/or do some testing.
Can someone clarify the issue of grid array dimensions in t1part.c?
Once all this is finished someone ought to describe "-noomega" in dvips.info.
regards Peter
-------------- next part --------------
diff -ur dvipsk-5.94b.orig/texk/dvipsk/Makefile.in dvipsk-5.94b/texk/dvipsk/Makefile.in
--- dvipsk-5.94b.orig/texk/dvipsk/Makefile.in 2004-08-14 19:09:52.000000000 +0200
+++ dvipsk-5.94b/texk/dvipsk/Makefile.in 2004-12-31 18:46:26.000000000 +0100
@@ -114,12 +114,17 @@
# TeX macros.
# cd $(srcdir)/tex && for m in *.tex; do \
# $(INSTALL_DATA) $$m $(dvips_plain_macrodir)/$$m; done
- $(POSTINSTALL)
+ $(POST_INSTALL)
if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
install-info --info-dir=$(infodir) $(infodir)/$(program).info; \
else true; fi
uninstall-data:
+ $(PRE_UNINSTALL)
+ if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
+ install-info --delete --info-dir=$(infodir) $(infodir)/$(program).info; \
+ else true; fi
+ $(NORMAL_UNINSTALL)
rm -f $(infodir)/dvips.i*
# for h in $(prologues); do rm -f $(psheaderdir)/base/$$h; done
# cd $(srcdir)/reencode && for e in *.enc; do rm -f $(psheaderdir)/base/$$e; \
-------------- next part --------------
Need to set TEXMFCNF for "make check"
No need to create unused dirs
diff -ur dvipsk-5.94b.orig/texk/dvipsk/Makefile.in dvipsk-5.94b/texk/dvipsk/Makefile.in
--- dvipsk-5.94b.orig/texk/dvipsk/Makefile.in 2004-12-31 18:46:26.000000000 +0100
+++ dvipsk-5.94b/texk/dvipsk/Makefile.in 2005-01-18 20:38:27.000000000 +0100
@@ -64,15 +64,19 @@
ac_include ../make/tkpathsea.mk
+# The environment for running check.
+# No need to specify TEXMF, as ../kpathsea/texmf.cnf should contain
+# suitable absolute paths at this point. Those are converted to
+# SELFAUTO* paths on installation.
+checkenv = TEXMFCNF=../kpathsea \
+ TFMFONTS=$(srcdir)/testdata: VFFONTS=$(srcdir)/testdata: \
+ TEXPSHEADERS=$(srcdir)/testdata TEXCONFIG=$(srcdir)/testdata:
+
check: all
rm -f mtest.ps
- -(TFMFONTS=$(srcdir)/testdata: VFFONTS=$(srcdir)/testdata: \
- TEXPSHEADERS=$(srcdir)/testdata TEXCONFIG=$(srcdir)/testdata \
- ./dvips -D 300 $(srcdir)/testdata/dvipstst.xdv -o dvipstst.ps)
+ -($(checkenv) ./dvips -D 300 $(srcdir)/testdata/dvipstst.xdv -o dvipstst.ps)
mv dvipstst.ps mtest.ps
- -(TFMFONTS=$(srcdir)/testdata: VFFONTS=$(srcdir)/testdata: \
- TEXPSHEADERS=$(srcdir)/testdata: TEXCONFIG=$(srcdir)/testdata: \
- ./dvips -D 300 $(srcdir)/testdata/dvipstst.xdv -o)
+ -($(checkenv) ./dvips -D 300 $(srcdir)/testdata/dvipstst.xdv -o)
-diff $(srcdir)/testdata/dvipstst.xps dvipstst.ps
install: install-exec install-data
@@ -81,7 +85,7 @@
uninstall: uninstall-exec uninstall-data
install-exec: all
- $(SHELL) $(top_srcdir)/../mkinstalldirs $(bindir) $(scriptdir) $(fontdir)
+ $(SHELL) $(top_srcdir)/../mkinstalldirs $(bindir)
for p in $(programs); do $(INSTALL_LIBTOOL_PROG) $$p $(bindir); done
uninstall-exec:
for p in $(programs); do rm -f $(bindir)/$$p; done
-------------- next part --------------
1. Changed return type of vfopen() from Boolean to int, since the result
can be 0, 1, or 2. Added explicit return type int for main().
2. The font numbers in a DVI file are (in principle) signed 32 bit
numbers. The old code was broken for negative font numbers,
in bbox.c for any font number outside 0..255.
Since the code has to handle arbitrary font numbers from VF, it seemed
best to completely discard baseFonts and always use the linked list of
fontmaps starting at ffont.
The loss in efficiency should be negligible.
diff -ur dvipsk-5.94b.orig/texk/dvipsk/bbox.c dvipsk-5.94b/texk/dvipsk/bbox.c
--- dvipsk-5.94b.orig/texk/dvipsk/bbox.c 2002-10-03 13:12:55.000000000 +0200
+++ dvipsk-5.94b/texk/dvipsk/bbox.c 2005-01-16 01:00:56.000000000 +0100
@@ -12,7 +12,7 @@
extern char *nextstring, errbuf[] ;
extern FILE *tfmfile, *dvifile ;
-extern fontdesctype *baseFonts[] ;
+extern fontmaptype *ffont ;
extern integer firstboploc, num, den ;
extern double mag ;
extern integer hoff, voff ;
@@ -29,8 +29,13 @@
bbchardesctype bbchardesc[256] ;
} bbfontdesctype ;
#endif
+typedef struct bbtft {
+ integer fontnum ;
+ bbfontdesctype *desc ;
+ struct bbtft *next ;
+} bbfontmaptype ;
-static bbfontdesctype *bbaseFonts[256] ;
+static bbfontmaptype *bbffont ;
integer nscalewidth P2C(register integer, a, register integer, b)
{
if (a < 0)
@@ -41,7 +46,7 @@
return scalewidth(a, b) ;
}
-void bbtfmload P1C(int, n)
+void bbtfmload P1C(register fontdesctype *, curfnt)
{
#ifdef Omega
register integer i, j ;
@@ -65,11 +70,10 @@
#endif
integer slant = 0 ;
bbchardesctype *cc ;
- register fontdesctype *curfnt = baseFonts[n] ;
register bbfontdesctype *bbcurfnt =
(bbfontdesctype *)mymalloc(sizeof(bbfontdesctype)) ;
- bbaseFonts[n] = bbcurfnt ;
+ bbffont->desc = bbcurfnt ;
tfmopen(curfnt) ;
/*
* Next, we read the font data from the tfm file, and store it in
@@ -234,6 +238,8 @@
register bbchardesctype *bcd ;
register chardesctype *cd ;
register integer h ;
+ register fontmaptype *cfnt ;
+ bbfontmaptype *bbcfnt ;
integer fnt ;
#ifdef Omega
integer mychar ;
@@ -378,12 +384,17 @@
while (cmd-- > 235)
fnt = (fnt << 8) + dvibyte() ;
}
- curfnt = baseFonts[fnt] ;
- bbcurfnt = bbaseFonts[fnt] ;
- if (bbcurfnt == 0) {
- bbtfmload(fnt) ;
- bbcurfnt = bbaseFonts[fnt] ;
- }
+ for (cfnt=ffont; cfnt; cfnt = cfnt->next)
+ if (cfnt->fontnum == fnt) break ;
+ curfnt = cfnt->desc ;
+ for (bbcfnt=bbffont; bbcfnt; bbcfnt = bbcfnt->next)
+ if (bbcfnt->fontnum == fnt) goto fontfound ;
+ bbcfnt = (bbfontmaptype *)mymalloc(sizeof(bbfontmaptype)) ;
+ bbcfnt->fontnum = fnt ;
+ bbcfnt->next = bbffont ;
+ bbffont = bbcfnt ;
+ bbtfmload(curfnt) ;
+fontfound: bbcurfnt = bbcfnt->desc ;
break ;
case 243: case 244: case 245: case 246: /*fntdef1 */
skipover(cmd - 230) ;
diff -ur dvipsk-5.94b.orig/texk/dvipsk/dopage.c dvipsk-5.94b/texk/dvipsk/dopage.c
--- dvipsk-5.94b.orig/texk/dvipsk/dopage.c 2002-09-24 20:24:21.000000000 +0200
+++ dvipsk-5.94b/texk/dvipsk/dopage.c 2005-01-16 01:01:20.000000000 +0100
@@ -12,7 +12,6 @@
* Now the external variables.
*/
extern fontdesctype *curfnt ;
-extern fontdesctype *baseFonts[] ;
extern fontmaptype *ffont ;
extern quarterword *curpos, *curlim ;
extern integer hh, vv ;
@@ -367,12 +366,9 @@
while (cmd-- > 235)
fnt = (fnt << 8) + dvibyte() ;
}
- if (curpos || fnt > 255) {
- for (cfnt=ffont; cfnt; cfnt = cfnt->next)
- if (cfnt->fontnum == fnt) break ;
- curfnt = cfnt->desc ;
- } else
- curfnt = baseFonts[fnt] ;
+ for (cfnt=ffont; cfnt; cfnt = cfnt->next)
+ if (cfnt->fontnum == fnt) break ;
+ curfnt = cfnt->desc ;
thinspace = curfnt->thinspace ;
goto beginloop ;
case 243: case 244: case 245: case 246: /*fntdef1 */
diff -ur dvipsk-5.94b.orig/texk/dvipsk/dvips.c dvipsk-5.94b/texk/dvipsk/dvips.c
--- dvipsk-5.94b.orig/texk/dvipsk/dvips.c 2004-08-14 19:08:59.000000000 +0200
+++ dvipsk-5.94b/texk/dvipsk/dvips.c 2005-01-16 01:01:24.000000000 +0100
@@ -176,7 +176,6 @@
int mfmode_option; /* set by -mode command-line option */
int oname_option; /* set by -o option */
frametype frames[MAXFRAME] ; /* stack for virtual fonts */
-fontdesctype *baseFonts[256] ; /* base fonts for dvi file */
integer pagecost; /* memory used on the page being prescanned */
int delchar; /* characters to delete from prescanned page */
integer fsizetol; /* max dvi units error for psfile font sizes */
@@ -553,6 +552,7 @@
#ifdef VMS
main P1H(void)
#else
+int
main P2C(int, argc, char **, argv)
#endif
{
@@ -762,7 +762,7 @@
error("! Bad section size arg (-S).") ;
break ;
case 'm' :
- if (STREQ (p, "ode")) {
+ if (STREQ (p, "ode") && argv[i+1]) {
mfmode = argv[++i];
mfmode_option = 1;
} else
@@ -779,8 +779,7 @@
error("! Bad number of pages option (-n).") ;
break ;
case 'o' :
- if (*p == 0 && argv[i+1]
- && (*argv[i+1] != '-' || argv[i+1][1] == 0))
+ if (*p == 0 && argv[i+1] && !STREQ (argv[i+1], "-"))
p = argv[++i] ;
oname_option = 1;
oname = p ;
diff -ur dvipsk-5.94b.orig/texk/dvipsk/fontdef.c dvipsk-5.94b/texk/dvipsk/fontdef.c
--- dvipsk-5.94b.orig/texk/dvipsk/fontdef.c 2002-10-03 13:12:55.000000000 +0200
+++ dvipsk-5.94b/texk/dvipsk/fontdef.c 2005-01-16 00:58:00.000000000 +0100
@@ -18,13 +18,13 @@
*/
extern char *nextstring, *maxstring ;
extern double mag ;
-extern fontdesctype *baseFonts[] ;
#ifdef DEBUG
extern integer debug_flag;
#endif /* DEBUG */
extern int actualdpi ;
extern real alpha ;
extern fontmaptype *ffont ;
+extern quarterword *curpos ;
extern fontdesctype *fonthead ;
extern integer fsizetol ;
/*
@@ -163,8 +163,6 @@
fonthead = fp ;
}
cfnt->desc = fp ;
- if (fn < 256)
- baseFonts[fn] = fp ;
return ;
alreadydefined:
/* A DVI file will not define a font twice; but we may be scanning
diff -ur dvipsk-5.94b.orig/texk/dvipsk/pprescan.c dvipsk-5.94b/texk/dvipsk/pprescan.c
--- dvipsk-5.94b.orig/texk/dvipsk/pprescan.c 1998-11-01 04:45:08.000000000 +0100
+++ dvipsk-5.94b/texk/dvipsk/pprescan.c 2005-01-16 01:02:23.000000000 +0100
@@ -23,7 +23,6 @@
extern Boolean abspage ;
extern FILE *dvifile ;
extern fontdesctype *curfnt ;
-extern fontdesctype *baseFonts[] ;
extern fontmaptype *ffont ;
extern quarterword *curpos, *curlim ;
extern integer pagenum ;
@@ -190,16 +189,12 @@
while (cmd-- > 235)
fnt = (fnt << 8) + dvibyte() ;
}
- if (curpos || fnt > 255) {
- for (cfnt=ffont; cfnt; cfnt = cfnt->next)
- if (cfnt->fontnum == fnt) goto fontfound ;
- } else
- if (0 != (curfnt = baseFonts[fnt]))
- goto fontfound2 ;
- error("! no font selected") ;
+ for (cfnt=ffont; cfnt; cfnt = cfnt->next)
+ if (cfnt->fontnum == fnt) goto fontfound ;
+ error("! no font selected") ;
fontfound: curfnt = cfnt->desc ;
-fontfound2: ppreselectfont(curfnt) ;
- break ;
+ ppreselectfont(curfnt) ;
+ break ;
case 239: predospecial((integer)dvibyte(), 1) ; break ; /* xxx1 */
case 240: predospecial((integer)twobytes(), 1) ; break ; /* xxx2 */
case 241: predospecial(threebytes(), 1) ; break ; /* xxx3 */
diff -ur dvipsk-5.94b.orig/texk/dvipsk/protos.h dvipsk-5.94b/texk/dvipsk/protos.h
--- dvipsk-5.94b.orig/texk/dvipsk/protos.h 2002-09-24 20:24:21.000000000 +0200
+++ dvipsk-5.94b/texk/dvipsk/protos.h 2005-01-16 00:30:59.000000000 +0100
@@ -11,7 +11,7 @@
/* prototypes for functions from bbox.c */
extern int nscalewidth P2H(int a, int b);
-extern void bbtfmload P1H(int n);
+extern void bbtfmload P1H(fontdesctype *curfnt);
extern void bbspecial P3H(int h, int v, int nbytes);
extern void bbdopage P1H(void);
extern void findbb P1H(int bop);
@@ -359,7 +359,7 @@
extern short vfbyte P1H(void);
extern int vfquad P1H(void);
extern int vftrio P1H(void);
-extern Boolean vfopen P1H(fontdesctype *fd);
+extern int vfopen P1H(fontdesctype *fd);
extern struct tft *vfontdef P2H(int s, int siz);
extern Boolean virtualfont P1H(fontdesctype *curfnt);
diff -ur dvipsk-5.94b.orig/texk/dvipsk/scanpage.c dvipsk-5.94b/texk/dvipsk/scanpage.c
--- dvipsk-5.94b.orig/texk/dvipsk/scanpage.c 1998-11-01 04:45:09.000000000 +0100
+++ dvipsk-5.94b/texk/dvipsk/scanpage.c 2005-01-16 01:00:05.000000000 +0100
@@ -20,7 +20,6 @@
extern integer debug_flag;
#endif /* DEBUG */
extern fontdesctype *curfnt ;
-extern fontdesctype *baseFonts[] ;
extern fontmaptype *ffont ;
extern quarterword *curpos, *curlim ;
extern integer fontmem ;
@@ -269,18 +268,14 @@
while (cmd-- > 235)
fnt = (fnt << 8) + dvibyte() ;
}
- if (curpos || fnt > 255) {
- for (cfnt=ffont; cfnt; cfnt = cfnt->next)
- if (cfnt->fontnum == fnt) goto fontfound ;
- } else
- if (0 != (curfnt = baseFonts[fnt]))
- goto fontfound2 ;
- printf("Font number %d not found\n", fnt) ;
- error("! no font selected") ;
+ for (cfnt=ffont; cfnt; cfnt = cfnt->next)
+ if (cfnt->fontnum == fnt) goto fontfound ;
+ printf("Font number %d not found\n", fnt) ;
+ error("! no font selected") ;
fontfound: curfnt = cfnt->desc ;
-fontfound2: if (!preselectfont(curfnt))
+ if (!preselectfont(curfnt))
goto outofmem ;
- break ;
+ break ;
case 239: predospecial((integer)dvibyte(), 1) ; break ; /* xxx1 */
case 240: predospecial((integer)twobytes(), 1) ; break ; /* xxx2 */
case 241: predospecial(threebytes(), 1) ; break ; /* xxx3 */
diff -ur dvipsk-5.94b.orig/texk/dvipsk/virtualfont.c dvipsk-5.94b/texk/dvipsk/virtualfont.c
--- dvipsk-5.94b.orig/texk/dvipsk/virtualfont.c 2002-05-27 23:08:12.000000000 +0200
+++ dvipsk-5.94b/texk/dvipsk/virtualfont.c 2005-01-15 18:40:38.000000000 +0100
@@ -78,7 +78,7 @@
return(i) ;
}
-Boolean
+int
vfopen P1C(register fontdesctype *, fd)
{
register char *d, *n ;
@@ -183,15 +183,10 @@
#endif
register quarterword *tempr ;
fontmaptype *fm, *newf ;
-#ifdef Omega
- integer kindfont;
- kindfont=vfopen(curfnt); /* 1 for TeX, 2 for Omega */
+ int kindfont ;
+ kindfont = vfopen(curfnt) ; /* 1 for TeX, 2 for Omega */
if (!kindfont)
return (0) ;
-#else
- if (!vfopen(curfnt))
- return (0) ;
-#endif
#ifdef DEBUG
if (dd(D_FONTS))
(void)fprintf(stderr,"Loading virtual font %s at %.1fpt\n",
-------------- next part --------------
diff -ur dvipsk-5.94b.orig/texk/dvipsk/tfmload.c dvipsk-5.94b/texk/dvipsk/tfmload.c
--- dvipsk-5.94b.orig/texk/dvipsk/tfmload.c 2002-10-03 13:12:55.000000000 +0200
+++ dvipsk-5.94b/texk/dvipsk/tfmload.c 2005-01-17 20:55:42.000000000 +0100
@@ -48,29 +48,29 @@
#else
(void)sprintf(name, "%s.tfm", n) ;
#endif
- if ((tfmfile=search(d, name, READBIN))==NULL) {
+ if ((tfmfile=search(d, name, READBIN))!=NULL)
+ return ;
#ifdef Omega
+ {
#ifdef KPATHSEA
- d = ofmpath;
+ d = ofmpath;
#endif
- (void)sprintf(name, "%s.ofm", n) ;
- if ((tfmfile=search(d, name, READBIN))==NULL) {
+ (void)sprintf(name, "%s.ofm", n) ;
+ if ((tfmfile=search(d, name, READBIN))!=NULL)
+ return ;
+ }
#endif
- (void)sprintf(errbuf, "Can't open font metric file %s%s",
- fd->area, name) ;
- error(errbuf) ;
- error("I will use cmr10.tfm instead, so expect bad output.") ;
+ (void)sprintf(errbuf, "Can't open font metric file %s%s",
+ fd->area, name) ;
+ error(errbuf) ;
+ error("I will use cmr10.tfm instead, so expect bad output.") ;
#ifdef MVSXA /* IBM: MVS/XA */
- if ((tfmfile=search(d, "tfm(cmr10)", READBIN))==NULL)
+ if ((tfmfile=search(d, "tfm(cmr10)", READBIN))!=NULL)
#else
- if ((tfmfile=search(d, "cmr10.tfm", READBIN))==NULL)
-#endif
- error(
- "! I can't find cmr10.tfm; please reinstall me with proper paths") ;
- }
-#ifdef Omega
- }
+ if ((tfmfile=search(d, "cmr10.tfm", READBIN))!=NULL)
#endif
+ return ;
+ error("! I can't find cmr10.tfm; please reinstall me with proper paths") ;
}
shalfword
-------------- next part --------------
This patch prepares for the unification of dvipsk/odvipsk
At the moment there are still a few instances on "#if(n)def Omega":
1. dvips.c: Define noomega as 0 for Omega, 1 for !Omega
Program name in helparr
2. dvips.h: Progam name in BANNER
3. t1part.c: Size of grid/tmpgrid array (Why?)
Are there T1 fonts with >256 chars?
And if so are they in any way Omega-specific?
BTW: there is a statement (t1part.c:1888)
for(i=0;i<=255;i++)
grid[i]=tmpgrid[i];
and there is (t1part.c:2624)
fprintf(stderr,
"Found %d chars instead 256\n", max(index_grid,CharCount));
I have the very strong suspicion that the grid arrays dimensions
should be 256 for !Omega as well as for Omega
In addition there is code in dvips.c for the "-noomega" command
line switch, at present deactivated via "#if 0"
The program should still be functionally equivalent with the present
dvipsk when compiled without "-DOmega" resp. odvipsk with "-DOmega"
with the following exceptions:
1. There are lots of additional checks in order not to violate
array bounds
2. I have removed the function nscalewidth, since scalewidth
already handles negative arguments in exactly the same way
3. Stricter checks for valid characters in tfm/ofm files
4. There was a bug in the bbox computation ("-E") for Omega fonts
5. I have modified the bbox computation for slant<0
6. The manpage already mentions "-noomega", although this is not
yet valid
Apart from the size of the grid arrays, where I just don't know what
is needed, the final transition to a unified program should be
a triviality.
I have done some basic tests, but nothing thorough.
I think it would be very helpful if one or more people could
1. Look at the code. The changes are fairly extensive but mostly
well localized
2. Do extensive tests with both versions
diff -ur dvipsk-5.94b.orig/texk/dvipsk/bbox.c dvipsk-5.94b/texk/dvipsk/bbox.c
--- dvipsk-5.94b.orig/texk/dvipsk/bbox.c 2005-01-16 01:00:56.000000000 +0100
+++ dvipsk-5.94b/texk/dvipsk/bbox.c 2005-01-19 11:33:18.000000000 +0100
@@ -16,19 +16,14 @@
extern integer firstboploc, num, den ;
extern double mag ;
extern integer hoff, voff ;
+extern Boolean noomega ;
typedef struct {
integer llx, lly, urx, ury ;
} bbchardesctype ;
-#ifdef Omega
typedef struct {
bbchardesctype *bbchardesc ;
} bbfontdesctype ;
-#else
-typedef struct {
- bbchardesctype bbchardesc[256] ;
-} bbfontdesctype ;
-#endif
typedef struct bbtft {
integer fontnum ;
bbfontdesctype *desc ;
@@ -36,38 +31,19 @@
} bbfontmaptype ;
static bbfontmaptype *bbffont ;
-integer nscalewidth P2C(register integer, a, register integer, b)
-{
- if (a < 0)
- return - nscalewidth(-a, b) ;
- else if (b < 0)
- return - scalewidth(a, -b) ;
- else
- return scalewidth(a, b) ;
-}
void bbtfmload P1C(register fontdesctype *, curfnt)
{
-#ifdef Omega
register integer i, j ;
-#else
- register shalfword i ;
-#endif
- register integer li ;
+ register integer li, cd ;
integer scaledsize ;
- shalfword nw, nh, nd, ns, hd ;
-#ifdef Omega
+ integer nw, nh, nd, ns, hd ;
integer bc, ec ;
- integer nco, ncw, npc, no_repeats ;
- integer scaled[65536] ;
- integer chardat[65536] ;
- integer font_level;
+ integer nco, ncw, npc, no_repeats = 0 ;
+ integer *scaled ;
+ integer *chardat ;
+ int font_level;
integer pretend_no_chars;
-#else
- shalfword bc, ec ;
- integer scaled[300] ;
- integer chardat[256] ;
-#endif
integer slant = 0 ;
bbchardesctype *cc ;
register bbfontdesctype *bbcurfnt =
@@ -79,7 +55,6 @@
* Next, we read the font data from the tfm file, and store it in
* our own arrays.
*/
-#ifdef Omega
li = tfm16() ;
if (li!=0) {
font_level = -1;
@@ -91,7 +66,10 @@
ns += tfm16() ;
ns += tfm16() ;
li = tfm16() ;
+ if (hd<2 || bc>ec+1 || ec>255 || nw>256 || nh>16 || nd>16)
+ badtfm("header") ;
} else { /* In an .ofm file */
+ if (noomega) badtfm("length") ;
font_level = tfm16();
li = tfm32() ;
hd = tfm32() ;
@@ -103,6 +81,9 @@
ns += tfm32() ;
li = tfm32() ;
li = tfm32() ;
+ if (font_level>1 || hd<2 || bc<0 || ec<0 || nw<2 || nh<1 || nd<1 || ns<1
+ || bc>ec+1 || ec>65535 || nw>65536 || nh>256 || nd>256)
+ badtfm("header") ;
if (font_level==1) {
nco = tfm32() ;
ncw = tfm32() ;
@@ -110,42 +91,24 @@
for (i=0; i<12; i++) li=tfm32();
}
}
-#else
- li = tfm16() ; hd = tfm16() ;
- bc = tfm16() ; ec = tfm16() ;
- nw = tfm16() ; nh = tfm16() ; nd = tfm16() ;
- ns = tfm16() ;
- ns += tfm16() ;
- ns += tfm16() ;
- ns += tfm16() ;
- li = tfm16() ;
-#endif
li = tfm32() ;
check_checksum (li, curfnt->checksum, curfnt->name);
li = tfm32() ;
-#ifdef Omega
pretend_no_chars=ec+1;
if (pretend_no_chars<256) pretend_no_chars=256;
bbcurfnt->bbchardesc = (bbchardesctype *)
xmalloc(pretend_no_chars*sizeof(bbchardesctype));
for (i=2; i<((font_level==1)?nco-29:hd); i++)
li = tfm32() ;
- no_repeats = 0 ;
+ chardat = (integer *) xmalloc(pretend_no_chars*sizeof(integer)) ;
for (i=0; i<pretend_no_chars; i++)
-#else
- for (i=2; i<hd; i++)
- li = tfm32() ;
- for (i=0; i<256; i++)
-#endif
chardat[i] = -1 ;
for (i=bc; i<=ec; i++) {
-#ifdef Omega
if (no_repeats>0) {
- chardat[i] = chardat[i-1] ;
no_repeats-- ;
} else if (font_level>=0) {
- chardat[i] = tfm32() ;
+ cd = tfm32() ;
li = tfm32() ;
if (font_level==1) {
no_repeats = tfm16() ;
@@ -153,46 +116,42 @@
ncw -= 3 + npc/2 ;
}
} else {
- chardat[i] = tfm16() ;
+ cd = tfm16() ;
li = tfm16() ;
}
-#else
- chardat[i] = tfm16() ;
- li = tfm16() ;
-#endif
+ if (cd) chardat[i] = cd ;
}
-#ifdef Omega
if (font_level==1&&ncw!=0) {
sprintf(errbuf, "Table size mismatch in %s", curfnt->name) ;
error(errbuf) ;
}
-#endif
scaledsize = curfnt->scaledsize ;
- for (i=0; i<nw + nh + nd; i++)
+ scaled = (integer *) xmalloc((nh + nd)*sizeof(integer)) ;
+ for (i=0; i<nw; i++)
+ tfm32() ;
+ for (i=0; i<nh + nd; i++)
scaled[i] = scalewidth(tfm32(), scaledsize) ;
for (i=0; i<ns; i++)
tfm32() ;
slant = tfm32() ;
(void)fclose(tfmfile) ;
-#ifdef Omega
for (i=0; i<pretend_no_chars; i++) {
-#else
- for (i=0; i<256; i++) {
-#endif
cc = &(bbcurfnt->bbchardesc[i]) ;
if (chardat[i] != -1) {
-#ifdef Omega
+ halfword iw ;
+ int ih, id ;
if (font_level>=0) {
- cc->ury = scaled[(chardat[i] >> 16) + nw] ;
- cc->lly = - scaled[(chardat[i] & 255) + nw + nh] ;
+ iw = chardat[i] >> 16 ;
+ ih = (chardat[i] >> 8) & 255 ;
+ id = chardat[i] & 255 ;
} else {
- cc->ury = scaled[((chardat[i] >> 4) & 15) + nw] ;
- cc->lly = - scaled[(chardat[i] & 15) + nw + nh] ;
+ iw = chardat[i] >> 8 ;
+ ih = (chardat[i] >> 4) & 15 ;
+ id = chardat[i] & 15 ;
}
-#else
- cc->ury = scaled[((chardat[i] >> 4) & 15) + nw] ;
- cc->lly = - scaled[(chardat[i] & 15) + nw + nh] ;
-#endif
+ if (iw>=nw || ih>=nh || id>=nd) badtfm("char info") ;
+ cc->ury = scaled[ih] ;
+ cc->lly = - scaled[nh + id] ;
cc->llx = 0 ;
cc->urx = curfnt->chardesc[i].TFMwidth ;
} else {
@@ -200,16 +159,18 @@
}
}
if (slant) {
-#ifdef Omega
for (i=0; i<pretend_no_chars; i++) {
-#else
- for (i=0; i<256; i++) {
-#endif
cc = &(bbcurfnt->bbchardesc[i]) ;
- cc->llx += nscalewidth(cc->lly, slant) ;
- cc->urx += nscalewidth(cc->ury, slant) ;
+ li = scalewidth(cc->lly, slant) ;
+ if (slant > 0) cc->llx += li ;
+ else cc->urx += li ;
+ li = scalewidth(cc->ury, slant) ;
+ if (slant > 0) cc->urx += li ;
+ else cc->llx += li ;
}
}
+ free(chardat) ;
+ free(scaled) ;
}
extern struct dvistack {
integer hh, vv ;
@@ -241,9 +202,7 @@
register fontmaptype *cfnt ;
bbfontmaptype *bbcfnt ;
integer fnt ;
-#ifdef Omega
integer mychar ;
-#endif
int charmove ;
struct dvistack *sp = stack ;
integer v, w, x, y, z ;
@@ -258,25 +217,23 @@
while (1) {
switch (cmd=dvibyte()) {
case 138: break ;
-#ifdef Omega
case 134: /* put2 */
+ if (noomega) error("! synch") ;
mychar = dvibyte() ;
mychar = (mychar << 8) + dvibyte() ;
charmove = 0 ;
goto dochar ;
-case 133: /* put1 */
- mychar = dvibyte() ;
- charmove = 0 ;
- goto dochar ;
case 129: /* set2 */
+ if (noomega) error("! synch") ;
mychar = dvibyte() ;
mychar = (mychar << 8) + dvibyte() ;
charmove = 1;
goto dochar ;
-case 128: /* set1 */
+case 133: /* put1 */
mychar = dvibyte() ;
- charmove = 1;
+ charmove = 0 ;
goto dochar ;
+case 128: cmd = dvibyte() ; /* set1 command drops through to setchar */
default: /* these are commands 0 (setchar0) thru 127 (setchar127) */
mychar = cmd ;
charmove = 1 ;
@@ -287,30 +244,10 @@
if (h + bcd->urx > urx) urx = h + bcd->urx ;
if (v - bcd->ury < lly) lly = v - bcd->ury ;
if (v - bcd->lly > ury) ury = v - bcd->lly ;
-#else
-case 133: /* put1 */
- cmd = dvibyte() ;
- charmove = 0 ;
- goto dochar ;
-case 128: cmd = dvibyte() ; /* set1 command drops through to setchar */
-default: /* these are commands 0 (setchar0) thru 127 (setchar127) */
- charmove = 1 ;
-dochar:
- cd = &(curfnt->chardesc[cmd]) ;
- bcd = &(bbcurfnt->bbchardesc[cmd]) ;
- if (h + bcd->llx < llx) llx = h + bcd->llx ;
- if (h + bcd->urx > urx) urx = h + bcd->urx ;
- if (v - bcd->ury < lly) lly = v - bcd->ury ;
- if (v - bcd->lly > ury) ury = v - bcd->lly ;
-#endif
if (charmove)
h += cd->TFMwidth ;
break ;
-#ifdef Omega
case 130: case 131: case 135: case 136: case 139:
-#else
-case 129: case 130: case 131: case 134: case 135: case 136: case 139:
-#endif
case 247: case 248: case 249: case 250: case 251: case 252: case 253:
case 254: case 255: /* unimplemented or illegal commands */
error("! synch") ;
diff -ur dvipsk-5.94b.orig/texk/dvipsk/config.h dvipsk-5.94b/texk/dvipsk/config.h
--- dvipsk-5.94b.orig/texk/dvipsk/config.h 2004-02-12 20:56:27.000000000 +0100
+++ dvipsk-5.94b/texk/dvipsk/config.h 2005-01-16 15:12:07.000000000 +0100
@@ -31,10 +31,8 @@
#define pictpath kpse_pict_format
#define pkpath kpse_pk_format
#define tfmpath kpse_tfm_format
-#ifdef Omega
#define ovfpath kpse_ovf_format
#define ofmpath kpse_ofm_format
-#endif
#define vfpath kpse_vf_format
#define configpath kpse_dvips_config_format
#define headerpath kpse_tex_ps_header_format
diff -ur dvipsk-5.94b.orig/texk/dvipsk/dopage.c dvipsk-5.94b/texk/dvipsk/dopage.c
--- dvipsk-5.94b.orig/texk/dvipsk/dopage.c 2005-01-16 01:01:20.000000000 +0100
+++ dvipsk-5.94b/texk/dvipsk/dopage.c 2005-01-19 01:01:47.000000000 +0100
@@ -16,6 +16,7 @@
extern quarterword *curpos, *curlim ;
extern integer hh, vv ;
extern integer hoff, voff ;
+extern Boolean noomega ;
/*
* CONVENTION: conv -> horizontial converter
* vconv -> vertical converter
@@ -74,9 +75,7 @@
register fontmaptype *cfnt ;
register frametype *frp = frames ;
integer fnt ;
-#ifdef Omega
integer mychar;
-#endif
int charmove ;
struct dvistack *sp = stack ;
integer v, w, x, y, z ;
@@ -125,39 +124,27 @@
* For put1 commands, we subtract the width of the character before
* dropping through to the normal character setting routines. This
*/
-#ifdef Omega
case 134: /* put2 */
+ if (noomega) error("! synch") ;
mychar = dvibyte() ;
mychar = (mychar << 8) + dvibyte() ;
charmove = 0 ;
goto dochar ;
-case 133: /* put1 */
- mychar = dvibyte() ;
- charmove = 0 ;
- goto dochar ;
case 129: /* set2 */
+ if (noomega) error("! synch") ;
mychar = dvibyte() ;
mychar = (mychar << 8) + dvibyte() ;
charmove = 1 ;
goto dochar ;
-case 128: /* set1 */
- mychar = dvibyte() ;
- charmove = 1 ;
- goto dochar ;
-default: /* these are commands 0 (setchar0) thru 127 (setchar127) */
- mychar = cmd ;
- charmove = 1 ;
-dochar:
-#else
case 133: /* put1 */
- cmd = dvibyte() ;
+ mychar = dvibyte() ;
charmove = 0 ;
goto dochar ;
case 128: cmd = dvibyte() ; /* set1 command drops through to setchar */
default: /* these are commands 0 (setchar0) thru 127 (setchar127) */
+ mychar = cmd ;
charmove = 1 ;
dochar:
-#endif
#ifdef HPS
if (HPS_FLAG && PAGEUS_INTERUPPTUS) {
HREF_COUNT-- ;
@@ -169,11 +156,7 @@
NEED_NEW_BOX = 0;
}
#endif
-#ifdef Omega
cd = &(curfnt->chardesc[mychar]) ;
-#else
- cd = &(curfnt->chardesc[cmd]) ;
-#endif
if (cd->flags & EXISTS) {
if (curfnt->loaded == 2) { /* virtual character being typeset */
if (charmove) {
@@ -204,22 +187,14 @@
}
goto beginloop ;
}
-#ifdef Omega
drawchar(cd, mychar) ;
-#else
- drawchar(cd, cmd) ;
-#endif
}
if (charmove) {
h += cd->TFMwidth ;
hh += cd->pixelwidth ;
}
goto setmotion ;
-#ifdef Omega
case 130: case 131: case 135: case 136: case 139:
-#else
-case 129: case 130: case 131: case 134: case 135: case 136: case 139:
-#endif
case 247: case 248: case 249: case 250: case 251: case 252: case 253:
case 254: case 255: /* unimplemented or illegal commands */
error("! synch") ;
diff -ur dvipsk-5.94b.orig/texk/dvipsk/download.c dvipsk-5.94b/texk/dvipsk/download.c
--- dvipsk-5.94b.orig/texk/dvipsk/download.c 2002-10-03 13:12:55.000000000 +0200
+++ dvipsk-5.94b/texk/dvipsk/download.c 2005-01-16 15:32:56.000000000 +0100
@@ -214,7 +214,6 @@
int cc, maxcc = -1, numcc ;
double fontscale ;
char name[10] ;
- int non_empty=0;
lastccout = -5 ;
name[0] = '/' ;
makepsname(name + 1, psfont) ;
@@ -222,13 +221,12 @@
curfnt->psname = psfont ;
if (curfnt->resfont) {
struct resfont *rf = curfnt->resfont ;
-#ifndef Omega /* from ASCII jpatch */
+ int non_empty=0;
for (b=0; b<16; b++)
if(p->bitmap[b] !=0)
non_empty =1;
- if(non_empty==0)
+ if(non_empty==0 && curfnt->codewidth==1)
return;
-#endif
cmdout(name) ;
/* following code re-arranged - Rob Hutchings 1992Apr02 */
c = curfnt->chardesc + 255 ;
diff -ur dvipsk-5.94b.orig/texk/dvipsk/dvips.1 dvipsk-5.94b/texk/dvipsk/dvips.1
--- dvipsk-5.94b.orig/texk/dvipsk/dvips.1 2004-05-27 22:45:38.000000000 +0200
+++ dvipsk-5.94b/texk/dvipsk/dvips.1 2005-01-19 01:22:36.000000000 +0100
@@ -251,6 +251,24 @@
PostScript printers. Old versions of TranScript in particular cannot
handle modern Encapsulated PostScript.
.TP
+.B \-noomega
+This will disable the use of Omega extensions when interpreting DVI files.
+By default, the additional opcodes
+.I 129
+and
+.I 134
+are recognized by dvips as Omega extensions and interpreted as requests to
+set 2-byte characters. The only drawback is that the virtual font array will
+(at least temporarily) require 65536 positions instead of the default 256
+positions, i.e. the memory requirements of dvips will be slightly larger. If
+you find this unacceptable or encounter another problem with the Omega
+extensions, you can switch this extension off by using
+.B \-noomega
+(but please do send a bug report if you find such problems - see the bug
+address in the
+.B AUTHORS
+section below).
+.TP
.B -o name
The output will be sent to file
.I name
diff -ur dvipsk-5.94b.orig/texk/dvipsk/dvips.c dvipsk-5.94b/texk/dvipsk/dvips.c
--- dvipsk-5.94b.orig/texk/dvipsk/dvips.c 2005-01-16 01:01:24.000000000 +0100
+++ dvipsk-5.94b/texk/dvipsk/dvips.c 2005-01-19 01:13:28.000000000 +0100
@@ -112,6 +112,11 @@
long bytesleft ; /* number of bytes left in raster */
quarterword *raster ; /* area for raster manipulations */
integer hh, vv ; /* horizontal and vertical pixel positions */
+#ifdef Omega
+Boolean noomega = 0 ; /* Omega extensions are enabled */
+#else
+Boolean noomega = 1 ; /* Omega extensions are disabled */
+#endif
/*-----------------------------------------------------------------------*
* The PATH definitions cannot be defined on the command line because so many
@@ -273,6 +278,9 @@
"m* Manual feed M* Don't make fonts ",
"mode s Metafont device name ",
"n # Maximum number of pages N* No structured comments ",
+#if 0
+"noomega Disable Omega extensions ",
+#endif
"o f Output file O c Set/change paper offset ",
#if defined(MSDOS) || defined(OS2)
"p # First page P s Load $s.cfg ",
@@ -769,6 +777,11 @@
manualfeed = (*p != '0') ;
break ;
case 'n' :
+#if 0
+ if (STREQ (p, "oomega")) {
+ noomega = 1 ;
+ } else {
+#endif
if (*p == 0 && argv[i+1])
p = argv[++i] ;
#ifdef SHORTINT
@@ -777,6 +790,9 @@
if (sscanf(p, "%d", &maxpages)==0)
#endif /* ~SHORTINT */
error("! Bad number of pages option (-n).") ;
+#if 0
+ }
+#endif
break ;
case 'o' :
if (*p == 0 && argv[i+1] && !STREQ (argv[i+1], "-"))
diff -ur dvipsk-5.94b.orig/texk/dvipsk/dvips.h dvipsk-5.94b/texk/dvipsk/dvips.h
--- dvipsk-5.94b.orig/texk/dvipsk/dvips.h 2004-08-14 19:08:08.000000000 +0200
+++ dvipsk-5.94b/texk/dvipsk/dvips.h 2005-01-16 18:14:36.000000000 +0100
@@ -176,24 +176,16 @@
halfword alreadyscaled ;
halfword psname ;
halfword loaded ;
-#ifdef Omega
+ quarterword psflag;
+ quarterword codewidth ;
integer maxchars ;
-#else
- halfword maxchars ;
-#endif
char *name, *area ;
struct resfont *resfont ;
struct tft *localfonts ;
struct tfd *next ;
struct tfd *nextsize;
char *scalename;
- quarterword psflag;
-#ifdef Omega
chardesctype *chardesc ;
- quarterword codewidth ;
-#else
- chardesctype chardesc[256] ;
-#endif
} fontdesctype ;
/* A fontmap associates a fontdesc with a font number.
diff -ur dvipsk-5.94b.orig/texk/dvipsk/fontdef.c dvipsk-5.94b/texk/dvipsk/fontdef.c
--- dvipsk-5.94b.orig/texk/dvipsk/fontdef.c 2005-01-16 00:58:00.000000000 +0100
+++ dvipsk-5.94b/texk/dvipsk/fontdef.c 2005-01-18 21:55:03.000000000 +0100
@@ -38,10 +38,8 @@
register fontdesctype *fp ;
fp = (fontdesctype *)mymalloc((integer)sizeof(fontdesctype)) ;
-#ifdef Omega
-fp->chardesc = (chardesctype *)mymalloc(256*(integer)sizeof(chardesctype)) ;
- fp->codewidth = 1 ;
-#endif
+ fp->chardesc = (chardesctype *)mymalloc(256*(integer)sizeof(chardesctype)) ;
+ fp->maxchars = 256 ;
fp->psname = 0 ;
fp->loaded = 0 ;
fp->checksum = cksum ;
@@ -50,6 +48,7 @@
fp->thinspace = scsize / 6 ;
fp->scalename = NULL ;
fp->psflag = 0 ;
+ fp->codewidth = 1 ;
fp->name = name;
#ifdef VMCMS /* IBM: VM/CMS */
{
diff -ur dvipsk-5.94b.orig/texk/dvipsk/loadfont.c dvipsk-5.94b/texk/dvipsk/loadfont.c
--- dvipsk-5.94b.orig/texk/dvipsk/loadfont.c 2002-05-27 23:08:07.000000000 +0200
+++ dvipsk-5.94b/texk/dvipsk/loadfont.c 2005-01-16 18:16:39.000000000 +0100
@@ -322,11 +322,7 @@
void
loadfont P1C(register fontdesctype *, curfnt)
{
-#ifdef Omega
register integer i ;
-#else
- register shalfword i ;
-#endif
register shalfword cmd ;
register integer k ;
register integer length = 0 ;
diff -ur dvipsk-5.94b.orig/texk/dvipsk/output.c dvipsk-5.94b/texk/dvipsk/output.c
--- dvipsk-5.94b.orig/texk/dvipsk/output.c 2004-05-10 01:22:51.000000000 +0200
+++ dvipsk-5.94b/texk/dvipsk/output.c 2005-01-16 15:37:46.000000000 +0100
@@ -724,7 +724,6 @@
}
}
-#ifdef Omega
void
scout2 P1C(int, c)
{
@@ -733,7 +732,6 @@
sprintf(s, "<%04x>p", c) ;
cmdout(s) ;
}
-#endif
void
cmdout P1C(char *, s)
@@ -1535,12 +1533,8 @@
fontout((int)curfnt->psname) ;
lastfont = curfnt->psname ;
}
-#ifdef Omega
if (curfnt->codewidth==1) scout((unsigned char)cc) ;
else scout2(cc) ;
-#else
- scout((unsigned char)cc) ;
-#endif
rhh = hh + c->pixelwidth ; /* rvv = rv */
}
/*
diff -ur dvipsk-5.94b.orig/texk/dvipsk/pprescan.c dvipsk-5.94b/texk/dvipsk/pprescan.c
--- dvipsk-5.94b.orig/texk/dvipsk/pprescan.c 2005-01-16 01:02:23.000000000 +0100
+++ dvipsk-5.94b/texk/dvipsk/pprescan.c 2005-01-19 01:05:03.000000000 +0100
@@ -28,6 +28,7 @@
extern integer pagenum ;
extern char errbuf[] ;
extern frametype frames[] ;
+extern Boolean noomega ;
/*
* We declare this to tell everyone we are prescanning early.
*/
@@ -61,9 +62,7 @@
register chardesctype *cd ;
register fontmaptype *cfnt = 0 ;
integer fnt ;
-#ifdef Omega
integer mychar ;
-#endif
register frametype *frp = frames ;
#ifdef DEBUG
@@ -79,7 +78,6 @@
bopcolor(0) ;
while (1) {
switch (cmd=dvibyte()) {
-#ifdef Omega
case 130: case 131: case 135: case 136: case 139:
case 247: case 248: case 249: case 250: case 251: case 252: case 253:
case 254: case 255: /* unimplemented or illegal commands */
@@ -106,45 +104,24 @@
case 147: case 152: case 161: case 166: /* w0, x0, y0, z0 */
case 138: case 141: case 142: /* nop, push, pop */
break ;
-case 134: case 129: mychar = dvibyte() ; mychar = (mychar << 8) + dvibyte() ;
- goto dochar ;
-case 133: case 128: mychar = dvibyte() ;
+case 134: case 129: /* set2, put2 */
+ if (noomega) {
+ (void)sprintf(errbuf,
+ "! DVI file contains unexpected Omega command (%d)",cmd) ;
+ error(errbuf) ;
+ }
+ mychar = dvibyte() ; mychar = (mychar << 8) + dvibyte() ;
goto dochar ;
+case 133: case 128: cmd = dvibyte() ; /* set1, put1 commands drops through */
default: /* these are commands 0 (setchar0) thru 127 (setchar 127) */
mychar = cmd ;
- dochar:
-#else
-case 129: case 130: case 131: case 134: case 135: case 136: case 139:
-case 247: case 248: case 249: case 250: case 251: case 252: case 253:
-case 254: case 255: /* unimplemented or illegal commands */
- (void)sprintf(errbuf,
- "! DVI file contains unexpected command (%d)",cmd) ;
- error(errbuf) ;
-case 132: case 137: /* eight-byte commands setrule, putrule */
- (void)dvibyte() ;
- (void)dvibyte() ;
- (void)dvibyte() ;
- (void)dvibyte() ;
-case 146: case 151: case 156: case 160: case 165: case 170:
- /* four-byte commands right4, w4, x4, down4, y4, z4 */
- (void)dvibyte() ;
-case 145: case 150: case 155: case 159: case 164: case 169:
- /* three-byte commands right3, w3, x3, down3, y3, z3 */
- (void)dvibyte() ;
-case 144: case 149: case 154: case 158: case 163: case 168:
- /* two-byte commands right2, w2, x2, down2, y2, z2 */
- (void)dvibyte() ;
-case 143: case 148: case 153: case 157: case 162: case 167:
- /* one-byte commands right1, w1, x1, down1, y1, z1 */
- (void)dvibyte() ;
-case 147: case 152: case 161: case 166: /* w0, x0, y0, z0 */
-case 138: case 141: case 142: /* nop, push, pop */
- break ;
-case 133: case 128: cmd = dvibyte() ; /* set1 commands drops through */
-default: /* these are commands 0 (setchar0) thru 127 (setchar 127) */
-#endif
+dochar:
if (curfnt==NULL)
error("! Bad DVI file: no font selected") ;
+ if (mychar>=curfnt->maxchars) {
+ (void)sprintf(errbuf,"! invalid char %d from font %s", mychar, curfnt->name) ;
+ error(errbuf) ;
+ }
if (curfnt->loaded == 2) { /* scanning a virtual font character */
frp->curp = curpos ;
frp->curl = curlim ;
@@ -152,11 +129,7 @@
frp->curf = curfnt ;
if (++frp == &frames[MAXFRAME] )
error("! virtual recursion stack overflow") ;
-#ifdef Omega
cd = curfnt->chardesc + mychar;
-#else
- cd = curfnt->chardesc + cmd ;
-#endif
if (cd->packptr == 0)
error("! a non-existent virtual char is being used; check vf/tfm files") ;
curpos = cd->packptr + 2 ;
@@ -167,11 +140,7 @@
else
ppreselectfont(ffont->desc) ;
} else if (curfnt->loaded == 3)
-#ifdef Omega
curfnt->chardesc[mychar].flags = EXISTS ;
-#else
- curfnt->chardesc[cmd].flags = EXISTS ;
-#endif
break ;
case 171: case 172: case 173: case 174: case 175: case 176: case 177:
case 178: case 179: case 180: case 181: case 182: case 183: case 184:
diff -ur dvipsk-5.94b.orig/texk/dvipsk/protos.h dvipsk-5.94b/texk/dvipsk/protos.h
--- dvipsk-5.94b.orig/texk/dvipsk/protos.h 2005-01-16 00:30:59.000000000 +0100
+++ dvipsk-5.94b/texk/dvipsk/protos.h 2005-01-18 20:43:45.000000000 +0100
@@ -10,7 +10,6 @@
struct tcd;
/* prototypes for functions from bbox.c */
-extern int nscalewidth P2H(int a, int b);
extern void bbtfmload P1H(fontdesctype *curfnt);
extern void bbspecial P3H(int h, int v, int nbytes);
extern void bbdopage P1H(void);
@@ -341,6 +340,7 @@
extern void NameOfProgram P1H(void);
/* prototypes for functions from tfmload.c */
+extern void badtfm P1H(char *s);
extern void tfmopen P1H(fontdesctype *fd);
extern short tfmbyte P1H(void);
extern unsigned short tfm16 P1H(void);
diff -ur dvipsk-5.94b.orig/texk/dvipsk/scanpage.c dvipsk-5.94b/texk/dvipsk/scanpage.c
--- dvipsk-5.94b.orig/texk/dvipsk/scanpage.c 2005-01-16 01:00:05.000000000 +0100
+++ dvipsk-5.94b/texk/dvipsk/scanpage.c 2005-01-19 01:05:05.000000000 +0100
@@ -30,6 +30,7 @@
extern char errbuf[] ;
extern frametype frames[] ;
extern integer pagecost ;
+extern Boolean noomega ;
/*
* Charge pagecost for the cost of showing the character that *cd refers to
* and charge fontmem for the cost of downloading the character if necessary.
@@ -150,7 +151,6 @@
while (1) {
switch (cmd=dvibyte()) {
-#ifdef Omega
case 130: case 131: case 135: case 136: case 139:
case 247: case 248: case 249: case 250: case 251: case 252: case 253:
case 254: case 255: /* unimplemented or illegal commands */
@@ -177,50 +177,28 @@
case 147: case 152: case 161: case 166: /* w0, x0, y0, z0 */
case 138: case 141: case 142: /* nop, push, pop */
break ;
-case 134: case 129: mychar = dvibyte() ; mychar = (mychar << 8) + dvibyte() ;
- goto dochar ;
-case 133: case 128: mychar = dvibyte() ;
+case 134: case 129: /* set2, put2 */
+ if (noomega) {
+ (void)sprintf(errbuf,
+ "! DVI file contains unexpected Omega command (%d)",cmd) ;
+ error(errbuf) ;
+ }
+ mychar = dvibyte() ; mychar = (mychar << 8) + dvibyte() ;
goto dochar ;
-#else
-case 129: case 130: case 131: case 134: case 135: case 136: case 139:
-case 247: case 248: case 249: case 250: case 251: case 252: case 253:
-case 254: case 255: /* unimplemented or illegal commands */
- (void)sprintf(errbuf,
- "! DVI file contains unexpected command (%d)",cmd) ;
- error(errbuf) ;
-case 132: case 137: /* eight-byte commands setrule, putrule */
- (void)dvibyte() ;
- (void)dvibyte() ;
- (void)dvibyte() ;
- (void)dvibyte() ;
-case 146: case 151: case 156: case 160: case 165: case 170:
- /* four-byte commands right4, w4, x4, down4, y4, z4 */
- (void)dvibyte() ;
-case 145: case 150: case 155: case 159: case 164: case 169:
- /* three-byte commands right3, w3, x3, down3, y3, z3 */
- (void)dvibyte() ;
-case 144: case 149: case 154: case 158: case 163: case 168:
- /* two-byte commands right2, w2, x2, down2, y2, z2 */
- (void)dvibyte() ;
-case 143: case 148: case 153: case 157: case 162: case 167:
- /* one-byte commands right1, w1, x1, down1, y1, z1 */
- (void)dvibyte() ;
-case 147: case 152: case 161: case 166: /* w0, x0, y0, z0 */
-case 138: case 141: case 142: /* nop, push, pop */
- break ;
case 133: case 128: cmd = dvibyte() ; /* set1 commands drops through */
-#endif
default: /* these are commands 0 (setchar0) thru 127 (setchar 127) */
+ mychar = cmd ;
+dochar:
/*
* We are going to approximate that each string of consecutive characters
* requires (length of string) bytes of PostScript VM.
*/
-#ifdef Omega
- mychar = cmd ;
- dochar:
-#endif
if (curfnt==NULL)
error("! Bad DVI file: no font selected") ;
+ if (mychar>=curfnt->maxchars) {
+ (void)sprintf(errbuf,"! invalid char %d from font %s", mychar, curfnt->name) ;
+ error(errbuf) ;
+ }
if (curfnt->loaded == 2) { /* scanning a virtual font character */
frp->curp = curpos ;
frp->curl = curlim ;
@@ -228,11 +206,7 @@
frp->curf = curfnt ;
if (++frp == &frames[MAXFRAME] )
error("! virtual recursion stack overflow") ;
-#ifdef Omega
cd = curfnt->chardesc + mychar ;
-#else
- cd = curfnt->chardesc + cmd ;
-#endif
if (cd->packptr == 0)
error("! a non-existent virtual character is being used; check vf/tfm files") ;
curpos = cd->packptr + 2 ;
@@ -244,11 +218,7 @@
goto outofmem ;
} else {
pagecost++ ;
-#ifdef Omega
if (!prescanchar(curfnt->chardesc + mychar))
-#else
- if (!prescanchar(curfnt->chardesc + cmd))
-#endif
goto outofmem ;
}
break ;
diff -ur dvipsk-5.94b.orig/texk/dvipsk/skippage.c dvipsk-5.94b/texk/dvipsk/skippage.c
--- dvipsk-5.94b.orig/texk/dvipsk/skippage.c 1999-02-17 08:04:06.000000000 +0100
+++ dvipsk-5.94b/texk/dvipsk/skippage.c 2005-01-19 01:05:06.000000000 +0100
@@ -19,6 +19,7 @@
extern integer pagenum ;
extern char errbuf[] ;
extern FILE *dvifile ;
+extern Boolean noomega ;
/*
* And now the big routine.
*/
@@ -41,21 +42,11 @@
while ((cmd=dvibyte())!=140) {
switch (cmd) {
/* illegal options */
-#ifdef Omega
case 130: case 131: case 135: case 136: case 139:
case 247: case 248: case 249: case 250: case 251:
case 252: case 253: case 254: case 255:
-#else
-case 129: case 130: case 131: case 134: case 135: case 136: case 139:
-case 247: case 248: case 249: case 250: case 251: case 252: case 253:
-case 254: case 255:
-#endif
(void)sprintf(errbuf,
-#ifdef SHORTINT
- "! DVI file contains unexpected command (%ld)",cmd) ;
-#else /* ~SHORTINT */
"! DVI file contains unexpected command (%d)",cmd) ;
-#endif /* ~SHORTINT */
error(errbuf) ;
/* eight byte commands */
case 132: case 137:
@@ -70,9 +61,12 @@
case 145: case 150: case 155: case 159: case 164: case 169: case 237:
cmd = dvibyte() ;
/* two byte commands */
-#ifdef Omega
case 129: case 134:
-#endif
+ if (noomega) {
+ (void)sprintf(errbuf,
+ "! DVI file contains unexpected Omega command (%d)",cmd) ;
+ error(errbuf) ;
+ }
case 144: case 149: case 154: case 158: case 163: case 168: case 236:
cmd = dvibyte() ;
/* one byte commands */
diff -ur dvipsk-5.94b.orig/texk/dvipsk/tfmload.c dvipsk-5.94b/texk/dvipsk/tfmload.c
--- dvipsk-5.94b.orig/texk/dvipsk/tfmload.c 2005-01-17 20:55:42.000000000 +0100
+++ dvipsk-5.94b/texk/dvipsk/tfmload.c 2005-01-19 00:58:08.000000000 +0100
@@ -20,12 +20,20 @@
#endif
extern char errbuf[] ;
extern integer fsizetol ;
+extern Boolean noomega ;
/*
* Our static variables:
*/
FILE *tfmfile ;
static char name[50] ;
+void
+badtfm P1C(char *, s)
+{
+ (void)sprintf(errbuf,"! Bad TFM file %s: %s",name,s) ;
+ error(errbuf);
+}
+
/*
* Tries to open a tfm file. Uses cmr10.tfm if unsuccessful,
* and complains loudly about it.
@@ -50,8 +58,7 @@
#endif
if ((tfmfile=search(d, name, READBIN))!=NULL)
return ;
-#ifdef Omega
- {
+ if (!noomega) {
#ifdef KPATHSEA
d = ofmpath;
#endif
@@ -59,7 +66,6 @@
if ((tfmfile=search(d, name, READBIN))!=NULL)
return ;
}
-#endif
(void)sprintf(errbuf, "Can't open font metric file %s%s",
fd->area, name) ;
error(errbuf) ;
@@ -99,26 +105,16 @@
int
tfmload P1C(register fontdesctype *, curfnt)
{
-#ifdef Omega
register integer i, j ;
-#else
- register shalfword i ;
-#endif
- register integer li ;
+ register integer li, cd ;
integer scaledsize ;
- shalfword nw, hd ;
-#ifdef Omega
+ integer nw, hd ;
integer bc, ec ;
- integer nco, ncw, npc, no_repeats ;
- integer scaled[65536] ;
- integer chardat[65536] ;
- integer font_level ;
+ integer nco, ncw, npc, no_repeats = 0 ;
+ integer *scaled ;
+ integer *chardat ;
+ int font_level ;
integer pretend_no_chars ;
-#else
- shalfword bc, ec ;
- integer scaled[256] ;
- halfword chardat[256] ;
-#endif
int charcount = 0 ;
tfmopen(curfnt) ;
@@ -126,7 +122,6 @@
* Next, we read the font data from the tfm file, and store it in
* our own arrays.
*/
-#ifdef Omega
li = tfm16() ;
if (li!=0) {
font_level = -1 ;
@@ -134,12 +129,18 @@
bc = tfm16() ; ec = tfm16() ;
nw = tfm16() ;
li = tfm32() ; li = tfm32() ; li = tfm32() ; li = tfm16() ;
+ if (hd<2 || bc>ec+1 || ec>255 || nw>256)
+ badtfm("header") ;
} else { /* In an .ofm file */
+ if (noomega) badtfm("length") ;
font_level = tfm16();
li = tfm32() ; hd = tfm32() ;
bc = tfm32() ; ec = tfm32() ;
nw = tfm32() ;
for (i=0; i<8; i++) li=tfm32();
+ if (font_level>1 || hd<2 || bc<0 || ec<0 || nw<0
+ || bc>ec+1 || ec>65535 || nw>65536)
+ badtfm("header") ;
if (font_level==1) {
nco = tfm32() ;
ncw = tfm32() ;
@@ -147,12 +148,6 @@
for (i=0; i<12; i++) li=tfm32();
}
}
-#else
- li = tfm16() ; hd = tfm16() ;
- bc = tfm16() ; ec = tfm16() ;
- nw = tfm16() ;
- li = tfm32() ; li = tfm32() ; li = tfm32() ; li = tfm16() ;
-#endif
li = tfm32() ;
check_checksum (li, curfnt->checksum, curfnt->name);
li = (integer)(alpha * (real)tfm32()) ;
@@ -161,68 +156,50 @@
(void)sprintf(errbuf,"Design size mismatch in %s", name) ;
error(errbuf) ;
}
-#ifdef Omega
pretend_no_chars=ec+1 ;
if (pretend_no_chars<256) pretend_no_chars=256 ;
- curfnt->chardesc = (chardesctype *)
- realloc(curfnt->chardesc, sizeof(chardesctype)*pretend_no_chars) ;
+ else
+ curfnt->chardesc = (chardesctype *)
+ xrealloc(curfnt->chardesc, sizeof(chardesctype)*pretend_no_chars) ;
for (i=2; i<((font_level==1)?nco-29:hd); i++)
li = tfm32() ;
+ chardat = (integer *) xmalloc(pretend_no_chars*sizeof(integer)) ;
for (i=0; i<pretend_no_chars; i++)
chardat[i] = -1 ;
- no_repeats = 0 ;
-#else
- for (i=2; i<hd; i++)
- li = tfm32() ;
- for (i=0; i<256; i++)
- chardat[i] = 256 ;
-#endif
for (i=bc; i<=ec; i++) {
-#ifdef Omega
if (no_repeats>0) {
- chardat[i] = chardat[i-1] ;
no_repeats-- ;
} else if (font_level>=0) {
- chardat[i] = tfm16() ;
+ cd = tfm16() ;
li = tfm32() ;
- li |= tfm16() ;
+ li = tfm16() ;
if (font_level==1) {
no_repeats = tfm16() ;
for (j=0; j<(npc|1); j++) tfm16() ;
ncw -= 3 + npc/2 ;
}
} else {
- chardat[i] = tfmbyte() ;
+ cd = tfmbyte() ;
li = tfm16() ;
- li |= tfmbyte() ;
+ li = tfmbyte() ;
}
- if (li || chardat[i])
+ if (cd>=nw) badtfm("char info") ;
+ if (cd) {
+ chardat[i] = cd ;
charcount++ ;
-#else
- chardat[i] = tfmbyte() ;
- li = tfm16() ;
- li |= tfmbyte() ;
- if (li || chardat[i])
- charcount++ ;
-#endif
+ }
}
-#ifdef Omega
if (font_level==1&&ncw!=0) {
sprintf(errbuf, "Table size mismatch in %s", curfnt->name) ;
error(errbuf) ;
}
-#endif
scaledsize = curfnt->scaledsize ;
+ scaled = (integer *) xmalloc(nw*sizeof(integer)) ;
for (i=0; i<nw; i++)
scaled[i] = scalewidth(tfm32(), scaledsize) ;
(void)fclose(tfmfile) ;
-#ifdef Omega
for (i=0; i<pretend_no_chars; i++)
if (chardat[i]!= -1) {
-#else
- for (i=0; i<256; i++)
- if (chardat[i]!= 256) {
-#endif
li = scaled[chardat[i]] ;
curfnt->chardesc[i].TFMwidth = li ;
if (li >= 0)
@@ -231,10 +208,10 @@
curfnt->chardesc[i].pixelwidth = -((integer)(conv*-li+0.5)) ;
curfnt->chardesc[i].flags = (curfnt->resfont ? EXISTS : 0) ;
curfnt->chardesc[i].flags2 = EXISTS ;
- }
-#ifdef Omega
+ } else curfnt->chardesc[i].flags = curfnt->chardesc[i].flags2 = 0 ;
+ free(chardat) ;
+ free(scaled) ;
if (ec>=256) curfnt->codewidth = 2 ; /* XXX: 2byte-code can have ec<256 */
-#endif
curfnt->loaded = 1 ;
return charcount ;
}
diff -ur dvipsk-5.94b.orig/texk/dvipsk/virtualfont.c dvipsk-5.94b/texk/dvipsk/virtualfont.c
--- dvipsk-5.94b.orig/texk/dvipsk/virtualfont.c 2005-01-15 18:40:38.000000000 +0100
+++ dvipsk-5.94b/texk/dvipsk/virtualfont.c 2005-01-19 00:59:34.000000000 +0100
@@ -30,6 +30,7 @@
extern char *nextstring, *maxstring ;
extern fontdesctype *fonthead ;
extern real alpha ;
+extern Boolean noomega ;
/*
* Now we have some routines to get stuff from the VF file.
* Subroutine vfbyte returns the next byte.
@@ -100,14 +101,13 @@
if (0 != (vffile=search(d, name, READBIN)))
#endif
return(1) ;
-#ifdef Omega
+ if (!noomega)
#ifdef KPATHSEA
- if (0 != (vffile=search(ovfpath, n, READBIN)))
+ if (0 != (vffile=search(ovfpath, n, READBIN)))
#else
- if (0 != (vffile=search(d, n, READBIN)))
-#endif
- return(2) ;
+ if (0 != (vffile=search(d, n, READBIN)))
#endif
+ return(2) ;
return(0) ;
}
@@ -161,26 +161,15 @@
Boolean
virtualfont P1C(register fontdesctype *, curfnt)
{
-#ifdef Omega
register integer i ;
-#else
- register shalfword i ;
-#endif
register shalfword cmd ;
register integer k ;
register integer length ;
-#ifdef Omega
register integer cc ;
-#else
- register shalfword cc ;
-#endif
register chardesctype *cd ;
integer scaledsize = curfnt->scaledsize ;
-#ifdef Omega
- integer no_of_chars=256;
- integer maxcc=0;
- chardesctype *newchardesc;
-#endif
+ integer no_of_chars=256 ;
+ integer maxcc=255 ;
register quarterword *tempr ;
fontmaptype *fm, *newf ;
int kindfont ;
@@ -196,7 +185,6 @@
/*
* We clear out some pointers:
*/
-#ifdef Omega
if (kindfont==2) {
no_of_chars = 65536;
curfnt->maxchars=65536;
@@ -205,9 +193,6 @@
mymalloc(65536 * (integer)sizeof(chardesctype));
}
for (i=0; i<no_of_chars; i++) {
-#else
- for (i=0; i<256; i++) {
-#endif
curfnt->chardesc[i].TFMwidth = 0 ;
curfnt->chardesc[i].packptr = NULL ;
curfnt->chardesc[i].pixelwidth = 0 ;
@@ -250,11 +235,7 @@
if (length<2) badvf("negative length packet") ;
if (length>65535) badvf("packet too long") ;
cc = vfquad() ;
-#ifdef Omega
- if (cc<0 || cc>65535) badvf("character code out of range") ;
-#else
- if (cc<0 || cc>255) badvf("character code out of range") ;
-#endif
+ if (cc<0 || cc>=no_of_chars) badvf("character code out of range") ;
cd = curfnt->chardesc + cc ;
cd->TFMwidth = scalewidth(vfquad(), scaledsize) ;
} else {
@@ -263,9 +244,7 @@
cd = curfnt->chardesc + cc ;
cd->TFMwidth = scalewidth(vftrio(), scaledsize) ;
}
-#ifdef Omega
maxcc = (maxcc<cc) ? cc : maxcc;
-#endif
if (cd->TFMwidth >= 0)
cd->pixelwidth = ((integer)(conv*cd->TFMwidth+0.5)) ;
else
@@ -309,15 +288,11 @@
badvf("missing postamble") ;
(void)fclose(vffile) ;
curfnt->loaded = 2 ;
-#ifdef Omega
- newchardesc = (chardesctype *)
- mymalloc((maxcc+1) * (integer)sizeof(chardesctype));
- for (i=0; i<=maxcc; i++) {
- newchardesc[i] = curfnt->chardesc[i];
+ if (maxcc+1<no_of_chars) {
+ curfnt->chardesc = (chardesctype *)
+ xrealloc(curfnt->chardesc,
+ (maxcc+1) * (integer)sizeof(chardesctype));
+ curfnt->maxchars=maxcc+1;
}
- free(curfnt->chardesc);
- curfnt->chardesc = newchardesc;
- curfnt->maxchars=maxcc+1;
-#endif
return (1) ;
}
More information about the tex-k
mailing list