README-tl.txt100666 0 0 10037 11367657637 12026 0ustar kakutogroup dvipsk-5.98-p1.7b-tl2009.diff TeXLive 2009 中の dvipsk に、アスキー(株) による 日本語サポート拡張 機能p1.7b を付加する unofficial patch です。さらに TeXLive 2010 に向けて 開発中である最新の dvipsk-5.98dev になります。dvipsk-5.98 以降では標準 エラー出力へ出力されるファイル名がフルパス (場合によってカレントディレ クトリからの相対パス) となるようになっています。また環境変数 DVIPSDEBUG を定義するとconfiguration files と map files も表示します。ただしこれらは バナー表示より前に表示されます。変数 DVIPSDEBUG は定義されておればよく、 値は何でもよくなっています。日本語パッチをあてた実行ファイル名は pdvips と なるようにしています。オリジナルの dvips も build することをお勧めします。 従って次のようにすると良いでしょう。オリジナルの dvipsk ディレクトリと同じ レベルに pdvipsk なるディレクトリを作成し、その中にオリジナルのソースを コピーします。その後カレントディレクトリを新規作成した pdvipsk にして patch -p1 ";". 2010/03/26 security fixes for virtualfont.c and dospecial.c. 2010/03/01 patch for dvipsk in TeXLive 2009. 2009/06/27 synchronized with texlive repository. 2009/06/13 getline --> texlive_getline in afm2tfm.c 2009/06/10 updated dvips.texi and dvips.info 2009/06/01 dvipsk-5.98 2009/05/09 synchronized with texlive repository. 2009/05/07 check of ranges of some arrays in dvips.c and resident.c. Thanks Yamamoto san and Tsuchimura san. 2009/04/05 writet1.c 2009/03/24 writet1.c 2008/11/05 dvips.texi 2008/11/03 dvips.texi 2008/09/25 hps.c, hps.lpro Mark (doyle/aps/org) does not want to be notified of changes any longer (or for the past decade or so :). 2008/09/23 hps.c (do_html): get scale factors right. (hoff, voff): remove, hh and vv are already calculated by using hoff and voff in dopage.c. 2008/09/21 allow numbers beginning by a period in -O etc. 2008/09/05 email address of asciimw. 2008/08/17 source is assumed to be dvipsk in TL-2008. biary is pdvips. 2008/07/12 dvipsk-5.97 2008/05/08 Change of output.c by dmj@ams.org. 2008/04/17 1.7b (released) 2008/04/09 1.7a --> 1.7b 2008/02/20 bbox.c (256 --> MAX_CODE, report from ttk) 2007/12/24 dvips.c (helparr: show -) 2007/12/03 skippage.c (erased unused variable) 2007/10/22 hps.c 2007/10/11 resident.c 2007/09/02 paper sizes in config.ps 2007/06/10 special{ps::[nobreak]...} 2007/06/02 delete head.tmp and body.tmp in dvips -z ... . 2007/03/31 TeXLive SVN latest source 2007/03/24 dvipsk-5.96 and beyond. 2006/05/04 changed an error message in resident.c. 2006/04/26 indelta() in output.c etc. 2006/04/24 trytobreakout() in dospecial.c etc. 2006/03/07 added error message for the -R2 mode (output.c, header.c, writet1.c). 2006/03/05 added error message for the -R2 mode (output.c). enlarged errbuf from 200 to 512 (loadfont.c). 2006/03/03 hps.lpro (by Heiko Oberdiek) 2006/01/20 secure = 0, 1, 2 (default: 1) 2005/11/02 p1.7 --> p1.7a 2005/08/23 dvipsk-5.95b 2005/02/09 portability fix 2005/02/07 tetex-src-3.0 2005/02/04 tetex-src-2.99.12.20050203-beta 2005/01/31 dvipsk-5.95a 2005/01/30 changed search order of ofm and tfm in the case of noomega==0 2005/01/25 bug fix 2005/01/24 teTeX-src-2.99.10.20050123-beta 2005/01/17 dvipsk-5.95 2004/12/27 teTeX-src-2.99.7.20041226-beta 2004/12/21 new writet1.c 2004/12/08 tetex-src-2.99.5.20041207-beta 2004/10/23 tetex-src-beta-2.99.0.20041023 2004/08/20 p1.6a 2004/08/15 dvipsk-5.94b 2004/06/28 A. Kakuto dvipsk-5.98-p1.7b-tl2009.diff100666 0 0 2621442 11370007512 14244 0ustar kakutogroup dvipsk-5.98-p1.7b-tl2009.diff TeXLive 2009 中の dvipsk に、アスキー(株) による 日本語サポート拡張 機能p1.7b を付加する unofficial patch です。さらに TeXLive 2010 に向けて 開発中である最新の dvipsk-5.98dev になります。dvipsk-5.98 以降では標準 エラー出力へ出力されるファイル名がフルパス (場合によってカレントディレ クトリからの相対パス) となるようになっています。また環境変数 DVIPSDEBUG を定義するとconfiguration files と map files も表示します。ただしこれらは バナー表示より前に表示されます。変数 DVIPSDEBUG は定義されておればよく、 値は何でもよくなっています。日本語パッチをあてた実行ファイル名は pdvips と なるようにしています。オリジナルの dvips も build することをお勧めします。 従って次のようにすると良いでしょう。オリジナルの dvipsk ディレクトリと同じ レベルに pdvipsk なるディレクトリを作成し、その中にオリジナルのソースを コピーします。その後カレントディレクトリを新規作成した pdvipsk にして patch -p1 ";". 2010/03/26 security fixes for virtualfont.c and dospecial.c. 2010/03/01 patch for dvipsk in TeXLive 2009. 2009/06/27 synchronized with texlive repository. 2009/06/13 getline --> texlive_getline in afm2tfm.c 2009/06/10 updated dvips.texi and dvips.info 2009/06/01 dvipsk-5.98 2009/05/09 synchronized with texlive repository. 2009/05/07 check of ranges of some arrays in dvips.c and resident.c. Thanks Yamamoto san and Tsuchimura san. 2009/04/05 writet1.c 2009/03/24 writet1.c 2008/11/05 dvips.texi 2008/11/03 dvips.texi 2008/09/25 hps.c, hps.lpro Mark (doyle/aps/org) does not want to be notified of changes any longer (or for the past decade or so :). 2008/09/23 hps.c (do_html): get scale factors right. (hoff, voff): remove, hh and vv are already calculated by using hoff and voff in dopage.c. 2008/09/21 allow numbers beginning by a period in -O etc. 2008/09/05 email address of asciimw. 2008/08/17 source is assumed to be dvipsk in TL-2008. biary is pdvips. 2008/07/12 dvipsk-5.97 2008/05/08 Change of output.c by dmj@ams.org. 2008/04/17 1.7b (released) 2008/04/09 1.7a --> 1.7b 2008/02/20 bbox.c (256 --> MAX_CODE, report from ttk) 2007/12/24 dvips.c (helparr: show -) 2007/12/03 skippage.c (erased unused variable) 2007/10/22 hps.c 2007/10/11 resident.c 2007/09/02 paper sizes in config.ps 2007/06/10 special{ps::[nobreak]...} 2007/06/02 delete head.tmp and body.tmp in dvips -z ... . 2007/03/31 TeXLive SVN latest source 2007/03/24 dvipsk-5.96 and beyond. 2006/05/04 changed an error message in resident.c. 2006/04/26 indelta() in output.c etc. 2006/04/24 trytobreakout() in dospecial.c etc. 2006/03/07 added error message for the -R2 mode (output.c, header.c, writet1.c). 2006/03/05 added error message for the -R2 mode (output.c). enlarged errbuf from 200 to 512 (loadfont.c). 2006/03/03 hps.lpro (by Heiko Oberdiek) 2006/01/20 secure = 0, 1, 2 (default: 1) 2005/11/02 p1.7 --> p1.7a 2005/08/23 dvipsk-5.95b 2005/02/09 portability fix 2005/02/07 tetex-src-3.0 2005/02/04 tetex-src-2.99.12.20050203-beta 2005/01/31 dvipsk-5.95a 2005/01/30 changed search order of ofm and tfm in the case of noomega==0 2005/01/25 bug fix 2005/01/24 teTeX-src-2.99.10.20050123-beta 2005/01/17 dvipsk-5.95 2004/12/27 teTeX-src-2.99.7.20041226-beta 2004/12/21 new writet1.c 2004/12/08 tetex-src-2.99.5.20041207-beta 2004/10/23 tetex-src-beta-2.99.0.20041023 2004/08/20 p1.6a 2004/08/15 dvipsk-5.94b 2004/06/28 A. Kakuto diff -Nu dvipsk2009/AUTHORS dvipsk/AUTHORS --- dvipsk2009/AUTHORS Wed Jan 18 06:41:51 2006 +++ dvipsk/AUTHORS Fri Dec 25 03:38:48 2009 @@ -1,5 +1,6 @@ -This program, dvipsk, was modified by kb@mail.tug.org from Tom Rokicki's -dvips distribution. Send bug reports to tex-k@mail.tug.org, not to Tom. +This program, dvipsk, was originally modified by Karl Berry from Tom +Rokicki's dvips distribution. Send bug reports to tex-k@tug.org, +not to Tom personally. Jim Hafner originally implemented the color support. Sergey Lesenko originally implemented the partial Type 1 font downloading. diff -Nu dvipsk2009/ChangeLog dvipsk/ChangeLog --- dvipsk2009/ChangeLog Sun Sep 27 03:30:44 2009 +++ dvipsk/ChangeLog Tue May 04 08:42:14 2010 @@ -1,8 +1,260 @@ +2010-05-03 Jan Lieskovsky + + * dospecial.c (predospecial, bbdospecial): avoid numeric overflow. + tetex-3.0-CVE-2010-0739,1440-integer-overflows.patch, + from Ludwig Nussel, Karel Srot. + tlsecurity mail 30 Apr 2010 16:59:37. + +2010-04-26 Akira Kakuto + + * afm2tfm.c: (write16()): cast argument to short to avoid warning. + +2010-04-25 Akira Kakuto + + * writet1.c (edecrypt()): cast argument to byte to avoid warning. + * dvips.c: Use IS_DIR_SEP for the test of a directory separator. + +2010-04-12 Peter Breitenlohner + + * Makefile.am (EXTRA_DIST): Add afm2tfm-test.pl. + +2010-04-11 Karl Berry + + * afm2tfm.c (staticligkern): restore spaces around semicolons, + accidentally removed in source cleanup. + + * afm2tfm.c (throughout): use snprintf where needed. + + * afm2tfm-test.pl: New test script for afm2tfm. + + * Makefile.am (TESTS): Add the new test. + +2010-03-29 Karl Berry + + * loadfont.c, + * tfmload.c, + * virtualfont.c: concatn terminates with NULL. From Akira. + +2010-03-28 Karl Berry + + * all files: no spaces before semicolons. + + * loadfont.c, + * tfmload.c, + * virtualfont.c, + * bbox.c, + * writet1.c, + * dvips.c, + * header.c: dynamically concatenate more error strings. + * protos.h (errbuf): increase. + +2010-03-26 Karl Berry + + * virtualfont.c (badvf, virtualfont): use concat[n] instead of + sprintf for error messages. + (): #include. + + * virtualfont.c (vfopen): do not sprintf too long of a name. + CVE-2010-0827, found by Dan Rosenberg. + + * dospecial.c (predospecial): avoid seg fault from integer overflow. + CVE-2010-0739, found by Marc Schoenefeld, patch prepared + by Jindrich Novy. + +2010-02-26 Karl Berry + + * search.c (selfautoloc_prog, quote_name): remove kpse_ prefix for + the time being, since it seems web2c's safeness stuff can't be + easily factored into using them. + +2010-02-23 Peter Breitenlohner + + * search.c: #include for kpse_var_value. + +2010-02-19 Peter Breitenlohner + + * Makefile.am (EXTRA_DIST): Add the new files. + +2010-02-19 Karl Berry + + * search.c (kpse_self_autoloc_prog) [WIN32]: p needs to be + writable. From Akira. + +2010-02-18 Karl Berry + + * Makefile.am (TESTS): add quotecmd-test.pl. + * quotecmd-test.pl, + * testdata/quotecmd.tex: new files. + * search.c (search): selfautoloc gunzip, and quote name before + calling popen. + (kpse_quote_name, kpse_self_autoloc_prog): new fns, + only temporarily here until we factor out the common code from + texmfmp.c. + +2010-02-12 Peter Breitenlohner + + * dvips.c (main): Add '#if defined(KPSE_DEBUG)' to allow + compilation with '-DNO_DEBUG'. + +2010-02-12 Karl Berry + + * search.c: remove non-KPATHSEA code. It just got too confusing + to keep track of which conditional we were in. (And non-KPATHSEA + hasn't actually worked or been used for many years, as far as I know.) + +2010-02-01 Karl Berry + + * dvips.h: switch banner to 5.98dev + * writet1.c (append_cs_return): cast to byte * to avoid warning. + +2010-01-03 Karl Berry + + * output.c (copyfile_general) : write newline + after writing possibleDSCLine. + * beginfontk1.test, + * testdata/beginfontk1.{tex,eps}: new test. + Report from T S, 1 Jan 2010 16:32:16, + fix from Akira Kakuto, 02 Jan 2010 09:07:19. + + * Makefile.am (TESTS_ENVIRONMENT): set TEXFONTS instead of + TFMFONTS, VFFONTS, and TEXFONTMAPS. + +2010-01-02 Karl Berry + + * dvips.texi (Debug options), + * dvips.1: update. + Report at http://bugs.debian.org/269638. + +2009-12-24 Karl Berry + + * INSTALLATION: rm stale file. + * reencode: remove stale dir, except ... + * contrib/treen.sh, contrib.treen2.sh: ... preserve this. + * Makefile.am (EXTRA_DIST): update + + * AUTHORS, README, dvips.1, contrib/config.proto: doc updates. + * INSTALL: remove, completely stale. + +2009-12-22 Karl Berry + + * debug.h (D_MEM): disable completely by defining to 0. + Memory allocations just don't seem to be interesting. + +2009-12-21 Karl Berry + + * protos.h (fil2ps): remove decl. + * dospecial.c (fil2ps): remove fn. + (dospecial): warn if iff2ps or tek2ps specials are noticed. + The goal here was to avoid executing external programs, with that + inhererent security risk, when (we believe) no one is actually + using the functionality. + +2009-12-14 Karl Berry + + * emspecial.c (emspecial): + Increase size of emunit to 30. + Increase size of emstr to 250. + Attempt to check that we don't overflow emstr. + Report from Alexander, tlsec 02 Dec 2009 00:28:33. + + * pc: remove obsolete subdir. + * Makefile.am (EXTRA_DIST): rm. + +2009-12-11 Alexander Cherepanov + + * protos.h (hash): change decl. + * resident.c (hash): return and use unsigned instead of int. + tlsec mail, 05 Dec 2009 19:09:56. + 2009-09-26 Karl Berry * config/config.ps (unknown): move to before nopaper; else nonstandard paper sizes, e.g., with the geometry package, end up unrecognized. + +2009-08-26 Peter Breitenlohner + + * testdata/dvipstst.xps, pfbincl.xps: Update for version 5.98. + +2009-08-25 Peter Breitenlohner + + Avoid maximal compiler warnings. Done in steps. + + Step 1: Move all extern decls for global variables to headers. + * Makefile.am: Additional file 'protos_add.h'. + * protos.h: Add prototype for fliparse() from flib.c. + Remove prototypes from squeeze.c (now in squeeze/). + Add extern decls for globals from dopage.c, dosection.c, + dvips.c, flib.c, hps.c, loadfont.c, output.c, pprescan.c, + repack.c, resident.c, search.c, and tfmload.c. + * color.c, dosection.c, dospecial.c, download.c, dpicheck.c, + drawPS.c, dviinput.c, emspecial.c, finclude.c, fontdef.c, + header.c, makefont.c, output.c, paths.h, pprescan.c, + prescan.c, repack.c, resident.c, scanpage.c, skippage.c, + tfmload.c, virtualfont.c: Drop extern declarations. + * writet1.c: Remove '#ifndef pdfTeX' sections of code. + Drop extern declarations. + * dvips.c, hps.c: #include "protos.h" before defining globals. + Drop extern declarations. + * protos_add.h (new): First #include "protos.h", then add + extern decls for stack from dopage.c and name from loadfont.c. + * bbox.c, dopage.c, flib.c, loadfont.c, search.c: + #include "protos_add.h" (instead of protos.h). Drop externs. + + Step 2: Avoid warnings: declaration of 'xxx' shadows a parameter + or previous local: + * dospecial.c (predospecial): Rename local numbytes=>num_bytes, + not to shadow function param. + Drop inner local j, not to shadow previous local. + + Step 3: + * afm2tfm.c (vlevout, vlevnlout), download.c (clearExtraGlyphList): + ANSI C function definitions, i.e., '()'=>'(void)'. + + Step 4: Constification of strings: + Step 4a: Struct members + * afm2tfm.c (encoding.name, encoding.vec, adobeinfo.adobename, + lig.succ, lig.sub, kern.succ, pcc.partname), + dospecial.c (KeyDesc.Entry), + download.c (seenEncodings.name, seenEncodings.glyphs), + dvips.h (header_list.Hname, papsiz.name, papsiz.specdat), + emspecial.c (emunit.unit), t1part.c (tablecommand.command, + typefonts.extension, type_key.name). + Step 4b: Global or static variables + * afm2tfm.c (staticligkern, vplligops, encligops, fontname, + codingscheme, interesting, accents), dospecial.c (ValStr, tasks), + dvips.c (oname, infont, headerfile, helparr), + emspecial.c (extarr), output.c (hxdata), papersiz.c (scalenames), + resident.c (psmapfile), + t1part.c (RefKey, hexstr, AfmKey, InfoKey), + writet1.c (hexdigits), protos.h. + Step 4c: Function parameter/results and local variables + * afm2tfm.c (error, interest, expect, findadobe, makebcpl, + checksum, texheight), + dospecial.c (specerror, IsSame, dospecial, fil2ps), + download.c (getEncoding, addGlyph, downpsfont), + dvips.c (help, error_with_perror, error, initialize, newstring, + main), + finclude.c (scan_fontnames, scanfontusage, scanfontcomments), + header.c (add_name, add_name_general, checkhmem, add_header, + add_header), hps.c (set_bitfile), loadfont.c (badpk), + output.c (copyfile_general, copyfile, cmdout, mhexout, nlcmdout, + ncstrcmp, paperspec), papersiz.c (myatodim[B + resident.c (bad_config, getdefaults, getpsinfo), + search.c (search, pksearch, my_real_fopen), tfmload.c (badtfm), + unpack.c (unpack), virtualfont.c (badvf), + writet1.c (pdftex_fail, pdftex_warn, load_enc, t1_open_fontfile, + t1_subset), protos.h. + Step 4d: Work around modifying const strings (e.g., modify + malloc'ed or strdup'ed strings before assigning them to a const + string variable): + * afm2tfm.c (openfiles), dvips.c (newstring, newoutname), + resident.c (getdefaults). + +2009-08-22 Peter Breitenlohner + + * afm2tfm.c, dvips.c: #include and drop + nested extern decls. 2009-07-17 Peter Breitenlohner diff -Nu dvipsk2009/INSTALL dvipsk/INSTALL --- dvipsk2009/INSTALL Wed Jan 18 06:41:51 2006 +++ dvipsk/INSTALL Thu Jan 01 09:00:00 1970 @@ -1,358 +0,0 @@ -Contents: - -Installation - `config.ps' installation - PostScript font installation - Ghostscript installation - Diagnosing problems - Debug options - No output at all - Output too small or inverted - Error messages from printer - Long documents fail to print - Including graphics fails - - -Installation -************ - - (A copy of this chapter is in the distribution file `dvipsk/INSTALL'.) - - Installing Dvips is mostly the same as installing any Kpathsea-using -program. Therefore, for the basic steps involved, *note Installation: -(kpathsea)Installation.. (A copy is in the file `kpathsea/INSTALL'.) - - For solutions to common installation problems and information on how -to report a bug, see the file `kpathsea/BUGS' (*note Bugs: -(kpathsea)Bugs.). For solutions to Dvips-specific problems, *note -Debug options::.. Also see the Dvips home page at -`http://www.radicaleye.com/dvips'. - - Dvips does require some additional installation, detailed in the -sections below. Also, to configure color devices, *note Color device -configuration::.. - -`config.ps' installation -======================== - - Dvips has its own configuration files: a file `config.ps' for -sitewide defaults, and a file `config.PRINTER' for each printer (output -device). Since these are site-specific, `make install' does not create -them; you must create them yourself. - - (These Dvips configuration files are independent of the Kpathsea -onfiguration file `texmf.cnf' (*note Config files: (kpathsea)Config -files.). - - Dvips configuration files contents and searching are described fully -in *Note Config files::. The simplest way to create a new -configuration file is to copy and modify the file -`dvipsk/contrib/config.proto', seasoning with options to your taste -from *Note Config files::. Here is `config.proto' for your reading -pleasure: - % Prototype Dvips configuration file. - - % How to print, maybe with lp instead lpr, etc. - o |lpr - - % Default resolution of this device, in dots per inch. - D 600 - - % Metafont mode. (This is completely different from the -M command-line - % option, which controls whether mktexpk is invoked.) Get - % `ftp://ftp.tug.org/tex/modes.mf' for a list of mode names. This mode - % and the D number above must agree, or mktexpk will get confused. - M ljfour - - % Memory available. Download the three-line PostScript file: - % %! Hey, we're PostScript - % /Times-Roman findfont 30 scalefont setfont 144 432 moveto - % vmstatus exch sub 40 string cvs show pop showpage - % to determine this number. (It will be the only thing printed.) - m 3500000 - - % Correct printer offset. You can use testpage.tex from the LaTeX - % distribution to find these numbers. Print testpage.dvi more than once. - O 0pt,0pt - - % Partially download Type 1 fonts by default. Only reason not to do - % this is if you encounter bugs. (Please report them to - % if you do.) - j - - % Also look for fonts at these resolutions. - R 300 600 - - % With a high resolution and a RISC cpu, better to compress the bitmaps. - Z - - % Uncomment these if you have and want to use PostScript versions of the - % fonts. - %p +cmfonts.map - %p +lafonts.map - %p +cyrfonts.map - %p +eufonts.map - - % You will also want definitions for alternative paper sizes -- A4, - % legal, and such. Examples in `contrib/papersize.level2' and - % `contrib/papersize.simple'. - -PostScript font installation -============================ - - To use PostScript fonts with TeX and Dvips, you need both metric -files (`.tfm' and `.vf') and the outlines (`.pfa' or `.pfb'). *Note -Font concepts::. - - To support the basic PostScript font set, the recommended (and -simplest) approach is to retrieve -`ftp://ftp.tug.org/tex/psfonts.tar.gz' and unpack it in your -`$(fontdir)' directory (`/usr/local/share/texmf/fonts' by default). -This archive contains metrics, outlines, and bitmaps (for previewing) -for the 35 de facto standard fonts donated by URW and the additional -high-quality freely available PostScript fonts donated by Adobe, -Bitstream, and URW, including geometrically-created variants such as -oblique and small caps. - - `CTAN:/fonts/psfonts' contains support for many additional fonts for -which you must buy outlines (Adobe, Bigelow & Holmes, Monotype, -Softkey, Y&Y). `psfonts.tar.gz' is a small extract from this -directory. (For CTAN info, *note unixtex.ftp: (kpathsea)unixtex.ftp.; -a copy is in the top-level file `INSTALL'.) - - If you have additional PostScript fonts, you can make them available -to Dvips by (1) giving them with appropriate filenames; and (2) running -Afm2tfm (*note Making a font available::.) to make TFM and VF metrics -for TeX and Dvips to use. Also add them to `psfonts.map' if necessary -(*note psfonts.map::.); it contains everything contained in -`psfonts.tar.gz' and most fonts that come with Unix systems. - - Following are locations for vendor-supplied fonts. Please mail - if you find fonts elsewhere on your system. - -DEC Ultrix - /usr/lib/DPS/outline/decwin - -DEC Digital Unix - /usr/lib/X11/fonts/Type1Adobe - -HP HP-UX 9, 10 - /usr/lib/X11/fonts/type1.st/typefaces - -IBM AIX - /usr/lpp/DPS/fonts/outlines - /usr/lpp/X11/lib/X11/fonts/Type1 - /usr/lpp/X11/lib/X11/fonts/Type1/DPS - -NeXT - /NextLibrary/Fonts/outline - -SGI IRIX - /usr/lib/DPS/outline/base /usr/lib/X11/fonts/Type1 - -Sun SunOS 4.x - (NeWSprint only) - newsprint_2.5/SUNWsteNP/reloc/$BASEDIR/ - NeWSprint/small_openwin/lib/fonts - /usr/openwin/lib/X11/fonts/Type1/outline - -Sun Solaris 2 - /usr/openwin/lib/X11/fonts/Type1/outline - -VMS - SYS$COMMON:[SYSFONT.XDPS.OUTLINE] - -The NeXT system supplies more fonts than any others, but there's a lot -of overlap. - - Finally, if you have an Hewlett-Packard printer, you should be able to -get Type 1 font files for the standard 35 fonts from HP, if the freely -available URW Type 1's do not satisfy for whatever reason. The phone -number for HP Printer Drivers is (in the United States) 303-339-7009. -The driver set to ask for is Adobe Type Manager 2.51, and the disk set -number is `MP210en3'. Mentioning anything other than Microsoft Windows -when you ask for the driver set will likely lead to great confusion on -the other end. - -Ghostscript installation -======================== - - Ghostscript is a PostScript interpreter freely available to end-users, -written by Peter Deutsch. It can read the PostScript produced by Dvips -and render it on your monitor, or for another device (e.g., an Epson -printer) that does not support PostScript, or in PDF format. The latest -version is available via `http://www.cs.wisc.edu/~ghost/index.html' and -`ftp://ftp.cs.wisc.edu/pub/ghost/aladdin/'. - - A somewhat older version of Ghostscript is available under the GNU -General Public License, free to everyone. You can get that from -`ftp://prep.ai.mit.edu/pub/gnu/'. - - The program Ghostview, written by Tim Theisen, provides typical -previewing capabilities (next page/previous page, magnification, etc.). -It requires Ghostscript to run, and files in structured Postscript, -specifically with `%%Page' comments (no `N' in `config.ps'). You can -get Ghostview from the same places as Ghostscript. - -Diagnosing problems -=================== - - You've gone through all the trouble of installing Dvips, carefully -read all the instructions in this manual, and still can't get something -to work. The following sections provide some helpful hints if you find -yourself in such a situation. - - For details on effective bug reporting, common installation problems, -and `mktexpk' problems, *note Bugs: (kpathsea)Bugs.. - -Debug options -------------- - - The `-d' flag to Dvips helps in tracking down certain errors. The -parameter to this flag is an integer that tells what errors are -currently being tracked. To track a certain class of debug messages, -simply provide the appropriate number given below; if you wish to track -multiple classes, sum the numbers of the classes you wish to track. To -track all classes, you can use `-1'. Another useful value is `3650', -which tracks everything having to do with file searching and opening. - - Some of these debugging options are actually provided by Kpathsea -(*note Debugging: (kpathsea)Debugging.). - - The classes are: -1 - specials - -2 - paths - -4 - fonts - -8 - pages - -16 - headers - -32 - font compression - -64 - files - -128 - config files - -256 - Partial Type 1 font encoding vectors - -512 - Partial Type 1 subr calls - -1024 - Kpathsea `stat' calls - -2048 - Kpathsea hash table lookups - -4096 - Kpathsea path element expansion - -8192 - Kpathsea path searches - -No output at all ----------------- - - If you are not getting any output at all, even from the simplest -one-character file (for instance, `\ \bye'), then something is very -wrong. Practically any file sent to a PostScript laser printer should -generate some output, at the very least a page detailing what error -occurred, if any. Talk to your system administrator about downloading a -PostScript error handler. (Adobe distributes a good one called -`ehandler.ps'.) - - It is possible, especially if you are using non-Adobe PostScript, that -your PostScript interpreter is broken. Even then it should generate an -error message. Dvips tries to work around as many bugs as possible in -common non-Adobe PostScript interpreters, but doubtless it misses a few. -PowerPage Revision 1, Interpreter Version 20001.001, on a Mitsubishi -Shinko CHC-S446i color thermal dye sublimation printer is known to be -unable to print with any but builtin fonts. - - If Dvips gives any strange error messages, or compilation on your -machine generated a lot of warnings, perhaps the Dvips program itself is -broken. Try using the debug options to determine where the error -occurred (*note Debug options::.). - - It is possible your spooler is broken and is misinterpreting the -structured comments. Try the `-N' flag to turn off structured comments -and see what happens. - -Output too small or inverted ----------------------------- - - If some documents come out inverted or too small, probably your -spooler is not supplying an end of job indicator at the end of each -file. (This commonly happens on small machines that don't have -spoolers.) You can force Dvips to do this with the `-F' flag (or `F' -config file option), but this generates files with a terminating binary -character (control-D). You can also try using the `-s' flag (or `s' -config file option) to enclose the entire job in a save/restore pair. -*Note Command-line options::, and *Note Config files::. - -Error messages from printer ---------------------------- - - If your printer returns error messages, the error message gives very -good information on what might be going wrong. One of the most common -error messages is `bop undefined'. This is caused by old versions of -Transcript and other spoolers that do not properly parse the setup -section of the PostScript. To fix this, turn off structured comments -with the `-N' option, but it'd be best to get your spooling software -updated. - - Another error message is `VM exhausted'. Some printers indicate this -error by locking up, others quietly reset. This is caused by Dvips -thinking that the printer has more memory than it actually does, and -then printing a complicated document. To fix this, try lowering the -`m' parameter in the configuration file; use the debug option to make -sure you adjust the correct file. - - Other errors may indicate you are trying to include graphics that -don't nest properly in other PostScript documents, among other things. -Try the PostScript file on a QMS PS-810 or other Adobe PostScript -printer if you have one, or Ghostscript (*note Ghostscript -installation::.); it might be a problem with the printer itself. - -Long documents fail to print ----------------------------- - - This is usually caused by incorrectly specifying the amount of memory -the printer has in the configuration file; see the previous section. - -Including graphics fails ------------------------- - - The most common problem with including graphics is an incorrect -bounding box (*note Bounding box::.). Complain to whoever wrote the -software that generated the file if the bounding box is indeed -incorrect. - - Another possible problem is that the figure you are trying to include -does not nest properly; there are certain rules PostScript applications -must follow when generating files to be included. The Dvips program -includes work-arounds for such errors in Adobe Illustrator and other -programs, but there are certainly applications that haven't been tested. - - One possible thing to try is the `-K' flag which strips the comments -from an included figure. This might be necessary if the PostScript -spooling software does not read the structured comments correctly. Use -of this flag will break graphics from some applications, though, since -some applications read the PostScript file from the input stream, -looking for a particular comment. - - Any application which generates graphics output containing raw binary -(not ASCII hex) will probably fail with Dvips. - diff -Nu dvipsk2009/INSTALLATION dvipsk/INSTALLATION --- dvipsk2009/INSTALLATION Wed Jan 18 06:41:51 2006 +++ dvipsk/INSTALLATION Thu Jan 01 09:00:00 1970 @@ -1,227 +0,0 @@ -THIS FILE IS WAY OUT OF DATE. - -Installation - -If dvips has not already been installed on your system, the -following steps are all that is needed for installation of the program. -After untaring, all installation files are found in this subdirectory. - -1. Update Makefile---in particular, the paths. Everything -concerning dvips can be adjusted in the Makefile. Make sure -you set key parameters such as the default resolution, and make sure -that the path given for packed pixel files is correct. - -2. Check the file name definitions in mktexpk. If you don't -have METAFONT installed, you cannot use mktexpk to automatically -generate the fonts; you can, however, modify it to generate pk -fonts from gf fonts if you don't have a full set of pk fonts -but do have a set of gf fonts. If you don't have that, you should -probably not install mktexpk at all; this will disable automatic -font generation. - -3. Check the configuration parameters in config.ps. You should -also update the default resolution here (default is set to 400 - this -is found in line 13). This file is the system-wide configuration -file that will be automatically installed. If you are unsure how -much memory your PostScript printer has, print the following file: - -%! Hey, we're PostScript -/Times-Roman findfont 30 scalefont setfont 144 432 moveto -vmstatus exch sub 40 string cvs show pop showpage - -Note that the number returned by this file is the total memory free; -it is often a good idea to tell dvips that the printer has somewhat -less memory. This is because many programs download permanent macros -that can reduce the memory in the printer. In general, a memory size -of about 300000 is plenty, since dvips can automatically split -a document if required. It is unfortunate that PostScript printers with -much less virtual memory still exist. - -Some systems or printers can dynamically increase the memory available -to a PostScript interpreter; for these systems, a value of one million -works well. - -4. Run make ("make dvips"). Everything should compile smoothly. -You may need to adjust the compiler options in the Makefile if something -goes amiss. - -5. Once everything is compiled, make install ("make install"). After -this is done, you may want to create a configuration file for each -PostScript printer at your site. - -6. If the font caching is considered a security hole, make the `cache' -directory be something like /tmp/pks, and cron a job to move the -good pk files into the real directory. Or simply disable this -feature by not installing mktexpk. - -7. Don't forget to install the new vf files and tfm files. Note -that the tfm files distributed with earlier (pre-5.471) versions -of dvips, and all versions of other PostScript drivers, are different. - -Diagnosing Problems - -You've gone through all the trouble of installing dvips, carefully -read all the instructions in this manual, and still can't get something -to work. This is all too common, and is usually caused by some broken -PostScript application out there. The following sections provide some -helpful hints if you find yourself in such a situation. - -In all cases, you should attempt to find the smallest file that causes -the problem. This will not only make debugging easier, it will also -reduce the number of possible interactions among different parts of the -system. - -Debug Options - -The -d flag to dvips is very useful for helping to track down -certain errors. The parameter to this flag is an integer that tells -what errors are currently being tracked. To track a certain class of -debug messages, simply provide the appropriate number given below; -if you wish to track multiple classes, sum the numbers of the classes -you wish to track. The classes are: - -1 specials -2 paths -4 fonts -8 pages -16 headers -32 font compression -64 files -128 memory - -No Output At All - -If you are not getting any output at all, even from the simplest -one-character file (for instance, \ \bye), -then something is very wrong. Practically any file sent to a -PostScript laser printer should generate some output, at the very -least a page detailing what error occurred, if any. Talk to your -system administrator about downloading a PostScript error handler. -(Adobe distributes a good one called ehandler.ps.) - -It is possible, especially if you are using non-Adobe PostScript, -that your PostScript interpreter is broken. Even then it should -generate an error message. I've tried to work around as many bugs -as possible in common non-Adobe PostScript interpreters, but I'm -sure I've missed a few. - -If dvips gives any strange error messages, or compilation on your -machine generated a lot of warnings, perhaps the dvips program -itself is broken. Carefully check the types in dvips.h and -the declarations in the Makefile, and try using the debug options -to determine where the error occurred. - -It is possible your spooler is broken and is misinterpreting the -structured comments. Try the -N flag to turn off -structured comments and see what happens. - -Output Too Small or Inverted - -If some documents come out inverted or too small, your spooler is not -supplying an end of job indicator at the end of each file. (This happens -a lot on small machines that don't have spoolers.) You can -force dvips to do this with the -F flag, but note that this -generates files with a binary character (control-D) in them. You can -also try using the -s flag to enclose the entire job in a save/restore -pair. - -Error Messages From Printer - -If your printer returns error messages, the error message gives very -good information on what might be going wrong. One of the most common -error messages is bop undefined. This is caused by old versions -of Transcript and other spoolers that do not properly parse the -setup section of the PostScript. To fix this, turn off structured -comments with the -N option, but make sure you get your spooling -software updated. - -Another error message is VM exhausted. (Some printers indicate -this error by locking up; others quietly reset.) This is caused by telling -dvips that the printer has more memory than it actually does, and -then printing a complicated document. To fix this, try lowering the -parameter to m in the configuration file; use the debug option -to make sure you adjust the correct file. - -Other errors may indicate that the graphics you are trying to include -don't nest properly in other PostScript documents, or any of a number of -other possibilities. Try the output on a QMS PS-810 or other Adobe -PostScript printer; it might be a problem with the printer itself. - -400 DPI Is Used Instead Of 300 DPI - -This common error is caused by not editing the config.ps file to -reflect the correct resolution for your site. You can use the debug flags -(-d64) to see what files are actually being read. - -Long Documents Fail To Print - -This is usually caused by incorrectly specifying the amount of memory -the printer has in config.ps; see the description above. - -Including Graphics Fails - -The reasons why graphics inclusions fail are too numerous to mention. -The most common problem is an incorrect bounding box; read the section -on bounding boxes and check your PostScript file. Complain very loudly -to whoever wrote the software that generated the file if the bounding -box is indeed incorrect. - -Another possible problem is that the figure you are trying to include -does not nest properly; there are certain rules PostScript applications -should follow when generating files to be included. The dvips -program includes work-arounds for such errors in Adobe Illustrator and -other programs, but there are certainly applications that haven't -been tested. - -One possible thing to try is the -K flag, to strip the comments from -an included figure. This might be necessary if the PostScript spooling -software does not read the structuring comments correctly. Use of this -flag will break graphics from some applications, though, since some -applications read the PostScript file from the input stream looking for -a particular comment. - -Any application which generates graphics output containing raw binary -(not hex) will probably fail with dvips. - -Can't Find Font Files - -If dvips complains that it cannot find certain font files, it is -possible that the paths haven't been set up correctly for your system. -Use the debug flags to determine precisely what fonts are being looked -for and make sure these match where the fonts are located on your system. - -Can't Generate Fonts - -This happens a lot if either mktexpk hasn't been properly edited -and installed, or if the local installation of METAFONT isn't correct. -If mktexpk isn't properly edited or isn't installed, an error -such as mktexpk not found will be printed on the console. The -fix is to talk to the person who installed dvips and have them fix -this. - -If METAFONT isn't found when mktexpk is running, make sure it is installed -on your system. The person who installed TeX should be able to install -METAFONT easily. - -If METAFONT runs but generates fonts that are too large (and prints out the -name of each character as well as just a character number), then your -METAFONT base file probably hasn't been made properly. To make a proper -plain.base, assuming the local mode definitions are contained in -local.mf (on the NeXT, next.mf; on the Amiga, amiga.mf), -type the following command (assuming csh under UNIX): - -localhost> inimf "plain; input local; dump" - -Now, copy the plain.base file from the current directory to where -the base files are stored on your system. - -Note that a preloaded cmbase.base should never be used when creating -fonts, and a program such as cmmf should never exist on the system. -The macros defined in cmbase will break fonts that do not use -cmbase; such fonts include the LaTeX fonts. Loading the cmbase -macros when they are needed is done automatically and takes less than a -second---an insignificant fraction of the total run time of METAFONT for a -font, especially when the possibility of generating incorrect fonts is -taken into account. If you create the LaTeX font {\tt circle10, -for instance, with the cmbase macros loaded, the characters will -have incorrect widths. diff -Nu dvipsk2009/Makefile.am dvipsk/Makefile.am --- dvipsk2009/Makefile.am Tue Jun 23 18:46:14 2009 +++ dvipsk/Makefile.am Tue Mar 02 20:55:57 2010 @@ -11,7 +11,7 @@ AM_CPPFLAGS = -DUNIX -DKPATHSEA -DSHIFTLOWCHARS AM_CFLAGS = $(WARNING_CFLAGS) -bin_PROGRAMS = afm2tfm dvips +bin_PROGRAMS = afm2tfm pdvips afm2tfm_SOURCES = afm2tfm.c @@ -43,6 +43,7 @@ pprescan.c \ prescan.c \ protos.h \ + protos_add.h \ ptexmac.h \ repack.c \ resident.c \ diff -Nu dvipsk2009/Makefile.in dvipsk/Makefile.in --- dvipsk2009/Makefile.in Tue Jun 23 18:46:14 2009 +++ dvipsk/Makefile.in Tue Mar 02 20:56:31 2010 @@ -35,7 +35,7 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -bin_PROGRAMS = afm2tfm$(EXEEXT) dvips$(EXEEXT) +bin_PROGRAMS = afm2tfm$(EXEEXT) pdvips$(EXEEXT) subdir = . DIST_COMMON = README $(am__configure_deps) $(dist_man1_MANS) \ $(dvips_TEXINFOS) $(srcdir)/../../build-aux/config.guess \ @@ -118,7 +118,7 @@ TEXI2PDF = $(TEXI2DVI) --pdf --batch MAKEINFOHTML = $(MAKEINFO) --html AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS) -DVIPS = dvips +DVIPS = pdvips RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ @@ -346,6 +346,7 @@ pprescan.c \ prescan.c \ protos.h \ + protos_add.h \ ptexmac.h \ repack.c \ resident.c \ @@ -505,8 +506,8 @@ afm2tfm$(EXEEXT): $(afm2tfm_OBJECTS) $(afm2tfm_DEPENDENCIES) @rm -f afm2tfm$(EXEEXT) $(LINK) $(afm2tfm_OBJECTS) $(afm2tfm_LDADD) $(LIBS) -dvips$(EXEEXT): $(dvips_OBJECTS) $(dvips_DEPENDENCIES) - @rm -f dvips$(EXEEXT) +pdvips$(EXEEXT): $(dvips_OBJECTS) $(dvips_DEPENDENCIES) + @rm -f pdvips$(EXEEXT) $(LINK) $(dvips_OBJECTS) $(dvips_LDADD) $(LIBS) mostlyclean-compile: diff -Nu dvipsk2009/README dvipsk/README --- dvipsk2009/README Wed Jan 18 06:41:51 2006 +++ dvipsk/README Fri Dec 25 03:38:48 2009 @@ -1,31 +1,17 @@ -This directory contains Dvipsk, my (kb@mail.tug.org) modified version of -Tom Rokicki's dvips, a DVI-to-PostScript translator. +This directory contains Dvipsk, a modified version of +Tom Rokicki's dvips, a DVI-to-PostScript translator. This has become +the only maintained Dvips, and functions as the original. -See `NEWS' for major changes by release, `ChangeLog` for all changes. -See `INSTALL' for installation instructions. +See `ChangeLog` for all changes. See `../kpathsea/BUGS' for details on reporting bugs. -AT LEAST NEWS, ChangeLog, AND INSTALL ARE WOEFULLY OUT OF DATE. -Aside from configuration, this differs from the original primarily in -that it uses the same code for path searching as TeX and my other -distributions. - -Dvipsk does not install any default config.ps file, since no one file is -generally suitable. Sample Dvips config files are in the contrib/ -directory. See ./INSTALL. - -The documentation is now in Texinfo format. I've removed the font -naming section, since it was an old version of the font naming document -(which you can get from ftp://ftp.tug.org/tex/fontname/). +Dvipsk does not install by itself any default config.ps file, since no +one file is generally suitable. Sample Dvips config files are in the +contrib/ directory. Dvipsk is free software; Tom's original files are public domain. The -files I wrote (originally for the Free Software Foundation) are covered -by the GNU General Public License -- see the files COPYING*. - -You can get the original dvips from ftp://labrea.stanford.edu/pub/dvips*. - -kb@mail.tug.org -Member of the League for Programming Freedom -- write lpf@uunet.uu.net. +files Karl wrote (originally for the Free Software Foundation) are +covered by the GNU General Public License -- see the files COPYING*. ------------------------------------------------------------------------- dvips 5.86 notes: diff -Nu dvipsk2009/afm2tfm.c dvipsk/afm2tfm.c --- dvipsk2009/afm2tfm.c Tue Jun 23 18:46:14 2009 +++ dvipsk/afm2tfm.c Sat Apr 10 10:01:43 2010 @@ -1,4 +1,4 @@ -/* $Id: afm2tfm.c 13914 2009-06-23 09:46:14Z peter $ */ +/* $Id: afm2tfm.c 15969 2009-11-10 10:29:32Z peter $ */ /* Public domain, originally written by Tom Rokicki. * This program converts AFM files to TeX TFM files, and optionally @@ -26,6 +26,7 @@ #include "config.h" #include #include +#include #include #else /* ! KPATHSEA */ #include @@ -54,9 +55,9 @@ #ifdef VMCMS #define interesting lookstr /* for 8 character truncation conflicts */ #include "dvipscms.h" -extern FILE *cmsfopen() ; -extern char ebcdic2ascii[] ; -extern char ascii2ebcdic[] ; +extern FILE *cmsfopen(); +extern char ebcdic2ascii[]; +extern char ascii2ebcdic[]; #ifdef fopen #undef fopen #endif @@ -71,9 +72,9 @@ #endif struct encoding { - char *name ; - char *vec[256] ; -} ; + const char *name; + const char *vec[256]; +}; struct encoding staticencoding = { "TeX text", {"Gamma", "Delta", "Theta", "Lambda", "Xi", "Pi", "Sigma", @@ -97,12 +98,12 @@ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "" } } ; + "", "", "", "", "", "", "" } }; /* * It's easier to put this in static storage and parse it as we go * than to build the structures ourselves. */ -char *staticligkern[] = { +const char *staticligkern[] = { "% LIGKERN space l =: lslash ; space L =: Lslash ;", "% LIGKERN question quoteleft =: questiondown ;", "% LIGKERN exclam quoteleft =: exclamdown ;", @@ -116,183 +117,183 @@ "% LIGKERN seven {} * ; * {} seven ; eight {} * ; * {} eight ;", "% LIGKERN nine {} * ; * {} nine ;", /* Kern accented characters the same way as their base. */ - "% LIGKERN Aacute <> A ; aacute <> a ;", - "% LIGKERN Acircumflex <> A ; acircumflex <> a ;", - "% LIGKERN Adieresis <> A ; adieresis <> a ;", - "% LIGKERN Agrave <> A ; agrave <> a ;", - "% LIGKERN Aring <> A ; aring <> a ;", - "% LIGKERN Atilde <> A ; atilde <> a ;", - "% LIGKERN Ccedilla <> C ; ccedilla <> c ;", - "% LIGKERN Eacute <> E ; eacute <> e ;", - "% LIGKERN Ecircumflex <> E ; ecircumflex <> e ;", - "% LIGKERN Edieresis <> E ; edieresis <> e ;", - "% LIGKERN Egrave <> E ; egrave <> e ;", - "% LIGKERN Iacute <> I ; iacute <> i ;", - "% LIGKERN Icircumflex <> I ; icircumflex <> i ;", - "% LIGKERN Idieresis <> I ; idieresis <> i ;", - "% LIGKERN Igrave <> I ; igrave <> i ;", - "% LIGKERN Ntilde <> N ; ntilde <> n ;", - "% LIGKERN Oacute <> O ; oacute <> o ;", - "% LIGKERN Ocircumflex <> O ; ocircumflex <> o ;", - "% LIGKERN Odieresis <> O ; odieresis <> o ;", - "% LIGKERN Ograve <> O ; ograve <> o ;", - "% LIGKERN Oslash <> O ; oslash <> o ;", - "% LIGKERN Otilde <> O ; otilde <> o ;", - "% LIGKERN Scaron <> S ; scaron <> s ;", - "% LIGKERN Uacute <> U ; uacute <> u ;", - "% LIGKERN Ucircumflex <> U ; ucircumflex <> u ;", - "% LIGKERN Udieresis <> U ; udieresis <> u ;", - "% LIGKERN Ugrave <> U ; ugrave <> u ;", - "% LIGKERN Yacute <> Y ; yacute <> y ;", - "% LIGKERN Ydieresis <> Y ; ydieresis <> y ;", - "% LIGKERN Zcaron <> Z ; zcaron <> z ;", + "% LIGKERN Aacute <> A ; aacute <> a ;", + "% LIGKERN Acircumflex <> A ; acircumflex <> a ;", + "% LIGKERN Adieresis <> A ; adieresis <> a ;", + "% LIGKERN Agrave <> A ; agrave <> a ;", + "% LIGKERN Aring <> A ; aring <> a ;", + "% LIGKERN Atilde <> A ; atilde <> a ;", + "% LIGKERN Ccedilla <> C ; ccedilla <> c ;", + "% LIGKERN Eacute <> E ; eacute <> e ;", + "% LIGKERN Ecircumflex <> E ; ecircumflex <> e ;", + "% LIGKERN Edieresis <> E ; edieresis <> e ;", + "% LIGKERN Egrave <> E ; egrave <> e ;", + "% LIGKERN Iacute <> I ; iacute <> i ;", + "% LIGKERN Icircumflex <> I ; icircumflex <> i ;", + "% LIGKERN Idieresis <> I ; idieresis <> i ;", + "% LIGKERN Igrave <> I ; igrave <> i ;", + "% LIGKERN Ntilde <> N ; ntilde <> n ;", + "% LIGKERN Oacute <> O ; oacute <> o ;", + "% LIGKERN Ocircumflex <> O ; ocircumflex <> o ;", + "% LIGKERN Odieresis <> O ; odieresis <> o ;", + "% LIGKERN Ograve <> O ; ograve <> o ;", + "% LIGKERN Oslash <> O ; oslash <> o ;", + "% LIGKERN Otilde <> O ; otilde <> o ;", + "% LIGKERN Scaron <> S ; scaron <> s ;", + "% LIGKERN Uacute <> U ; uacute <> u ;", + "% LIGKERN Ucircumflex <> U ; ucircumflex <> u ;", + "% LIGKERN Udieresis <> U ; udieresis <> u ;", + "% LIGKERN Ugrave <> U ; ugrave <> u ;", + "% LIGKERN Yacute <> Y ; yacute <> y ;", + "% LIGKERN Ydieresis <> Y ; ydieresis <> y ;", + "% LIGKERN Zcaron <> Z ; zcaron <> z ;", /* * These next are only included for deficient afm files that * have the lig characters but not the lig commands. */ "% LIGKERN f i =: fi ; f l =: fl ; f f =: ff ; ff i =: ffi ;", "% LIGKERN ff l =: ffl ;", - 0 } ; + 0 }; /* * The above layout corresponds to TeX Typewriter Type and is compatible * with TeX Text because the position of ligatures is immaterial. */ -struct encoding *outencoding = 0 ; -struct encoding *inencoding = 0 ; +struct encoding *outencoding = 0; +struct encoding *inencoding = 0; char *outenname = NULL, *inenname = NULL;/* the file names for input and output encodings */ -int boundarychar = -1 ; /* the boundary character */ -int ignoreligkern ; /* do we look at ligkern info in the encoding? */ +int boundarychar = -1; /* the boundary character */ +int ignoreligkern; /* do we look at ligkern info in the encoding? */ /* * This is what we store Adobe data in. */ struct adobeinfo { - struct adobeinfo *next ; - int adobenum, texnum, width ; - char *adobename ; - int llx, lly, urx, ury ; - struct lig *ligs ; - struct kern *kerns ; - struct adobeptr *kern_equivs ; - struct pcc *pccs ; - int wptr, hptr, dptr, iptr ; + struct adobeinfo *next; + int adobenum, texnum, width; + const char *adobename; + int llx, lly, urx, ury; + struct lig *ligs; + struct kern *kerns; + struct adobeptr *kern_equivs; + struct pcc *pccs; + int wptr, hptr, dptr, iptr; } *adobechars, *adobeptrs[256], *texptrs[256], - *uppercase[256], *lowercase[256] ; -int nexttex[256] ; /* for characters encoded multiple times in output */ + *uppercase[256], *lowercase[256]; +int nexttex[256]; /* for characters encoded multiple times in output */ /* * These are the eight ligature ops, in VPL terms and in METAFONT terms. */ -char *vplligops[] = { +const char *vplligops[] = { "LIG", "/LIG", "/LIG>", "LIG/", "LIG/>", "/LIG/", "/LIG/>", "/LIG/>>", 0 -} ; -char *encligops[] = { +}; +const char *encligops[] = { "=:", "|=:", "|=:>", "=:|", "=:|>", "|=:|", "|=:|>", "|=:|>>", 0 -} ; +}; struct lig { - struct lig *next ; - char *succ, *sub ; - short op, boundleft ; -} ; + struct lig *next; + const char *succ, *sub; + short op, boundleft; +}; struct kern { - struct kern *next ; - char *succ ; - int delta ; -} ; + struct kern *next; + const char *succ; + int delta; +}; struct adobeptr { struct adobeptr *next; struct adobeinfo *ch; }; struct pcc { - struct pcc *next ; - char * partname ; - int xoffset, yoffset ; -} ; - -FILE *afmin, *vplout, *tfmout ; -char inname[200], outname[200] ; /* names of input and output files */ -char tmpstr[200] ; /* a buffer for one string */ + struct pcc *next; + const char * partname; + int xoffset, yoffset; +}; + +FILE *afmin, *vplout, *tfmout; +char inname[200], outname[200]; /* names of input and output files */ +char tmpstr[200]; /* a buffer for one string */ #define INBUFSIZE 1024 char buffer[INBUFSIZE+10]; /* input buffer (modified while parsing) */ -char obuffer[INBUFSIZE+10] ; /* unmodified copy of input buffer */ -char *param ; /* current position in input buffer */ -char *fontname = "Unknown" ; -char *codingscheme = "Unspecified" ; +char obuffer[INBUFSIZE+10]; /* unmodified copy of input buffer */ +char *param; /* current position in input buffer */ +const char *fontname = "Unknown"; +const char *codingscheme = "Unspecified"; #ifdef VMCMS -char *ebfontname ; -char *ebcodingscheme ; +char *ebfontname; +char *ebcodingscheme; #endif -float italicangle = 0.0 ; -char fixedpitch ; -char makevpl ; -char pedantic ; -int xheight = 400 ; -int fontspace ; -int bc, ec ; -long cksum ; -float efactor = 1.0, slant = 0.0 ; -float capheight = 0.8 ; -char *efactorparam, *slantparam ; -double newslant ; -char titlebuf[500] ; +float italicangle = 0.0; +char fixedpitch; +char makevpl; +char pedantic; +int xheight = 400; +int fontspace; +int bc, ec; +long cksum; +float efactor = 1.0, slant = 0.0; +float capheight = 0.8; +char *efactorparam, *slantparam; +double newslant; +char titlebuf[500]; static void -error(register char *s) +error(const char *s) { - (void)fprintf(stderr, "%s\n", s) ; + (void)fprintf(stderr, "%s\n", s); if (obuffer[0]) { - (void)fprintf(stderr, "%s\n", obuffer) ; + (void)fprintf(stderr, "%s\n", obuffer); while (param > buffer) { - (void)fprintf(stderr, " ") ; - param-- ; + (void)fprintf(stderr, " "); + param--; } - (void)fprintf(stderr, "^\n") ; + (void)fprintf(stderr, "^\n"); } if (*s == '!') - exit(1) ; + exit(1); } static int transform(register int x, register int y) { - register double acc ; - acc = efactor * x + slant *y ; - return (int)(acc>=0? floor(acc+0.5) : ceil(acc-0.5) ) ; + register double acc; + acc = efactor * x + slant *y; + return (int)(acc>=0? floor(acc+0.5) : ceil(acc-0.5) ); } static int texlive_getline(void) { - register char *p ; - register int c ; + register char *p; + register int c; - param = buffer ; + param = buffer; for (p=buffer; (c=getc(afmin)) != EOF;) { if (p - buffer >= INBUFSIZE) - error("! input line too long; perhaps input file is malformed?") ; - *p++ = c ; + error("! input line too long; perhaps input file is malformed?"); + *p++ = c; if (c == '\r') { - c = getc(afmin) ; + c = getc(afmin); if (c != EOF) { if (c == '\n') { - *p++ = c ; + *p++ = c; } else { - ungetc(c, afmin) ; + ungetc(c, afmin); } } - break ; + break; } else if (c == '\n') { - break ; + break; } } - *p = 0 ; - (void)strcpy(obuffer, buffer) ; + *p = 0; + (void)strcpy(obuffer, buffer); if (p == buffer && c == EOF) - return(0) ; + return(0); else - return(1) ; + return(1); } -char *interesting[] = { "FontName", "ItalicAngle", "IsFixedPitch", - "XHeight", "C", "KPX", "CC", "EncodingScheme", NULL} ; +const char *interesting[] = { "FontName", "ItalicAngle", "IsFixedPitch", + "XHeight", "C", "KPX", "CC", "EncodingScheme", NULL}; #define FontName (0) #define ItalicAngle (1) #define IsFixedPitch (2) @@ -303,222 +304,222 @@ #define EncodingScheme (7) #define NONE (-1) static int -interest(char *s) +interest(const char *s) { - register char **p ; - register int n ; + register const char **p; + register int n; for (p=interesting, n=0; *p; p++, n++) if (strcmp(s, *p)==0) - return(n) ; - return(NONE) ; + return(n); + return(NONE); } static char * mymalloc(unsigned long len) { - register char *p ; - int i ; + register char *p; + int i; #ifdef SMALLMALLOC if (len > 65500L) - error("! can't allocate more than 64K!") ; + error("! can't allocate more than 64K!"); #endif - p = (char *) malloc((unsigned)len) ; + p = (char *) malloc((unsigned)len); if (p==NULL) - error("! out of memory") ; + error("! out of memory"); for (i=0; i ' ') - p++ ; + p++; if (*p != 0) - *p++ = 0 ; - q = newstring(param) ; + *p++ = 0; + q = newstring(param); while (*p && *p <= ' ') - p++ ; - param = p ; - return(q) ; + p++; + param = p; + return(q); } static char * paramstring(void) { - register char *p, *q ; + register char *p, *q; - p = param ; + p = param; while (*p > ' ') - p++ ; - q = param ; + p++; + q = param; if (*p != 0) - *p++ = 0 ; + *p++ = 0; while (*p && *p <= ' ') - p++ ; - param = p ; - return(q) ; + p++; + param = p; + return(q); } static int paramnum(void) { - register char *p ; - int i ; + register char *p; + int i; - p = paramstring() ; + p = paramstring(); if (sscanf(p, "%d", &i) != 1) - error("! integer expected") ; - return(i) ; + error("! integer expected"); + return(i); } static float paramfloat(void) { - register char *p ; - float i ; + register char *p; + float i; - p = paramstring() ; + p = paramstring(); if (sscanf(p, "%f", &i) != 1) - error("! number expected") ; - return(i) ; + error("! number expected"); + return(i); } static struct adobeinfo * newchar(void) { - register struct adobeinfo *ai ; + register struct adobeinfo *ai; - ai = (struct adobeinfo *)mymalloc((unsigned long)sizeof(struct adobeinfo)) ; - ai->adobenum = -1 ; - ai->texnum = -1 ; - ai->width = -1 ; - ai->adobename = NULL ; - ai->llx = -1 ; - ai->lly = -1 ; - ai->urx = -1 ; - ai->ury = -1 ; - ai->ligs = NULL ; - ai->kerns = NULL ; - ai->kern_equivs = NULL ; - ai->pccs = NULL ; - ai->next = adobechars ; - adobechars = ai ; - return(ai) ; + ai = (struct adobeinfo *)mymalloc((unsigned long)sizeof(struct adobeinfo)); + ai->adobenum = -1; + ai->texnum = -1; + ai->width = -1; + ai->adobename = NULL; + ai->llx = -1; + ai->lly = -1; + ai->urx = -1; + ai->ury = -1; + ai->ligs = NULL; + ai->kerns = NULL; + ai->kern_equivs = NULL; + ai->pccs = NULL; + ai->next = adobechars; + adobechars = ai; + return(ai); } static struct kern * newkern(void) { - register struct kern *nk ; + register struct kern *nk; - nk = (struct kern *)mymalloc((unsigned long)sizeof(struct kern)) ; - nk->next = NULL ; - nk->succ = NULL ; - nk->delta = 0 ; - return(nk) ; + nk = (struct kern *)mymalloc((unsigned long)sizeof(struct kern)); + nk->next = NULL; + nk->succ = NULL; + nk->delta = 0; + return(nk); } static struct pcc * newpcc(void) { - register struct pcc *np ; + register struct pcc *np; - np = (struct pcc *)mymalloc((unsigned long)sizeof(struct pcc)) ; - np->next = NULL ; - np->partname = NULL ; - np->xoffset = 0 ; - np->yoffset = 0 ; - return(np) ; + np = (struct pcc *)mymalloc((unsigned long)sizeof(struct pcc)); + np->next = NULL; + np->partname = NULL; + np->xoffset = 0; + np->yoffset = 0; + return(np); } static struct lig * newlig(void) { - register struct lig *nl ; + register struct lig *nl; - nl = (struct lig *)mymalloc((unsigned long)sizeof(struct lig)) ; - nl->next = NULL ; - nl->succ = NULL ; - nl->sub = NULL ; - nl->op = 0 ; /* the default =: op */ - nl->boundleft = 0 ; - return(nl) ; + nl = (struct lig *)mymalloc((unsigned long)sizeof(struct lig)); + nl->next = NULL; + nl->succ = NULL; + nl->sub = NULL; + nl->op = 0; /* the default =: op */ + nl->boundleft = 0; + return(nl); } static void -expect(char *s) +expect(const char *s) { if (strcmp(paramstring(), s) != 0) { - (void)fprintf(stderr, "%s expected: ", s) ; - error("! syntax error") ; + (void)fprintf(stderr, "%s expected: ", s); + error("! syntax error"); } } static void handlechar(void) { /* an input line beginning with C */ - register struct adobeinfo *ai ; - register struct lig *nl ; + register struct adobeinfo *ai; + register struct lig *nl; - ai = newchar() ; - ai->adobenum = paramnum() ; - expect(";") ; - expect("WX") ; - ai->width = transform(paramnum(),0) ; + ai = newchar(); + ai->adobenum = paramnum(); + expect(";"); + expect("WX"); + ai->width = transform(paramnum(),0); if (ai->adobenum >= 0 && ai->adobenum < 256) { - adobeptrs[ai->adobenum] = ai ; + adobeptrs[ai->adobenum] = ai; } - expect(";") ; + expect(";"); /* Ignore vertical metrics information */ if (*param == 'W' && *(param + 1) == 'Y') { - expect("WY") ; - (void)paramnum() ; - expect(";") ; - } - expect("N") ; - ai->adobename = paramnewstring() ; - expect(";") ; - expect("B") ; - ai->llx = paramnum() ; - ai->lly = paramnum() ; - ai->llx = transform(ai->llx, ai->lly) ; - ai->urx = paramnum() ; - ai->ury = paramnum() ; - ai->urx = transform(ai->urx, ai->ury) ; + expect("WY"); + (void)paramnum(); + expect(";"); + } + expect("N"); + ai->adobename = paramnewstring(); + expect(";"); + expect("B"); + ai->llx = paramnum(); + ai->lly = paramnum(); + ai->llx = transform(ai->llx, ai->lly); + ai->urx = paramnum(); + ai->ury = paramnum(); + ai->urx = transform(ai->urx, ai->ury); /* We need to avoid negative heights or depths. They break accents in math mode, among other things. */ if (ai->lly > 0) - ai->lly = 0 ; + ai->lly = 0; if (ai->ury < 0) - ai->ury = 0 ; - expect(";") ; + ai->ury = 0; + expect(";"); /* Now look for ligatures (which aren't present in fixedpitch fonts) */ while (*param == 'L' && !fixedpitch) { - expect("L") ; - nl = newlig() ; - nl->succ = paramnewstring() ; - nl->sub = paramnewstring() ; - nl->next = ai->ligs ; - ai->ligs = nl ; - expect(";") ; + expect("L"); + nl = newlig(); + nl->succ = paramnewstring(); + nl->sub = paramnewstring(); + nl->next = ai->ligs; + ai->ligs = nl; + expect(";"); } } static struct adobeinfo * -findadobe(char *p) +findadobe(const char *p) { - register struct adobeinfo *ai ; + register struct adobeinfo *ai; for (ai=adobechars; ai; ai = ai->next) if (strcmp(p, ai->adobename)==0) - return(ai) ; - return(NULL) ; + return(ai); + return(NULL); } @@ -533,73 +534,73 @@ */ static void handlekern(void) { /* an input line beginning with KPX */ - register struct adobeinfo *ai ; - register char *p ; - register struct kern *nk ; + register struct adobeinfo *ai; + register char *p; + register struct kern *nk; - p = paramstring() ; - ai = findadobe(p) ; + p = paramstring(); + ai = findadobe(p); if (ai == NULL) - error("kern char not found") ; + error("kern char not found"); else { - nk = newkern() ; - nk->succ = paramnewstring() ; - nk->delta = transform(paramnum(),0) ; - nk->next = ai->kerns ; - ai->kerns = nk ; + nk = newkern(); + nk->succ = paramnewstring(); + nk->delta = transform(paramnum(),0); + nk->next = ai->kerns; + ai->kerns = nk; } } static void handleconstruct(void) { /* an input line beginning with CC */ - register struct adobeinfo *ai ; - register char *p ; - register struct pcc *np ; - register int n ; + register struct adobeinfo *ai; + register char *p; + register struct pcc *np; + register int n; struct pcc *npp = NULL; - p = paramstring() ; - ai = findadobe(p) ; + p = paramstring(); + ai = findadobe(p); if (ai == NULL) - error("! composite character name not found") ; - n = paramnum() ; - expect(";") ; + error("! composite character name not found"); + n = paramnum(); + expect(";"); while (n--) { - if (strcmp(paramstring(),"PCC") != 0) return ; + if (strcmp(paramstring(),"PCC") != 0) return; /* maybe I should expect("PCC") instead, but I'm playing it safe */ - np = newpcc() ; - np->partname = paramnewstring() ; - if (findadobe(np->partname)==NULL) return ; - np->xoffset = paramnum() ; - np->yoffset = paramnum() ; - np->xoffset = transform(np->xoffset, np->yoffset) ; - if (npp) npp->next = np ; - else ai->pccs = np ; - npp = np ; - expect(";") ; + np = newpcc(); + np->partname = paramnewstring(); + if (findadobe(np->partname)==NULL) return; + np->xoffset = paramnum(); + np->yoffset = paramnum(); + np->xoffset = transform(np->xoffset, np->yoffset); + if (npp) npp->next = np; + else ai->pccs = np; + npp = np; + expect(";"); } } -static struct encoding *readencoding(char *) ; +static struct encoding *readencoding(char *); #if 0 /* Not used */ static void makeaccentligs(void) { - register struct adobeinfo *ai, *aci ; - register char *p ; - register struct lig *nl ; + register struct adobeinfo *ai, *aci; + register char *p; + register struct lig *nl; for (ai=adobechars; ai; ai=ai->next) { - p = ai->adobename ; + p = ai->adobename; if (strlen(p)>2) if ((aci=findadobe(p+1)) && (aci->adobenum > 127)) { - nl = newlig() ; - nl->succ = mymalloc((unsigned long)2) ; - *(nl->succ + 1) = 0 ; - *(nl->succ) = *p ; - nl->sub = ai->adobename ; - nl->next = aci->ligs ; - aci->ligs = nl ; + nl = newlig(); + nl->succ = mymalloc((unsigned long)2); + *(nl->succ + 1) = 0; + *(nl->succ) = *p; + nl->sub = ai->adobename; + nl->next = aci->ligs; + aci->ligs = nl; } } } @@ -607,7 +608,7 @@ static void readadobe(void) { - struct adobeinfo *ai ; + struct adobeinfo *ai; #ifdef VMCMS int i; #endif @@ -615,63 +616,63 @@ /* * We allocate a placeholder boundary char. */ - ai = newchar() ; - ai->adobenum = -1 ; - ai->adobename = "||" ; /* boundary character name */ + ai = newchar(); + ai->adobenum = -1; + ai->adobename = "||"; /* boundary character name */ while (texlive_getline()) { switch(interest(paramstring())) { case FontName: - fontname = paramnewstring() ; + fontname = paramnewstring(); #ifdef VMCMS /* fontname comes in as ebcdic but we need it asciified for tfm file so we save it in ebfontname and change it in fontname */ - ebfontname = newstring(fontname) ; + ebfontname = newstring(fontname); i=0; while(fontname[i] != '\0') { fontname[i]=ebcdic2ascii[fontname[i]]; i++; }; #endif - break ; + break; case EncodingScheme: - codingscheme = paramnewstring() ; + codingscheme = paramnewstring(); #ifdef VMCMS /* for codingscheme, we do the same as we did for fontname */ - ebcodingscheme = newstring(codingscheme) ; + ebcodingscheme = newstring(codingscheme); i=0; while(codingscheme[i] != '\0') { codingscheme[i]=ebcdic2ascii[codingscheme[i]]; i++; } #endif - break ; + break; case ItalicAngle: - italicangle = paramfloat() ; - break ; + italicangle = paramfloat(); + break; case IsFixedPitch: if (*param == 't' || *param == 'T') - fixedpitch = 1 ; + fixedpitch = 1; else - fixedpitch = 0 ; - break ; + fixedpitch = 0; + break; case XHeight: - xheight = paramnum() ; - break ; + xheight = paramnum(); + break; case C: - handlechar() ; - break ; + handlechar(); + break; case KPX: - handlekern() ; - break ; + handlekern(); + break; case CC: - handleconstruct() ; - break ; + handleconstruct(); + break; default: - break ; + break; } } - fclose(afmin) ; - afmin = 0 ; + fclose(afmin); + afmin = 0; } /* * Re-encode the adobe font. Assumes that the header file will @@ -680,31 +681,31 @@ static void handlereencoding(void) { if (inenname) { - int i ; - struct adobeinfo *ai ; - char *p ; + int i; + struct adobeinfo *ai; + const char *p; - ignoreligkern = 1 ; - inencoding = readencoding(inenname) ; + ignoreligkern = 1; + inencoding = readencoding(inenname); for (i=0; i<256; i++) if (0 != (ai=adobeptrs[i])) { - ai->adobenum = -1 ; - adobeptrs[i] = NULL ; + ai->adobenum = -1; + adobeptrs[i] = NULL; } for (i=0; i<256; i++) { - p = inencoding->vec[i] ; + p = inencoding->vec[i]; if (p && *p && strcmp(p, ".notdef") != 0 && 0 != (ai = findadobe(p))) { - ai->adobenum = i ; - adobeptrs[i] = ai ; + ai->adobenum = i; + adobeptrs[i] = ai; } } - codingscheme = inencoding->name ; + codingscheme = inencoding->name; } - ignoreligkern = 0 ; + ignoreligkern = 0; if (outenname) { - outencoding = readencoding(outenname) ; + outencoding = readencoding(outenname); } else { - outencoding = readencoding((char *)0) ; + outencoding = readencoding((char *)0); } } @@ -717,24 +718,24 @@ static struct adobeinfo * revlist (struct adobeinfo *p) { - struct adobeinfo *q = 0, *t ; + struct adobeinfo *q = 0, *t; while (p) { - t = p->next ; - p->next = q ; - q = p ; - p = t ; + t = p->next; + p->next = q; + q = p; + p = t; } - return q ; + return q; } static void assignchars(void) { - register char **p ; - register int i, j ; - register struct adobeinfo *ai, *pai ; - int nextfree = 128 ; - struct pcc *pcp ; + register const char **p; + register int i, j; + register struct adobeinfo *ai, *pai; + int nextfree = 128; + struct pcc *pcp; /* * First, we assign all those that match perfectly. @@ -743,12 +744,12 @@ if (*p && strcmp(*p, ".notdef") != 0 && (ai=findadobe(*p)) && (ai->adobenum >= 0 || ai->pccs != NULL)) { if (ai->texnum >= 0) - nexttex[i] = ai->texnum ; /* linked list */ - ai->texnum = i ; - texptrs[i] = ai ; + nexttex[i] = ai->texnum; /* linked list */ + ai->texnum = i; + texptrs[i] = ai; } if (pedantic) - return ; + return; /* * Next, we assign all the others, retaining the adobe positions, possibly * multiply assigning characters. Unless the output encoding was @@ -757,23 +758,23 @@ for (ai=adobechars; ai; ai=ai->next) if (ai->adobenum >= 0 && ai->adobenum <256 && ai->texnum < 0 && texptrs[ai->adobenum] == 0) { - ai->texnum = ai->adobenum ; - texptrs[ai->adobenum] = ai ; + ai->texnum = ai->adobenum; + texptrs[ai->adobenum] = ai; } /* * Finally, we map all remaining characters into free locations beginning * with 128, if we know how to construct those characters. We need to * make sure the component pieces are mapped. */ - adobechars = revlist(adobechars) ; + adobechars = revlist(adobechars); for (ai=adobechars; ai; ai=ai->next) if (ai->texnum<0 && (ai->adobenum>=0 || ai->pccs != NULL)) { while (texptrs[nextfree]) { - nextfree=(nextfree+1)&255 ; - if (nextfree==128) goto finishup ; /* all slots full */ + nextfree=(nextfree+1)&255; + if (nextfree==128) goto finishup; /* all slots full */ } - ai->texnum = nextfree ; - texptrs[nextfree] = ai ; + ai->texnum = nextfree; + texptrs[nextfree] = ai; } finishup: /* @@ -781,14 +782,14 @@ * components are not mapped, we unmap the composite character. */ for (i=0; i<256; i++) { - ai = texptrs[i] ; + ai = texptrs[i]; if (ai && ai->pccs != NULL && ai->texnum >= 0) { for (pcp = ai->pccs; pcp; pcp = pcp->next) { - pai = findadobe(pcp->partname) ; + pai = findadobe(pcp->partname); if (pai == NULL || pai->texnum < 0) { - texptrs[ai->texnum] = 0 ; - ai->texnum = -1 ; - break ; + texptrs[ai->texnum] = 0; + ai->texnum = -1; + break; } } } @@ -800,41 +801,42 @@ */ for (ai=adobechars; ai; ai=ai->next) if (ai->texnum >= 0 && ai->texnum < 256) { - j = -1 ; + j = -1; while (nexttex[ai->texnum] >= 0) { - i = nexttex[ai->texnum] ; - nexttex[ai->texnum] = j ; - j = ai->texnum ; - ai->texnum = i ; + i = nexttex[ai->texnum]; + nexttex[ai->texnum] = j; + j = ai->texnum; + ai->texnum = i; } - nexttex[ai->texnum] = j ; + nexttex[ai->texnum] = j; } } static void upmap(void) { /* Compute uppercase mapping, when making a small caps font */ - register struct adobeinfo *ai, *Ai ; - register char *p, *q ; - register struct pcc *np, *nq ; - int i ; - char lwr[50] ; + register struct adobeinfo *ai, *Ai; + register const char *p; + register char *q; + register struct pcc *np, *nq; + int i; + char lwr[50]; /* JLH: changed some lines below to be ascii<->ebcdic independent any reason we don't use 'isupper'?. Looks like we should use isupper to me --karl. */ for (Ai=adobechars; Ai; Ai=Ai->next) { - p = Ai->adobename ; + p = Ai->adobename; if (isupper (*p)) { - q = lwr ; + q = lwr; for (; *p; p++) *q++ = TOLOWER (*p); *q = '\0'; /* changed this too! */ if (0 != (ai=findadobe(lwr))) { for (i = ai->texnum; i >= 0; i = nexttex[i]) - uppercase[i] = Ai ; + uppercase[i] = Ai; for (i = Ai->texnum; i >= 0; i = nexttex[i]) - lowercase[i] = ai ; + lowercase[i] = ai; } } } @@ -845,28 +847,28 @@ if (0 != (ai=findadobe("germandbls"))) if (0 != (Ai=findadobe("S"))) { /* we also construct SS */ for (i=ai->texnum; i >= 0; i = nexttex[i]) - uppercase[i] = ai ; - ai->adobenum = -1 ; - ai->width = Ai->width << 1 ; - ai->llx = Ai->llx ; - ai->lly = Ai->lly ; - ai->urx = Ai->width + Ai->urx ; - ai->ury = Ai->ury ; - ai->kerns = Ai->kerns ; - np = newpcc() ; - np->partname = "S" ; - nq = newpcc() ; - nq->partname = "S" ; - nq->xoffset = Ai->width ; - np->next = nq ; - ai->pccs = np ; + uppercase[i] = ai; + ai->adobenum = -1; + ai->width = Ai->width << 1; + ai->llx = Ai->llx; + ai->lly = Ai->lly; + ai->urx = Ai->width + Ai->urx; + ai->ury = Ai->ury; + ai->kerns = Ai->kerns; + np = newpcc(); + np->partname = "S"; + nq = newpcc(); + nq->partname = "S"; + nq->xoffset = Ai->width; + np->next = nq; + ai->pccs = np; } if ((ai=findadobe("dotlessi"))) for (i=ai->texnum; i >= 0; i = nexttex[i]) - uppercase[i] = findadobe("I") ; + uppercase[i] = findadobe("I"); if ((ai=findadobe("dotlessj"))) for (i=ai->texnum; i >= 0; i = nexttex[i]) - uppercase[i] = findadobe("J") ; + uppercase[i] = findadobe("J"); } /* The logic above seems to work well enough, but it leaves useless characters * like `fi' and `fl' in the font if they were present initially, @@ -874,51 +876,51 @@ /* Now we turn to computing the TFM file */ -int lf, lh, nw, nh, nd, ni, nl, nk, ne, np ; +int lf, lh, nw, nh, nd, ni, nl, nk, ne, np; static void write16(register short what) { - (void)fputc(what >> 8, tfmout) ; - (void)fputc(what & 255, tfmout) ; + (void)fputc(what >> 8, tfmout); + (void)fputc(what & 255, tfmout); } static void writearr(register long *p, register int n) { while (n) { - write16((short)(*p >> 16)) ; - write16((short)(*p & 65535)) ; - p++ ; - n-- ; + write16((short)(*p >> 16)); + write16((short)(*p & 65535)); + p++; + n--; } } static void -makebcpl(register long *p, register char *s, register int n) +makebcpl(register long *p, register const char *s, register int n) { - register long t ; - register long sc ; + register long t; + register long sc; if (strlen(s) < n) - n = strlen(s) ; - t = ((long)n) << 24 ; - sc = 16 ; + n = strlen(s); + t = ((long)n) << 24; + sc = 16; while (n > 0) { - t |= ((long)(*(unsigned char *)s++)) << sc ; - sc -= 8 ; + t |= ((long)(*(unsigned const char *)s++)) << sc; + sc -= 8; if (sc < 0) { - *p++ = t ; - t = 0 ; - sc = 24 ; + *p++ = t; + t = 0; + sc = 24; } - n-- ; + n--; } - *p++ = t ; + *p++ = t; } -int source[257] ; -int unsort[257] ; +int source[257]; +int unsort[257]; /* * Next we need a routine to reduce the number of distinct dimensions @@ -931,83 +933,83 @@ * borrow a neat algorithm from METAFONT to find the true optimum. * Memory location what[oldn] is set to 0x7fffffffL for convenience. */ -long nextd ; /* smallest value that will give a different mincover */ +long nextd; /* smallest value that will give a different mincover */ static int mincover(long *what, register long d) /* tells how many clusters result, given max difference d */ { - register int m ; - register long l ; - register long *p ; - - nextd = 0x7fffffffL ; - p = what+1 ; - m = 1 ; + register int m; + register long l; + register long *p; + + nextd = 0x7fffffffL; + p = what+1; + m = 1; while (*p<0x7fffffffL) { - m++ ; - l = *p ; - while (*++p <= l+d) ; - if (*p-l < nextd) nextd = *p-l ; + m++; + l = *p; + while (*++p <= l+d); + if (*p-l < nextd) nextd = *p-l; } - return (m) ; + return (m); } static void remap(long * what, int oldn, int newn) { - register int i, j ; - register long d, l ; + register int i, j; + register long d, l; - what[oldn] = 0x7fffffffL ; + what[oldn] = 0x7fffffffL; for (i=oldn-1; i>0; i--) { - d = what[i] ; + d = what[i]; for (j=i; what[j+1]newn) d += d ; - while (mincover(what,d)>newn) d = nextd ; + i = mincover(what, 0L); + d = nextd; + while (mincover(what,d+d)>newn) d += d; + while (mincover(what,d)>newn) d = nextd; - i = 1 ; - j = 0 ; + i = 1; + j = 0; while (i>31)) ^ ai->width ; /* cyclic left shift */ + s1 = ((s1 << 1) ^ (s1>>31)) ^ ai->width; /* cyclic left shift */ s1 &= 0xffffffff; /* in case we're on a 64-bit machine */ for (p=ai->adobename; *p; p++) #ifndef VMCMS - s2 = (s2 * 3) + *p ; + s2 = (s2 * 3) + *p; #else - s2 = (s2 * 3) + ebcdic2ascii[*p] ; + s2 = (s2 * 3) + ebcdic2ascii[*p]; #endif } - s1 = (s1 << 1) ^ s2 ; - return s1 ; + s1 = (s1 << 1) ^ s2; + return s1; } /* @@ -1019,102 +1021,102 @@ scale(long what) { return(((what / 1000) << 20) + - (((what % 1000) << 20) + 500) / 1000) ; + (((what % 1000) << 20) + 500) / 1000); } long *header, *charinfo, *width, *height, *depth, *ligkern, *kern, *tparam, - *italic ; -long *tfmdata ; + *italic; +long *tfmdata; static void buildtfm(void) { - register int i, j ; - register struct adobeinfo *ai ; + register int i, j; + register struct adobeinfo *ai; - header = tfmdata ; - cksum = checksum() ; - header[0] = cksum ; - header[1] = 0xa00000 ; /* 10pt design size */ - makebcpl(header+2, codingscheme, 39) ; - makebcpl(header+12, fontname, 19) ; - lh = 17 ; - charinfo = header + lh ; - - for (i=0; i<256 && adobeptrs[i]==NULL; i++) ; - bc = i ; - for (i=255; i>=0 && adobeptrs[i]==NULL; i--) ; + header = tfmdata; + cksum = checksum(); + header[0] = cksum; + header[1] = 0xa00000; /* 10pt design size */ + makebcpl(header+2, codingscheme, 39); + makebcpl(header+12, fontname, 19); + lh = 17; + charinfo = header + lh; + + for (i=0; i<256 && adobeptrs[i]==NULL; i++); + bc = i; + for (i=255; i>=0 && adobeptrs[i]==NULL; i--); ec = i; if (ec < bc) - error("! no Adobe characters") ; + error("! no Adobe characters"); - width = charinfo + (ec - bc + 1) ; - width[0] = 0 ; - nw++ ; + width = charinfo + (ec - bc + 1); + width[0] = 0; + nw++; for (i=bc; i<=ec; i++) if (0 != (ai=adobeptrs[i])) { - width[nw]=ai->width ; - for (j=1; width[j]!=ai->width; j++) ; - ai->wptr = j ; + width[nw]=ai->width; + for (j=1; width[j]!=ai->width; j++); + ai->wptr = j; if (j==nw) - nw++ ; + nw++; } if (nw>256) - error("! 256 chars with different widths") ; - depth = width + nw ; - depth[0] = 0 ; - nd = 1 ; + error("! 256 chars with different widths"); + depth = width + nw; + depth[0] = 0; + nd = 1; for (i=bc; i<=ec; i++) if (0 != (ai=adobeptrs[i])) { - depth[nd] = -ai->lly ; - for (j=0; depth[j]!=-ai->lly; j++) ; - ai->dptr = j ; + depth[nd] = -ai->lly; + for (j=0; depth[j]!=-ai->lly; j++); + ai->dptr = j; if (j==nd) - nd++ ; + nd++; } if (nd > 16) { - remap(depth, nd, 16) ; - nd = 16 ; + remap(depth, nd, 16); + nd = 16; for (i=bc; i<=ec; i++) if (0 != (ai=adobeptrs[i])) - ai->dptr = unsort[ai->dptr] ; + ai->dptr = unsort[ai->dptr]; } - height = depth + nd ; - height[0] = 0 ; - nh = 1 ; + height = depth + nd; + height[0] = 0; + nh = 1; for (i=bc; i<=ec; i++) if (0 != (ai=adobeptrs[i])) { - height[nh]=ai->ury ; - for (j=0; height[j]!=ai->ury; j++) ; - ai->hptr = j ; + height[nh]=ai->ury; + for (j=0; height[j]!=ai->ury; j++); + ai->hptr = j; if (j==nh) - nh++ ; + nh++; } if (nh > 16) { - remap(height, nh, 16) ; - nh = 16 ; + remap(height, nh, 16); + nh = 16; for (i=bc; i<=ec; i++) if (0 != (ai=adobeptrs[i])) - ai->hptr = unsort[ai->hptr] ; + ai->hptr = unsort[ai->hptr]; } - italic = height + nh ; - italic[0] = 0 ; - ni = 1 ; + italic = height + nh; + italic[0] = 0; + ni = 1; for (i=bc; i<=ec; i++) if (0 != (ai=adobeptrs[i])) { - italic[ni] = ai->urx - ai->width ; + italic[ni] = ai->urx - ai->width; if (italic[ni]<0) - italic[ni] = 0 ; - for (j=0; italic[j]!=italic[ni]; j++) ; - ai->iptr = j ; + italic[ni] = 0; + for (j=0; italic[j]!=italic[ni]; j++); + ai->iptr = j; if (j==ni) - ni++ ; + ni++; } if (ni > 64) { - remap(italic, ni, 64) ; - ni = 64 ; + remap(italic, ni, 64); + ni = 64; for (i=bc; i<=ec; i++) if (0 != (ai=adobeptrs[i])) - ai->iptr = unsort[ai->iptr] ; + ai->iptr = unsort[ai->iptr]; } for (i=bc; i<=ec; i++) @@ -1122,65 +1124,65 @@ charinfo[i-bc] = ((long)(ai->wptr)<<24) + ((long)(ai->hptr)<<20) + ((long)(ai->dptr)<<16) + - ((long)(ai->iptr)<<10) ; + ((long)(ai->iptr)<<10); - ligkern = italic + ni ; - nl = 0 ; /* ligatures and kerns omitted from raw Adobe font */ - kern = ligkern + nl ; - nk = 0 ; - - newslant = (double)slant - efactor * tan(italicangle*(3.1415926535/180.0)) ; - tparam = kern + nk ; - tparam[0] = (long)(FIXFACTOR * newslant + 0.5) ; - tparam[1] = scale((long)fontspace) ; - tparam[2] = (fixedpitch ? 0 : scale((long)(300*efactor+0.5))) ; - tparam[3] = (fixedpitch ? 0 : scale((long)(100*efactor+0.5))) ; - tparam[4] = scale((long)xheight) ; - tparam[5] = scale((long)(1000*efactor+0.5)) ; - np = 6 ; + ligkern = italic + ni; + nl = 0; /* ligatures and kerns omitted from raw Adobe font */ + kern = ligkern + nl; + nk = 0; + + newslant = (double)slant - efactor * tan(italicangle*(3.1415926535/180.0)); + tparam = kern + nk; + tparam[0] = (long)(FIXFACTOR * newslant + 0.5); + tparam[1] = scale((long)fontspace); + tparam[2] = (fixedpitch ? 0 : scale((long)(300*efactor+0.5))); + tparam[3] = (fixedpitch ? 0 : scale((long)(100*efactor+0.5))); + tparam[4] = scale((long)xheight); + tparam[5] = scale((long)(1000*efactor+0.5)); + np = 6; } static void writesarr(long *what, int len) { - register long *p ; - int i ; + register long *p; + int i; - p = what ; - i = len ; + p = what; + i = len; while (i) { - *p = scale(*p) ; - (void)scale(*p) ; /* need this kludge for some compilers */ - p++ ; - i-- ; + *p = scale(*p); + (void)scale(*p); /* need this kludge for some compilers */ + p++; + i--; } - writearr(what, len) ; + writearr(what, len); } static void writetfm(void) { - lf = 6 + lh + (ec - bc + 1) + nw + nh + nd + ni + nl + nk + ne + np ; - write16(lf) ; - write16(lh) ; - write16(bc) ; - write16(ec) ; - write16(nw) ; - write16(nh) ; - write16(nd) ; - write16(ni) ; - write16(nl) ; - write16(nk) ; - write16(ne) ; - write16(np) ; - writearr(header, lh) ; - writearr(charinfo, ec-bc+1) ; - writesarr(width, nw) ; - writesarr(height, nh) ; - writesarr(depth, nd) ; - writesarr(italic, ni) ; - writearr(ligkern, nl) ; - writesarr(kern, nk) ; - writearr(tparam, np) ; + lf = 6 + lh + (ec - bc + 1) + nw + nh + nd + ni + nl + nk + ne + np; + write16((short)lf); + write16((short)lh); + write16((short)bc); + write16((short)ec); + write16((short)nw); + write16((short)nh); + write16((short)nd); + write16((short)ni); + write16((short)nl); + write16((short)nk); + write16((short)ne); + write16((short)np); + writearr(header, lh); + writearr(charinfo, ec-bc+1); + writesarr(width, nw); + writesarr(height, nh); + writesarr(depth, nd); + writesarr(italic, ni); + writearr(ligkern, nl); + writesarr(kern, nk); + writearr(tparam, np); } /* OK, the TFM file is done! Now for our next trick, the VPL file. */ @@ -1191,37 +1193,39 @@ * We only do this if the xheight has a reasonable value. * (>50) */ -char *accents[] = { "acute", "tilde", "caron", "dieresis", NULL} ; +const char *accents[] = { "acute", "tilde", "caron", "dieresis", NULL}; static int texheight(register struct adobeinfo *ai) { - register char **p; - register struct adobeinfo *aci, *acci ; - if (xheight <= 50 || *(ai->adobename + 1)) return (ai->ury) ; + register const char **p; + register struct adobeinfo *aci, *acci; + if (xheight <= 50 || *(ai->adobename + 1)) return (ai->ury); /* that was the simple case */ for (p=accents; *p; p++) /* otherwise we look for accented letters */ if (0 != (aci=findadobe(*p))) { - strcpy(buffer,ai->adobename) ; - strcat(buffer,*p) ; + strcpy(buffer,ai->adobename); + strcat(buffer,*p); if (0 != (acci=findadobe(buffer))) - return (acci->ury - aci->ury + xheight) ; + return (acci->ury - aci->ury + xheight); } - return (ai->ury) ; + return (ai->ury); } /* modified tgr to eliminate varargs problems */ #define vout(s) fprintf(vplout, s) -int level ; /* the depth of parenthesis nesting in VPL file being written */ +int level; /* the depth of parenthesis nesting in VPL file being written */ static void -vlevout() { - register int l = level ; - while (l--) vout(" ") ; +vlevout(void) +{ + register int l = level; + while (l--) vout(" "); } static void -vlevnlout() { - vout("\n") ; - vlevout() ; +vlevnlout(void) +{ + vout("\n"); + vlevout(); } #define voutln(str) {fprintf(vplout,"%s\n",str);vlevout();} #define voutln2(f,s) {fprintf(vplout,f,s);vlevnlout();} @@ -1230,32 +1234,32 @@ static void vleft(void) { - level++ ; - vout("(") ; + level++; + vout("("); } static void vright(void) { - level-- ; - voutln(")") ; + level--; + voutln(")"); } -int forceoctal = 0 ; +int forceoctal = 0; -char vcharbuf[6] ; +char vcharbuf[6]; static char * vchar(int c) { if (forceoctal == 0 && ISALNUM (c)) (void) sprintf(vcharbuf,"C %c", #ifndef VMCMS - c) ; + c); #else - ascii2ebcdic[c]) ; + ascii2ebcdic[c]); #endif - else (void) sprintf(vcharbuf,"O %o", (unsigned)c) ; - return (vcharbuf) ; + else (void) sprintf(vcharbuf,"O %o", (unsigned)c); + return (vcharbuf); } char vnamebuf[100]; @@ -1273,35 +1277,35 @@ static void writevpl(void) { - register int i, j, k ; - register struct adobeinfo *ai ; - register struct lig *nlig ; - register struct kern *nkern ; - register struct pcc *npcc ; - struct adobeinfo *asucc, *asub, *api ; + register int i, j, k; + register struct adobeinfo *ai; + register struct lig *nlig; + register struct kern *nkern; + register struct pcc *npcc; + struct adobeinfo *asucc, *asub, *api; struct adobeptr *kern_eq; - int xoff, yoff, ht ; - char unlabeled ; + int xoff, yoff, ht; + char unlabeled; - voutln2("(VTITLE Created by %s)", titlebuf) ; - voutln("(COMMENT Please edit that VTITLE if you edit this file)") ; + voutln2("(VTITLE Created by %s)", titlebuf); + voutln("(COMMENT Please edit that VTITLE if you edit this file)"); (void)sprintf(obuffer, "TeX-%s%s%s%s", outname, (efactor==1.0? "" : "-E"), (slant==0.0? "" : "-S"), - (makevpl==1? "" : "-CSC")) ; + (makevpl==1? "" : "-CSC")); if (strlen(obuffer)>19) { /* too long, will retain first 9 and last 10 */ - register char *p, *q ; - for (p = &obuffer[9], q = &obuffer[strlen(obuffer)-10] ; p<&obuffer[19]; - p++, q++) *p = *q ; - obuffer[19] = '\0' ; + register char *p, *q; + for (p = &obuffer[9], q = &obuffer[strlen(obuffer)-10]; p<&obuffer[19]; + p++, q++) *p = *q; + obuffer[19] = '\0'; } - voutln2("(FAMILY %s)" , obuffer) ; + voutln2("(FAMILY %s)" , obuffer); { - char tbuf[300] ; - char *base_encoding = + char tbuf[300]; + const char *base_encoding = #ifndef VMCMS - codingscheme ; + codingscheme; #else - ebcodingscheme ; + ebcodingscheme; #endif if (strcmp (outencoding->name, base_encoding) == 0) { @@ -1311,70 +1315,70 @@ } if (strlen(tbuf) > 39) { - error("Coding scheme too long; shortening to 39 characters.") ; - tbuf[39] = 0 ; + error("Coding scheme too long; shortening to 39 characters."); + tbuf[39] = 0; } - voutln2("(CODINGSCHEME %s)", tbuf) ; + voutln2("(CODINGSCHEME %s)", tbuf); } - voutln("(DESIGNSIZE R 10.0)") ; - voutln("(DESIGNUNITS R 1000)") ; - voutln("(COMMENT DESIGNSIZE (1 em) IS IN POINTS)") ; - voutln("(COMMENT OTHER DIMENSIONS ARE MULTIPLES OF DESIGNSIZE/1000)") ; + voutln("(DESIGNSIZE R 10.0)"); + voutln("(DESIGNUNITS R 1000)"); + voutln("(COMMENT DESIGNSIZE (1 em) IS IN POINTS)"); + voutln("(COMMENT OTHER DIMENSIONS ARE MULTIPLES OF DESIGNSIZE/1000)"); /* Let vptovf compute the checksum. */ - /* voutln2("(CHECKSUM O %lo)",cksum ^ 0xffffffff) ; */ + /* voutln2("(CHECKSUM O %lo)",cksum ^ 0xffffffff); */ if (boundarychar >= 0) - voutln2("(BOUNDARYCHAR O %lo)", (unsigned long)boundarychar) ; - vleft() ; voutln("FONTDIMEN") ; + voutln2("(BOUNDARYCHAR O %lo)", (unsigned long)boundarychar); + vleft(); voutln("FONTDIMEN"); if (newslant) - voutln2("(SLANT R %f)", newslant) ; - voutln2("(SPACE D %d)", fontspace) ; + voutln2("(SLANT R %f)", newslant); + voutln2("(SPACE D %d)", fontspace); if (! fixedpitch) { - voutln2("(STRETCH D %d)", transform(200,0)) ; - voutln2("(SHRINK D %d)", transform(100,0)) ; + voutln2("(STRETCH D %d)", transform(200,0)); + voutln2("(SHRINK D %d)", transform(100,0)); } - voutln2("(XHEIGHT D %d)", xheight) ; - voutln2("(QUAD D %d)", transform(1000,0)) ; - voutln2("(EXTRASPACE D %d)", fixedpitch ? fontspace : transform(111, 0)) ; - vright() ; - vleft() ; voutln("MAPFONT D 0"); - voutln2("(FONTNAME %s)", outname) ; - /* voutln2("(FONTCHECKSUM O %lo)", (unsigned long)cksum) ; */ - vright() ; + voutln2("(XHEIGHT D %d)", xheight); + voutln2("(QUAD D %d)", transform(1000,0)); + voutln2("(EXTRASPACE D %d)", fixedpitch ? fontspace : transform(111, 0)); + vright(); + vleft(); voutln("MAPFONT D 0"); + voutln2("(FONTNAME %s)", outname); + /* voutln2("(FONTCHECKSUM O %lo)", (unsigned long)cksum); */ + vright(); if (makevpl>1) { - vleft() ; voutln("MAPFONT D 1"); - voutln2("(FONTNAME %s)", outname) ; - voutln2("(FONTAT D %d)", (int)(1000.0*capheight+0.5)) ; - /* voutln2("(FONTCHECKSUM O %lo)", (unsigned long)cksum) ; */ - vright() ; + vleft(); voutln("MAPFONT D 1"); + voutln2("(FONTNAME %s)", outname); + voutln2("(FONTAT D %d)", (int)(1000.0*capheight+0.5)); + /* voutln2("(FONTCHECKSUM O %lo)", (unsigned long)cksum); */ + vright(); } - for (i=0; i<256 && texptrs[i]==NULL; i++) ; - bc = i ; - for (i=255; i>=0 && texptrs[i]==NULL; i--) ; + for (i=0; i<256 && texptrs[i]==NULL; i++); + bc = i; + for (i=255; i>=0 && texptrs[i]==NULL; i--); ec = i; - vleft() ; voutln("LIGTABLE") ; - ai = findadobe("||") ; - unlabeled = 1 ; + vleft(); voutln("LIGTABLE"); + ai = findadobe("||"); + unlabeled = 1; for (nlig=ai->ligs; nlig; nlig=nlig->next) if (0 != (asucc=findadobe(nlig->succ))) { if (0 != (asub=findadobe(nlig->sub))) if (asucc->texnum>=0) if (asub->texnum>=0) { if (unlabeled) { - voutln("(LABEL BOUNDARYCHAR)") ; - unlabeled = 0 ; + voutln("(LABEL BOUNDARYCHAR)"); + unlabeled = 0; } for (j = asucc->texnum; j >= 0; j = nexttex[j]) { voutln4("(%s %s O %o)", vplligops[nlig->op], - vchar(j), (unsigned)asub->texnum) ; + vchar(j), (unsigned)asub->texnum); } } } - if (! unlabeled) voutln("(STOP)") ; + if (! unlabeled) voutln("(STOP)"); for (i=bc; i<=ec; i++) if ((ai=texptrs[i]) && ai->texnum == i) { - unlabeled = 1 ; + unlabeled = 1; if (uppercase[i]==NULL) /* omit ligatures from smallcap lowercase */ for (nlig=ai->ligs; nlig; nlig=nlig->next) if (0 != (asucc=findadobe(nlig->succ))) @@ -1383,14 +1387,14 @@ if (asub->texnum>=0) { if (unlabeled) { for (j = ai->texnum; j >= 0; j = nexttex[j]) - voutln3("(LABEL %s)%s", vchar(j), vname(j)) ; - unlabeled = 0 ; + voutln3("(LABEL %s)%s", vchar(j), vname(j)); + unlabeled = 0; } for (j = asucc->texnum; j >= 0; j = nexttex[j]) { voutln4("(%s %s O %o)", vplligops[nlig->op], - vchar(j), (unsigned)asub->texnum) ; + vchar(j), (unsigned)asub->texnum); if (nlig->boundleft) - break ; + break; } } for (nkern = (uppercase[i] ? uppercase[i]->kerns : ai->kerns); @@ -1400,8 +1404,8 @@ if (uppercase[j]==NULL) { if (unlabeled) { for (k = ai->texnum; k >= 0; k = nexttex[k]) - voutln3("(LABEL %s)%s", vchar(k), vname(k)) ; - unlabeled = 0 ; + voutln3("(LABEL %s)%s", vchar(k), vname(k)); + unlabeled = 0; } /* If other characters have the same kerns as this one, output the label here. This makes the TFM @@ -1411,95 +1415,94 @@ kern_eq = kern_eq->next) { k = kern_eq->ch->texnum; if (k >= 0 && k < 256) - voutln3("(LABEL %s)%s", vchar(k), vname(k)) ; + voutln3("(LABEL %s)%s", vchar(k), vname(k)); } ai->kern_equivs = 0; /* Only output those labels once. */ if (uppercase[i]) { if (lowercase[j]) { for (k=lowercase[j]->texnum; k >= 0; k = nexttex[k]) voutln4("(KRN %s R %.1f)%s", vchar(k), - capheight*nkern->delta, vname(k)) ; + capheight*nkern->delta, vname(k)); } else voutln4("(KRN %s R %.1f)%s", - vchar(j), capheight*nkern->delta, vname(j)) ; + vchar(j), capheight*nkern->delta, vname(j)); } else { voutln4("(KRN %s R %d)%s", vchar(j), - nkern->delta, vname(j)) ; + nkern->delta, vname(j)); if (lowercase[j]) for (k=lowercase[j]->texnum; k >= 0; k = nexttex[k]) voutln4("(KRN %s R %.1f)%s", vchar(k), - capheight*nkern->delta, vname(k)) ; + capheight*nkern->delta, vname(k)); } } } - if (! unlabeled) voutln("(STOP)") ; + if (! unlabeled) voutln("(STOP)"); } - vright() ; + vright(); for (i=bc; i<=ec; i++) if (0 != (ai=texptrs[i])) { - vleft() ; fprintf(vplout, "CHARACTER %s", vchar(i)) ; + vleft(); fprintf(vplout, "CHARACTER %s", vchar(i)); if (*vcharbuf=='C') { - voutln("") ; + voutln(""); } else - voutln2(" (comment %s)", ai->adobename) ; + voutln2(" (comment %s)", ai->adobename); if (uppercase[i]) { - ai=uppercase[i] ; - voutln2("(CHARWD R %.1f)", capheight * (ai->width)) ; + ai=uppercase[i]; + voutln2("(CHARWD R %.1f)", capheight * (ai->width)); if (0 != (ht=texheight(ai))) - voutln2("(CHARHT R %.1f)", capheight * ht) ; + voutln2("(CHARHT R %.1f)", capheight * ht); if (ai->lly) - voutln2("(CHARDP R %.1f)", -capheight * ai->lly) ; + voutln2("(CHARDP R %.1f)", -capheight * ai->lly); if (ai->urx > ai->width) - voutln2("(CHARIC R %.1f)", capheight * (ai->urx - ai->width)) ; + voutln2("(CHARIC R %.1f)", capheight * (ai->urx - ai->width)); } else { - voutln2("(CHARWD R %d)", ai->width) ; + voutln2("(CHARWD R %d)", ai->width); if (0 != (ht=texheight(ai))) - voutln2("(CHARHT R %d)", ht) ; + voutln2("(CHARHT R %d)", ht); if (ai->lly) - voutln2("(CHARDP R %d)", -ai->lly) ; + voutln2("(CHARDP R %d)", -ai->lly); if (ai->urx > ai->width) - voutln2("(CHARIC R %d)", ai->urx - ai->width) ; + voutln2("(CHARIC R %d)", ai->urx - ai->width); } if (ai->adobenum != i || uppercase[i]) { - vleft() ; voutln("MAP") ; - if (uppercase[i]) voutln("(SELECTFONT D 1)") ; + vleft(); voutln("MAP"); + if (uppercase[i]) voutln("(SELECTFONT D 1)"); if (ai->pccs && ai->adobenum < 0) { - xoff = 0 ; yoff = 0 ; + xoff = 0; yoff = 0; for (npcc = ai->pccs; npcc; npcc=npcc->next) if (0 != (api=findadobe(npcc->partname))) if (api->texnum>=0) { if (npcc->xoffset != xoff) { if (uppercase[i]) { voutln2("(MOVERIGHT R %.1f)", - capheight * (npcc->xoffset - xoff)) ; + capheight * (npcc->xoffset - xoff)); } else voutln2("(MOVERIGHT R %d)", - npcc->xoffset - xoff) ; - xoff = npcc->xoffset ; + npcc->xoffset - xoff); + xoff = npcc->xoffset; } if (npcc->yoffset != yoff) { if (uppercase[i]) { voutln2("(MOVEUP R %.1f)", - capheight * (npcc->yoffset - yoff)) ; + capheight * (npcc->yoffset - yoff)); } else voutln2("(MOVEUP R %d)", - npcc->yoffset - yoff) ; - yoff = npcc->yoffset ; + npcc->yoffset - yoff); + yoff = npcc->yoffset; } - voutln2("(SETCHAR O %o)", (unsigned)api->adobenum) ; - xoff += texptrs[api->texnum]->width ; + voutln2("(SETCHAR O %o)", (unsigned)api->adobenum); + xoff += texptrs[api->texnum]->width; } - } else voutln2("(SETCHAR O %o)", (unsigned)ai->adobenum) ; - vright() ; + } else voutln2("(SETCHAR O %o)", (unsigned)ai->adobenum); + vright(); } - vright() ; + vright(); } - if (level) error("! I forgot to match the parentheses") ; + if (level) error("! I forgot to match the parentheses"); } #ifdef KPATHSEA static void version(FILE *f) { - extern KPSEDLL char *kpathsea_version_string; fputs ("afm2tfm(k) (dvips(k) 5.98) 8.1\n", f); fprintf (f, "%s\n", kpathsea_version_string); fputs ("Copyright 2009 Radical Eye Software.\n\ @@ -1531,8 +1534,6 @@ static void usage(FILE *f) { - extern KPSEDLL char *kpse_bug_address; - fputs ("Usage: afm2tfm FILE[.afm] [OPTION]... [FILE[.tfm]]\n", f); fputs (USAGE, f); putc ('\n', f); @@ -1543,13 +1544,13 @@ usage(FILE *f) { (void)fprintf(f, - "afm2tfm 8.1, Copyright 1990-97 by Radical Eye Software\n") ; + "afm2tfm 8.1, Copyright 1990-97 by Radical Eye Software\n"); (void)fprintf(f, - "Usage: afm2tfm foo[.afm] [-O] [-u] [-v|-V bar[.vpl]]\n") ; + "Usage: afm2tfm foo[.afm] [-O] [-u] [-v|-V bar[.vpl]]\n"); (void)fprintf(f, - " [-e expansion] [-s slant] [-c capheight]\n") ; + " [-e expansion] [-s slant] [-c capheight]\n"); (void)fprintf(f, - " [-p|-t|-T encodingfile] [foo[.tfm]]\n") ; + " [-p|-t|-T encodingfile] [foo[.tfm]]\n"); } #endif @@ -1559,64 +1560,66 @@ openfiles(int argc, char **argv) { #ifndef KPATHSEA - register int lastext ; + register int lastext; +#else + const char *q; #endif - register int i ; - char *p ; - int arginc ; + register int i; + char *p; + int arginc; - tfmout = (FILE *)NULL ; + tfmout = (FILE *)NULL; if (argc == 1) { - usage(stdout) ; - exit(0) ; + usage(stdout); + exit(0); } #if defined(MSDOS) || defined(OS2) || defined(ATARIST) /* Make VPL file identical to that created under Unix */ - (void)sprintf(titlebuf, "afm2tfm %s", argv[1]) ; + (void)sprintf(titlebuf, "afm2tfm %s", argv[1]); #else #ifdef VMCMS /* Make VPL file identical to that created under Unix */ - (void)sprintf(titlebuf, "afm2tfm %s", argv[1]) ; + (void)sprintf(titlebuf, "afm2tfm %s", argv[1]); #else - (void)sprintf(titlebuf, "%s %s", argv[0], argv[1]) ; + (void)sprintf(titlebuf, "%s %s", argv[0], argv[1]); #endif #endif - (void)strcpy(inname, argv[1]) ; + (void)strcpy(inname, argv[1]); #ifdef KPATHSEA if (find_suffix(inname) == NULL) - (void)strcat(inname, ".afm") ; + (void)strcat(inname, ".afm"); #else - lastext = -1 ; + lastext = -1; for (i=0; inname[i]; i++) if (inname[i] == '.') - lastext = i ; + lastext = i; else if (inname[i] == '/' || inname[i] == ':') - lastext = -1 ; - if (lastext == -1) (void)strcat(inname, ".afm") ; + lastext = -1; + if (lastext == -1) (void)strcat(inname, ".afm"); #endif while (argc>2 && *argv[2]=='-') { - arginc = 2 ; - i = argv[2][1] ; + arginc = 2; + i = argv[2][1]; if (i == '/') - i = argv[2][2] - 32 ; /* /a ==> A for VMS */ + i = argv[2][2] - 32; /* /a ==> A for VMS */ switch (i) { -case 'V': makevpl++ ; -case 'v': makevpl++ ; +case 'V': makevpl++; +case 'v': makevpl++; CHECKARG3 - (void)strcpy(outname, argv[3]) ; + (void)strcpy(outname, argv[3]); #ifdef KPATHSEA if (find_suffix(outname) == NULL) - (void)strcat(outname, ".vpl") ; + (void)strcat(outname, ".vpl"); #else - lastext = -1 ; + lastext = -1; for (i=0; outname[i]; i++) if (outname[i] == '.') - lastext = i ; + lastext = i; else if (outname[i] == '/' || outname[i] == ':') - lastext = -1 ; - if (lastext == -1) (void)strcat(outname, ".vpl") ; + lastext = -1; + if (lastext == -1) (void)strcat(outname, ".vpl"); #endif #ifndef VMCMS #ifndef ATARIST @@ -1627,52 +1630,52 @@ #else if ((vplout=fopen(outname, "w"))==NULL) #endif - error("! can't open vpl output file") ; - break ; + error("! can't open vpl output file"); + break; case 'e': CHECKARG3 if (sscanf(argv[3], "%f", &efactor)==0 || efactor<0.01) - error("! Bad extension factor") ; - efactorparam = argv[3] ; - break ; + error("! Bad extension factor"); + efactorparam = argv[3]; + break; case 'c': CHECKARG3 if (sscanf(argv[3], "%f", &capheight)==0 || capheight<0.01) - error("! Bad small caps height") ; - break ; + error("! Bad small caps height"); + break; case 's': CHECKARG3 if (sscanf(argv[3], "%f", &slant)==0) - error("! Bad slant parameter") ; - slantparam = argv[3] ; - break ; + error("! Bad slant parameter"); + slantparam = argv[3]; + break; case 'P': case 'p': CHECKARG3 - inenname = argv[3] ; - break ; + inenname = argv[3]; + break; case 'T': CHECKARG3 - inenname = outenname = argv[3] ; - break ; + inenname = outenname = argv[3]; + break; case 't': CHECKARG3 - outenname = argv[3] ; - break ; + outenname = argv[3]; + break; case 'O': - forceoctal = 1 ; - arginc = 1 ; - break ; + forceoctal = 1; + arginc = 1; + break; case 'u': - pedantic = 1 ; - arginc = 1 ; - break ; + pedantic = 1; + arginc = 1; + break; default: (void)fprintf(stderr, "Unknown option %s %s will be ignored.\n", - argv[2], argv[3]) ; + argv[2], argv[3]); } for (i=0; i3 || (argc==3 && *argv[2]=='-')) { - error("! need at most two non-option arguments") ; - usage(stderr) ; + error("! need at most two non-option arguments"); + usage(stderr); } - if (argc == 2) (void)strcpy(outname, inname) ; - else (void)strcpy(outname, argv[2]) ; + if (argc == 2) (void)strcpy(outname, inname); + else (void)strcpy(outname, argv[2]); #ifdef KPATHSEA if ((p = find_suffix(outname)) != NULL) *(p-1) = 0; - (void)strcat(outname, ".tfm") ; + (void)strcat(outname, ".tfm"); if (tfmout == NULL && (tfmout=fopen(outname, WRITEBIN))==NULL) - error("! can't open tfm output file") ; + error("! can't open tfm output file"); /* * Now we strip off any directory information, so we only use the * base name in the vf file. @@ -1706,27 +1709,27 @@ p = find_suffix(outname); *(p-1) = 0; - p = (char *)xbasename(outname) ; - strcpy(tmpstr, p); /* be careful, p and outname are overlapping */ + q = (char *)xbasename(outname); + strcpy(tmpstr, q); /* be careful, q and outname are overlapping */ strcpy(outname, tmpstr); #else - lastext = -1 ; + lastext = -1; for (i=0; outname[i]; i++) if (outname[i] == '.') - lastext = i ; + lastext = i; else if (outname[i] == '/' || outname[i] == ':' || outname[i] == '\\') - lastext = -1 ; + lastext = -1; if (argc == 2) { - outname[lastext] = 0 ; - lastext = -1 ; + outname[lastext] = 0; + lastext = -1; } if (lastext == -1) { - lastext = strlen(outname) ; - (void)strcat(outname, ".tfm") ; + lastext = strlen(outname); + (void)strcat(outname, ".tfm"); } if (tfmout == NULL && (tfmout=fopen(outname, WRITEBIN))==NULL) - error("! can't open tfm output file") ; - outname[lastext] = 0 ; + error("! can't open tfm output file"); + outname[lastext] = 0; /* * Now we strip off any directory information, so we only use the * base name in the vf file. We accept any of /, :, or \ as directory @@ -1735,9 +1738,9 @@ */ for (i=0, lastext=0; outname[i]; i++) if (outname[i] == '/' || outname[i] == ':' || outname[i] == '\\') - lastext = i + 1 ; + lastext = i + 1; if (lastext) - strcpy(outname, outname + lastext) ; + strcpy(outname, outname + lastext); #endif } /* @@ -1746,16 +1749,16 @@ static struct kern * rmkernmatch(struct kern *k, char *s) { - struct kern *nkern ; + struct kern *nkern; while (k && strcmp(k->succ, s)==0) - k = k->next ; + k = k->next; if (k) { for (nkern = k; nkern; nkern = nkern->next) while (nkern->next && strcmp(nkern->next->succ, s)==0) - nkern->next = nkern->next->next ; + nkern->next = nkern->next->next; } - return k ; + return k; } /* * Recursive to one level. @@ -1766,18 +1769,18 @@ if (ai == 0) { if (strcmp(s1, "*") == 0) { for (ai=adobechars; ai; ai = ai->next) - rmkern(s1, s2, ai) ; - return ; + rmkern(s1, s2, ai); + return; } else { - ai = findadobe(s1) ; + ai = findadobe(s1); if (ai == 0) - return ; + return; } } if (strcmp(s2, "*")==0) - ai->kerns = 0 ; /* drop them on the floor */ + ai->kerns = 0; /* drop them on the floor */ else - ai->kerns = rmkernmatch(ai->kerns, s2) ; + ai->kerns = rmkernmatch(ai->kerns, s2); } /* Make the kerning for character S1 equivalent to that for S2. @@ -1797,7 +1800,7 @@ ai2->kern_equivs = ap; } } -int sawligkern ; +int sawligkern; /* * Reads a ligkern line, if this is one. Assumes the first character * passed is `%'. @@ -1805,152 +1808,152 @@ static void checkligkern(char *s) { - char *oparam = param ; - char *mlist[5] ; - int n ; + char *oparam = param; + char *mlist[5]; + int n; - s++ ; + s++; while (*s && *s <= ' ') - s++ ; + s++; if (strncmp(s, "LIGKERN", 7)==0) { - sawligkern = 1 ; - s += 7 ; + sawligkern = 1; + s += 7; while (*s && *s <= ' ') - s++ ; - param = s ; + s++; + param = s; while (*param) { for (n=0; n<5;) { if (*param == 0) - break ; - mlist[n] = paramstring() ; + break; + mlist[n] = paramstring(); if (strcmp(mlist[n], ";") == 0) - break ; - n++ ; + break; + n++; } if (n > 4) - error("! too many parameters in lig kern data") ; + error("! too many parameters in lig kern data"); if (n < 3) - error("! too few parameters in lig kern data") ; + error("! too few parameters in lig kern data"); if (n == 3 && strcmp(mlist[1], "{}") == 0) { /* rmkern command */ - rmkern(mlist[0], mlist[2], (struct adobeinfo *)0) ; + rmkern(mlist[0], mlist[2], (struct adobeinfo *)0); } else if (n == 3 && strcmp(mlist[1], "<>") == 0) { /* addkern */ - addkern(mlist[0], mlist[2]) ; + addkern(mlist[0], mlist[2]); } else if (n == 3 && strcmp(mlist[0], "||") == 0 && strcmp(mlist[1], "=") == 0) { /* bc command */ - struct adobeinfo *ai = findadobe("||") ; + struct adobeinfo *ai = findadobe("||"); if (boundarychar != -1) - error("! multiple boundary character commands?") ; + error("! multiple boundary character commands?"); if (sscanf(mlist[2], "%d", &n) != 1) - error("! expected number assignment for boundary char") ; + error("! expected number assignment for boundary char"); if (n < 0 || n > 255) - error("! boundary character number must be 0..255") ; - boundarychar = n ; + error("! boundary character number must be 0..255"); + boundarychar = n; if (ai == 0) - error("! internal error: boundary char") ; - ai->texnum = n ; /* prime the pump, so to speak, for lig/kerns */ + error("! internal error: boundary char"); + ai->texnum = n; /* prime the pump, so to speak, for lig/kerns */ } else if (n == 4) { - int op = -1 ; - struct adobeinfo *ai ; + int op = -1; + struct adobeinfo *ai; for (n=0; encligops[n]; n++) if (strcmp(mlist[2], encligops[n])==0) { - op = n ; - break ; + op = n; + break; } if (op < 0) - error("! bad ligature op specified") ; + error("! bad ligature op specified"); if (0 != (ai = findadobe(mlist[0]))) { - struct lig *lig ; + struct lig *lig; if (findadobe(mlist[2])) /* remove coincident kerns */ - rmkern(mlist[0], mlist[1], ai) ; + rmkern(mlist[0], mlist[1], ai); if (strcmp(mlist[3], "||") == 0) - error("! you can't lig to the boundary character!") ; + error("! you can't lig to the boundary character!"); if (! fixedpitch) { /* fixed pitch fonts get *0* ligs */ for (lig=ai->ligs; lig; lig = lig->next) if (strcmp(lig->succ, mlist[1]) == 0) - break ; /* we'll re-use this structure */ + break; /* we'll re-use this structure */ if (lig == 0) { - lig = newlig() ; - lig->succ = newstring(mlist[1]) ; - lig->next = ai->ligs ; - ai->ligs = lig ; + lig = newlig(); + lig->succ = newstring(mlist[1]); + lig->next = ai->ligs; + ai->ligs = lig; } - lig->sub = newstring(mlist[3]) ; - lig->op = op ; + lig->sub = newstring(mlist[3]); + lig->op = op; if (strcmp(mlist[1], "||")==0) { - lig->boundleft = 1 ; + lig->boundleft = 1; if (strcmp(mlist[0], "||")==0) - error("! you can't lig boundarychar boundarychar!") ; + error("! you can't lig boundarychar boundarychar!"); } else - lig->boundleft = 0 ; + lig->boundleft = 0; } } } else - error("! bad form in LIGKERN command") ; + error("! bad form in LIGKERN command"); } } - param = oparam ; + param = oparam; } /* * Here we get a token from the AFM file. We parse just as much PostScript * as we expect to find in an encoding file. We allow commented lines and * names like 0, .notdef, _foo_. We do not allow //abc. */ -char smbuffer[100] ; /* for tokens */ +char smbuffer[100]; /* for tokens */ static char * gettoken(void) { - char *p, *q ; + char *p, *q; while (1) { while (param == 0 || *param == 0) { if (texlive_getline() == 0) - error("! premature end in encoding file") ; + error("! premature end in encoding file"); for (p=buffer; *p; p++) if (*p == '%') { if (ignoreligkern == 0) - checkligkern(p) ; - *p = 0 ; - break ; + checkligkern(p); + *p = 0; + break; } } while (*param && *param <= ' ') - param++ ; + param++; if (*param) { if (*param == '[' || *param == ']' || *param == '{' || *param == '}') { - smbuffer[0] = *param++ ; - smbuffer[1] = 0 ; - return smbuffer ; + smbuffer[0] = *param++; + smbuffer[1] = 0; + return smbuffer; } else if (*param == '/' || *param == '-' || *param == '_' || *param == '.' || ('0' <= *param && *param <= '9') || ('a' <= *param && *param <= 'z') || ('A' <= *param && *param <= 'Z')) { - smbuffer[0] = *param ; + smbuffer[0] = *param; for (p=param+1, q=smbuffer+1; *p == '-' || *p == '_' || *p == '.' || ('0' <= *p && *p <= '9') || ('a' <= *p && *p <= 'z') || ('A' <= *p && *p <= 'Z'); p++, q++) - *q = *p ; - *q = 0 ; - param = p ; - return smbuffer ; + *q = *p; + *q = 0; + param = p; + return smbuffer; } } } } static void getligkerndefaults(void) { - int i ; + int i; for (i=0; staticligkern[i]; i++) { - strcpy(buffer, staticligkern[i]) ; - strcpy(obuffer, staticligkern[i]) ; - param = buffer ; - checkligkern(buffer) ; + strcpy(buffer, staticligkern[i]); + strcpy(obuffer, staticligkern[i]); + param = buffer; + checkligkern(buffer); } } /* @@ -1960,63 +1963,63 @@ static struct encoding * readencoding(char *enc) { - char *p ; - int i ; + char *p; + int i; struct encoding *e = - (struct encoding *)mymalloc((unsigned long)sizeof(struct encoding)) ; + (struct encoding *)mymalloc((unsigned long)sizeof(struct encoding)); - sawligkern = 0 ; + sawligkern = 0; if (afmin) - error("! oops; internal afmin error") ; + error("! oops; internal afmin error"); if (enc) { #ifdef KPATHSEA afmin = kpse_open_file(enc, kpse_enc_format); #else - afmin = fopen(enc, "r") ; + afmin = fopen(enc, "r"); #endif - (void)SET_BINARY(fileno(afmin)) ; - param = 0 ; + (void)SET_BINARY(fileno(afmin)); + param = 0; if (afmin == 0) #ifdef KPATHSEA - FATAL1 ("couldn't open encoding file `%s'", enc) ; + FATAL1 ("couldn't open encoding file `%s'", enc); #else - error("! couldn't open that encoding file") ; + error("! couldn't open that encoding file"); #endif - p = gettoken() ; + p = gettoken(); if (*p != '/' || p[1] == 0) - error("! first token in encoding must be literal encoding name") ; - e->name = newstring(p+1) ; - p = gettoken() ; + error("! first token in encoding must be literal encoding name"); + e->name = newstring(p+1); + p = gettoken(); if (strcmp(p, "[")) - error("! second token in encoding must be mark ([) token") ; + error("! second token in encoding must be mark ([) token"); for (i=0; i<256; i++) { - p = gettoken() ; + p = gettoken(); if (*p != '/' || p[1] == 0) - error("! tokens 3 to 257 in encoding must be literal names") ; - e->vec[i] = newstring(p+1) ; + error("! tokens 3 to 257 in encoding must be literal names"); + e->vec[i] = newstring(p+1); } - p = gettoken() ; + p = gettoken(); if (strcmp(p, "]")) - error("! token 258 in encoding must be make-array (])") ; + error("! token 258 in encoding must be make-array (])"); while (texlive_getline()) { for (p=buffer; *p; p++) if (*p == '%') { if (ignoreligkern == 0) - checkligkern(p) ; - *p = 0 ; - break ; + checkligkern(p); + *p = 0; + break; } } - fclose(afmin) ; - afmin = 0 ; + fclose(afmin); + afmin = 0; if (ignoreligkern == 0 && sawligkern == 0) - getligkerndefaults() ; + getligkerndefaults(); } else { - e = &staticencoding ; - getligkerndefaults() ; + e = &staticencoding; + getligkerndefaults(); } - param = 0 ; - return e ; + param = 0; + return e; } /* * This routine prints out the line that needs to be added to psfonts.map. @@ -2025,31 +2028,32 @@ conspsfonts(void) { #ifndef VMCMS (void)printf("%s %s", outname, - fontname) ; + fontname); #else /* VM/CMS: fontname is ascii, so we use ebfontname */ (void)printf("%s %s", outname, - ebfontname) ; + ebfontname); #endif if (slantparam || efactorparam || inenname) { - (void)printf(" \"") ; + (void)printf(" \""); if (slantparam) - (void)printf(" %s SlantFont", slantparam) ; + (void)printf(" %s SlantFont", slantparam); if (efactorparam) - (void)printf(" %s ExtendFont", efactorparam) ; + (void)printf(" %s ExtendFont", efactorparam); if (inenname) - (void)printf(" %s ReEncodeFont", inencoding->name) ; - (void)printf(" \"") ; + (void)printf(" %s ReEncodeFont", inencoding->name); + (void)printf(" \""); if (inenname) - (void)printf(" <%s", inenname) ; + (void)printf(" <%s", inenname); } - (void)printf("\n") ; + (void)printf("\n"); } #ifndef VMS int #endif + main(int argc, char **argv) { - int i ; + int i; #ifdef KPATHSEA kpse_set_program_name (argv[0], "afm2tfm"); @@ -2070,30 +2074,30 @@ } #endif /* KPATHSEA */ for (i=0; i<256; i++) - nexttex[i] = -1 ; /* encoding chains have length 0 */ - tfmdata = (long *)mymalloc((unsigned long)40000L) ; - openfiles(argc, argv) ; - readadobe() ; + nexttex[i] = -1; /* encoding chains have length 0 */ + tfmdata = (long *)mymalloc((unsigned long)40000L); + openfiles(argc, argv); + readadobe(); if (fontspace == 0) { - struct adobeinfo *ai ; + struct adobeinfo *ai; if (0 != (ai = findadobe("space"))) - fontspace = ai->width ; + fontspace = ai->width; else if (adobeptrs[32]) - fontspace = adobeptrs[32]->width ; + fontspace = adobeptrs[32]->width; else - fontspace = transform(500, 0) ; + fontspace = transform(500, 0); } - handlereencoding() ; - buildtfm() ; - writetfm() ; - conspsfonts() ; + handlereencoding(); + buildtfm(); + writetfm(); + conspsfonts(); if (makevpl) { - assignchars() ; - if (makevpl>1) upmap() ; - writevpl() ; + assignchars(); + if (makevpl>1) upmap(); + writevpl(); } - return 0 ; + return 0; /*NOTREACHED*/ } diff -Nu dvipsk2009/bbox.c dvipsk/bbox.c --- dvipsk2009/bbox.c Tue Jun 23 18:46:14 2009 +++ dvipsk/bbox.c Mon Mar 29 23:25:36 2010 @@ -8,306 +8,417 @@ */ #include "dvips.h" /* The copyright notice in that file is included too! */ #include -#include "protos.h" - -extern char *nextstring, errbuf[] ; -extern FILE *tfmfile, *dvifile ; -extern fontmaptype *ffont ; -extern integer firstboploc, num, den ; -extern double mag ; -extern integer hoff, voff ; -extern Boolean noomega ; +/* + * The external declarations: + */ +#include "protos_add.h" typedef struct { - integer llx, lly, urx, ury ; -} bbchardesctype ; + integer llx, lly, urx, ury; +} bbchardesctype; typedef struct { - bbchardesctype *bbchardesc ; -} bbfontdesctype ; + bbchardesctype *bbchardesc; +} bbfontdesctype; typedef struct bbtft { - integer fontnum ; - bbfontdesctype *desc ; - struct bbtft *next ; -} bbfontmaptype ; + integer fontnum; + bbfontdesctype *desc; + struct bbtft *next; +} bbfontmaptype; -static bbfontmaptype *bbffont ; +static bbfontmaptype *bbffont; -void -bbtfmload(register fontdesctype *curfnt) +void bbtfmload(register fontdesctype *curfnt) { - register integer i, j ; - register integer li, cd = 0 ; - integer scaledsize ; - integer nw, nh, nd, ns, hd ; - integer bc, ec ; - integer nco = 0, ncw = 0, npc = 0, no_repeats = 0 ; - integer *scaled ; - integer *chardat ; + register integer i, j; + register integer li, cd = 0; + integer scaledsize; + integer id, nt, lf; + integer nw, nh, nd, ns, hd; + integer bc, ec; + integer nco = 0, ncw = 0, npc = 0, no_repeats = 0; + halfword *index; + halfword *chartype; + integer *scaled; + integer *chardat; int font_level; integer pretend_no_chars; - integer slant = 0 ; - bbchardesctype *cc ; + integer slant = 0; + bbchardesctype *cc; register bbfontdesctype *bbcurfnt = - (bbfontdesctype *)mymalloc(sizeof(bbfontdesctype)) ; + (bbfontdesctype *)mymalloc(sizeof(bbfontdesctype)); - bbffont->desc = bbcurfnt ; - tfmopen(curfnt) ; + bbffont->desc = bbcurfnt; + tfmopen(curfnt); /* * Next, we read the font data from the tfm file, and store it in * our own arrays. */ - li = tfm16() ; - if (li!=0) { + curfnt->dir = 0; + id = tfm16(); + if (id != 0) { font_level = -1; - hd = tfm16() ; - bc = tfm16() ; ec = tfm16() ; - nw = tfm16() ; nh = tfm16(); nd = tfm16(); - ns = tfm16() ; - ns += tfm16() ; - ns += tfm16() ; - ns += tfm16() ; - li = tfm16() ; - if (hd<2 || bc>ec+1 || ec>255 || nw>256 || nh>16 || nd>16) - badtfm("header") ; + if (id == 9 || id == 11) { + if (id == 9) curfnt->dir = id; + nt = tfm16(); lf = tfm16(); + } + hd = tfm16(); + bc = tfm16(); ec = tfm16(); + nw = tfm16(); nh = tfm16(); nd = tfm16(); + ns = tfm16(); + ns += tfm16(); + ns += tfm16(); + ns += tfm16(); + li = tfm16(); + if (id != 9 && id != 11) { + 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") ; + if (noomega) badtfm("length"); font_level = tfm16(); - li = tfm32() ; - hd = tfm32() ; - bc = tfm32() ; ec = tfm32() ; - nw = tfm32() ; nh = tfm32() ; nd = tfm32(); - ns = tfm32() ; - ns += tfm32() ; - ns += tfm32() ; - ns += tfm32() ; - li = tfm32() ; - li = tfm32() ; + li = tfm32(); + hd = tfm32(); + bc = tfm32(); ec = tfm32(); + nw = tfm32(); nh = tfm32(); nd = tfm32(); + ns = tfm32(); + ns += tfm32(); + ns += tfm32(); + 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") ; + badtfm("header"); if (font_level==1) { - nco = tfm32() ; - ncw = tfm32() ; - npc = tfm32() ; - for (i=0; i<12; i++) li=tfm32(); + nco = tfm32(); + ncw = tfm32(); + npc = tfm32(); + for (i=0; i<12; i++) li=tfm32(); } } - li = tfm32() ; + li = tfm32(); check_checksum (li, curfnt->checksum, curfnt->name); - - li = tfm32() ; - 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() ; - chardat = (integer *) xmalloc(pretend_no_chars*sizeof(integer)) ; - for (i=0; ibbchardesc = (bbchardesctype *) + xmalloc(MAX_CODE*sizeof(bbchardesctype)); + for (i=2; i>8)-0x21)*94 + (li&0xff)-0x21; +#else + index[i] = li; +#endif + chartype[i] = tfm16(); + } + for (i=0; i<256; i++) + chardat[i] = -1; + } + else { + 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(); + chardat = (integer *) xmalloc(pretend_no_chars*sizeof(integer)); + for (i=0; i0) { - no_repeats-- ; - } else if (font_level>=0) { - cd = tfm32() ; - li = tfm32() ; - if (font_level==1) { - no_repeats = tfm16() ; - for (j=0; j<(npc|1); j++) tfm16() ; - ncw -= 3 + npc/2 ; - } + if (id == 9 || id == 11) { + chardat[i] = tfm16(); + li = tfm16(); } else { - cd = tfm16() ; - li = tfm16() ; + if (no_repeats>0) { + no_repeats--; + } else if (font_level>=0) { + cd = tfm32(); + li = tfm32(); + if (font_level==1) { + no_repeats = tfm16(); + for (j=0; j<(npc|1); j++) tfm16(); + ncw -= 3 + npc/2; + } + } else { + cd = tfm16(); + li = tfm16(); + } + if (cd) chardat[i] = cd; } - if (cd) chardat[i] = cd ; } if (font_level==1&&ncw!=0) { - sprintf(errbuf, "Table size mismatch in %s", curfnt->name) ; - error(errbuf) ; + char *msg = concat ("Table size mismatch in ", curfnt->name); + error(msg); + free(msg); + } + scaledsize = curfnt->scaledsize; + if (id == 9 || id == 11) { + scaled = (integer *) xmalloc(300*sizeof(integer)); + for (i=0; iscaledsize ; - scaled = (integer *) xmalloc((nh + nd)*sizeof(integer)) ; - for (i=0; ibbchardesc[i]) ; - if (chardat[i] != -1) { - halfword iw ; - int ih, id ; - if (font_level>=0) { - iw = chardat[i] >> 16 ; - ih = (chardat[i] >> 8) & 255 ; - id = chardat[i] & 255 ; + tfm32(); + slant = tfm32(); + (void)fclose(tfmfile); + if (id == 9 || id == 11) { + for (i=0; ibbchardesc[i]); + if (chardat[0] != -1) { + cc->ury = scaled[((chardat[0] >> 4) & 15) + nw]; + cc->lly = - scaled[(chardat[0] & 15) + nw + nh]; + cc->llx = 0; +#ifdef VFLIB + cc->urx = curfnt->chardesc[0].TFMwidth; +#else + cc->urx = curfnt->chardesc[0x2121].TFMwidth; +#endif } else { - iw = chardat[i] >> 8 ; - ih = (chardat[i] >> 4) & 15 ; - id = chardat[i] & 15 ; + cc->llx = cc->lly = cc->urx = cc->ury = 0; + } + } + for (i=1; ibbchardesc[index[i]]); + if (chardat[chartype[i]] != -1) { + cc->ury = scaled[((chardat[chartype[i]] >> 4) & 15) + nw]; + cc->lly = - scaled[(chardat[chartype[i]] & 15) + nw + nh]; + cc->llx = 0; + cc->urx = curfnt->chardesc[index[i]].TFMwidth; + } else { + cc->llx = cc->lly = cc->urx = cc->ury = 0; + } + } + free(index); + free(chartype); + } else { + for (i=0; ibbchardesc[i]); + if (chardat[i] != -1) { + halfword iw; + int ih, id; + if (font_level>=0) { + iw = chardat[i] >> 16; + ih = (chardat[i] >> 8) & 255; + id = chardat[i] & 255; + } else { + iw = chardat[i] >> 8; + ih = (chardat[i] >> 4) & 15; + id = chardat[i] & 15; + } + 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 { + cc->llx = cc->lly = cc->urx = cc->ury = 0; } - 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 { - cc->llx = cc->lly = cc->urx = cc->ury = 0 ; } } if (slant) { - for (i=0; ibbchardesc[i]) ; - 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 ; + if (id == 9 || id == 11) { + for (i=0; ibbchardesc[i]); + 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; + } + } else { + for (i=0; ibbchardesc[i]); + 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) ; + free(chardat); + free(scaled); } -extern struct dvistack { - integer hh, vv ; - integer h, v, w, x, y, z ; -} stack[] ; -static integer llx, lly, urx, ury ; -void -bbspecial(integer h, integer v, int nbytes) +static integer llx, lly, urx, ury; +void bbspecial(integer h, integer v, integer dir, int nbytes) { - float *r = bbdospecial(nbytes) ; + float *r = bbdospecial(nbytes); if (r) { /* convert from magnified PostScript units back to scaled points */ - real conv = 72.0 * (real)num / (real)den * (real)mag / 254000000.0 ; - if (llx > h + r[0] / conv) - llx = (integer) (h + r[0] / conv) ; - if (lly > v - r[3] / conv) - lly = (integer) (v - r[3] / conv) ; - if (urx < h + r[2] / conv) - urx = (integer) (h + r[2] / conv) ; - if (ury < v - r[1] / conv) - ury = (integer) (v - r[1] / conv) ; + real conv = 72.0 * (real)num / (real)den * (real)mag / 254000000.0; + if (!dir) { + if (llx > h + r[0] / conv) + llx = (integer) (h + r[0] / conv); + if (lly > v - r[3] / conv) + lly = (integer) (v - r[3] / conv); + if (urx < h + r[2] / conv) + urx = (integer) (h + r[2] / conv); + if (ury < v - r[1] / conv) + ury = (integer) (v - r[1] / conv); + } else { + if (llx > h + r[1] / conv) + llx = (integer)(h + r[1] / conv); + if (lly > v + r[2] / conv) + lly = (integer)(v + r[2] / conv); + if (urx < h + r[3] / conv) + urx = (integer)(h + r[3] / conv); + if (ury < v + r[0] / conv) + ury = (integer)(v + r[0] / conv); + } } } -void -bbdopage(void) +void bbdopage(void) { - register shalfword cmd ; - register bbchardesctype *bcd ; - register chardesctype *cd ; - register integer h ; - register fontmaptype *cfnt ; - bbfontmaptype *bbcfnt ; - integer fnt ; - integer mychar ; - int charmove ; - struct dvistack *sp = stack ; - integer v, w, x, y, z ; - register fontdesctype *curfnt = 0 ; - register bbfontdesctype *bbcurfnt = 0 ; + register shalfword cmd; + register bbchardesctype *bcd; + register chardesctype *cd; + register integer h; + register fontmaptype *cfnt; + bbfontmaptype *bbcfnt; + integer fnt; + integer mychar; + int charmove; + struct dvistack *sp = stack; + integer v, w, x, y, z, dir; + register fontdesctype *curfnt = 0; + register bbfontdesctype *bbcurfnt = 0; - w = x = y = z = 0 ; - h = 0 ; v = 0 ; - llx = lly = 1000000000 ; - urx = ury = -1000000000 ; - charmove = 0 ; + w = x = y = z = dir = 0; + h = 0; v = 0; + llx = lly = 1000000000; + urx = ury = -1000000000; + charmove = 0; while (1) { switch (cmd=dvibyte()) { -case 138: break ; +case 138: break; case 134: /* put2 */ - if (noomega) error("! synch") ; - mychar = dvibyte() ; - mychar = (mychar << 8) + dvibyte() ; - charmove = 0 ; - goto dochar ; + mychar = dvibyte(); + mychar = (mychar << 8) + dvibyte(); + charmove = 0; + goto dochar; case 129: /* set2 */ - if (noomega) error("! synch") ; - mychar = dvibyte() ; - mychar = (mychar << 8) + dvibyte() ; + mychar = dvibyte(); + mychar = (mychar << 8) + dvibyte(); charmove = 1; - goto dochar ; + goto dochar; case 133: /* put1 */ - mychar = dvibyte() ; - charmove = 0 ; - goto dochar ; -case 128: cmd = dvibyte() ; /* set1 command drops through to setchar */ + 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 ; + mychar = cmd; + charmove = 1; dochar: - cd = &(curfnt->chardesc[mychar]) ; - bcd = &(bbcurfnt->bbchardesc[mychar]) ; - 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 ; +#ifdef VFLIB + if (mychar>=256) mychar = ((mychar>>8)-0x21)*94 + (mychar&0xff)-0x21; +#endif + cd = &(curfnt->chardesc[mychar]); + bcd = &(bbcurfnt->bbchardesc[mychar]); + if (!dir) { + 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; + } else { + if (h + bcd->ury < llx) llx = h + bcd->ury; + if (h + bcd->lly > urx) urx = h + bcd->lly; + if (v + bcd->llx < lly) lly = v + bcd->llx; + if (v + bcd->urx > ury) ury = v + bcd->urx; + } if (charmove) - h += cd->TFMwidth ; - break ; + if (!dir) + h += cd->TFMwidth; + else + v += cd->TFMwidth; + break; 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 */ - error("! synch") ; +case 254: /* unimplemented or illegal commands */ + error("! synch"); +case 255: /* dir */ + dir = dvibyte(); + break; case 132: case 137: /* rules */ - { integer ry, rx ; - ry = signedquad() ; rx = signedquad() ; + { integer ry, rx; + ry = signedquad(); rx = signedquad(); if (rx>0 && ry>0) { - if (h < llx) llx = h ; - if (v - ry < lly) lly = v - ry ; - if (h + rx > urx) urx = h + rx ; - if (v > ury) ury = v ; + if (!dir) { + if (h < llx) llx = h; + if (v - ry < lly) lly = v - ry; + if (h + rx > urx) urx = h + rx; + if (v > ury) ury = v; + } else { + if (h < llx) llx = h; + if (v + rx < lly) lly = v + rx; + if (h + ry > urx) urx = h + ry; + if (v > ury) ury = v; + } } else - rx = 0 ; + rx = 0; if (cmd != 137) - h += rx ; - break ; + if (!dir) + h += rx; + else + v += rx; + break; } case 141: /* push */ - sp->h = h ; sp->v = v ; - sp->w = w ; sp->x = x ; sp->y = y ; sp->z = z ; - if (++sp >= &stack[STACKSIZE]) error("! Out of stack space") ; - break ; + sp->h = h; sp->v = v; + sp->w = w; sp->x = x; sp->y = y; sp->z = z; sp->dir = dir; + if (++sp >= &stack[STACKSIZE]) error("! Out of stack space"); + break; case 140: /* eop or end of virtual character */ - return ; + return; case 142: /* pop */ - if (--sp < stack) error("! More pops than pushes") ; - h = sp->h ; v = sp->v ; - w = sp->w ; x = sp->x ; y = sp->y ; z = sp->z ; - break ; -case 143: h += signedbyte() ; break ; -case 144: h += signedpair() ; break ; -case 145: h += signedtrio() ; break ; -case 146: h += signedquad() ; break ; -case 147: h += w ; break ; -case 148: h += (w = signedbyte()) ; break ; -case 149: h += (w = signedpair()) ; break ; -case 150: h += (w = signedtrio()) ; break ; -case 151: h += (w = signedquad()) ; break ; -case 152: h += x ; break ; -case 153: h += (x = signedbyte()) ; break ; -case 154: h += (x = signedpair()) ; break ; -case 155: h += (x = signedtrio()) ; break ; -case 156: h += (x = signedquad()) ; break ; -case 157: v += signedbyte() ; break ; -case 158: v += signedpair() ; break ; -case 159: v += signedtrio() ; break ; -case 160: v += signedquad() ; break ; -case 161: v += y ; break ; -case 162: v += (y = signedbyte()) ; break ; -case 163: v += (y = signedpair()) ; break ; -case 164: v += (y = signedtrio()) ; break ; -case 165: v += (y = signedquad()) ; break ; -case 166: v += z ; break ; -case 167: v += (z = signedbyte()) ; break ; -case 168: v += (z = signedpair()) ; break ; -case 169: v += (z = signedtrio()) ; break ; -case 170: v += (z = signedquad()) ; break ; + if (--sp < stack) error("! More pops than pushes"); + h = sp->h; v = sp->v; + w = sp->w; x = sp->x; y = sp->y; z = sp->z; dir = sp->dir; + break; +case 143: if (!dir) h += signedbyte(); else v += signedbyte(); break; +case 144: if (!dir) h += signedpair(); else v += signedpair(); break; +case 145: if (!dir) h += signedtrio(); else v += signedtrio(); break; +case 146: if (!dir) h += signedquad(); else v += signedquad(); break; +case 147: if (!dir) h += w; else v += w; break; +case 148: if (!dir) h += (w = signedbyte()); else v += (w = signedbyte()); break; +case 149: if (!dir) h += (w = signedpair()); else v += (w = signedpair()); break; +case 150: if (!dir) h += (w = signedtrio()); else v += (w = signedtrio()); break; +case 151: if (!dir) h += (w = signedquad()); else v += (w = signedquad()); break; +case 152: if (!dir) h += x; else v += x; break; +case 153: if (!dir) h += (x = signedbyte()); else v += (x = signedbyte()); break; +case 154: if (!dir) h += (x = signedpair()); else v += (x = signedpair()); break; +case 155: if (!dir) h += (x = signedtrio()); else v += (x = signedtrio()); break; +case 156: if (!dir) h += (x = signedquad()); else v += (x = signedquad()); break; +case 157: if (!dir) v += signedbyte(); else h -= signedbyte(); break; +case 158: if (!dir) v += signedpair(); else h -= signedpair(); break; +case 159: if (!dir) v += signedtrio(); else h -= signedtrio(); break; +case 160: if (!dir) v += signedquad(); else h -= signedquad(); break; +case 161: if (!dir) v += y; else h -= y; break; +case 162: if (!dir) v += (y = signedbyte()); else h -= (y = signedbyte()); break; +case 163: if (!dir) v += (y = signedpair()); else h -= (y = signedpair()); break; +case 164: if (!dir) v += (y = signedtrio()); else h -= (y = signedtrio()); break; +case 165: if (!dir) v += (y = signedquad()); else h -= (y = signedquad()); break; +case 166: if (!dir) v += z; else h += z; break; +case 167: if (!dir) v += (z = signedbyte()); else h -= (z = signedbyte()); break; +case 168: if (!dir) v += (z = signedpair()); else h -= (z = signedpair()); break; +case 169: if (!dir) v += (z = signedtrio()); else h -= (z = signedtrio()); break; +case 170: if (!dir) v += (z = signedquad()); else h -= (z = signedquad()); 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: case 185: case 186: case 187: case 188: case 189: case 190: case 191: @@ -318,61 +429,60 @@ case 220: case 221: case 222: case 223: case 224: case 225: case 226: case 227: case 228: case 229: case 230: case 231: case 232: case 233: case 234: case 235: case 236: case 237: case 238: /* font selection commands */ - if (cmd < 235) fnt = cmd - 171 ; /* fntnum0 thru fntnum63 */ + if (cmd < 235) fnt = cmd - 171; /* fntnum0 thru fntnum63 */ else { - fnt = dvibyte() ; + fnt = dvibyte(); while (cmd-- > 235) - fnt = (fnt << 8) + dvibyte() ; + fnt = (fnt << 8) + dvibyte(); } for (cfnt=ffont; cfnt; cfnt = cfnt->next) - if (cfnt->fontnum == fnt) break ; - curfnt = cfnt->desc ; + 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 ; + 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) ; - skipover(dvibyte() + dvibyte()) ; - break ; -case 239: bbspecial(h, v, (int)dvibyte()) ; break ; -case 240: bbspecial(h, v, (int)twobytes()) ; break ; -case 241: bbspecial(h, v, (int)threebytes()) ; break ; -case 242: bbspecial(h, v, (int)signedquad()) ; break ; + skipover(cmd - 230); + skipover(dvibyte() + dvibyte()); + break; +case 239: bbspecial(h, v, dir, (int)dvibyte()); break; +case 240: bbspecial(h, v, dir, (int)twobytes()); break; +case 241: bbspecial(h, v, dir, (int)threebytes()); break; +case 242: bbspecial(h, v, dir, (int)signedquad()); break; } } } -void -findbb(integer bop) +void findbb(integer bop) { - integer curpos = ftell(dvifile) ; - real conv = 72.0 * (real)num / (real)den * (real)mag / 254000000.0 ; - real off = 72.0 / conv ; - real margin = 1.0 / conv ; - real vsize = 792.0 / conv ; - real hadj = -72.0 * hoff / 4736286.72 ; - real vadj = 72.0 * voff / 4736286.72 ; + integer curpos = ftell(dvifile); + real conv = 72.0 * (real)num / (real)den * (real)mag / 254000000.0; + real off = 72.0 / conv; + real margin = 1.0 / conv; + real vsize = 792.0 / conv; + real hadj = -72.0 * hoff / 4736286.72; + real vadj = 72.0 * voff / 4736286.72; - fseek(dvifile, bop, 0) ; - bbdopage() ; - fseek(dvifile, curpos, 0) ; - lly = (int) (vsize - 2 * off - lly) ; - ury = (int) (vsize - 2 * off - ury) ; - llx = (int)floor((llx + off - margin) * conv - hadj + 0.5) ; - lly = (int)floor((lly + off + margin) * conv - vadj + 0.5) ; - urx = (int)floor((urx + off + margin) * conv - hadj + 0.5) ; - ury = (int)floor((ury + off - margin) * conv - vadj + 0.5) ; + fseek(dvifile, bop, 0); + bbdopage(); + fseek(dvifile, curpos, 0); + lly = (int) (vsize - 2 * off - lly); + ury = (int) (vsize - 2 * off - ury); + llx = (int)floor((llx + off - margin) * conv - hadj + 0.5); + lly = (int)floor((lly + off + margin) * conv - vadj + 0.5); + urx = (int)floor((urx + off + margin) * conv - hadj + 0.5); + ury = (int)floor((ury + off - margin) * conv - vadj + 0.5); /* no marks on the page? */ if (llx >= urx || lly <= ury) - llx = lly = urx = ury = 72 ; + llx = lly = urx = ury = 72; #ifdef SHORTINT - sprintf(nextstring, "%ld %ld %ld %ld", llx, ury, urx, lly) ; + sprintf(nextstring, "%ld %ld %ld %ld", llx, ury, urx, lly); #else - sprintf(nextstring, "%d %d %d %d", llx, ury, urx, lly) ; + sprintf(nextstring, "%d %d %d %d", llx, ury, urx, lly); #endif } diff -Nu dvipsk2009/beginfontk1.test dvipsk/beginfontk1.test --- dvipsk2009/beginfontk1.test Thu Jan 01 09:00:00 1970 +++ dvipsk/beginfontk1.test Wed Jan 06 08:46:40 2010 @@ -0,0 +1,9 @@ +#! /bin/sh +# ensure -K1 does not remove newline after %%BeginFont line. +# Report from T S, 1 Jan 2010 16:32:16. + +tst=beginfontk1 +./dvips -K1 $srcdir/testdata/$tst.dvi -o || exit 1 +grep '^%%BeginFont: /MC1_ArialBold$' $tst.ps || exit 1 + +exit 0 diff -Nu dvipsk2009/c-auto.in dvipsk/c-auto.in --- dvipsk2009/c-auto.in Wed Jun 24 01:30:37 2009 +++ dvipsk/c-auto.in Mon Nov 23 23:20:22 2009 @@ -52,6 +52,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H +/* Define to 1 if you have the `mkstemp' function. */ +#undef HAVE_MKSTEMP + +/* Define to 1 if you have the `mktemp' function. */ +#undef HAVE_MKTEMP + /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H @@ -95,7 +101,7 @@ /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL -/* Define to 1 if `st_mtim' is member of `struct stat'. */ +/* Define to 1 if `st_mtim' is a member of `struct stat'. */ #undef HAVE_STRUCT_STAT_ST_MTIM /* Define to 1 if you have the header file, and it defines `DIR'. @@ -136,6 +142,9 @@ /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION diff -Nu dvipsk2009/color.c dvipsk/color.c --- dvipsk2009/color.c Tue Jun 23 18:46:14 2009 +++ dvipsk/color.c Mon Mar 29 23:26:05 2010 @@ -17,17 +17,16 @@ #include "dvips.h" /* The copyright notice in that file is included too! */ #include /* - * Externals we use. + * The external declarations: */ #include "protos.h" -extern integer pagenum ; -extern FILE *dvifile ; + /* * Here we set some limits on some color stuff. */ #define COLORHASH (89) #define MAXCOLORLEN (120) /* maximum color length for background */ -#define INITCOLORLEN (3000) /* initial stack size in chars */ +#define INITCOLORLEN (10000) /* initial stack size in chars */ /* * This is where we store the color information for a particular page. * If we free all of these, we free all of the allocated color @@ -35,12 +34,12 @@ * these. */ static struct colorpage { - struct colorpage *next ; - integer boploc ; /* we use the bop loc as a page indicator */ - char *bg ; - char colordat[2] ; -} *colorhash[COLORHASH] ; -static char *cstack, *csp, *cend, *bg ; + struct colorpage *next; + integer boploc; /* we use the bop loc as a page indicator */ + char *bg; + char colordat[2]; +} *colorhash[COLORHASH]; +static char *cstack, *csp, *cend, *bg; /* * This routine sends a color command out. If the command is a * single `word' or starts with a double quote, we send it out @@ -51,50 +50,50 @@ void colorcmdout(char *s) { - char *p ; - char tempword[100] ; + char *p; + char tempword[100]; while (*s && *s <= ' ') - s++ ; + s++; if (*s == '"') { - cmdout(s+1) ; - return ; + cmdout(s+1); + return; } - for (p=s; *p && *p > ' '; p++) ; - for (; *p && *p <= ' '; p++) ; + for (p=s; *p && *p > ' '; p++); + for (; *p && *p <= ' '; p++); if (*p == 0) { - cmdout(s) ; - return ; + cmdout(s); + return; } - cmdout(p) ; - strcpy(tempword, "TeXcolor") ; + cmdout(p); + strcpy(tempword, "TeXcolor"); for (p=tempword + strlen(tempword); *s && *s > ' '; p++, s++) - *p = *s ; - *p = 0 ; - cmdout(tempword) ; - return ; + *p = *s; + *p = 0; + cmdout(tempword); + return; } /* * For a new dvi file, call this. Frees all allocated memory. */ #define DEFAULTCOLOR "Black" void initcolor(void) { - int i ; - struct colorpage *p, *q ; + int i; + struct colorpage *p, *q; for (i=0; inext ; - free(p) ; + q = p->next; + free(p); } - colorhash[i] = 0 ; + colorhash[i] = 0; } - cstack = (char *)mymalloc(INITCOLORLEN) ; - strcpy(cstack, "\n") ; - strcat(cstack, DEFAULTCOLOR) ; - csp = cstack + strlen(cstack) ; - cend = cstack + INITCOLORLEN - 3 ; /* for conservativeness */ - bg = 0 ; + cstack = (char *)mymalloc(INITCOLORLEN); + strcpy(cstack, "\n"); + strcat(cstack, DEFAULTCOLOR); + csp = cstack + strlen(cstack); + cend = cstack + INITCOLORLEN - 3; /* for conservativeness */ + bg = 0; } /* * This takes a call from predospecial to set the background color for @@ -106,9 +105,9 @@ { if (bkgrnd && *bkgrnd) { if (strlen(bkgrnd) > MAXCOLORLEN) - error(" color name too long; ignored") ; + error(" color name too long; ignored"); else - strcpy(bg, bkgrnd) ; + strcpy(bg, bkgrnd); } } /* @@ -119,18 +118,18 @@ pushcolor(char *p, Boolean outtops) { while (strlen(p) + csp > cend) { - int newlen = 3 * (cend - cstack) ; - char *newcs = (char *)mymalloc(newlen) ; - strcpy(newcs, cstack) ; - csp = newcs + (csp - cstack) ; - cend = newcs + newlen - 3 ; - cstack = newcs ; - } - *csp++ = '\n' ; - strcpy(csp, p) ; - csp += strlen(p) ; + int newlen = 3 * (cend - cstack); + char *newcs = (char *)mymalloc(newlen); + strcpy(newcs, cstack); + csp = newcs + (csp - cstack); + cend = newcs + newlen - 3; + cstack = newcs; + } + *csp++ = '\n'; + strcpy(csp, p); + csp += strlen(p); if (outtops) { - colorcmdout(p) ; + colorcmdout(p); } } /* @@ -140,18 +139,18 @@ void popcolor(Boolean outtops) { - char *p = csp - 1 ; + char *p = csp - 1; while (p >= cstack && *p != '\n') - p-- ; + p--; if (p == cstack) - return ; /* We don't pop the last color as that is global */ - *p = 0 ; - csp = p ; - for (p--; p >= cstack && *p != '\n'; p--) ; - p++ ; + return; /* We don't pop the last color as that is global */ + *p = 0; + csp = p; + for (p--; p >= cstack && *p != '\n'; p--); + p++; if ( outtops ) { - colorcmdout(p) ; + colorcmdout(p); } } /* @@ -161,24 +160,24 @@ void resetcolorstack(char * p, int outtops) { - char *q = csp - 1 ; + char *q = csp - 1; while (q > cstack && *q != '\n') - q-- ; + q--; if (q > cstack && outtops == 0) { #ifdef SHORTINT - (void)fprintf(stderr, "You've mistakenly made a global color change ") ; - (void)fprintf(stderr, "to %s within nested colors\n", p) ; - (void)fprintf(stderr, "on page %ld. Will try to recover.\n", pagenum) ; + (void)fprintf(stderr, "You've mistakenly made a global color change "); + (void)fprintf(stderr, "to %s within nested colors\n", p); + (void)fprintf(stderr, "on page %ld. Will try to recover.\n", pagenum); #else /* ~SHORTINT */ - (void)fprintf(stderr, "You've mistakenly made a global color change ") ; - (void)fprintf(stderr, "to %s within nested colors\n", p) ; - (void)fprintf(stderr, "on page %d. Will try to recover.\n", pagenum) ; + (void)fprintf(stderr, "You've mistakenly made a global color change "); + (void)fprintf(stderr, "to %s within nested colors\n", p); + (void)fprintf(stderr, "on page %d. Will try to recover.\n", pagenum); #endif /* ~SHORTINT */ } - csp = cstack ; - *csp = 0 ; - pushcolor(p, outtops) ; + csp = cstack; + *csp = 0; + pushcolor(p, outtops); } /* * This routine is a bit magic. It looks up the page in the current @@ -196,46 +195,46 @@ void bopcolor(int outtops) { - integer pageloc = ftell(dvifile) ; - int h = pageloc % COLORHASH ; - struct colorpage *p = colorhash[h] ; + integer pageloc = ftell(dvifile); + int h = pageloc % COLORHASH; + struct colorpage *p = colorhash[h]; while (p) { if (p->boploc == pageloc) - break ; + break; else - p = p->next ; + p = p->next; } if (p) { - strcpy(cstack, p->colordat) ; - csp = cstack + strlen(cstack) ; - bg = p->bg ; + strcpy(cstack, p->colordat); + csp = cstack + strlen(cstack); + bg = p->bg; if (outtops && strcmp(bg, "White")!=0 && bg[0]) { - cmdout("gsave") ; - colorcmdout(bg) ; - cmdout("clippath fill grestore") ; + cmdout("gsave"); + colorcmdout(bg); + cmdout("clippath fill grestore"); } } else { p = (struct colorpage *)mymalloc((integer) - (strlen(cstack) + sizeof(struct colorpage) + MAXCOLORLEN)) ; - p->next = colorhash[h] ; - p->boploc = pageloc ; - strcpy(p->colordat, cstack) ; - p->bg = p->colordat + strlen(cstack) + 1 ; + (strlen(cstack) + sizeof(struct colorpage) + MAXCOLORLEN)); + p->next = colorhash[h]; + p->boploc = pageloc; + strcpy(p->colordat, cstack); + p->bg = p->colordat + strlen(cstack) + 1; if (bg) - strcpy(p->bg, bg) ; + strcpy(p->bg, bg); else - *(p->bg) = 0 ; - bg = p->bg ; - colorhash[h] = p ; + *(p->bg) = 0; + bg = p->bg; + colorhash[h] = p; } if (outtops) { - char *pp = csp - 1 ; + char *pp = csp - 1; while (pp >= cstack && *pp != '\n') - pp-- ; - pp++ ; + pp--; + pp++; if (strcmp(pp, DEFAULTCOLOR)!=0) { - colorcmdout(pp) ; + colorcmdout(pp); } } } diff -Nu dvipsk2009/debug.h dvipsk/debug.h --- dvipsk2009/debug.h Mon Mar 19 02:18:44 2007 +++ dvipsk/debug.h Mon Mar 29 23:26:32 2010 @@ -13,11 +13,11 @@ #define D_HEADER (1<<4) #define D_COMPRESS (1<<5) #define D_FILES (1<<6) -#define D_MEM (1<<7) +#define D_MEM (0) /* too verbose 1<<7 */ #define D_CONFIG (1<<8) #ifndef KPATHSEA #define fopen my_real_fopen -extern FILE *my_real_fopen() ; +extern FILE *my_real_fopen(); #endif #endif /* DEBUG */ diff -Nu dvipsk2009/dopage.c dvipsk/dopage.c --- dvipsk2009/dopage.c Tue Jun 23 18:46:14 2009 +++ dvipsk/dopage.c Mon Mar 29 23:26:42 2010 @@ -5,31 +5,10 @@ #include "dvips.h" /* The copyright notice in that file is included too! */ #include /* - * The external routines we use: + * The external declarations: */ -#include "protos.h" -/* - * Now the external variables. - */ -extern fontdesctype *curfnt ; -extern fontmaptype *ffont ; -extern quarterword *curpos, *curlim ; -extern integer hh, vv ; -extern integer hoff, voff ; -extern Boolean noomega ; -/* - * CONVENTION: conv -> horizontial converter - * vconv -> vertical converter - */ -extern real conv ; -extern real vconv ; - -extern FILE *bitfile ; -extern int actualdpi ; -extern int vactualdpi ; -extern frametype frames[] ; -extern int maxdrift ; -extern int vmaxdrift ; +integer dir; +#include "protos_add.h" #ifdef XENIX #define PixRound(x) ((integer)(x + (iconv >> 1)) / iconv) @@ -48,283 +27,327 @@ * Most error checking is suppressed because the prescan has already * verified that the DVI data is OK....except for stack over/underflow. */ -struct dvistack { - integer hh, vv ; - integer h, v, w, x, y, z ; -} stack[STACKSIZE] ; +struct dvistack stack[STACKSIZE]; #ifdef HPS -extern int pagecounter ; -extern Boolean HPS_FLAG ; -extern Boolean inHTMLregion ; -integer vvmem, hhmem ; -integer pushcount = 0 ; -Boolean PAGEUS_INTERUPPTUS = 0 ; -Boolean NEED_NEW_BOX = 0 ; -extern integer HREF_COUNT ; -extern int current_pushcount ; -integer H_BREAK ; /* An empirical parameter for guessing line breaks; needs +integer hhmem, vvmem; +integer pushcount = 0; +Boolean PAGEUS_INTERUPPTUS = 0; +Boolean NEED_NEW_BOX = 0; +integer H_BREAK; /* An empirical parameter for guessing line breaks; needs dpi dependence */ #endif void dopage(void) { - register shalfword cmd ; - register integer p ; - register chardesctype *cd ; - register integer h ; - register fontmaptype *cfnt ; - register frametype *frp = frames ; - integer fnt ; + register shalfword cmd; + register integer p; + register chardesctype *cd; + register integer h; + register fontmaptype *cfnt; + register frametype *frp = frames; + integer fnt; +#ifdef VFLIB + integer rawchar; +#endif integer mychar; - int charmove ; - struct dvistack *sp = stack ; - integer v, w, x, y, z ; - integer roundpos ; - integer thinspace ; - integer vertsmallspace ; + int charmove; + struct dvistack *sp = stack; + integer v, w, x, y, z; + integer roundpos; + integer thinspace; + integer vertsmallspace; #ifdef XENIX - integer iconv ; - integer viconv ; + integer iconv; + integer viconv; - iconv = (integer)(1.0 / conv + 0.5) ; - viconv = (integer)(1.0 / vconv + 0.5) ; + iconv = (integer)(1.0 / conv + 0.5); + viconv = (integer)(1.0 / vconv + 0.5); #else #ifdef __THINK__ - integer iconv ; - integer viconv ; + integer iconv; + integer viconv; - iconv = (integer)(1.0 / conv + 0.5) ; - viconv = (integer)(1.0 / vconv + 0.5) ; + iconv = (integer)(1.0 / conv + 0.5); + viconv = (integer)(1.0 / vconv + 0.5); #endif #endif #ifdef EMTEX - emclear() ; + emclear(); #endif - pageinit() ; + pageinit(); - bopcolor(1) ; - thinspace = (integer)(0.025*DPI/conv) ; /* 0.025 inches */ - vertsmallspace = (integer)(0.025*VDPI/vconv) ; /* 0.025 inches */ + bopcolor(1); + thinspace = (integer)(0.025*DPI/conv); /* 0.025 inches */ + vertsmallspace = (integer)(0.025*VDPI/vconv); /* 0.025 inches */ #ifdef HPS - if (HPS_FLAG) pagecounter++ ; - H_BREAK = (30 * DPI / 400 ) ; /* 30 seems to have worked well at 400 dpi */ + if (HPS_FLAG) pagecounter++; + H_BREAK = (30 * DPI / 400 ); /* 30 seems to have worked well at 400 dpi */ #endif - w = x = y = z = 0 ; - h = (integer) (DPI / conv * hoff / 4736286.72) ; - v = (integer) (DPI / conv * voff / 4736286.72) ; - hh = PixRound(h) ; - vv = PixRound(v) ; - curfnt = NULL ; - curpos = NULL ; - charmove = 0 ; + w = x = y = z = dir = rdir = fdir = 0; + h = (integer) (DPI / conv * hoff / 4736286.72); + v = (integer) (DPI / conv * voff / 4736286.72); + hh = PixRound(h); + vv = PixRound(v); + curfnt = NULL; + curpos = NULL; + charmove = 0; beginloop: switch (cmd=dvibyte()) { -case 138: goto beginloop ; /* nop command does nuttin */ +case 138: goto beginloop; /* nop command does nuttin */ /* * For put1 commands, we subtract the width of the character before * dropping through to the normal character setting routines. This */ case 134: /* put2 */ - if (noomega) error("! synch") ; - mychar = dvibyte() ; - mychar = (mychar << 8) + dvibyte() ; - charmove = 0 ; - goto dochar ; + mychar = dvibyte(); + mychar = (mychar << 8) + dvibyte(); + charmove = 0; + goto dochar; case 129: /* set2 */ - if (noomega) error("! synch") ; - mychar = dvibyte() ; - mychar = (mychar << 8) + dvibyte() ; - charmove = 1 ; - goto dochar ; + mychar = dvibyte(); + mychar = (mychar << 8) + dvibyte(); + charmove = 1; + goto dochar; case 133: /* put1 */ - mychar = dvibyte() ; - charmove = 0 ; - goto dochar ; -case 128: cmd = dvibyte() ; /* set1 command drops through to setchar */ + 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 ; + mychar = cmd; + charmove = 1; dochar: #ifdef HPS if (HPS_FLAG && PAGEUS_INTERUPPTUS) { - HREF_COUNT-- ; - start_new_box() ; - PAGEUS_INTERUPPTUS = 0 ; + HREF_COUNT--; + start_new_box(); + PAGEUS_INTERUPPTUS = 0; } if (HPS_FLAG && NEED_NEW_BOX) { vertical_in_hps(); NEED_NEW_BOX = 0; } #endif - cd = &(curfnt->chardesc[mychar]) ; +#ifdef VFLIB + rawchar = mychar; + if (mychar>=256) mychar = ((mychar>>8)-0x21)*94 + (mychar&0xff)-0x21; +#endif + cd = &(curfnt->chardesc[mychar]); if (cd->flags & EXISTS) { if (curfnt->loaded == 2) { /* virtual character being typeset */ if (charmove) { - sp->hh = hh + cd->pixelwidth ; - sp->h = h + cd->TFMwidth ; + if (!dir) { + sp->hh = hh + cd->pixelwidth; + sp->h = h + cd->TFMwidth; + } else { + sp->v = v + cd->TFMwidth; + sp->vv = PixRound(sp->v); + } + } else { + if (!dir) { + sp->hh = hh; sp->h = h; + } else { + sp->vv = vv; sp->v = v; + } + } + if (!dir) { + sp->vv = vv; sp->v = v; } else { - sp->hh = hh ; sp->h = h ; + sp->hh = hh; sp->h = h; } - sp->vv = vv ; sp-> v = v ; - sp->w = w ; sp->x = x ; sp->y = y ; sp->z = z ; - if (++sp >= &stack[STACKSIZE]) error("! Out of stack space") ; - w = x = y = z = 0 ; /* will be in relative units at new stack level */ - frp->curp = curpos ; - frp->curl = curlim ; - frp->ff = ffont ; - frp->curf = curfnt ; + sp->w = w; sp->x = x; sp->y = y; sp->z = z; sp->dir = dir; + if (++sp >= &stack[STACKSIZE]) error("! Out of stack space"); + w = x = y = z = 0; /* will be in relative units at new stack level */ + frp->curp = curpos; + frp->curl = curlim; + frp->ff = ffont; + frp->curf = curfnt; if (++frp == &frames[MAXFRAME] ) - error("! virtual recursion stack overflow") ; - curpos = cd->packptr + 2 ; - curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1))) ; - ffont = curfnt->localfonts ; + error("! virtual recursion stack overflow"); + curpos = cd->packptr + 2; + curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1))); + ffont = curfnt->localfonts; if (ffont) { - curfnt = ffont->desc ; - thinspace = curfnt->thinspace ; + curfnt = ffont->desc; + thinspace = curfnt->thinspace; } else { - curfnt = NULL ; - thinspace = vertsmallspace ; + curfnt = NULL; + thinspace = vertsmallspace; } - goto beginloop ; + goto beginloop; } - drawchar(cd, mychar) ; +#ifdef VFLIB + if (rawchar >= 256) + drawchar(cd, (mychar/94+0x21)*256 + (mychar%94) + 0x21); + else + drawchar(cd, mychar); +#else + drawchar(cd, mychar); +#endif } if (charmove) { - h += cd->TFMwidth ; - hh += cd->pixelwidth ; + if (!dir) { + h += cd->TFMwidth; + hh += cd->pixelwidth; + } else { + v += cd->TFMwidth; + vv += cd->pixelwidth; + } } - goto setmotion ; + goto setmotion; 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 */ - error("! synch") ; +case 254: /* unimplemented or illegal commands */ + error("! synch"); +case 255: + dir = dvibyte(); + cmddir(); + goto beginloop; case 132: case 137: /* rules */ - { integer ry, rx , rxx, ryy ; - ry = signedquad() ; rx = signedquad() ; + { integer ry, rx , rxx, ryy; + ry = signedquad(); rx = signedquad(); if (rx>0 && ry>0) { if (curpos) { - rx = scalewidth(rx, (frp-1)->curf->scaledsize) ; - ry = scalewidth(ry, (frp-1)->curf->scaledsize) ; + rx = scalewidth(rx, (frp-1)->curf->scaledsize); + ry = scalewidth(ry, (frp-1)->curf->scaledsize); } - rxx = (int)(conv * rx + 0.9999999) ; - ryy = (int)(vconv * ry + 0.9999999) ; - drawrule(rxx, ryy) ; + if (!dir) { + rxx = (int)(conv * rx + 0.9999999); + ryy = (int)(vconv * ry + 0.9999999); + } + else { + rxx = (int)(vconv * rx + 0.9999999); + ryy = (int)(conv * ry + 0.9999999); + } + /* HO 2001/06/03: synchronisation added for vertical rules + because of alignment reasons. + */ + if (ry > rx) { + hh = PixRound(h); + } + drawrule(rxx, ryy); } else - rxx = 0 ; - if (cmd == 137) goto beginloop ; - h += rx ; hh += rxx ; - goto setmotion ; + rxx = 0; + if (cmd == 137) goto beginloop; + if (!dir) { + h += rx; hh += rxx; + } + else { + v += rx; vv += rxx; + } + goto setmotion; } case 141: /* push */ #ifdef HPS - if (HPS_FLAG) pushcount++ ; + if (HPS_FLAG) pushcount++; /* if (HPS_FLAG && PAGEUS_INTERUPPTUS) { - HREF_COUNT-- ; - start_new_box() ; - PAGEUS_INTERUPPTUS = 0 ; + HREF_COUNT--; + start_new_box(); + PAGEUS_INTERUPPTUS = 0; } */ if (HPS_FLAG && NEED_NEW_BOX) { vertical_in_hps(); NEED_NEW_BOX = 0; } - /* printf("push %i, %i\n", pushcount, inHTMLregion) ; */ + /* printf("push %i, %i\n", pushcount, inHTMLregion); */ #endif - sp->hh = hh ; sp->vv = vv ; sp->h = h ; sp->v = v ; - sp->w = w ; sp->x = x ; sp->y = y ; sp->z = z ; - if (++sp >= &stack[STACKSIZE]) error("! Out of stack space") ; - goto beginloop ; + sp->hh = hh; sp->vv = vv; sp->h = h; sp->v = v; + sp->w = w; sp->x = x; sp->y = y; sp->z = z; sp->dir = dir; + if (++sp >= &stack[STACKSIZE]) error("! Out of stack space"); + goto beginloop; case 140: /* eop or end of virtual character */ if (curpos == NULL) { /* eop */ #ifdef HPS - if (HPS_FLAG && inHTMLregion) PAGEUS_INTERUPPTUS = 1 ; + if (HPS_FLAG && inHTMLregion) PAGEUS_INTERUPPTUS = 1; /* printf("Page interrupted"); */ #endif break; } - --frp ; - curfnt = frp->curf ; - thinspace = (curfnt) ? curfnt->thinspace : vertsmallspace ; - ffont = frp->ff ; - curlim = frp->curl ; - curpos = frp->curp ; + --frp; + curfnt = frp->curf; + thinspace = (curfnt) ? curfnt->thinspace : vertsmallspace; + ffont = frp->ff; + curlim = frp->curl; + curpos = frp->curp; if (hh < (sp-1)->hh+2 && hh > (sp-1)->hh-2) (sp-1)->hh = hh; /* retain `intelligence' of pixel width, if close */ /* falls through */ case 142: /* pop */ #ifdef HPS - pushcount-- ; - /* printf("pop %i\n", pushcount) ; */ + pushcount--; + /* printf("pop %i\n", pushcount); */ #endif - if (--sp < stack) error("! More pops than pushes") ; + if (--sp < stack) error("! More pops than pushes"); #ifdef HPS if (HPS_FLAG) { - hhmem = hh ; vvmem = vv ; + hhmem = hh; vvmem = vv; } #endif - hh = sp->hh ; vv = sp->vv ; h = sp->h ; v = sp->v ; - w = sp->w ; x = sp->x ; y = sp->y ; z = sp->z ; + hh = sp->hh; vv = sp->vv; h = sp->h; v = sp->v; + w = sp->w; x = sp->x; y = sp->y; z = sp->z; dir = sp->dir; #ifdef HPS if (HPS_FLAG && inHTMLregion && (hhmem - hh > H_BREAK) && (pushcount > 0) && (pushcount < current_pushcount)) - end_current_box() ; + end_current_box(); #endif - goto beginloop ; + cmddir(); + goto beginloop; case 143: /* right1 */ - p = signedbyte() ; goto horizontalmotion ; + p = signedbyte(); goto horizontalmotion; case 144: /* right2 */ - p = signedpair() ; goto horizontalmotion ; + p = signedpair(); goto horizontalmotion; case 145: /* right3 */ - p = signedtrio() ; goto horizontalmotion ; + p = signedtrio(); goto horizontalmotion; case 146: /* right4 */ - p = signedquad() ; goto horizontalmotion ; + p = signedquad(); goto horizontalmotion; case 147: /* w0 */ - p = w ; goto horizontalmotion ; + p = w; goto horizontalmotion; case 148: /* w1 */ - p = w = signedbyte() ; goto horizontalmotion ; + p = w = signedbyte(); goto horizontalmotion; case 149: /* w2 */ - p = w = signedpair() ; goto horizontalmotion ; + p = w = signedpair(); goto horizontalmotion; case 150: /* w3 */ - p = w = signedtrio() ; goto horizontalmotion ; + p = w = signedtrio(); goto horizontalmotion; case 151: /* w4 */ - p = w = signedquad() ; goto horizontalmotion ; + p = w = signedquad(); goto horizontalmotion; case 152: /* x0 */ - p = x ; goto horizontalmotion ; + p = x; goto horizontalmotion; case 153: /* x1 */ - p = x = signedbyte() ; goto horizontalmotion ; + p = x = signedbyte(); goto horizontalmotion; case 154: /* x2 */ - p = x = signedpair() ; goto horizontalmotion ; + p = x = signedpair(); goto horizontalmotion; case 155: /* x3 */ - p = x = signedtrio() ; goto horizontalmotion ; + p = x = signedtrio(); goto horizontalmotion; case 156: /* x4 */ - p = x = signedquad() ; goto horizontalmotion ; + p = x = signedquad(); goto horizontalmotion; case 157: /* down1 */ - p = signedbyte() ; goto verticalmotion ; + p = signedbyte(); goto verticalmotion; case 158: /* down2 */ - p = signedpair() ; goto verticalmotion ; + p = signedpair(); goto verticalmotion; case 159: /* down3 */ - p = signedtrio() ; goto verticalmotion ; + p = signedtrio(); goto verticalmotion; case 160: /* down4 */ - p = signedquad() ; goto verticalmotion ; + p = signedquad(); goto verticalmotion; case 161: /* y0 */ - p = y ; goto verticalmotion ; + p = y; goto verticalmotion; case 162: /* y1 */ - p = y = signedbyte() ; goto verticalmotion ; + p = y = signedbyte(); goto verticalmotion; case 163: /* y2 */ - p = y = signedpair() ; goto verticalmotion ; + p = y = signedpair(); goto verticalmotion; case 164: /* y3 */ - p = y = signedtrio() ; goto verticalmotion ; + p = y = signedtrio(); goto verticalmotion; case 165: /* y4 */ - p = y = signedquad() ; goto verticalmotion ; + p = y = signedquad(); goto verticalmotion; case 166: /* z0 */ - p = z ; goto verticalmotion ; + p = z; goto verticalmotion; case 167: /* z1 */ - p = z = signedbyte() ; goto verticalmotion ; + p = z = signedbyte(); goto verticalmotion; case 168: /* z2 */ - p = z = signedpair() ; goto verticalmotion ; + p = z = signedpair(); goto verticalmotion; case 169: /* z3 */ - p = z = signedtrio() ; goto verticalmotion ; + p = z = signedtrio(); goto verticalmotion; case 170: /* z4 */ - p = z = signedquad() ; goto verticalmotion ; + p = z = signedquad(); goto verticalmotion; 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: case 185: case 186: case 187: case 188: case 189: case 190: case 191: @@ -335,37 +358,37 @@ case 220: case 221: case 222: case 223: case 224: case 225: case 226: case 227: case 228: case 229: case 230: case 231: case 232: case 233: case 234: case 235: case 236: case 237: case 238: /* font selection commands */ - if (cmd < 235) fnt = cmd - 171 ; /* fntnum0 thru fntnum63 */ + if (cmd < 235) fnt = cmd - 171; /* fntnum0 thru fntnum63 */ else { - fnt = dvibyte() ; + fnt = dvibyte(); while (cmd-- > 235) - fnt = (fnt << 8) + dvibyte() ; + fnt = (fnt << 8) + dvibyte(); } for (cfnt=ffont; cfnt; cfnt = cfnt->next) - if (cfnt->fontnum == fnt) break ; - curfnt = cfnt->desc ; - thinspace = curfnt->thinspace ; - goto beginloop ; + if (cfnt->fontnum == fnt) break; + curfnt = cfnt->desc; + thinspace = curfnt->thinspace; + goto beginloop; case 243: case 244: case 245: case 246: /*fntdef1 */ - skipover(cmd - 230) ; - skipover(dvibyte() + dvibyte()) ; - goto beginloop ; + skipover(cmd - 230); + skipover(dvibyte() + dvibyte()); + goto beginloop; case 239: /* xxx1 */ - p = dvibyte() ; - dospecial(p) ; - goto beginloop ; + p = dvibyte(); + dospecial(p); + goto beginloop; case 240: /* xxx2 */ - p = twobytes() ; - dospecial(p) ; - goto beginloop ; + p = twobytes(); + dospecial(p); + goto beginloop; case 241: /* xxx3 */ - p = threebytes() ; - dospecial(p) ; - goto beginloop ; + p = threebytes(); + dospecial(p); + goto beginloop; case 242: /* xxx4 */ - p = signedquad() ; - dospecial(p) ; - goto beginloop ; + p = signedquad(); + dospecial(p); + goto beginloop; /* * The calculations here are crucial to the appearance of the document. @@ -377,22 +400,34 @@ verticalmotion: /* vertical motion cases */ if (curpos) - p = scalewidth(p, (frp-1)->curf->scaledsize) ; - v += p ; - if (p >= vertsmallspace) vv = VPixRound(v) ; - else if (p <= -vertsmallspace) vv = VPixRound(v) ; - else - { vv += VPixRound(p) ; - roundpos = VPixRound(v) ; - if (roundpos - vv > vmaxdrift) vv = roundpos - vmaxdrift ; - else if (vv - roundpos > vmaxdrift) vv = roundpos + vmaxdrift ; + p = scalewidth(p, (frp-1)->curf->scaledsize); + if (!dir) { + v += p; + if (p >= vertsmallspace) vv = VPixRound(v); + else if (p <= -vertsmallspace) vv = VPixRound(v); + else + { vv += VPixRound(p); + roundpos = VPixRound(v); + if (roundpos - vv > vmaxdrift) vv = roundpos - vmaxdrift; + else if (vv - roundpos > vmaxdrift) vv = roundpos + vmaxdrift; + } + } else { + h -= p; + if (p >= vertsmallspace) hh = VPixRound(h); + else if (p <= -vertsmallspace) hh = VPixRound(h); + else + { hh -= VPixRound(p); + roundpos = VPixRound(h); + if (roundpos - hh > vmaxdrift) hh = roundpos - vmaxdrift; + else if (hh - roundpos > vmaxdrift) hh = roundpos + vmaxdrift; + } } #ifdef HPS /* printf("Doing vertical motion: p = %i, v = %i, vv = %i\n",p,v,vv); */ - /* printf("inHTMLregion %i\n", inHTMLregion) ; */ + /* printf("inHTMLregion %i\n", inHTMLregion); */ if (HPS_FLAG && inHTMLregion) NEED_NEW_BOX = 1 /* vertical_in_hps() */; #endif - goto beginloop ; + goto beginloop; /* * Horizontal motion is analogous. We know the exact width of each * character in pixels. Kerning is distinguished from space between @@ -402,21 +437,35 @@ horizontalmotion: /* horizontal motion cases */ if (curpos) - p = scalewidth(p, (frp-1)->curf->scaledsize) ; - h += p ; - if (p >= thinspace || p <= -6 * thinspace) { - hh = PixRound(h) ; goto beginloop ; + p = scalewidth(p, (frp-1)->curf->scaledsize); + if (!dir) { + h += p; + if (p >= thinspace || p <= -6 * thinspace) { + hh = PixRound(h); goto beginloop; + } + else hh += PixRound(p); + } else { + v += p; + if (p >= thinspace || p <= -6 * thinspace) { + vv = PixRound(v); goto beginloop; + } + else vv += PixRound(p); } - else hh += PixRound(p) ; #ifdef HPS /* printf("Doing horizontal motion: p = %i, h = %i, hh = %i\n",p,h,hh); */ #endif setmotion: - roundpos = PixRound(h) ; - if (roundpos - hh > maxdrift) { hh = roundpos - maxdrift ; } - else if (hh - roundpos > maxdrift) { hh = roundpos + maxdrift ; } -goto beginloop ; + if (!dir) { + roundpos = PixRound(h); + if (roundpos - hh > maxdrift) { hh = roundpos - maxdrift; } + else if (hh - roundpos > maxdrift) { hh = roundpos + maxdrift; } + } else { + roundpos = PixRound(v); + if (roundpos - vv > maxdrift) { vv = roundpos - maxdrift; } + else if (vv - roundpos > maxdrift) { vv = roundpos + maxdrift; } + } +goto beginloop; } /* end of the big switch */ - pageend() ; + pageend(); } diff -Nu dvipsk2009/dosection.c dvipsk/dosection.c --- dvipsk2009/dosection.c Tue Jun 23 18:46:14 2009 +++ dvipsk/dosection.c Mon Mar 29 23:26:55 2010 @@ -3,110 +3,91 @@ */ #include "dvips.h" /* The copyright notice in that file is included too! */ /* - * These are the external routines we call. + * The external declarations: */ #include "protos.h" -/* - * These are the external variables we access. - */ -extern shalfword linepos ; -extern FILE *dvifile ; -extern FILE *bitfile ; -extern integer pagenum ; -extern long bytesleft ; -extern quarterword *raster ; -extern int quiet ; -extern Boolean reverse, multiplesects, disablecomments ; -extern Boolean evenpages, oddpages, pagelist ; -extern int actualdpi ; -extern int vactualdpi ; -extern int prettycolumn ; -extern integer hpapersize, vpapersize ; -extern integer pagecopies ; -static int psfont ; -extern double mag ; -extern char *fulliname ; +static int psfont; #ifdef HPS -int pagecounter ; -extern Boolean HPS_FLAG ; +int pagecounter; #endif + /* * Now we have the main procedure. */ void dosection(sectiontype *s, int c) { - charusetype *cu ; - integer prevptr ; - int np ; - int k ; - integer thispage = 0 ; + charusetype *cu; + integer prevptr; + int np; + int k; + integer thispage = 0; char buf[104]; - dopsfont(s) ; + dopsfont(s); #ifdef HPS if (HPS_FLAG) pagecounter = 0; #endif if (multiplesects) { - setup() ; + setup(); } - cmdout("TeXDict") ; - cmdout("begin") ; - numout(hpapersize) ; - numout(vpapersize) ; - doubleout(mag) ; - numout((integer)DPI) ; - numout((integer)VDPI) ; - sprintf(buf, "(%.99s)", fulliname) ; - cmdout(buf) ; - cmdout("@start") ; + cmdout("TeXDict"); + cmdout("begin"); + numout(hpapersize); + numout(vpapersize); + doubleout(mag); + numout((integer)DPI); + numout((integer)VDPI); + sprintf(buf, "(%.99s)", fulliname); + cmdout(buf); + cmdout("@start"); if (multiplesects) - cmdout("bos") ; + cmdout("bos"); /* * We insure raster is even-word aligned, because download might want that. */ if (bytesleft & 1) { - bytesleft-- ; - raster++ ; + bytesleft--; + raster++; } - cleanres() ; - cu = (charusetype *) (s + 1) ; - psfont = 1 ; + cleanres(); + cu = (charusetype *) (s + 1); + psfont = 1; while (cu->fd) { if (cu->psfused) - cu->fd->psflag = EXISTS ; - download(cu++, psfont++) ; + cu->fd->psflag = EXISTS; + download(cu++, psfont++); } - fonttableout() ; + fonttableout(); if (! multiplesects) { - cmdout("end") ; - setup() ; + cmdout("end"); + setup(); } for (cu=(charusetype *)(s+1); cu->fd; cu++) - cu->fd->psflag = 0 ; + cu->fd->psflag = 0; while (c > 0) { - c-- ; - prevptr = s->bos ; + c--; + prevptr = s->bos; if (! reverse) - (void)fseek(dvifile, (long)prevptr, 0) ; - np = s->numpages ; + (void)fseek(dvifile, (long)prevptr, 0); + np = s->numpages; while (np-- != 0) { if (reverse) - (void)fseek(dvifile, (long)prevptr, 0) ; - pagenum = signedquad() ; + (void)fseek(dvifile, (long)prevptr, 0); + pagenum = signedquad(); if ((evenpages && (pagenum & 1)) || (oddpages && (pagenum & 1)==0) || (pagelist && !InPageList(pagenum))) { if (reverse) { - skipover(36) ; - prevptr = signedquad()+1 ; + skipover(36); + prevptr = signedquad()+1; } else { - skipover(40) ; - skippage() ; - skipnop() ; + skipover(40); + skippage(); + skipnop(); } - ++np ; /* this page wasn't counted for s->numpages */ + ++np; /* this page wasn't counted for s->numpages */ continue; } /* @@ -114,75 +95,75 @@ * small, so we do it quick. */ if (! quiet) { - int t = pagenum, i = 0 ; + int t = pagenum, i = 0; if (t < 0) { - t = -t ; - i++ ; + t = -t; + i++; } do { - i++ ; - t /= 10 ; - } while (t > 0) ; + i++; + t /= 10; + } while (t > 0); if (pagecopies < 20) - i += pagecopies - 1 ; + i += pagecopies - 1; if (i + prettycolumn > STDOUTSIZE) { - fprintf(stderr, "\n") ; - prettycolumn = 0 ; + fprintf(stderr, "\n"); + prettycolumn = 0; } - prettycolumn += i + 1 ; + prettycolumn += i + 1; #ifdef SHORTINT - (void)fprintf(stderr, "[%ld", pagenum) ; + (void)fprintf(stderr, "[%ld", pagenum); #else /* ~SHORTINT */ - (void)fprintf(stderr, "[%d", pagenum) ; + (void)fprintf(stderr, "[%d", pagenum); #endif /* ~SHORTINT */ - (void)fflush(stderr) ; + (void)fflush(stderr); } - skipover(36) ; - prevptr = signedquad()+1 ; + skipover(36); + prevptr = signedquad()+1; for (k=0; k 1) - thispage = ftell(dvifile) ; + thispage = ftell(dvifile); } else { - (void)fseek(dvifile, (long)thispage, 0) ; + (void)fseek(dvifile, (long)thispage, 0); if (prettycolumn + 1 > STDOUTSIZE) { - (void)fprintf(stderr, "\n") ; - prettycolumn = 0 ; + (void)fprintf(stderr, "\n"); + prettycolumn = 0; } - (void)fprintf(stderr, ".") ; - (void)fflush(stderr) ; - prettycolumn++ ; + (void)fprintf(stderr, "."); + (void)fflush(stderr); + prettycolumn++; } - dopage() ; + dopage(); } if (! quiet) { - (void)fprintf(stderr, "] ") ; - (void)fflush(stderr) ; - prettycolumn += 2 ; + (void)fprintf(stderr, "] "); + (void)fflush(stderr); + prettycolumn += 2; } if (! reverse) - (void)skipnop() ; + (void)skipnop(); } } if (! multiplesects && ! disablecomments) { - newline() ; - (void)fprintf(bitfile, "%%%%Trailer\n") ; + newline(); + (void)fprintf(bitfile, "%%%%Trailer\n"); } if (multiplesects) { if (! disablecomments) { - newline() ; - (void)fprintf(bitfile, "%%DVIPSSectionTrailer\n") ; + newline(); + (void)fprintf(bitfile, "%%DVIPSSectionTrailer\n"); } - cmdout("eos") ; - cmdout("end") ; + cmdout("eos"); + cmdout("end"); } #ifdef HPS - if (HPS_FLAG) cmdout("\nend") ; /* close off HPSDict */ + if (HPS_FLAG) cmdout("\nend"); /* close off HPSDict */ #endif if (multiplesects && ! disablecomments) { - newline() ; - (void)fprintf(bitfile, "%%DVIPSEndSection\n") ; - linepos = 0 ; + newline(); + (void)fprintf(bitfile, "%%DVIPSEndSection\n"); + linepos = 0; } } /* @@ -235,10 +216,10 @@ int ParsePages(register char *s) { - register int c ; /* current character */ + register int c; /* current character */ register integer n = 0, /* current numeric value */ innumber; /* true => gathering a number */ - integer ps_low = 0, ps_high = 0 ; + integer ps_low = 0, ps_high = 0; int range, /* true => saw a range indicator */ negative = 0; /* true => number being built is negative */ diff -Nu dvipsk2009/dospecial.c dvipsk/dospecial.c --- dvipsk2009/dospecial.c Tue Jun 23 18:46:14 2009 +++ dvipsk/dospecial.c Tue May 04 08:41:37 2010 @@ -16,142 +16,188 @@ #endif /* WIN32*/ #endif /* - * These are the external routines called: + * The external declarations: */ /**/ #include "protos.h" -/* IBM: color - end */ -#ifdef HPS -extern Boolean PAGEUS_INTERUPPTUS ; -extern integer HREF_COUNT ; -extern Boolean NEED_NEW_BOX ; -extern Boolean HPS_FLAG ; -#endif -extern char errbuf[] ; -extern shalfword linepos; -extern Boolean usesspecial ; -extern Boolean usescolor ; /* IBM: color */ -extern int landscape ; -extern char *paperfmt ; -extern char *nextstring; -extern char *maxstring; -extern char *oname; -extern FILE *bitfile; -extern int quiet; -extern fontdesctype *curfnt ; -extern int actualdpi ; -extern int vactualdpi ; -extern integer hh, vv; -extern int lastfont ; -extern real conv ; -extern real vconv ; -extern integer hpapersize, vpapersize ; -extern Boolean pprescan ; -#ifndef KPATHSEA -extern char *figpath ; -#endif -extern int prettycolumn ; -extern Boolean disablecomments ; - -#ifdef DEBUG -extern integer debug_flag; -#endif - -static int specialerrors = 20 ; +static int specialerrors = 20; struct bangspecial { - struct bangspecial *next ; - char actualstuff[1] ; /* more space will actually be allocated */ -} *bangspecials = NULL ; + struct bangspecial *next; + char actualstuff[1]; /* more space will actually be allocated */ +} *bangspecials = NULL; void -specerror(char *s) +specerror(const char *s) { if (specialerrors > 0 #ifdef KPATHSEA && !kpse_tex_hush ("special") #endif ) { - error(s) ; - specialerrors-- ; + error(s); + specialerrors--; } else if (specialerrors == 0 #ifdef KPATHSEA && !kpse_tex_hush ("special") #endif ) { - error("more errors in special, being ignored . . .") ; + error("more errors in special, being ignored . . ."); error("(perhaps dvips doesn't support your macro package?)"); - specialerrors-- ; + specialerrors--; } } -static void -outputstring(register char *p) +static void outputstring(register char *p) { - (void)putc('\n', bitfile) ; + (void)putc('\n', bitfile); while(*p) { - (void)putc(*p, bitfile) ; - p++ ; + (void)putc(*p, bitfile); + p++; } - (void)putc('\n', bitfile) ; + (void)putc('\n', bitfile); } -static void -trytobreakout(register char *p) +static void trytobreakout(register char *p) { - register int i ; - register int instring = 0 ; - int lastc = 0 ; + register int i; + register int instring = 0; + int lastc = 0; - i = 0 ; - (void)putc('\n', bitfile) ; + i = 0; + (void)putc('\n', bitfile); if(*p == '%') { while(*p) { - (void)putc(*p, bitfile) ; - p++ ; + (void)putc(*p, bitfile); + p++; } - (void)putc('\n', bitfile) ; - return ; + (void)putc('\n', bitfile); + return; } while (*p) { if (i > 65 && *p == ' ' && instring == 0) { - (void)putc('\n', bitfile) ; - i = 0 ; + (void)putc('\n', bitfile); + i = 0; } else { - (void)putc(*p, bitfile) ; - i++ ; + (void)putc(*p, bitfile); + i++; } if (*p == '(' && lastc != '\\') - instring = 1 ; + instring = 1; else if (*p == ')' && lastc != '\\') - instring = 0 ; - lastc = *p ; - p++ ; + instring = 0; + lastc = *p; + p++; } - (void)putc('\n', bitfile) ; + (void)putc('\n', bitfile); } -static void -dobs(register struct bangspecial *q) +static void dobs(register struct bangspecial *q) { if (q) { - dobs(q->next) ; - trytobreakout(q->actualstuff) ; + dobs(q->next); + trytobreakout(q->actualstuff); } } +/* added for dvi2ps & jdvi2kps format */ +static void +fgetboundingbox(f, llx_p, lly_p, urx_p, ury_p) +char *f; +float *llx_p; +float *lly_p; +float *urx_p; +float *ury_p; +{ + FILE *fp; + char buf[BUFSIZ]; + char *mfgets(char *buf, unsigned int bytes, FILE *fp); + + fp = search(figpath, f, READ); + if (fp == 0) + fp = search(headerpath, f, READ); + if (fp) { + while (mfgets(buf, BUFSIZ, fp) != 0) { + if (buf[0] == '%' && buf[1] == '%' + && strncmp(buf+2, "BoundingBox:", 12) == 0) { + if (sscanf(buf+14, "%f %f %f %f", + llx_p, lly_p, urx_p, ury_p) == 4) { + fclose(fp); + return; + } + } + } + fclose(fp); + } + sprintf(errbuf, "Couldn't get BoundingBox of %s: assuming full A4 size", f); + specerror(errbuf); + *llx_p = 0.0; + *lly_p = 0.0; + *urx_p = 595.0; + *ury_p = 842.0; + return; +} + +char *mfgets(buf, bytes, fp) +char *buf; +unsigned int bytes; +FILE *fp; +{ + int i, cc; + + for (i = 0; i < bytes; i++) { + cc = fgetc(fp); + if (cc == 0x0a || cc == 0x0d) { + if (cc == 0x0d) { + cc = fgetc(fp); + if (cc != 0x0a) { + ungetc(cc, fp); + } + } + cc = 0x0a; + buf[i] = cc; + buf[i+1] = '\0'; + return buf; + } + else if (cc == EOF) { + buf[i] = '\0'; + if (i == 0) return NULL; + else return buf; + } + else { + buf[i] = cc; + } + } + buf[i] = '\0'; + return buf; +} + +static void +floatroundout(f) +float f; +{ + integer i; + i = (integer)(f<0 ? f-0.5 : f+0.5); + if (i-f < 0.001 && i-f > -0.001) { + numout((integer)i); + } else { + floatout(f); + } +} +/* end addition */ + void outbangspecials(void) { if (bangspecials) { - cmdout("TeXDict") ; - cmdout("begin") ; - cmdout("@defspecial\n") ; - dobs(bangspecials) ; - cmdout("\n@fedspecial") ; - cmdout("end") ; + cmdout("TeXDict"); + cmdout("begin"); + cmdout("@defspecial\n"); + dobs(bangspecials); + cmdout("\n@fedspecial"); + cmdout("end"); } } @@ -175,7 +221,7 @@ typedef enum {None, String, Integer, Number, Dimension} ValTyp; typedef struct { - char *Entry; + const char *Entry; ValTyp Type; } KeyDesc; @@ -215,105 +261,103 @@ /* * compare strings, ignore case */ -char -Tolower(register char c) +char Tolower(register char c) { if ('A' <= c && c <= 'Z') - return(c+32) ; + return(c+32); else - return(c) ; + return(c); } #endif #endif /* IBM: VM/CMS */ #endif #endif /* !KPATHSEA */ -int -IsSame(char *a, char *b) +IsSame(const char *a, const char *b) { - for( ; *a != '\0'; ) { + for(; *a != '\0'; ) { if( TOLOWER(*a) != TOLOWER(*b) ) return( 0 ); - a++ ; - b++ ; + a++; + b++; } return( *b == '\0' ); } -char *KeyStr, *ValStr ; /* Key and String values found */ -long ValInt ; /* Integer value found */ -float ValNum ; /* Number or Dimension value found */ +char *KeyStr; /* Key and ... */ +const char *ValStr; /* ... String values found */ +long ValInt; /* Integer value found */ +float ValNum; /* Number or Dimension value found */ -char * -GetKeyVal(char *str, int *tno) /* returns NULL if none found, else next scan point */ +char *GetKeyVal(char *str, int *tno) /* returns NULL if none found, else next scan point */ /* str : starting point for scan */ /* tno : table entry number of keyword, or -1 if keyword not found */ { - register char *s ; - register int i ; - register char t ; + register char *s; + register int i; + register char t; - for (s=str; *s <= ' ' && *s; s++) ; /* skip over blanks */ + for (s=str; *s <= ' ' && *s; s++); /* skip over blanks */ if (*s == '\0') - return (NULL) ; - KeyStr = s ; - while (*s>' ' && *s!='=') s++ ; + return (NULL); + KeyStr = s; + while (*s>' ' && *s!='=') s++; if (0 != (t = *s)) - *s++ = 0 ; + *s++ = 0; for(i=0; iscaledsize) * conv * 72 / DPI ; + error("! No font selected"); + ValNum = ValNum * ((double)curfnt->scaledsize) * conv * 72 / DPI; } - break ; - default: break ; + break; + default: break; } - return (s) ; + return (s); } /* @@ -325,40 +369,43 @@ * new string buffer if necessary. */ -void -predospecial(integer numbytes, Boolean scanning) +void predospecial(integer numbytes, Boolean scanning) { - register char *p = nextstring ; - register int i = 0 ; - int j ; + register char *p = nextstring; + register int i = 0; + int j; static int omega_specials = 0; - if (nextstring + numbytes > maxstring) { - p = nextstring = mymalloc(1000 + 2 * numbytes) ; - maxstring = nextstring + 2 * numbytes + 700 ; + if (numbytes < 0 || numbytes > maxstring - nextstring) { + if (numbytes < 0 || numbytes > (INT_MAX - 1000) / 2 ) { + error("! Integer overflow in predospecial"); + exit(1); + } + p = nextstring = mymalloc(1000 + 2 * numbytes); + maxstring = nextstring + 2 * numbytes + 700; } for (i=numbytes; i>0; i--) #ifdef VMCMS /* IBM: VM/CMS */ - *p++ = ascii2ebcdic[(char)dvibyte()] ; + *p++ = ascii2ebcdic[(char)dvibyte()]; #else #ifdef MVSXA /* IBM: MVS/XA */ - *p++ = ascii2ebcdic[(char)dvibyte()] ; + *p++ = ascii2ebcdic[(char)dvibyte()]; #else - *p++ = (char)dvibyte() ; + *p++ = (char)dvibyte(); #endif /* IBM: VM/CMS */ #endif if (pprescan) - return ; + return; while (p[-1] <= ' ' && p > nextstring) - p-- ; /* trim trailing blanks */ - if (p==nextstring) return ; /* all blank is no-op */ - *p = 0 ; - p = nextstring ; + p--; /* trim trailing blanks */ + if (p==nextstring) return; /* all blank is no-op */ + *p = 0; + p = nextstring; while (*p <= ' ') - p++ ; + p++; #ifdef DEBUG if (dd(D_SPECIAL)) - (void)fprintf(stderr, "Preprocessing special: %s\n", p) ; + (void)fprintf(stderr, "Preprocessing special: %s\n", p); #endif /* @@ -375,111 +422,111 @@ } return; } - break ; + break; case 'l': if (strncmp(p, "landscape", 9)==0) { if (hpapersize || vpapersize) error( - "both landscape and papersize specified: ignoring landscape") ; + "both landscape and papersize specified: ignoring landscape"); else - landscape = 1 ; - return ; + landscape = 1; + return; } - break ; + break; case 'p': - if (strncmp(p, "pos:", 4)==0) return ; /* positional specials */ + if (strncmp(p, "pos:", 4)==0) return; /* positional specials */ if (strncmp(p, "papersize", 9)==0) { - p += 9 ; + p += 9; while (*p == '=' || *p == ' ') - p++ ; + p++; if (hpapersize == 0 || vpapersize == 0) { if (landscape) { error( - "both landscape and papersize specified: ignoring landscape") ; - landscape = 0 ; + "both landscape and papersize specified: ignoring landscape"); + landscape = 0; } - handlepapersize(p, &hpapersize, &vpapersize) ; + handlepapersize(p, &hpapersize, &vpapersize); } - return ; + return; } - break ; + break; case 'x': - if (strncmp(p, "xtex:", 5)==0) return ; - break ; + if (strncmp(p, "xtex:", 5)==0) return; + break; case 's': - if (strncmp(p, "src:", 4)==0) return ; /* source specials */ - break ; + if (strncmp(p, "src:", 4)==0) return; /* source specials */ + break; case 'h': if (strncmp(p, "header", 6)==0) { - char *q, *r, *pre = NULL, *post = NULL ; - p += 6 ; + char *q, *r, *pre = NULL, *post = NULL; + p += 6; while ((*p <= ' ' || *p == '=' || *p == '(') && *p != 0) - p++ ; + p++; if(*p == '{') { p++; while ((*p <= ' ' || *p == '=' || *p == '(') && *p != 0) p++; - q = p ; + q = p; while (*p != '}' && *p != 0) p++; - r = p-1 ; + r = p-1; while ((*r <= ' ' || *r == ')') && r >= q) - r-- ; - if (*p != 0) p++ ; - r[1] = 0 ; /* q is the file name */ + r--; + if (*p != 0) p++; + r[1] = 0; /* q is the file name */ while ((*p <= ' ' || *p == '=' || *p == '(') && *p != 0) - p++ ; + p++; if(strncmp(p, "pre", 3) == 0) { - int bracecount = 1, numbytes = 0, j ; + int bracecount = 1, num_bytes = 0; while(*p != '{' && *p != 0) - p++ ; + p++; if (*p != 0) p++; for(r = p; *r != 0; r++) { - if (*r == '{') bracecount++ ; - else if (*r == '}') bracecount-- ; - if (bracecount == 0) break ; - numbytes++ ; + if (*r == '{') bracecount++; + else if (*r == '}') bracecount--; + if (bracecount == 0) break; + num_bytes++; } - pre = (char *)malloc(numbytes+1); - r = pre ; - for (j=0; j < numbytes; j++) + pre = (char *)malloc(num_bytes+1); + r = pre; + for (j=0; j < num_bytes; j++) *r++ = *p++; *r = 0; if (*p != 0) p++; } while ((*p <= ' ' || *p == '=' || *p == '(') && *p != 0) - p++ ; + p++; if(strncmp(p, "post", 4) == 0) { - int bracecount = 1, numbytes = 0, j ; + int bracecount = 1, num_bytes = 0; while(*p != '{' && *p != 0) - p++ ; + p++; if (*p != 0) p++; for(r = p; *r != 0; r++) { - if (*r == '{') bracecount++ ; - else if (*r == '}') bracecount-- ; - if (bracecount == 0) break ; - numbytes++ ; + if (*r == '{') bracecount++; + else if (*r == '}') bracecount--; + if (bracecount == 0) break; + num_bytes++; } - post = (char *)malloc(numbytes+1); - r = post ; - for (j=0; j < numbytes; j++) + post = (char *)malloc(num_bytes+1); + r = post; + for (j=0; j < num_bytes; j++) *r++ = *p++; *r = 0; } if (strlen(q) > 0) - (void)add_header_general(q, pre, post) ; + (void)add_header_general(q, pre, post); } else { - q = p ; /* we will remove enclosing parentheses */ - p = p + strlen(p) - 1 ; + q = p; /* we will remove enclosing parentheses */ + p = p + strlen(p) - 1; while ((*p <= ' ' || *p == ')') && p >= q) - p-- ; - p[1] = 0 ; + p--; + p[1] = 0; if (p >= q) - (void)add_header(q) ; + (void)add_header(q); } } - break ; + break; /* IBM: color - added section here for color header and color history */ /* using strncmp in this fashion isn't perfect; if later someone wants to introduce a verb like colorspace, well, just checking @@ -487,84 +534,76 @@ --tgr */ case 'b': if (strncmp(p, "background", 10) == 0) { - usescolor = 1 ; - p += 10 ; - while ( *p && *p <= ' ' ) p++ ; - background(p) ; - return ; + usescolor = 1; + p += 10; + while ( *p && *p <= ' ' ) p++; + background(p); + return; } - break ; + break; case 'c': if (strncmp(p, "color", 5) == 0) { - usescolor = 1 ; - p += 5 ; - while ( *p && *p <= ' ' ) p++ ; + usescolor = 1; + p += 5; + while ( *p && *p <= ' ' ) p++; if (strncmp(p, "push", 4) == 0 ) { - p += 4 ; - while ( *p && *p <= ' ' ) p++ ; - pushcolor(p, 0) ; + p += 4; + while ( *p && *p <= ' ' ) p++; + pushcolor(p, 0); } else if (strncmp(p, "pop", 3) == 0 ) { - popcolor(0) ; + popcolor(0); } else { - resetcolorstack(p,0) ; + resetcolorstack(p,0); } } /* IBM: color - end changes */ - break ; + break; case '!': { - register struct bangspecial *q ; - p++ ; + register struct bangspecial *q; + p++; q = (struct bangspecial *)mymalloc((integer) - (sizeof(struct bangspecial) + strlen(p))) ; - (void)strcpy(q->actualstuff, p) ; - q->next = bangspecials ; - bangspecials = q ; - usesspecial = 1 ; - return ; - } - break ; -default: -#if 0 - { - /* Unknown special, must return */ + (sizeof(struct bangspecial) + strlen(p))); + (void)strcpy(q->actualstuff, p); + q->next = bangspecials; + bangspecials = q; + usesspecial = 1; return; } -#endif - break ; + break; +default: + break; } - usesspecial = 1 ; /* now the special prolog will be sent */ + usesspecial = 1; /* now the special prolog will be sent */ if (scanning && *p != '"' && (p=GetKeyVal(p, &j)) != NULL && j==0 && *ValStr != '`') /* Don't bother to scan compressed files. */ - scanfontcomments(ValStr) ; + scanfontcomments(ValStr); } -int -maccess(char *s) +int maccess(char *s) { - FILE *f = search(figpath, s, "r") ; + FILE *f = search(figpath, s, "r"); if (f) - (*close_file) (f) ; - return (f != 0) ; + (*close_file) (f); + return (f != 0); } -char *tasks[] = { 0, "iff2ps", "tek2ps" } ; +const char *tasks[] = { 0, "iff2ps", "tek2ps" }; -static char psfile[511] ; -void -dospecial(integer numbytes) +static char psfile[511]; +void dospecial(integer numbytes) { - register char *p = nextstring ; - register int i = 0 ; - int j, systemtype = 0 ; - register char *q ; - Boolean psfilewanted = 1 ; - char *task = 0 ; - char cmdbuf[111] ; + register char *p = nextstring; + register int i = 0; + int j, systemtype = 0; + register const char *q; + Boolean psfilewanted = 1; + const char *task = 0; + char cmdbuf[111]; #ifdef HPS if (HPS_FLAG && PAGEUS_INTERUPPTUS) { - HREF_COUNT-- ; - start_new_box() ; - PAGEUS_INTERUPPTUS = 0 ; + HREF_COUNT--; + start_new_box(); + PAGEUS_INTERUPPTUS = 0; } if (HPS_FLAG && NEED_NEW_BOX) { vertical_in_hps(); @@ -572,27 +611,27 @@ } #endif if (nextstring + numbytes > maxstring) - error("! out of string space in dospecial") ; + error("! out of string space in dospecial"); for (i=numbytes; i>0; i--) #ifdef VMCMS /* IBM: VM/CMS */ - *p++ = ascii2ebcdic[(char)dvibyte()] ; + *p++ = ascii2ebcdic[(char)dvibyte()]; #else #ifdef MVSXA /* IBM: MVS/XA */ - *p++ = ascii2ebcdic[(char)dvibyte()] ; + *p++ = ascii2ebcdic[(char)dvibyte()]; #else - *p++ = (char)dvibyte() ; + *p++ = (char)dvibyte(); #endif /* IBM: VM/CMS */ #endif while (p[-1] <= ' ' && p > nextstring) - p-- ; /* trim trailing blanks */ - if (p==nextstring) return ; /* all blank is no-op */ - *p = 0 ; - p = nextstring ; + p--; /* trim trailing blanks */ + if (p==nextstring) return; /* all blank is no-op */ + *p = 0; + p = nextstring; while (*p <= ' ') - p++ ; + p++; #ifdef DEBUG if (dd(D_SPECIAL)) - (void)fprintf(stderr, "Processing special: %s\n", p) ; + (void)fprintf(stderr, "Processing special: %s\n", p); #endif switch (*p) { @@ -600,30 +639,85 @@ if (strncmp(p, "om:", 3)==0) { /* Omega specials ignored */ return; } - break ; + break; case 'e': if (strncmp(p, "em:", 3)==0) { /* emTeX specials in emspecial.c */ emspecial(p); return; } - break ; + +/* added for dvi2ps format */ + if (strncmp(p, "epsfile=", 8)==0) { /* epsf.sty for dvi2ps-j */ + float llx, lly, urx, ury; + + p += 8; + sscanf(p, "%s", psfile); + p += strlen(psfile); + fgetboundingbox(psfile, &llx, &lly, &urx, &ury); + hvpos(); + cmdout("@beginspecial"); + floatroundout(llx); + cmdout("@llx"); + floatroundout(lly); + cmdout("@lly"); + floatroundout(urx); + cmdout("@urx"); + floatroundout(ury); + cmdout("@ury"); + + while (p = GetKeyVal(p, &j)) { + switch (j) { + case 3: /* hsize */ + floatroundout(ValNum*10); + cmdout("@rwi"); + break; + case 4: /* vsize */ + floatroundout(ValNum*10); + cmdout("@rhi"); + break; + case 7: /* hscale */ + floatroundout((urx-llx)*ValNum*10); + cmdout("@rwi"); + break; + case 8: /* vscale */ + floatroundout((ury-lly)*ValNum*10); + cmdout("@rhi"); + break; + default: + sprintf(errbuf, "Unknown keyword `%s' in \\special{epsfile=%s...} will be ignored\n", KeyStr, psfile); + specerror(errbuf); + break; + } + } + cmdout("@setspecial"); + numout((integer)0); + cmdout("lly"); + cmdout("ury"); + cmdout("sub"); + cmdout("TR"); + figcopyfile(psfile, 0); + cmdout("\n@endspecial"); + return; + } +/* end addition */ + break; case 'p': - if (strncmp(p, "pos:", 4)==0) return ; /* positional specials */ + if (strncmp(p, "pos:", 4)==0) return; /* positional specials */ if (strncmp(p, "ps:", 3)==0) { - psflush() ; /* now anything can happen. */ + psflush(); /* now anything can happen. */ if (p[3]==':') { if (strncmp(p+4, "[nobreak]", 9) == 0) { - hvpos() ; - outputstring(&p[13]) ; + hvpos(); + outputstring(&p[13]); } else if (strncmp(p+4, "[begin]", 7) == 0) { - hvpos() ; - trytobreakout(&p[11]) ; + hvpos(); + trytobreakout(&p[11]); } else if (strncmp(p+4, "[end]", 5) == 0) trytobreakout(&p[9]); else trytobreakout(&p[4]); } else if (strncmp(p+3, " plotfile ", 10) == 0) { - char *sfp ; - hvpos() ; + char *sfp; + hvpos(); p += 13; /* * Fixed to allow popen input for plotfile @@ -632,9 +726,9 @@ while (*p == ' ') p++; if (*p == '"') { p++; - for (sfp = p; *sfp && *sfp != '"'; sfp++) ; + for (sfp = p; *sfp && *sfp != '"'; sfp++); } else { - for (sfp = p; *sfp && *sfp != ' '; sfp++) ; + for (sfp = p; *sfp && *sfp != ' '; sfp++); } *sfp = '\0'; if (*p == '`') @@ -643,27 +737,55 @@ figcopyfile (p, 0); /* End TJD changes */ } else { - hvpos() ; + hvpos(); trytobreakout(&p[3]); - psflush() ; - hvpos() ; + psflush(); + hvpos(); } return; } if (strncmp(p, "papersize", 9) == 0) - return ; + return; #ifdef TPIC if (strncmp(p, "pn ", 3) == 0) {setPenSize(p+2); return;} if (strncmp(p, "pa ", 3) == 0) {addPath(p+2); return;} #endif - break ; + +/* added for jdvi2kps format */ + if (strncmp(p, "postscriptbox", 13)==0) { /* epsbox.sty for jdvi2kps */ + float w, h; + float llx, lly, urx, ury; + if (sscanf(p+13, "{%fpt}{%fpt}{%[^}]}", &w, &h, psfile) != 3) + break; + fgetboundingbox(psfile, &llx, &lly, &urx, &ury); + hvpos(); + cmdout("@beginspecial"); + floatroundout(llx); + cmdout("@llx"); + floatroundout(lly); + cmdout("@lly"); + floatroundout(urx); + cmdout("@urx"); + floatroundout(ury); + cmdout("@ury"); + floatroundout(w*10*72/72.27); + cmdout("@rwi"); + floatroundout(h*10*72/72.27); + cmdout("@rhi"); + cmdout("@setspecial"); + figcopyfile(psfile, 0); + cmdout("\n@endspecial"); + return; + } +/* end addition */ + break; case 'l': - if (strncmp(p, "landscape", 9)==0) return ; - break ; + if (strncmp(p, "landscape", 9)==0) return; + break; case '!': - return ; + return; case 'h': - if (strncmp(p, "header", 6)==0) return ; + if (strncmp(p, "header", 6)==0) return; #ifdef HPS if (strncmp(p, "html:", 5)==0) { if (! HPS_FLAG) return; @@ -703,60 +825,60 @@ case 'w': case 'W': if (strncmp(p+1, "arning", 6) == 0) { - static int maxwarns = 50 ; + static int maxwarns = 50; if (maxwarns > 0) { - error(p) ; - maxwarns-- ; + error(p); + maxwarns--; } else if (maxwarns == 0) { - error(". . . rest of warnings suppressed") ; - maxwarns-- ; + error(". . . rest of warnings suppressed"); + maxwarns--; } - return ; + return; } #ifdef TPIC if (strcmp(p, "wh") == 0) {whitenLast(); return;} #endif - break ; + break; case 'b': if ( strncmp(p, "background", 10) == 0 ) - return ; /* already handled in prescan */ + return; /* already handled in prescan */ #ifdef TPIC if (strcmp(p, "bk") == 0) {blackenLast(); return;} #endif - break ; + break; case 'c': if (strncmp(p, "color", 5) == 0) { - p += 5 ; - while ( *p && *p <= ' ' ) p++ ; + p += 5; + while ( *p && *p <= ' ' ) p++; if (strncmp(p, "push", 4) == 0 ) { - p += 4 ; - while ( *p && *p <= ' ' ) p++ ; + p += 4; + while ( *p && *p <= ' ' ) p++; pushcolor(p,1); } else if (strncmp(p, "pop", 3) == 0 ) { - popcolor(1) ; + popcolor(1); } else { - resetcolorstack(p,1) ; + resetcolorstack(p,1); } - return ; + return; } /* IBM: color - end changes*/ - break ; + break; case 'f': #ifdef TPIC if (strcmp(p, "fp") == 0) {flushPath(0); return;} #endif - break ; + break; case 'i': #ifdef TPIC if (strcmp(p, "ip") == 0) {flushPath(1); return;} /* tpic 2.0 */ if (strncmp(p, "ia ", 3) == 0) {arc(p+2, 1); return;} /* tpic 2.0 */ #endif - break ; + break; case 'd': #ifdef TPIC if (strncmp(p, "da ", 3) == 0) {flushDashed(p+2, 0); return;} if (strncmp(p, "dt ", 3) == 0) {flushDashed(p+2, 1); return;} #endif - break ; + break; case 's': if (strncmp(p, "src:", 4) == 0) return; /* source specials */ #ifdef TPIC @@ -765,35 +887,27 @@ if (strcmp(p, "sh") == 0) {shadeLast(p+2); return;} /* tpic 2.0 */ if (strncmp(p, "sh ", 3) == 0) {shadeLast(p+3); return;} /* tpic 2.0 */ #endif - break ; + break; case 'a': #ifdef TPIC if (strncmp(p, "ar ", 3) == 0) {arc(p+2, 0); return;} /* tpic 2.0 */ #endif - break ; + break; case 't': #ifdef TPIC if (strncmp(p, "tx ", 3) == 0) {SetShade(p+3); return;} #endif - break ; + break; case '"': - hvpos() ; - cmdout("@beginspecial") ; - cmdout("@setspecial") ; - trytobreakout(p+1) ; - cmdout("\n@endspecial") ; - return ; - break ; + hvpos(); + cmdout("@beginspecial"); + cmdout("@setspecial"); + trytobreakout(p+1); + cmdout("\n@endspecial"); + return; + break; default: -#if 0 - { - /* Unknown special, must return */ - sprintf(errbuf,"Unrecognized special (first 10 chars: %.10s)", p); - specerror(errbuf); - return; - } -#endif - break ; + break; } /* At last we get to the key/value conventions */ psfile[0] = '\0'; @@ -805,181 +919,147 @@ case -1: /* for compatability with old conventions, we allow a file name * to be given without the 'psfile=' keyword */ if (!psfile[0] && maccess(KeyStr)==0) /* yes we can read it */ - (void)strcpy(psfile,KeyStr) ; + (void)strcpy(psfile,KeyStr); else { if (strlen(KeyStr) < 40) { - sprintf(errbuf, - "Unknown keyword (%s) in \\special will be ignored", - KeyStr) ; + sprintf(errbuf, + "Unknown keyword (%s) in \\special will be ignored", + KeyStr); } else { sprintf(errbuf, "Unknown keyword (%.40s...) in \\special will be ignored", - KeyStr) ; + KeyStr); } - specerror(errbuf) ; + specerror(errbuf); } - break ; + break; case 0: case 1: case 2: /* psfile */ if (psfile[0]) { sprintf(errbuf, "More than one \\special %s given; %s ignored", - "psfile", ValStr) ; - specerror(errbuf) ; + "psfile", ValStr); + specerror(errbuf); } - else (void)strcpy(psfile,ValStr) ; - task = tasks[j] ; - break ; + else (void)strcpy(psfile,ValStr); + task = tasks[j]; + break; default: /* most keywords are output as PostScript procedure calls */ if (KeyTab[j].Type == Integer) numout((integer)ValInt); else if (KeyTab[j].Type == String) for (q=ValStr; *q; q++) - scout(*q) ; - else if (KeyTab[j].Type == None) ; + scout(*q); + else if (KeyTab[j].Type == None); else { /* Number or Dimension */ - ValInt = (integer)(ValNum<0? ValNum-0.5 : ValNum+0.5) ; + ValInt = (integer)(ValNum<0? ValNum-0.5 : ValNum+0.5); if (ValInt-ValNum < 0.001 && ValInt-ValNum > -0.001) - numout((integer)ValInt) ; + numout((integer)ValInt); else { - (void)sprintf(cmdbuf, "%f", ValNum) ; - cmdout(cmdbuf) ; + (void)sprintf(cmdbuf, "%f", ValNum); + cmdout(cmdbuf); } } (void)sprintf(cmdbuf, "@%s", KeyStr); - cmdout(cmdbuf) ; + cmdout(cmdbuf); } cmdout("@setspecial"); if(psfile[0]) { if (task == 0) { - systemtype = (psfile[0]=='`') ; + systemtype = (psfile[0]=='`'); figcopyfile(psfile+systemtype, systemtype); } else { - fil2ps(task, psfile) ; + fprintf (stderr, "dvips: iff2ps and tek2ps are not supported.\n"); } } else if (psfilewanted #ifdef KPATHSEA && !kpse_tex_hush ("special") #endif ) - specerror("No \\special psfile was given; figure will be blank") ; + specerror("No \\special psfile was given; figure will be blank"); cmdout("@endspecial"); } -#ifdef KPATHSEA -extern char *realnameoffile; -#else -extern char realnameoffile[] ; -extern char *pictpath ; -#endif -void -fil2ps(char *task, char *iname) -{ - char cmd[400] ; - FILE *f ; - if (0 != (f=search(pictpath, iname, "r"))) { - close_file(f) ; - } else { - fprintf(stderr, " couldn't open %s\n", iname) ; - return ; - } - if (!quiet) { - fprintf(stderr, " [%s", realnameoffile) ; - fflush(stderr) ; - } - if (oname && oname[0] && oname[0] != '-') { - putc(10, bitfile) ; - close_file(bitfile) ; - sprintf(cmd, "%s -f %s %s", task, realnameoffile, oname) ; - system(cmd) ; - if ((bitfile=fopen(oname, FOPEN_ABIN_MODE))==NULL) - error_with_perror ("! couldn't reopen PostScript file", oname) ; - linepos = 0 ; - } else { - sprintf(cmd, "%s -f %s", task, realnameoffile) ; - system(cmd) ; - } - if (!quiet) - fprintf(stderr, "]") ; -} - /* * Handles specials encountered during bounding box calculations. * Currently we only deal with psfile's or PSfiles and only those * that do not use rotations. */ -static float rbbox[4] ; -float * -bbdospecial(int nbytes) -{ - char *p = nextstring ; - int i, j ; - char seen[NKEYS] ; - float valseen[NKEYS] ; - - if (nextstring + nbytes > maxstring) { - p = nextstring = mymalloc(1000 + 2 * nbytes) ; - maxstring = nextstring + 2 * nbytes + 700 ; +static float rbbox[4]; +float *bbdospecial(int nbytes) +{ + char *p = nextstring; + int i, j; + char seen[NKEYS]; + float valseen[NKEYS]; + + if (nbytes < 0 || nbytes > maxstring - nextstring) { + if (nbytes < 0 || nbytes > (INT_MAX - 1000) / 2 ) { + error("! Integer overflow in bbdospecial"); + exit(1); + } + p = nextstring = mymalloc(1000 + 2 * nbytes); + maxstring = nextstring + 2 * nbytes + 700; } if (nextstring + nbytes > maxstring) - error("! out of string space in bbdospecial") ; + error("! out of string space in bbdospecial"); for (i=nbytes; i>0; i--) #ifdef VMCMS /* IBM: VM/CMS */ - *p++ = ascii2ebcdic[(char)dvibyte()] ; + *p++ = ascii2ebcdic[(char)dvibyte()]; #else #ifdef MVSXA /* IBM: MVS/XA */ - *p++ = ascii2ebcdic[(char)dvibyte()] ; + *p++ = ascii2ebcdic[(char)dvibyte()]; #else - *p++ = (char)dvibyte() ; + *p++ = (char)dvibyte(); #endif /* IBM: VM/CMS */ #endif while (p[-1] <= ' ' && p > nextstring) - p-- ; /* trim trailing blanks */ - if (p==nextstring) return NULL ; /* all blank is no-op */ - *p = 0 ; - p = nextstring ; + p--; /* trim trailing blanks */ + if (p==nextstring) return NULL; /* all blank is no-op */ + *p = 0; + p = nextstring; while (*p && *p <= ' ') - p++ ; + p++; if (strncmp(p, "psfile", 6)==0 || strncmp(p, "PSfile", 6)==0) { float originx = 0, originy = 0, hscale = 1, vscale = 1, - hsize = 0, vsize = 0 ; + hsize = 0, vsize = 0; for (j=0; j= 0 && j < NKEYS && KeyTab[j].Type == Number) { - seen[j]++ ; - valseen[j] = ValNum ; + seen[j]++; + valseen[j] = ValNum; } } /* * This code mimics what happens in @setspecial. */ if (seen[3]) - hsize = valseen[3] ; + hsize = valseen[3]; if (seen[4]) - vsize = valseen[4] ; + vsize = valseen[4]; if (seen[5]) - originx = valseen[5] ; + originx = valseen[5]; if (seen[6]) - originy = valseen[6] ; + originy = valseen[6]; if (seen[7]) - hscale = valseen[7] / 100.0 ; + hscale = valseen[7] / 100.0; if (seen[8]) - vscale = valseen[8] / 100.0 ; + vscale = valseen[8] / 100.0; if (seen[10] && seen[12]) - hsize = valseen[12] - valseen[10] ; + hsize = valseen[12] - valseen[10]; if (seen[11] && seen[13]) - vsize = valseen[13] - valseen[11] ; + vsize = valseen[13] - valseen[11]; if (seen[14] || seen[15]) { if (seen[14] && seen[15] == 0) { - hscale = vscale = valseen[14] / (10.0 * hsize) ; + hscale = vscale = valseen[14] / (10.0 * hsize); } else if (seen[15] && seen[14] == 0) { - hscale = vscale = valseen[15] / (10.0 * vsize) ; + hscale = vscale = valseen[15] / (10.0 * vsize); } else { - hscale = valseen[14] / (10.0 * hsize) ; - vscale = valseen[15] / (10.0 * vsize) ; + hscale = valseen[14] / (10.0 * hsize); + vscale = valseen[15] / (10.0 * vsize); } } /* at this point, the bounding box in PostScript units relative to @@ -987,11 +1067,11 @@ originx originy originx+hsize*hscale originy+vsize*vscale We'll let the bbox routine handle the remaining math. */ - rbbox[0] = originx ; - rbbox[1] = originy ; - rbbox[2] = originx+hsize*hscale ; - rbbox[3] = originy+vsize*vscale ; - return rbbox ; + rbbox[0] = originx; + rbbox[1] = originy; + rbbox[2] = originx+hsize*hscale; + rbbox[3] = originy+vsize*vscale; + return rbbox; } - return 0 ; + return 0; } diff -Nu dvipsk2009/download.c dvipsk/download.c --- dvipsk2009/download.c Tue Jun 23 18:46:14 2009 +++ dvipsk/download.c Mon Mar 29 23:27:17 2010 @@ -12,257 +12,238 @@ #endif #define DVIPS /* - * These are the external routines we call. + * The external declarations: */ #include "protos.h" -/* - * These are the external variables we access. - */ -extern char *nextstring, *infont ; -extern FILE *bitfile ; -extern fontdesctype *curfnt ; -extern long bytesleft ; -extern long mbytesleft ; -extern quarterword *raster ; -extern quarterword *mraster ; -extern Boolean compressed ; -extern Boolean partialdownload ; -extern double mag ; -extern int actualdpi ; -static unsigned char dummyend[8] = { 252 } ; -extern int prettycolumn ; -extern int quiet ; -extern Boolean disablecomments ; -extern real conv ; + +static unsigned char dummyend[8] = { 252 }; /* * We have a routine that downloads an individual character. */ -static int lastccout ; -static void -downchar(chardesctype *c, shalfword cc) +static int lastccout; +void downchar(chardesctype *c, shalfword cc) { - register long i, j ; - register halfword cheight, cwidth ; - register long k ; - register quarterword *p ; - register halfword cmd ; - register shalfword xoff, yoff ; - halfword wwidth = 0 ; - register long len ; - int smallchar ; + register long i, j; + register halfword cheight, cwidth; + register long k; + register quarterword *p; + register halfword cmd; + register shalfword xoff, yoff; + halfword wwidth = 0; + register long len; + int smallchar; - p = c->packptr ; - cmd = *p++ ; + p = c->packptr; + cmd = *p++; if (cmd & 4) { if ((cmd & 7) == 7) { - cwidth = getlong(p) ; - cheight = getlong(p + 4) ; - xoff = getlong(p + 8) ; - yoff = getlong(p + 12) ; - p += 16 ; + cwidth = getlong(p); + cheight = getlong(p + 4); + xoff = getlong(p + 8); + yoff = getlong(p + 12); + p += 16; } else { - cwidth = p[0] * 256 + p[1] ; - cheight = p[2] * 256 + p[3] ; - xoff = p[4] * 256 + p[5] ; /* N.B.: xoff, yoff are signed halfwords */ - yoff = p[6] * 256 + p[7] ; - p += 8 ; + cwidth = p[0] * 256 + p[1]; + cheight = p[2] * 256 + p[3]; + xoff = p[4] * 256 + p[5]; /* N.B.: xoff, yoff are signed halfwords */ + yoff = p[6] * 256 + p[7]; + p += 8; } } else { - cwidth = *p++ ; - cheight = *p++ ; - xoff = *p++ ; - yoff = *p++ ; + cwidth = *p++; + cheight = *p++; + xoff = *p++; + yoff = *p++; if (xoff > 127) - xoff -= 256 ; + xoff -= 256; if (yoff > 127) - yoff -= 256 ; + yoff -= 256; } if (c->flags & BIGCHAR) - smallchar = 0 ; + smallchar = 0; else - smallchar = 5 ; + smallchar = 5; if (compressed) { - len = getlong(p) ; - p += 4 ; + len = getlong(p); + p += 4; } else { - wwidth = (cwidth + 15) / 16 ; - i = 2 * cheight * (long)wwidth ; + wwidth = (cwidth + 15) / 16; + i = 2 * cheight * (long)wwidth; if (i <= 0) - i = 2 ; - i += smallchar ; + i = 2; + i += smallchar; if (mbytesleft < i) { if (mbytesleft >= RASTERCHUNK) - (void) free((char *) mraster) ; + (void) free((char *) mraster); if (RASTERCHUNK > i) { - mraster = (quarterword *)mymalloc((integer)RASTERCHUNK) ; - mbytesleft = RASTERCHUNK ; + mraster = (quarterword *)mymalloc((integer)RASTERCHUNK); + mbytesleft = RASTERCHUNK; } else { - k = i + i / 4 ; - mraster = (quarterword *)mymalloc((integer)k) ; - mbytesleft = k ; + k = i + i / 4; + mraster = (quarterword *)mymalloc((integer)k); + mbytesleft = k; } } k = i; while (k > 0) - mraster[--k] = 0 ; - unpack(p, (halfword *)mraster, cwidth, cheight, cmd) ; - p = mraster ; - len = i - smallchar ; + mraster[--k] = 0; + unpack(p, (halfword *)mraster, cwidth, cheight, cmd); + p = mraster; + len = i - smallchar; } if (cheight == 0 || cwidth == 0 || len == 0) { - cwidth = 1 ; - cheight = 1 ; - wwidth = 1 ; - len = 2 ; + cwidth = 1; + cheight = 1; + wwidth = 1; + len = 2; if (compressed) - p = dummyend ; /* CMD(END); see repack.c */ + p = dummyend; /* CMD(END); see repack.c */ else - mraster[0] = 0 ; + mraster[0] = 0; } if (smallchar) { - p[len] = cwidth ; - p[len + 1] = cheight ; - p[len + 2] = xoff + 128 ; - p[len + 3] = yoff + 128 ; - p[len + 4] = c->pixelwidth ; + p[len] = cwidth; + p[len + 1] = cheight; + p[len + 2] = xoff + 128; + p[len + 3] = yoff + 128; + p[len + 4] = c->pixelwidth; } else /* * Now we actually send out the data. */ - specialout('[') ; + specialout('['); if (compressed) { - specialout('<') ; - mhexout(p, len + smallchar) ; - specialout('>') ; + specialout('<'); + mhexout(p, len + smallchar); + specialout('>'); } else { - i = (cwidth + 7) / 8 ; + i = (cwidth + 7) / 8; if (i * cheight > 65520) { - long bc = 0 ; - specialout('<') ; + long bc = 0; + specialout('<'); for (j=0; j 65520) { - specialout('>') ; - specialout('<') ; - bc = 0 ; + specialout('>'); + specialout('<'); + bc = 0; } - mhexout(p, i) ; - bc += i ; - p += 2*wwidth ; + mhexout(p, i); + bc += i; + p += 2*wwidth; } - specialout('>') ; + specialout('>'); } else { - specialout('<') ; + specialout('<'); if (2 * wwidth == i) - mhexout(p, ((long)cheight) * i + smallchar) ; + mhexout(p, ((long)cheight) * i + smallchar); else { for (j=0; j') ; + specialout('>'); } } if (smallchar == 0) { - numout((integer)cwidth) ; - numout((integer)cheight) ; - numout((integer)xoff + 128) ; /* not all these casts needed. */ - numout((integer)yoff + 128) ; - numout((integer)(c->pixelwidth)) ; + numout((integer)cwidth); + numout((integer)cheight); + numout((integer)xoff + 128); /* not all these casts needed. */ + numout((integer)yoff + 128); + numout((integer)(c->pixelwidth)); } if (lastccout + 1 == cc) { - cmdout("I") ; + cmdout("I"); } else { - numout((integer)cc) ; - cmdout("D") ; + numout((integer)cc); + cmdout("D"); } - lastccout = cc ; + lastccout = cc; } /* * Output the literal name of the font change command with PostScript index n */ static char goodnames[] = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ; + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; void makepsname(register char *s, register int n) { - n-- ; - *s++ = 'F' + n / (sizeof(goodnames)-1) ; - *s++ = goodnames[n % (sizeof(goodnames)-1)] ; - *s++ = 0 ; + n--; + *s++ = 'F' + n / (sizeof(goodnames)-1); + *s++ = goodnames[n % (sizeof(goodnames)-1)]; + *s++ = 0; } void lfontout(int n) { - char buf[10]; - char *b = buf ; - *b++ = '/' ; - makepsname(b, n) ; - cmdout(buf); + char buf[10]; + char *b = buf; + *b++ = '/'; + makepsname(b, n); + cmdout(buf); } /* * And the download procedure. */ -void -download(charusetype *p, int psfont) +void download(charusetype *p, int psfont) { - register int b, i ; - register halfword bit ; - register chardesctype *c ; - int cc, maxcc = -1, numcc ; - double fontscale ; - char name[10] ; - lastccout = -5 ; - name[0] = '/' ; - makepsname(name + 1, psfont) ; - curfnt = p->fd ; - curfnt->psname = psfont ; + register int b, i; + register halfword bit; + register chardesctype *c; + int cc, maxcc = -1, numcc; + double fontscale; + char name[10]; + lastccout = -5; + name[0] = '/'; + makepsname(name + 1, psfont); + curfnt = p->fd; + curfnt->psname = psfont; if (curfnt->resfont) { - struct resfont *rf = curfnt->resfont ; + struct resfont *rf = curfnt->resfont; int non_empty=0; for (b=0; b<16; b++) if(p->bitmap[b] !=0) non_empty =1; - if(non_empty==0 && curfnt->codewidth==1) + if(non_empty==0 && curfnt->iswide == 0 && curfnt->codewidth==1) return; - cmdout(name) ; + cmdout(name); /* following code re-arranged - Rob Hutchings 1992Apr02 */ - c = curfnt->chardesc + 255 ; - cc = 255 ; - numcc = 0 ; - i = 0 ; + c = curfnt->chardesc + 255; + cc = 255; + numcc = 0; + i = 0; for (b=15; b>=0; b--) { for (bit=1; bit; bit<<=1) { if (p->bitmap[b] & bit) { if (i > 0) { - numout((integer)i) ; - specialout('[') ; - i = 0 ; + numout((integer)i); + specialout('['); + i = 0; } - numout((integer)c->pixelwidth) ; - c->flags |= EXISTS ; - numcc++ ; + numout((integer)c->pixelwidth); + c->flags |= EXISTS; + numcc++; } else { - i++ ; - c->flags &= ~EXISTS ; + i++; + c->flags &= ~EXISTS; } - c-- ; - cc-- ; + c--; + cc--; } } if (i > 0) { - numout((integer)i) ; - specialout('[') ; + numout((integer)i); + specialout('['); } - specialout ('{') ; + specialout ('{'); if (rf->specialinstructions) - cmdout(rf->specialinstructions) ; - specialout ('}') ; - numout((integer)numcc) ; + cmdout(rf->specialinstructions); + specialout ('}'); + numout((integer)numcc); /* * This code has been bogus for a long time. The fix is * straightforward. The input, curfnt->scaledsize, is the @@ -273,42 +254,42 @@ * account magnification, num/den, output resolution, and so on. * Sorry this bug has been in here so long. -tgr */ - fontscale = curfnt->scaledsize * conv ; - (void)sprintf(nextstring, "%g", fontscale) ; - cmdout(nextstring) ; - (void)strcpy(nextstring, "/") ; - (void)strcat(nextstring, rf->PSname) ; - cmdout(nextstring) ; + fontscale = curfnt->scaledsize * conv; + (void)sprintf(nextstring, "%g", fontscale); + cmdout(nextstring); + (void)strcpy(nextstring, "/"); + (void)strcat(nextstring, rf->PSname); + cmdout(nextstring); /* end of changed section - Rob */ - cmdout("rf") ; - rf->sent = 1 ; - return ; + cmdout("rf"); + rf->sent = 1; + return; } /* * Here we calculate the largest character actually used, and * send it as a parameter to df. */ - cc = 0 ; - numcc = 0 ; + cc = 0; + numcc = 0; for (b=0; b<16; b++) { for (bit=32768; bit!=0; bit>>=1) { if (p->bitmap[b] & bit) { - maxcc = cc ; - numcc++ ; + maxcc = cc; + numcc++; } - cc++ ; + cc++; } } if (numcc <= 0) - return ; - fontscale = ((double)(curfnt->scaledsize)) / 65536.0 ; - fontscale *= (mag/1000.0) ; - newline() ; + return; + fontscale = ((double)(curfnt->scaledsize)) / 65536.0; + fontscale *= (mag/1000.0); + newline(); fprintf(bitfile, "%%DVIPSBitmapFont: %s %s %g %d\n", name+1, curfnt->name, - fontscale, numcc) ; - cmdout(name) ; - numout((integer)numcc) ; - numout((integer)maxcc + 1) ; + fontscale, numcc); + cmdout(name); + numout((integer)numcc); + numout((integer)maxcc + 1); /* * If we need to scale the font, we say so by using dfs * instead of df, and we give it a scale factor. We also @@ -316,68 +297,207 @@ * fonts is ugly, and this is the best we can probably do. */ if (curfnt->dpi != curfnt->loadeddpi) { - numout((integer)curfnt->dpi) ; - numout((integer)curfnt->loadeddpi) ; + numout((integer)curfnt->dpi); + numout((integer)curfnt->loadeddpi); if (curfnt->alreadyscaled == 0) { for (b=0, c=curfnt->chardesc; b<256; b++, c++) c->pixelwidth = (c->pixelwidth * - (long)curfnt->dpi * 2 + curfnt->loadeddpi) / (2 * curfnt->loadeddpi) ; - curfnt->alreadyscaled = 1 ; + (long)curfnt->dpi * 2 + curfnt->loadeddpi) / (2 * curfnt->loadeddpi); + curfnt->alreadyscaled = 1; } - cmdout("dfs") ; + cmdout("dfs"); } else - cmdout("df") ; - c = curfnt->chardesc ; - cc = 0 ; + cmdout("df"); + c = curfnt->chardesc; + cc = 0; for (b=0; b<16; b++) { for (bit=32768; bit; bit>>=1) { if (p->bitmap[b] & bit) { - downchar(c, cc) ; - c->flags |= EXISTS ; + downchar((chardesctype *)c, (shalfword)cc); + c->flags |= EXISTS; } else - c->flags &= ~EXISTS ; - c++ ; - cc++ ; + c->flags &= ~EXISTS; + c++; + cc++; } } - cmdout("E") ; - newline() ; - fprintf(bitfile, "%%EndDVIPSBitmapFont\n") ; + cmdout("E"); + newline(); + fprintf(bitfile, "%%EndDVIPSBitmapFont\n"); +} + +#ifdef VFLIB +void downvffont(charusetype *p, charusetype *all) +{ + register int b; + register halfword bit; + register chardesctype *c; + struct resfont *rf; + int cc; + int unuminfo[256][2], unumcc, lastunum, curunum, curlnum, jiscc; + halfword bitmap[553]; + int vffd; + + curfnt = p->fd; + rf = curfnt->resfont; + if (rf == 0 || rf->Fontfile == NULL) + return; + for (; all->fd; all++) + if (all->fd->resfont && + strcmp(rf->PSname, all->fd->resfont->PSname) == 0) + break; + if (all != p) + return; + if (all->fd == 0) + error("! internal error in downpsfont"); +/* This never happens. + if (!partialdownload) { + infont = all->fd->resfont->PSname; + copyfile(all->fd->resfont->Fontfile); + infont = 0; + return; + } +*/ + for (b=0; b<553; b++) + bitmap[b] = 0; + for (b=0; b<256; b++) + unuminfo[b][0] = unuminfo[b][1] = 0; + for (; all->fd; all++) { + if (all->fd->resfont == 0 || + strcmp(rf->PSname, all->fd->resfont->PSname)) + continue; + cc = 0; + for (b=0; b<553; b++) { + for (bit=32768; bit!=0 && cc>=1) { + if (all->bitmap[b] & bit) + bitmap[b] |= bit; + } + cc++; + } + } + + cc = 0; + unumcc = 0; + curunum = curlnum = lastunum = -1; + for (b=0; b<553; b++) { + for (bit=32768; bit!=0 && cc>=1) { + if (bitmap[b] & bit) { + jiscc = CCTOJIS(cc); + curunum = jiscc>>8; + curlnum = jiscc & 0xff; +/* fprintf(stderr, "curunum:%d\n", curunum); + fprintf(stderr, "curlnum:%d\n", curlnum); */ + unuminfo[curunum][0]++; /* numcc */ + if (unuminfo[curunum][1] < curlnum) { + unuminfo[curunum][1] = curlnum; /* maxcc */ + } + if (lastunum != curunum) { + lastunum = curunum; + unumcc++; + } + } + cc++; + } + } + +/* fprintf(stderr, "unumcc:%d\n", unumcc); */ + if (unumcc <= 0) + return; + + if (!quiet) { + if (strlen(rf->Fontfile) + prettycolumn > STDOUTSIZE) { + fprintf(stderr, "\n"); + prettycolumn = 0; + } + (void)fprintf(stderr, "<%s>", rf->Fontfile); + prettycolumn += strlen(rf->Fontfile) + 2; + } + if (! disablecomments) + (void)fprintf(bitfile, "%%%%BeginFont: %s\n", rf->PSname); + cmdout("TeXDict begin"); +/* composite font */ + (void)strcpy(nextstring, "/"); + (void)strcat(nextstring, rf->PSname); + cmdout(nextstring); + numout((integer)unumcc); + if (curfnt->dir) { + /* WMode */ + numout((integer)1); + } + else + numout((integer)0); + cmdout("Vdf"); + cc = 0; + lastunum = curunum = -1; + /* base font */ + if ((vffd = VF_OpenFont(rf->Fontfile))<0) { + sprintf(errbuf, "! Failed to open font %s.", curfnt->name); + error(errbuf); + } + for (b=0; b<553; b++) { + for (bit=32768; bit!=0 && cc>=1) { + if (bitmap[b] & bit){ + jiscc = CCTOJIS(cc); + curunum = jiscc>>8; + if (lastunum != curunum) { + if (lastunum != -1) cmdout("VE"); + lastunum = curunum; + numout((integer)curunum); + numout((integer)unuminfo[curunum][0]); + numout((integer)(unuminfo[curunum][1]+1)); + cmdout("Vsdf"); + } + /* fprintf(stderr, "Downloading VFchar %s 0x%02x\n", + curfnt->vfname, CCTOJIS(cc)); */ + downvfchar(vffd, jiscc, curfnt->dir); + } + cc++; + } + } + VF_CloseFont(vffd); + cmdout("VE"); + cmdout("VEE"); + cmdout("end"); + if (! disablecomments) { + (void)fprintf(bitfile, "\n"); + (void)fprintf(bitfile, "%%%%EndFont \n"); + } } +#endif /* * Magic code to deal with PostScript font partial downloading. * We track the encodings we've seen so far and keep them in these * structures. We rely on writet1 to load the encodings for us. */ static struct seenEncodings { - struct seenEncodings *next ; - char *name ; - char **glyphs ; -} *seenEncodings ; + struct seenEncodings *next; + const char *name; + const char **glyphs; +} *seenEncodings; #define MAX_CHAR_CODE 256 /* * Load a new encoding and return the array of glyphs as a vector. * Linear search. */ -static char **getEncoding(char *encoding) { - struct seenEncodings *p = seenEncodings ; +static const char **getEncoding(char *encoding) { + struct seenEncodings *p = seenEncodings; while (p != 0) if (strcmp(encoding, p->name) == 0) - break ; + break; else - p = p->next ; + p = p->next; if (p == 0) { - int i ; - p = (struct seenEncodings *)mymalloc(sizeof(struct seenEncodings)) ; - p->next = seenEncodings ; - seenEncodings = p ; - p->name = xstrdup(encoding) ; - p->glyphs = (char **)mymalloc((MAX_CHAR_CODE+1) * sizeof(char *)) ; + int i; + p = (struct seenEncodings *)mymalloc(sizeof(struct seenEncodings)); + p->next = seenEncodings; + seenEncodings = p; + p->name = xstrdup(encoding); + p->glyphs = (const char **)mymalloc((MAX_CHAR_CODE+1) * sizeof(char *)); for (i=0; iglyphs[i] = ".notdef" ; - load_enc(encoding, p->glyphs) ; + p->glyphs[i] = ".notdef"; + load_enc(encoding, p->glyphs); } - return p->glyphs ; + return p->glyphs; } /* * When partially downloading a type 1 font, sometimes the font uses @@ -390,128 +510,124 @@ * If no glyphs have been added, extraGlyphs is null. In all cases, * the memory allocated for this is in extraGlyphSpace. */ -static char *extraGlyphs = 0 ; +static char *extraGlyphs = 0; #ifdef DOWNLOAD_USING_PDFTEX -static char *extraGlyphSpace = 0 ; -static int extraGlyphSize = 0 ; -static int glyphSizeUsed = 0 ; +static char *extraGlyphSpace = 0; +static int extraGlyphSize = 0; +static int glyphSizeUsed = 0; /* * We want to make sure we pass in null or "/" but never "". */ -static void clearExtraGlyphList() { - glyphSizeUsed = 0 ; - extraGlyphs = 0 ; +static void clearExtraGlyphList(void) { + glyphSizeUsed = 0; + extraGlyphs = 0; } /* * Add the glyph name; make sure it hasn't been added already. * We do this by adding it, so we can get the // around it, * and *then* see if it's already there and if it is un-add it. */ -static void addGlyph(char *glyphName) { - int len = strlen(glyphName) ; - char *startOfAdd = 0 ; +static void addGlyph(const char *glyphName) { + int len = strlen(glyphName); + char *startOfAdd = 0; if (len + glyphSizeUsed + 3 > extraGlyphSize) { - extraGlyphSize = 2 * (extraGlyphSize + len + 100) ; - extraGlyphSpace = (char *) xrealloc(extraGlyphSpace, extraGlyphSize) ; + extraGlyphSize = 2 * (extraGlyphSize + len + 100); + extraGlyphSpace = (char *) xrealloc(extraGlyphSpace, extraGlyphSize); } - extraGlyphs = extraGlyphSpace ; + extraGlyphs = extraGlyphSpace; if (glyphSizeUsed == 0) { - startOfAdd = extraGlyphs + glyphSizeUsed ; - extraGlyphs[glyphSizeUsed++] = '/' ; /* leading / */ + startOfAdd = extraGlyphs + glyphSizeUsed; + extraGlyphs[glyphSizeUsed++] = '/'; /* leading / */ } else { - startOfAdd = extraGlyphs + glyphSizeUsed - 1 ; + startOfAdd = extraGlyphs + glyphSizeUsed - 1; } - strcpy(extraGlyphs + glyphSizeUsed, glyphName) ; - glyphSizeUsed += len ; - extraGlyphs[glyphSizeUsed++] = '/' ; /* trailing / */ - extraGlyphs[glyphSizeUsed] = 0 ; + strcpy(extraGlyphs + glyphSizeUsed, glyphName); + glyphSizeUsed += len; + extraGlyphs[glyphSizeUsed++] = '/'; /* trailing / */ + extraGlyphs[glyphSizeUsed] = 0; if (strstr(extraGlyphs, startOfAdd) != startOfAdd) { /* already there! */ - glyphSizeUsed = startOfAdd - extraGlyphs + 1 ; /* kill the second copy */ - extraGlyphs[glyphSizeUsed] = 0 ; + glyphSizeUsed = startOfAdd - extraGlyphs + 1; /* kill the second copy */ + extraGlyphs[glyphSizeUsed] = 0; } } #endif + /* * Download a PostScript font, using partial font downloading if * necessary. */ -extern char *downloadedpsnames[]; -extern int unused_top_of_psnames; - -static void -downpsfont(charusetype *p, charusetype *all) +void downpsfont(charusetype *p, charusetype *all) { #ifdef DOWNLOAD_USING_PDFTEX static unsigned char grid[256]; #endif - int GridCount ; + int GridCount; register int b; - register halfword bit ; - register chardesctype *c ; - struct resfont *rf ; + register halfword bit; + register chardesctype *c; + struct resfont *rf; int cc; - extern char *realnameoffile ; int j; - curfnt = p->fd ; - rf = curfnt->resfont ; + curfnt = p->fd; + rf = curfnt->resfont; if (rf == 0 || rf->Fontfile == NULL) - return ; + return; for (; all->fd; all++) if (all->fd->resfont && strcmp(rf->PSname, all->fd->resfont->PSname) == 0) - break ; + break; if (all != p) - return ; + return; if (rf->sent == 2) /* sent as header, from a PS file */ - return ; + return; for (j=0; downloadedpsnames[j] && j < unused_top_of_psnames; j++) { if (strcmp (downloadedpsnames[j], rf->PSname) == 0) return; } if (all->fd == 0) - error("! internal error in downpsfont") ; + error("! internal error in downpsfont"); if (!partialdownload) { - infont = all->fd->resfont->PSname ; - copyfile(all->fd->resfont->Fontfile); - infont = 0 ; - return; + infont = all->fd->resfont->PSname; + copyfile(all->fd->resfont->Fontfile); + infont = 0; + return; } for (cc=0; cc<256; cc++) - grid[cc] = 0 ; + grid[cc] = 0; #ifdef DOWNLOAD_USING_PDFTEX - clearExtraGlyphList() ; + clearExtraGlyphList(); #endif for (; all->fd; all++) { if (all->fd->resfont == 0 || strcmp(rf->PSname, all->fd->resfont->PSname)) - continue ; - curfnt = all->fd ; + continue; + curfnt = all->fd; #ifdef DOWNLOAD_USING_PDFTEX if (curfnt->resfont->Vectfile) { - char **glyphs = getEncoding(curfnt->resfont->Vectfile) ; - c = curfnt->chardesc + 255 ; - cc = 255 ; + const char **glyphs = getEncoding(curfnt->resfont->Vectfile); + c = curfnt->chardesc + 255; + cc = 255; for (b=15; b>=0; b--) { for (bit=1; bit; bit<<=1) { if (all->bitmap[b] & bit) { - addGlyph(glyphs[cc]) ; + addGlyph(glyphs[cc]); } - c-- ; - cc-- ; + c--; + cc--; } } } else { #endif - c = curfnt->chardesc + 255 ; - cc = 255 ; + c = curfnt->chardesc + 255; + cc = 255; for (b=15; b>=0; b--) { for (bit=1; bit; bit<<=1) { if (all->bitmap[b] & bit) { grid[cc]=1; } - c-- ; - cc-- ; + c--; + cc--; } } #ifdef DOWNLOAD_USING_PDFTEX @@ -526,7 +642,7 @@ } } if(GridCount!=0 || extraGlyphs) { - newline() ; + newline(); if (! disablecomments) (void)fprintf(bitfile, "%%%%BeginFont: %s\n", rf->PSname); #ifdef DOWNLOAD_USING_PDFTEX @@ -537,36 +653,47 @@ exit(1); if (!quiet) { if (strlen(realnameoffile) + prettycolumn > STDOUTSIZE) { - fprintf(stderr, "\n") ; - prettycolumn = 0 ; + fprintf(stderr, "\n"); + prettycolumn = 0; } (void)fprintf(stderr, "<%s>", realnameoffile); - prettycolumn += strlen(realnameoffile) + 2 ; - } + prettycolumn += strlen(realnameoffile) + 2; + } if (! disablecomments) (void)fprintf(bitfile, "%%%%EndFont \n"); } } -void -dopsfont(sectiontype *fs) +void dopsfont(sectiontype *fs) { - charusetype *cu ; + charusetype *cu; - cu = (charusetype *) (fs + 1) ; + cu = (charusetype *) (fs + 1); #ifdef DOWNLOAD_USING_PDFTEX while (cu->fd) { if (cu->psfused) - cu->fd->psflag = EXISTS ; - downpsfont(cu++, (charusetype *)(fs + 1)) ; + cu->fd->psflag = EXISTS; +#ifdef VFLIB + if (cu->fd->vflib) { + downvffont(cu++, (charusetype *)(fs + 1)); + } + else +#endif + downpsfont(cu++, (charusetype *)(fs + 1)); } #else line = getmem(BUFSIZ); tmpline=line; while (cu->fd) { if (cu->psfused) - cu->fd->psflag = EXISTS ; - downpsfont(cu++, (charusetype *)(fs + 1)) ; + cu->fd->psflag = EXISTS; +#ifdef VFLIB + if (cu->fd->vflib) { + downvffont(cu++, (charusetype *)(fs + 1)); + } + else +#endif + downpsfont(cu++, (charusetype *)(fs + 1)); } loadbase = ~FLG_LOAD_BASE; FirstCharB=UnDefineChars(FirstCharB); diff -Nu dvipsk2009/dpicheck.c dvipsk/dpicheck.c --- dvipsk2009/dpicheck.c Tue Jun 23 18:46:14 2009 +++ dvipsk/dpicheck.c Mon Mar 29 23:27:29 2010 @@ -4,53 +4,55 @@ * magnifications. */ #include "dvips.h" /* The copyright notice in that file is included too! */ +/* + * The external declarations: + */ #include "protos.h" -extern int actualdpi ; -static integer existsizes[30] = { 0 , 99999999 } ; -static int checkdpi ; +static integer existsizes[30] = { 0 , 99999999 }; +static int checkdpi; /* * This routine adds some sizes to `existsizes'. */ void addsiz(int rhsize) { - register integer *p ; - long t, hsize ; + register integer *p; + long t, hsize; - hsize = rhsize ; - for (p=existsizes; *p < hsize; p++) ; + hsize = rhsize; + for (p=existsizes; *p < hsize; p++); if (*p == hsize) - return ; + return; do { - t = *p ; - *p++ = hsize ; - hsize = t ; - } while (hsize) ; + t = *p; + *p++ = hsize; + hsize = t; + } while (hsize); } void adddpi(int hsize) { - long a, b, c ; - int i ; + long a, b, c; + int i; - addsiz(hsize) ; - addsiz((int)((hsize * 116161L + 53020L) / 106040L)) ; - a = hsize ; - b = 0 ; - c = 1 ; + addsiz(hsize); + addsiz((int)((hsize * 116161L + 53020L) / 106040L)); + a = hsize; + b = 0; + c = 1; for (i=0; i<9; i++) { - b = 6 * b + (a % 5) * c ; - a = a + a / 5 ; - c = c * 5 ; + b = 6 * b + (a % 5) * c; + a = a + a / 5; + c = c * 5; if (b > c) { - b -= c ; - a++ ; + b -= c; + a++; } if (b + b >= c) - addsiz((int)(a+1)) ; + addsiz((int)(a+1)); else - addsiz((int)a) ; + addsiz((int)a); } } /* @@ -59,18 +61,18 @@ halfword dpicheck(halfword dpi) { - integer i ; - integer margin = 1 + dpi / 500 ; + integer i; + integer margin = 1 + dpi / 500; if (! checkdpi) { - adddpi(DPI) ; - checkdpi = 1 ; + adddpi(DPI); + checkdpi = 1; } - for (i=0; existsizes[i] < dpi; i++) ; + for (i=0; existsizes[i] < dpi; i++); if (existsizes[i]-dpi <= margin) - return(existsizes[i]) ; + return(existsizes[i]); else if (dpi-existsizes[i-1] <= margin) - return(existsizes[i-1]) ; + return(existsizes[i-1]); else - return(dpi) ; + return(dpi); } diff -Nu dvipsk2009/drawPS.c dvipsk/drawPS.c --- dvipsk2009/drawPS.c Tue Jun 23 18:46:14 2009 +++ dvipsk/drawPS.c Mon Mar 29 23:27:40 2010 @@ -85,21 +85,10 @@ #include /* used in function "arc" */ -#ifdef DEBUG -extern integer debug_flag; -#endif /* DEBUG */ - /* - * external functions used here + * The external declarations: */ #include "protos.h" -/* - * external variables used here - */ -extern integer hh,vv; /* the current x,y position in pixel units */ -extern int actualdpi ; -extern int vactualdpi ; -extern double mag ; #define convRESOLUTION DPI #define convVRESOLUTION VDPI @@ -111,18 +100,21 @@ /* convert from tpic units to PS units */ #define PixRound(a,b) zPixRound((a),(b)) -#define convPS(x) PixRound((x),convRESOLUTION) -#define convVPS(x) PixRound((x),convVRESOLUTION) +#define convPS(x) PixRound((x), dir ? convVRESOLUTION : convRESOLUTION) +#define convVPS(x) PixRound((x), dir ? convRESOLUTION : convVRESOLUTION) +#define ConvPS(x) PixRound((x), convRESOLUTION) +#define ConvVPS(x) PixRound((x), convVRESOLUTION) + /* convert from tpic locn to abs horiz PS locn */ -#define hconvPS(x) (hh + convPS(x)) +#define hconvPS(x) dir ? (vv + ConvVPS(x)) : (hh + convPS(x)) /* convert from tpic locn to abs vert PS locn */ -#define vconvPS(x) (vv + convVPS(x)) +#define vconvPS(x) dir ? (-hh + ConvPS(x)) : (vv + convVPS(x)) /* convert to degrees */ #define convDeg(x) (360*(x)/(2*3.14159265358979)) /* if PostScript had splines, i wouldnt need to store the path */ -#define MAXPATHS 600 /* maximum number of path segments */ +#define MAXPATHS 6000 /* maximum number of path segments */ #define NONE 0 /* for shading */ #define BLACK 1 /* for shading */ #define GRAY 2 /* MJ; for shading */ @@ -211,8 +203,8 @@ doubleout(hconvPS(xc)); doubleout(vconvPS(yc)); doubleout(convPS(xrad)); - if (xrad != yrad && VDPI == DPI) - doubleout(convPS(yrad)); + if (xrad != yrad || VDPI != DPI) + doubleout(convVPS(yrad)); doubleout(convDeg(startAngle)); doubleout(convDeg(endAngle)); @@ -243,12 +235,12 @@ doubleout(hconvPS(xc)); doubleout(vconvPS(yc)); doubleout(convPS(xrad)); - if (xrad != yrad) - doubleout(convPS(yrad)); + if (xrad != yrad || VDPI != DPI) + doubleout(convVPS(yrad)); doubleout(degStAng); doubleout(degEnAng); - if (xrad == yrad) /* for arcs and circles */ + if (xrad == yrad && VDPI == DPI) /* for arcs and circles */ cmdout("arc"); else cmdout("ellipse"); @@ -284,11 +276,11 @@ int nipd = (integer) convPS((int) inchesPerDash); if (nipd == 0) - nipd = 1 ; + nipd = 1; if (pathLen < 2) { error("Path less than 2 points - ignored"); - pathLen = 0 ; + pathLen = 0; return; } @@ -318,10 +310,10 @@ else ndashes += 1; } else if (ndashes < 1) - ndashes = 1 ; + ndashes = 1; ipd = delta / ndashes; if (ipd <= 0.0) - ipd = 1.0 ; + ipd = 1.0; cmdout("["); if (dotted) { doubleout(penSize); @@ -352,7 +344,7 @@ if (pathLen < 2) { error("Path less than 2 points - ignored"); - pathLen = 0 ; + pathLen = 0; return; } @@ -471,12 +463,13 @@ void flushSpline(char *cp) { /* as exact as psdit!!! */ - register long i ; + register long i; + register double px, py, dx, dy; register double dxi, dyi, dxi1, dyi1; if (*cp) { double inchesPerDash; - int ipd ; + int ipd; if (sscanf(cp, "%lg ", &inchesPerDash) != 1) { error ("Illegal format for dotted/dashed spline"); @@ -509,23 +502,24 @@ doubleout(hconvPS(xx[1])); doubleout(vconvPS(yy[1])); cmdout(MOVETO); - doubleout(convPS((xx[2]-xx[1])/2)); - doubleout(convPS((yy[2]-yy[1])/2)); + px = convPS(xx[1]); + py = convVPS(yy[1]); + doubleout(dx = convPS((xx[2]+xx[1])/2) - px); + doubleout(dy = convVPS((yy[2]+yy[1])/2) - py); + px += dx; + py += dy; cmdout(RLINETO); for (i=2; i < pathLen; i++) { - dxi = convPS(xx[i] - xx[i-1]); - dyi = convVPS(yy[i] - yy[i-1]); - dxi1 = convPS(xx[i+1] - xx[i]); - dyi1 = convVPS(yy[i+1] - yy[i]); - - doubleout(dxi/3); - doubleout(dyi/3); - doubleout((3*dxi+dxi1)/6); - doubleout((3*dyi+dyi1)/6); - doubleout((dxi+dxi1)/2); - doubleout((dyi+dyi1)/2); + doubleout(convPS((xx[i-1]+5*xx[i])/6) - px); + doubleout(convVPS((yy[i-1]+5*yy[i])/6) - py); + doubleout(convPS((5*xx[i]+xx[i+1])/6) - px); + doubleout(convVPS((5*yy[i]+yy[i+1])/6) - py); + doubleout(dx = convPS((xx[i]+xx[i+1])/2) - px); + doubleout(dy = convVPS((yy[i]+yy[i+1])/2) - py); + px += dx; + py += dy; cmdout(RCURVETO); } @@ -641,6 +635,7 @@ cmdout("0 setgray"); /* actually this aint needed */ } /* end of whitenLast */ + #if 0 /* Not used */ static void @@ -664,12 +659,11 @@ */ static double zPixRound(register double x, /* in DVI units */ - register double convDPI /* dots per inch */ - ) /* return rounded number of pixels */ + register double convDPI /* dots per inch */ + ) /* return rounded number of pixels */ { return ((x * mag * (double)convDPI / - (1000.0 * tpicRESOLUTION))) ; + (1000.0 * tpicRESOLUTION))); } #endif /* TPIC */ - diff -Nu dvipsk2009/dviinput.c dvipsk/dviinput.c --- dvipsk2009/dviinput.c Tue Jun 23 18:46:14 2009 +++ dvipsk/dviinput.c Mon Mar 29 23:27:50 2010 @@ -6,83 +6,84 @@ * updating the current position as necessary. */ #include "dvips.h" /* The copyright notice in that file is included too! */ +/* + * The external declarations: + */ #include "protos.h" -extern FILE *dvifile ; -extern quarterword *curpos, *curlim ; void abortpage(void) { - error("! unexpected eof on DVI file") ; + error("! unexpected eof on DVI file"); } shalfword /* the value returned is, however, between 0 and 255 */ dvibyte(void) { - register shalfword i ; + register shalfword i; if (curpos) { - if (curpos>=curlim) return((shalfword)140) ; - return (*curpos++) ; + if (curpos>=curlim) return((shalfword)140); + return (*curpos++); } if ((i=getc(dvifile))==EOF) - abortpage() ; - return(i) ; + abortpage(); + return(i); } halfword twobytes(void) { - register halfword i ; - i = dvibyte() ; - return(i*256+dvibyte()) ; } + register halfword i; + i = dvibyte(); + return(i*256+dvibyte()); } integer threebytes(void) { - register integer i ; - i = twobytes() ; - return(i*256+dvibyte()) ; } + register integer i; + i = twobytes(); + return(i*256+dvibyte()); } shalfword signedbyte(void) { - register shalfword i ; + register shalfword i; if (curpos) { if (curpos>=curlim) - error("! unexpected end of virtual packet") ; - i = *curpos++ ; + error("! unexpected end of virtual packet"); + i = *curpos++; } else if ((i=getc(dvifile))==EOF) - abortpage() ; - if (i<128) return(i) ; - else return(i-256) ; + abortpage(); + if (i<128) return(i); + else return(i-256); } shalfword signedpair(void) { - register shalfword i ; - i = signedbyte() ; - return(i*256+dvibyte()) ; + register shalfword i; + i = signedbyte(); + return(i*256+dvibyte()); } integer signedtrio(void) { - register integer i ; - i = signedpair() ; - return(i*256+dvibyte()) ; + register integer i; + i = signedpair(); + return(i*256+dvibyte()); } integer signedquad(void) { - register integer i ; - i = signedpair() ; - return(i*65536+twobytes()) ; + register integer i; + i = signedpair(); + return(i*65536+twobytes()); } void skipover(int i) { - while (i-->0) (void)dvibyte() ; + while (i-->0) (void)dvibyte(); } diff -Nu dvipsk2009/dvips.1 dvipsk/dvips.1 --- dvipsk2009/dvips.1 Mon Apr 23 03:45:29 2007 +++ dvipsk/dvips.1 Sat Jan 02 09:30:28 2010 @@ -1,4 +1,4 @@ -.TH DVIPS 1 "27 May 2004" +.TH DVIPS 1 "1 January 2010" .SH NAME dvips \- convert a TeX DVI file to PostScript .SH SYNOPSIS @@ -13,7 +13,7 @@ You can read it either in Emacs or with the standalone .B info program which comes with the GNU texinfo distribution as -prep.ai.mit.edu:pub/gnu/texinfo*.tar.gz. +ftp.gnu.org:pub/gnu/texinfo/texinfo*.tar.gz. .PP The program .B dvips @@ -78,14 +78,8 @@ unusual fact-finding expeditions; it will work only if .B dvips has been compiled with the DEBUG option. If nonzero, prints additional -information on standard error. The number is taken as a set of -independent bits. The meaning of each bit follows. 1=specials; -2=paths; 4=fonts; 8=pages; 16=headers; 32=font compression; 64=files; -128=memory; 256=Kpathsea stat(2) calls; 512=Kpathsea hash table lookups; -1024=Kpathsea path element expansion; 2048=Kpathsea searches. To trace -everything having to do with file searching and opening, use 3650 (2048 -+ 1024 + 512 + 64 + 2). To track all classes, you can use `-1' (output -is extremely voluminous). +information on standard error. For maximum information, you can use +`-1'. See the Dvips Texinfo manual for more details. .TP .B -D num Set the resolution in dpi (dots per inch) to @@ -506,7 +500,8 @@ 68000-based PostScript printers. .SH "SEE ALSO" mf(1), afm2tfm(1), tex(1), latex(1), lpr(1), -.IR dvips.texi . +.IR dvips.texi , +http://tug.org/dvips. .SH ENVIRONMENT Dvipsk uses the same environment variables and algorithms for finding font files as TeX and its friends do. See the documentation for the @@ -520,4 +515,4 @@ .SH AUTHOR Tomas Rokicki ; extended to virtual fonts by Don Knuth. Path searching and configuration modifications by -kb@mail.tug.org. +Karl Berry. diff -Nu dvipsk2009/dvips.c dvipsk/dvips.c --- dvipsk2009/dvips.c Tue Jun 23 18:46:14 2009 +++ dvipsk/dvips.c Mon Mar 29 23:28:00 2010 @@ -8,6 +8,7 @@ #include #include #include +#include #include #ifdef strdup #undef strdup @@ -17,7 +18,7 @@ #else /* ! KPATHSEA */ #include /* for malloc, etc. */ #if !defined(SYSV) && !defined(WIN32) -extern char *strtok() ; /* some systems don't have this in strings.h */ +extern char *strtok(); /* some systems don't have this in strings.h */ #endif #if defined(WIN32) #include @@ -40,86 +41,102 @@ #include descrip #endif #endif +#ifdef __APPLE__ /* for Mac OS X, T. Uchiyama */ +#include +#include +#include +#endif #ifndef DEFRES #define DEFRES (600) #endif /* + * The external declarations: + */ +#include "protos.h" + +/* * First we define some globals. */ #ifdef VMS static char ofnme[252],infnme[252],pap[40],thh[20]; #endif +#if !defined(VFLIB) +Boolean SJIS; /* KANJI code */ +#endif /* PS fonts fully downloaded as headers */ char *downloadedpsnames[DOWNLOADEDPSSIZE]; -int unused_top_of_psnames ; /* unused top number of downloadedpsnames[#] */ -fontdesctype *fonthead ; /* list of all fonts mentioned so far */ -fontdesctype *curfnt ; /* the currently selected font */ -sectiontype *sections ; /* sections to process document in */ -Boolean partialdownload = 1 ; /* turn on partial downloading */ -Boolean manualfeed ; /* manual feed? */ -Boolean compressed ; /* compressed? */ -Boolean downloadpspk ; /* use PK for downloaded PS fonts? */ -Boolean safetyenclose ; - /* enclose in save/restore for stupid spoolers? */ -Boolean removecomments = 0 ; /* remove comments from included PS? */ -Boolean nosmallchars ; /* disable small char optimization for X4045? */ -Boolean cropmarks ; /* add cropmarks? */ -Boolean abspage = 0 ; /* are page numbers absolute? */ -Boolean tryepsf = 0 ; /* should we try to make it espf? */ -int secure = 1 ; /* make safe for suid */ +int unused_top_of_psnames; /* unused top number of downloadedpsnames[#] */ +fontdesctype *fonthead; /* list of all fonts mentioned so far */ +fontdesctype *curfnt; /* the currently selected font */ +sectiontype *sections; /* sections to process document in */ +Boolean partialdownload = 1; /* turn on partial downloading */ +Boolean manualfeed; /* manual feed? */ +Boolean compressed; /* compressed? */ +Boolean downloadpspk; /* use PK for downloaded PS fonts? */ +Boolean safetyenclose; /* enclose in save/restore for stupid spoolers? */ +Boolean removecomments = 0; /* remove comments from included PS? */ +Boolean nosmallchars; /* disable small char optimization for X4045? */ +Boolean cropmarks; /* add cropmarks? */ +Boolean abspage = 0; /* are page numbers absolute? */ +Boolean tryepsf = 0; /* should we try to make it espf? */ +int secure = 1; /* make safe for suid */ int secure_option = 0; /* set by -R */ -int collatedcopies = 1 ; /* how many collated copies? */ -int sectioncopies = 1 ; /* how many times to repeat each section? */ -integer pagecopies = 1 ; /* how many times to repeat each page? */ -shalfword linepos = 0 ; /* where are we on the line being output? */ -integer maxpages ; /* the maximum number of pages */ -Boolean notfirst, notlast ; /* true if a first page was specified */ -Boolean evenpages, oddpages ; /* true if doing only even/only odd pages */ -Boolean pagelist ; /* true if using page ranges */ -Boolean sendcontrolD ; /* should we send a control D at end? */ -Boolean shiftlowchars ; /* shift [0-32, 127] characters higher? */ -integer firstpage ; /* the number of the first page if specified */ -integer lastpage ; -integer firstseq ; -integer lastseq ; -integer hpapersize, vpapersize ; /* horizontal and vertical paper size */ -integer hoff, voff ; /* horizontal and vertical offsets */ +int collatedcopies = 1; /* how many collated copies? */ +int sectioncopies = 1; /* how many times to repeat each section? */ +integer pagecopies = 1; /* how many times to repeat each page? */ +shalfword linepos = 0; /* where are we on the line being output? */ +integer maxpages; /* the maximum number of pages */ +Boolean notfirst, notlast; /* true if a first page was specified */ +Boolean evenpages, oddpages; /* true if doing only even/only odd pages */ +Boolean pagelist; /* true if using page ranges */ +Boolean sendcontrolD; /* should we send a control D at end? */ +Boolean shiftlowchars; /* shift [0-32, 127] characters higher? */ +integer firstpage; /* the number of the first page if specified */ +integer lastpage; +integer firstseq; +integer lastseq; +integer hpapersize, vpapersize; /* horizontal and vertical paper size */ +integer hoff, voff; /* horizontal and vertical offsets */ integer maxsecsize = 0; /* the maximum size of a section */ -integer firstboploc ; /* where the first bop is */ -Boolean sepfiles ; /* each section in its own file? */ -int numcopies ; /* number of copies of each page to print */ -char *oname ; /* output file name */ -char *iname ; /* dvi file name */ -char *fulliname ; /* same, with current working directory */ -char *strings ; /* strings for program */ -char *nextstring, *maxstring ; /* string pointers */ -FILE *dvifile, *bitfile ; /* dvi and output files */ -quarterword *curpos ; /* current position in virtual character packet */ -quarterword *curlim ; /* final byte in virtual character packet */ -fontmaptype *ffont ; /* first font in current frame */ -real conv ; /* conversion ratio, pixels per DVI unit */ -real vconv ; /* conversion ratio, pixels per DVI unit */ -real alpha ; /* conversion ratio, DVI unit per TFM unit */ -double mag ; /* the magnification of this document */ -integer num, den ; /* the numerator and denominator */ -int overridemag ; /* substitute for mag value in DVI file? */ -int actualdpi = DEFRES ; /* the actual resolution of the printer */ -int vactualdpi = DEFRES ; /* the actual resolution of the printer */ -int maxdrift ; /* max pixels away from true rounded position */ -int vmaxdrift ; /* max pixels away from true rounded position */ -char *paperfmt ; /* command-line paper format */ -int landscape = 0 ; /* landscape mode */ -integer fontmem ; /* memory remaining in printer */ -integer pagecount ; /* page counter for the sections */ -integer pagenum ; /* the page number we currently look at */ -long bytesleft ; /* number of bytes left in raster */ -quarterword *raster ; /* area for raster manipulations */ -integer hh, vv ; /* horizontal and vertical pixel positions */ -Boolean noomega = 0 ; /* Omega extensions are enabled */ +integer firstboploc; /* where the first bop is */ +Boolean sepfiles; /* each section in its own file? */ +int numcopies; /* number of copies of each page to print */ +const char *oname; /* output file name */ +char *iname; /* dvi file name */ +char *fulliname; /* same, with current working directory */ +char *strings; /* strings for program */ +char *nextstring, *maxstring; /* string pointers */ +FILE *dvifile, *bitfile; /* dvi and output files */ +quarterword *curpos; /* current position in virtual character packet */ +quarterword *curlim; /* final byte in virtual character packet */ +fontmaptype *ffont; /* first font in current frame */ +real conv; /* conversion ratio, pixels per DVI unit */ +real vconv; /* conversion ratio, pixels per DVI unit */ +real alpha; /* conversion ratio, DVI unit per TFM unit */ +double mag; /* the magnification of this document */ +integer num, den; /* the numerator and denominator */ +int overridemag; /* substitute for mag value in DVI file? */ +int actualdpi = DEFRES; /* the actual resolution of the printer */ +int vactualdpi = DEFRES; /* the actual resolution of the printer */ +int maxdrift; /* max pixels away from true rounded position */ +int vmaxdrift; /* max pixels away from true rounded position */ +char *paperfmt; /* command-line paper format */ +int landscape = 0; /* landscape mode */ +integer fontmem; /* memory remaining in printer */ +integer pagecount; /* page counter for the sections */ +integer pagenum; /* the page number we currently look at */ +long bytesleft; /* number of bytes left in raster */ +quarterword *raster; /* area for raster manipulations */ +integer hh, vv; /* horizontal and vertical pixel positions */ +#if defined(VFLIB) +Boolean noomega = 1; /* Omega extensions are disabled */ +#else +Boolean noomega = 0; /* Omega extensions are enabled */ +#endif /*-----------------------------------------------------------------------* * The PATH definitions cannot be defined on the command line because so many @@ -129,7 +146,7 @@ #include "vms_gcc_paths.h" #endif -char *infont ; /* is the file we are downloading a font? */ +const char *infont; /* is the file we are downloading a font? */ #ifndef KPATHSEA #ifdef ATARIST # define TFMPATH "." @@ -139,12 +156,12 @@ # define HEADERPATH "." # define CONFIGPATH "." #endif -char *tfmpath = TFMPATH ; /* pointer to directories for tfm files */ -char *pkpath = PKPATH ; /* pointer to directories for pk files */ -char *vfpath = VFPATH ; /* pointer to directories for vf files */ -char *figpath = FIGPATH ; /* pointer to directories for figure files */ -char *headerpath = HEADERPATH ; /* pointer to directories for header files */ -char *configpath = CONFIGPATH ; /* where to find config files */ +char *tfmpath = TFMPATH; /* pointer to directories for tfm files */ +char *pkpath = PKPATH; /* pointer to directories for pk files */ +char *vfpath = VFPATH; /* pointer to directories for vf files */ +char *figpath = FIGPATH; /* pointer to directories for figure files */ +char *headerpath = HEADERPATH; /* pointer to directories for header files */ +char *configpath = CONFIGPATH; /* where to find config files */ #ifndef PICTPATH #ifndef __THINK__ #define PICTPATH "." @@ -152,39 +169,42 @@ #define PICTPATH ":" #endif #endif -char *pictpath = PICTPATH ; /* where IFF/etc. pictures are found */ +char *pictpath = PICTPATH; /* where IFF/etc. pictures are found */ #ifdef SEARCH_SUBDIRECTORIES -char *fontsubdirpath = FONTSUBDIRPATH ; +char *fontsubdirpath = FONTSUBDIRPATH; #endif #endif /* ! KPATHSEA */ #ifdef FONTLIB -char *flipath = FLIPATH ; /* pointer to directories for fli files */ -char *fliname = FLINAME ; /* pointer to names of fli files */ +char *flipath = FLIPATH; /* pointer to directories for fli files */ +char *fliname = FLINAME; /* pointer to names of fli files */ #endif -integer swmem ; /* font memory in the PostScript printer */ -int quiet ; /* should we only print errors to stderr? */ -int filter ; /* act as filter default output to stdout, +integer swmem; /* font memory in the PostScript printer */ +int quiet; /* should we only print errors to stderr? */ +int filter; /* act as filter default output to stdout, default input to stdin? */ -int dvips_debug_flag ; /* output config and map files to stderr if 1 */ -int prettycolumn ; /* the column we are at when running pretty */ -int gargc ; /* global argument count */ -char **gargv ; /* global argument vector */ -int totalpages = 0 ; /* total number of pages */ -Boolean reverse ; /* are we going reverse? */ -Boolean usesPSfonts ; /* do we use local PostScript fonts? */ -Boolean usesspecial ; /* do we use \special? */ -Boolean headers_off ; /* do we send headers or not? */ -Boolean usescolor ; /* IBM: color - do we use colors? */ -char *headerfile ; /* default header file */ -char *warningmsg ; /* a message to write, if set in config file */ -Boolean multiplesects ; /* more than one section? */ -Boolean disablecomments ; /* should we suppress any EPSF comments? */ -char *printer ; /* what printer to send this to? */ -char *mfmode ; /* default MF mode */ -char *mflandmode ; /* allow an optional landscape mode def */ +int dvips_debug_flag; /* output config and map files to stderr if 1 */ +int prettycolumn; /* the column we are at when running pretty */ +int gargc; /* global argument count */ +char **gargv; /* global argument vector */ +int totalpages = 0; /* total number of pages */ +Boolean reverse; /* are we going reverse? */ +Boolean usesPSfonts; /* do we use local PostScript fonts? */ +Boolean usesspecial; /* do we use \special? */ +Boolean headers_off; /* do we send headers or not? */ +Boolean usescolor; /* IBM: color - do we use colors? */ +#ifdef VFLIB +Boolean usesvflib; +#endif +const char *headerfile; /* default header file */ +char *warningmsg; /* a message to write, if set in config file */ +Boolean multiplesects; /* more than one section? */ +Boolean disablecomments; /* should we suppress any EPSF comments? */ +char *printer; /* what printer to send this to? */ +char *mfmode; /* default MF mode */ +char *mflandmode; /* allow an optional landscape mode def */ int mfmode_option; /* set by -mode command-line option */ int oname_option; /* set by -o option */ -frametype frames[MAXFRAME] ; /* stack for virtual fonts */ +frametype frames[MAXFRAME]; /* stack for virtual fonts */ 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 */ @@ -192,13 +212,13 @@ fontdesctype *fonthd[MAXFONTHD];/* list headers for included fonts of 1 name */ int nextfonthd; /* next unused fonthd[] index */ char xdig[256]; /* table for reading hexadecimal digits */ -char banner[] = BANNER ; /* our startup message */ -char banner2[] = BANNER2 ; /* our second startup message */ -Boolean noenv = 0 ; /* ignore PRINTER envir variable? */ -Boolean dopprescan = 0 ; /* do we do a scan before the prescan? */ -extern int dontmakefont ; -struct papsiz *papsizes ; /* all available paper size */ -int headersready ; /* ready to check headers? */ +char banner[] = BANNER; /* our startup message */ +char banner2[] = BANNER2; /* our second startup message */ +char weburl[] = WEBURL; /* DVIPSK WEB page */ +Boolean noenv = 0; /* ignore PRINTER envir variable? */ +Boolean dopprescan = 0; /* do we do a scan before the prescan? */ +struct papsiz *papsizes; /* all available paper size */ +int headersready; /* ready to check headers? */ #if defined(MSDOS) || defined(OS2) || defined(ATARIST) char *mfjobname = NULL; /* name of mfjob file if given */ FILE *mfjobfile = NULL; /* mfjob file for font making instructions */ @@ -210,15 +230,9 @@ int qargc; char *qargv[32]; char queryoptions; -/* - * This routine calls the following externals: - */ -#include "protos.h" #ifdef HPS -Boolean HPS_FLAG = 0 ; +Boolean HPS_FLAG = 0; #endif -extern int lastresortsizes[]; -extern char errbuf[]; /* Declare the routine to get the current working directory. */ @@ -245,15 +259,8 @@ #endif #endif /* not IGNORE_CWD */ -static char *helparr[] = { -#ifndef VMCMS -"Usage: dvips [OPTION]... FILENAME[.dvi]", -#else -" VM/CMS Usage:", -" dvips fname [ftype [fmode]] [options]", -"or", -" dvips fname[.ftype[.fmode]] [options]", -#endif +static const char *helparr[] = { +"Usage: pdvips [OPTION]... FILENAME[.dvi]", "Convert DVI input files to PostScript.", "See http://tug.org/dvips/ for the full manual and other information.", "", @@ -275,7 +282,7 @@ "-m* Manual feed -M* Don't make fonts", "-mode s Metafont device name", "-n # Maximum number of pages -N* No structured comments", -"-noomega Disable Omega extensions", +"-noomega* Disable/enable (-noomega/-noomega0) Omega extensions", "-o f Output file -O c Set/change paper offset", #if defined(MSDOS) || defined(OS2) "-p # First page -P s Load $s.cfg", @@ -286,36 +293,40 @@ "-q* Run quietly", "-r* Reverse order of pages -R* Run securely", "-s* Enclose output in save/restore -S # Max section size in pages", -"-t s Paper format -T c Specify desired page size", +"-t s Paper format -T c Specify desired page size", "-u s PS mapfile -U* Disable string param trick", "-v Print version number and quit -V* Send downloadable PS fonts as PK", "-x # Override dvi magnification -X # Horizontal resolution", -"-y # Multiply by dvi magnification -Y # Vertical resolution", +"-y # Multiply by dvi magnification -Y # Vertical resolution", #ifdef HPS "-z* Hyper PS -Z* Compress bitmap fonts", #else " -Z* Compress bitmap fonts", #endif +#if !defined(VFLIB) +"-SJIS* Shift-JIS encoding", +#endif /*"- Interactive query of options", */ " # = number f = file s = string * = suffix, `0' to turn off", " c = comma-separated dimension pair (e.g., 3.2in,-32.1cm)", -" l = comma-separated list of page ranges (e.g., 1-4,7-9)", 0} ; +" l = comma-separated list of page ranges (e.g., 1-4,7-9)", 0}; void help(int status) { - char **p; + const char **p; FILE *f = status == 0 ? stdout : stderr; -#ifdef KPATHSEA - extern KPSEDLL char *kpse_bug_address; -#endif + for (p=helparr; *p; p++) fprintf (f, "%s\n", *p); putc ('\n', f); +/* #ifdef KPATHSEA fputs (kpse_bug_address, f); #endif +*/ + fputs ("Email bug reports to ptex-staff@ml.asciimw.jp.\n", f); } static void @@ -332,15 +343,15 @@ * character is !, it aborts the job. */ -static char *progname ; +static char *progname; void -error_with_perror(char *s, char *fname) +error_with_perror(const char *s, const char *fname) { if (prettycolumn > 0) fprintf(stderr,"\n"); prettycolumn = 0; - (void)fprintf(stderr, "%s: %s", progname, s) ; + (void)fprintf(stderr, "%s: %s", progname, s); if (fname) { putc (' ', stderr); perror (fname); @@ -349,11 +360,11 @@ } if (*s=='!') { - freememforpsnames() ; + freememforpsnames(); if (bitfile != NULL) { - cleanprinter() ; + cleanprinter(); } - exit(1) ; /* fatal */ + exit(1); /* fatal */ } } @@ -362,7 +373,7 @@ * character is !, it aborts the job. */ void -error(char *s) +error(const char *s) { error_with_perror (s, NULL); } @@ -393,8 +404,9 @@ && !kpse_tex_hush ("checksum") #endif ) { - sprintf (errbuf, "Checksum mismatch in %s", name); - error (errbuf); + char *msg = concat ("Checksum mismatch in %s", name); + error (msg); + free (msg); } } @@ -406,45 +418,45 @@ * is when repacking *huge* characters anyway. */ #ifdef DEBUG -static integer totalalloc = 0 ; +static integer totalalloc = 0; #endif char * mymalloc(integer n) { - char *p ; + char *p; #ifdef SMALLMALLOC if (n > 65500L) - error("! can't allocate more than 64K!") ; + error("! can't allocate more than 64K!"); #endif if (n <= 0) /* catch strange 0 mallocs in flib.c without breaking code */ - n = 1 ; + n = 1; #ifdef DEBUG - totalalloc += n ; + totalalloc += n; if (dd(D_MEM)) { #ifdef SHORTINT - fprintf(stderr, "Alloc %ld\n", n) ; + fprintf(stderr, "Alloc %ld\n", n); #else - fprintf(stderr, "Alloc %d\n", n) ; + fprintf(stderr, "Alloc %d\n", n); #endif } #endif - p = (char *) malloc(n) ; + p = (char *)malloc(n); if (p == NULL) - error("! no memory") ; - return p ; + error("! no memory"); + return p; } void morestrings(void) { - strings = mymalloc((integer)STRINGSIZE) ; - nextstring = strings ; - maxstring = strings + STRINGSIZE - 200 ; - *nextstring++ = 0 ; + strings = mymalloc((integer)STRINGSIZE); + nextstring = strings; + maxstring = strings + STRINGSIZE - 200; + *nextstring++ = 0; } void checkstrings(void) { if (nextstring - strings > STRINGSIZE / 2) - morestrings() ; + morestrings(); } /* * Initialize sets up all the globals and data structures. @@ -453,7 +465,7 @@ initialize(void) { int i; - char *s; + const char *s; nextfonthd = 0; for (i=0; i<256; i++) @@ -464,71 +476,75 @@ i = 10; for (s="abcdef"; *s!=0; s++) xdig[(int)*s] = i++; - for(i=0 ; i < DOWNLOADEDPSSIZE; i++) + for(i=0; i < DOWNLOADEDPSSIZE; i++) downloadedpsnames[i] = NULL; unused_top_of_psnames = 0; - morestrings() ; - maxpages = 100000 ; - numcopies = 1 ; - iname = fulliname = strings ; - bitfile = NULL ; - bytesleft = 0 ; - swmem = SWMEM ; - oname = OUTPATH ; - sendcontrolD = 0 ; - shiftlowchars = 0 ; - multiplesects = 0 ; - disablecomments = 0 ; - maxdrift = -1 ; - vmaxdrift = -1 ; + morestrings(); +#if !defined(VFLIB) + SJIS = 0; +#endif + maxpages = 100000; + numcopies = 1; + iname = fulliname = strings; + bitfile = NULL; + bytesleft = 0; + swmem = SWMEM; + oname = OUTPATH; + sendcontrolD = 0; + shiftlowchars = 0; + multiplesects = 0; + disablecomments = 0; + maxdrift = -1; + vmaxdrift = -1; dontmakefont = !MAKE_TEX_PK_BY_DEFAULT; } /* * This routine copies a string into the string `pool', safely. */ char * -newstring(char *s) +newstring(const char *s) { - int l ; + int l; + char *q; if (s == NULL) - return(NULL) ; - l = strlen(s) ; + return(NULL); + l = strlen(s); if (nextstring + l >= maxstring) - morestrings() ; + morestrings(); if (nextstring + l >= maxstring) - error("! out of string space") ; - (void)strcpy(nextstring, s) ; - s = nextstring ; - nextstring += l + 1 ; - return(s) ; + error("! out of string space"); + (void)strcpy(nextstring, s); + q = nextstring; + nextstring += l + 1; + return(q); } void newoutname(void) { - static int seq = 0 ; - static char *seqptr = 0 ; - char *p ; + static int seq = 0; + static char *seqptr = 0; + char *p, *q; if (oname == 0 || *oname == 0) - error("! need an output file name to specify separate files") ; + error("! need an output file name to specify separate files"); if (*oname != '!' && *oname != '|') { if (seqptr == 0) { - oname = newstring(oname) ; - seqptr = 0 ; - for (p = oname; *p; p++) /* find last dot after last slash */ + q = newstring(oname); + for (p = q; *p; p++) /* find last dot after last slash */ if (*p == '.') - seqptr = p + 1 ; - else if (*p == '/') - seqptr = 0 ; + seqptr = p + 1; + else if(IS_DIR_SEP(*p)) + seqptr = 0; #ifdef DOSISH else if (*p == '\\') - seqptr = 0 ; + seqptr = 0; #endif if (seqptr == 0) - seqptr = p ; - nextstring += 5 ; /* make room for the number, up to five digits */ + seqptr = p; + nextstring += 5; /* make room for the number, up to five digits */ + oname = q; } - sprintf(seqptr, "%03d", ++seq) ; + sprintf(seqptr, "%03d", ++seq); } } /* @@ -539,16 +555,16 @@ revlist(VOID *p) { struct list { - struct list *next ; - } *pp = (struct list *)p, *qq = 0, *tt ; + struct list *next; + } *pp = (struct list *)p, *qq = 0, *tt; while (pp) { - tt = pp->next ; - pp->next = qq ; - qq = pp ; - pp = tt ; + tt = pp->next; + pp->next = qq; + qq = pp; + pp = tt; } - return (VOID *)qq ; + return (VOID *)qq; } /* this asks for a new set of arguments from the command line */ void @@ -565,11 +581,10 @@ } qargv[qargc] = (char *)NULL; } - + /* * Finally, our main routine. */ -extern void handlepapersize() ; #ifdef VMS main(void) #else @@ -577,26 +592,35 @@ main(int argc, char **argv) #endif { - int i, lastext = -1 ; + int i, lastext = -1; #ifdef MVSXA - int firstext = -1 ; + int firstext = -1; #endif - sectiontype *sects ; + sectiontype *sects; +#ifdef VFLIB + char *vfontcap; +#endif +#ifdef __APPLE__ /* for Mac OS X, T. Uchiyama */ + struct rlimit rl; + getrlimit(RLIMIT_STACK, &rl); + rl.rlim_cur = 2048 * 1024; + setrlimit(RLIMIT_STACK, &rl); +#endif #ifdef KPATHSEA kpse_set_program_name (argv[0], "dvips"); kpse_set_program_enabled (kpse_pk_format, MAKE_TEX_PK_BY_DEFAULT, kpse_src_compile); #endif #ifdef __THINK__ - argc = dcommand(&argv) ; /* do I/O stream redirection */ + argc = dcommand(&argv); /* do I/O stream redirection */ #endif #ifdef VMS /* Grab the command-line buffer */ short len_arg; $DESCRIPTOR( verb_dsc, "DVIPS "); /* assume the verb is always DVIPS */ struct dsc$descriptor_d temp_dsc = { 0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0}; - progname = &thh[0] ; + progname = &thh[0]; strcpy(progname,"DVIPS%ERROR"); lib$get_foreign( &temp_dsc, 0, &len_arg, 0); /* Get the command line */ @@ -604,30 +628,30 @@ len_arg += verb_dsc.dsc$w_length; /* update the length */ temp_dsc.dsc$a_pointer[len_arg] = '\0'; /* terminate the string */ gargv = &temp_dsc.dsc$a_pointer; /* point to the buffer */ - gargc = 1 ; /* only one big argv */ + gargc = 1; /* only one big argv */ #else - progname = argv[0] ; - gargv = argv ; - gargc = argc ; + progname = argv[0]; + gargv = argv; + gargc = argc; /* we sneak a look at the first arg in case it's debugging */ #ifdef DEBUG if (argc > 1 && strncmp(argv[1], "-d", 2)==0) { if (argv[1][2]==0 && argc > 2) { if (sscanf(argv[2], "%d", &debug_flag)==0) - debug_flag = 0 ; + debug_flag = 0; } else { if (sscanf(argv[1]+2, "%d", &debug_flag)==0) - debug_flag = 0 ; + debug_flag = 0; } } -#ifdef KPATHSEA +#if defined(KPATHSEA) && defined(KPSE_DEBUG) if (dd(D_FILES)) KPSE_DEBUG_SET (KPSE_DEBUG_FOPEN); if (dd(D_PATHS)) KPSE_DEBUG_SET (KPSE_DEBUG_PATHS); if (dd(D_STAT)) KPSE_DEBUG_SET (KPSE_DEBUG_STAT); if (dd(D_HASH)) KPSE_DEBUG_SET (KPSE_DEBUG_HASH); if (dd(D_EXPAND)) KPSE_DEBUG_SET (KPSE_DEBUG_EXPAND); if (dd(D_SEARCH)) KPSE_DEBUG_SET (KPSE_DEBUG_SEARCH); -#endif /* KPATHSEA */ +#endif /* KPATHSEA && KPSE_DEBUG */ #endif /* DEBUG */ #ifdef KPATHSEA if (argc > 1) { @@ -635,8 +659,8 @@ help (0); exit (0); } else if (strcmp (argv[1], "--version") == 0) { - extern KPSEDLL char *kpathsea_version_string; puts (BANNER); + puts (BANNER2); puts (kpathsea_version_string); puts ("Copyright 2009 Radical Eye Software.\n\ There is NO warranty. You may redistribute this software\n\ @@ -648,35 +672,38 @@ exit (0); } if (argc == 2 && strncmp(argv[1], "-?", 2) == 0) { - printf("%s %s\n", banner, banner2) ; + printf("%s\n%s\n", banner, banner2); help(0); exit(0); } if (argc == 2 && strncmp(argv[1], "-v", 2) == 0) { - printf("%s %s\n", banner, banner2) ; + printf("%s\n%s\n", banner, banner2); exit(0); } } #endif #endif - dvips_debug_flag = 0 ; + dvips_debug_flag = 0; { /* for compilers incompatible with c99 */ - char *s = (char *)getenv ("DVIPSDEBUG") ; + char *s = (char *)getenv ("DVIPSDEBUG"); if (s) { - dvips_debug_flag = 1 ; - free (s) ; + dvips_debug_flag = 1; + free (s); } else { - s = (char *) getenv ("KPATHSEA_DEBUG") ; + s = (char *) getenv ("KPATHSEA_DEBUG"); if (s) { - dvips_debug_flag = 1 ; - free (s) ; + dvips_debug_flag = 1; + free (s); } } } - initialize() ; - checkenv(0) ; - getdefaults(CONFIGFILE) ; - getdefaults((char *)0) ; + initialize(); + checkenv(0); + getdefaults(CONFIGFILE); + getdefaults((char *)0); +#ifdef VFLIB + VF_Init(NULL); +#endif /* * This next whole big section of code is straightforward; we just scan * the options. An argument can either immediately follow its option letter @@ -686,41 +713,41 @@ */ #ifdef VMS vmscli(void); - papsizes = (struct papsiz *)revlist((void *)papsizes) ; /* Added by PWD 21-Mar-1997 */ + papsizes = (struct papsiz *)revlist((void *)papsizes); /* Added by PWD 21-Mar-1997 */ #else queryoptions = 0; do { for (i=1; i 1000) - error("! can only print one to a thousand page copies") ; - break ; + error("! can only print one to a thousand page copies"); + break; case 'c' : if (*p == 0 && argv[i+1]) - p = argv[++i] ; + p = argv[++i]; if (sscanf(p, "%d", &numcopies)==0) - error("! Bad number of copies option (-c).") ; - break ; + error("! Bad number of copies option (-c)."); + break; case 'd' : #ifdef DEBUG { - int old_debug = debug_flag ; - static int warned_already = 0 ; + int old_debug = debug_flag; + static int warned_already = 0; if (*p == 0 && argv[i+1]) p = argv[++i]; @@ -728,131 +755,139 @@ error("! Bad debug option (-d)."); if (debug_flag != old_debug && warned_already++ == 0) { fprintf(stderr, - "I found a debug option that was not the first argument to the dvips\n") ; + "I found a debug option that was not the first argument to the dvips\n"); fprintf(stderr, - "command. Some debugging output may have been lost because of this.\n") ; + "command. Some debugging output may have been lost because of this.\n"); } break; } #else - error("not compiled in debug mode") ; - break ; + error("not compiled in debug mode"); + break; #endif /* DEBUG */ case 'e' : if (*p == 0 && argv[i+1]) - p = argv[++i] ; + p = argv[++i]; if (sscanf(p, "%d", &maxdrift)==0 || maxdrift<0) - error("! Bad maxdrift option (-e).") ; + error("! Bad maxdrift option (-e)."); vmaxdrift = maxdrift; - break ; + break; case 'f' : - filter = (*p != '0') ; + filter = (*p != '0'); if (filter) - oname = "" ; - noenv = 1 ; - sendcontrolD = 0 ; - break ; + oname = ""; + noenv = 1; + sendcontrolD = 0; + break; case 'u' : { - extern char *psmapfile; - char PSname[300] ; + char PSname[300]; if (*p == 0 && argv[i+1]) - p = argv[++i] ; - strcpy(PSname, p) ; + p = argv[++i]; + strcpy(PSname, p); if (!strchr(PSname, '.')) - strcat(PSname, ".map") ; /* default extension */ + strcat(PSname, ".map"); /* default extension */ if (PSname[0] == '+') - getpsinfo(PSname+1) ; + getpsinfo(PSname+1); else - psmapfile = strdup(PSname) ; /* a cute small memory leak (just as in 'p' option handling in resident.c) */ + psmapfile = strdup(PSname); /* a cute small memory leak (just as in 'p' option handling in resident.c) */ } - break ; + break; case 'h' : case 'H' : if (*p == 0 && argv[i+1]) - p = argv[++i] ; + p = argv[++i]; if (strcmp(p, "-") == 0) - headers_off = 1 ; + headers_off = 1; else - (void)add_header(p) ; - break ; + (void)add_header(p); + break; case 'i': - sepfiles = (*p != '0') ; + sepfiles = (*p != '0'); if (sepfiles && maxsecsize == 0) { maxsecsize = 1; /* default section size to one page/file */ } - break ; + break; case 'j': - partialdownload = (*p != '0') ; - break ; + partialdownload = (*p != '0'); + break; case 'k': - cropmarks = (*p != '0') ; - break ; + cropmarks = (*p != '0'); + break; case 'R': if (*p == '0') { - secure = 0 ; + secure = 0; } else if (*p == '2') { - secure = 2 ; + secure = 2; } else { - secure = 1 ; + secure = 1; } if (secure) - secure_option = 1 ; /* Never used */ - break ; + secure_option = 1; /* Never used */ + break; case 'S': - if (*p == 0 && argv[i+1]) - p = argv[++i] ; - if (sscanf(p, "%d", &maxsecsize)==0) - error("! Bad section size arg (-S).") ; - break ; +#if !defined(VFLIB) + if (strncmp (p, "JIS", 3) == 0) SJIS = (*(p + 3) != '0'); + else { +#endif + if (*p == 0 && argv[i+1]) + p = argv[++i]; + if (sscanf(p, "%d", &maxsecsize)==0) + error("! Bad section size arg (-S)."); +#if !defined(VFLIB) + } +#endif + break; case 'm' : if (STREQ (p, "ode") && argv[i+1]) { mfmode = argv[++i]; mfmode_option = 1; } else - manualfeed = (*p != '0') ; - break ; + manualfeed = (*p != '0'); + break; case 'n' : - if (STREQ (p, "oomega")) { - noomega = 1 ; + if (strncmp (p, "oomega", 6) == 0) { + noomega = 1; + if(*(p+6) != '\0') + noomega = *(p+6) - '0'; } else { if (*p == 0 && argv[i+1]) - p = argv[++i] ; + p = argv[++i]; #ifdef SHORTINT if (sscanf(p, "%ld", &maxpages)==0) #else /* ~SHORTINT */ if (sscanf(p, "%d", &maxpages)==0) #endif /* ~SHORTINT */ - error("! Bad number of pages option (-n).") ; + error("! Bad number of pages option (-n)."); } - break ; + break; case 'o' : if (*p == 0 && argv[i+1] && (STREQ (argv[i+1], "-") || argv[i+1][0] != '-')) - p = argv[++i] ; + p = argv[++i]; oname_option = 1; - oname = p ; - noenv = 1 ; - sendcontrolD = 0 ; + oname = p; + noenv = 1; + sendcontrolD = 0; #if defined(MSDOS) || defined(OS2) if (*oname && oname[strlen(oname)-1] == ':') oname[strlen(oname)-1] = 0; /* strip ':' off */ #endif - break ; + break; case 'O' : if (*p == 0 && argv[i+1]) - p = argv[++i] ; - handlepapersize(p, &hoff, &voff) ; - break ; + p = argv[++i]; + handlepapersize(p, &hoff, &voff); + break; case 'T' : if (*p == 0 && argv[i+1]) - p = argv[++i] ; - handlepapersize(p, &hpapersize, &vpapersize) ; + p = argv[++i]; + handlepapersize(p, &hpapersize, &vpapersize); if (landscape) { error( - "both landscape and papersize specified; ignoring landscape") ; - landscape = 0 ; + "both landscape and papersize specified; ignoring landscape"); + landscape = 0; } - break ; + break; case 'p' : #if defined(MSDOS) || defined(OS2) || defined(ATARIST) /* check for emTeX job file (-pj=filename) */ @@ -866,264 +901,264 @@ /* must be page number instead */ #endif if (*p == 'p') { /* a -pp specifier for a page list? */ - p++ ; + p++; if (*p == 0 && argv[i+1]) - p = argv[++i] ; + p = argv[++i]; if (ParsePages(p)) - error("! Bad page list specifier (-pp).") ; - pagelist = 1 ; - break ; + error("! Bad page list specifier (-pp)."); + pagelist = 1; + break; } if (*p == 0 && argv[i+1]) - p = argv[++i] ; + p = argv[++i]; if (*p == '=') { - abspage = 1 ; - p++ ; + abspage = 1; + p++; } #ifdef SHORTINT switch(sscanf(p, "%ld.%ld", &firstpage, &firstseq)) { #else /* ~SHORTINT */ switch(sscanf(p, "%d.%d", &firstpage, &firstseq)) { #endif /* ~SHORTINT */ -case 1: firstseq = 0 ; -case 2: break ; +case 1: firstseq = 0; +case 2: break; default: #ifdef KPATHSEA - error(concat3 ("! Bad first page option (-p ", p, ").")) ; + error(concat3 ("! Bad first page option (-p ", p, ").")); #else - error("! Bad first page option (-p).") ; + error("! Bad first page option (-p)."); #endif } - notfirst = 1 ; - break ; + notfirst = 1; + break; case 'l': if (*p == 0 && argv[i+1]) - p = argv[++i] ; + p = argv[++i]; if (*p == '=') { - abspage = 1 ; - p++ ; + abspage = 1; + p++; } #ifdef SHORTINT switch(sscanf(p, "%ld.%ld", &lastpage, &lastseq)) { #else /* ~SHORTINT */ switch(sscanf(p, "%d.%d", &lastpage, &lastseq)) { #endif /* ~SHORTINT */ -case 1: lastseq = 0 ; -case 2: break ; +case 1: lastseq = 0; +case 2: break; default: #ifdef KPATHSEA - error(concat3 ("! Bad last page option (-l ", p, ").")) ; + error(concat3 ("! Bad last page option (-l ", p, ").")); #else - error("! Bad last page option (-l).") ; + error("! Bad last page option (-l)."); #endif } - notlast = 1 ; - break ; + notlast = 1; + break; case 'A': - oddpages = 1 ; - break ; + oddpages = 1; + break; case 'B': - evenpages = 1 ; - break ; + evenpages = 1; + break; case 'q' : case 'Q' : - quiet = (*p != '0') ; - break ; + quiet = (*p != '0'); + break; case 'r' : - reverse = (*p != '0') ; - break ; + reverse = (*p != '0'); + break; case 't' : if (*p == 0 && argv[i+1]) - p = argv[++i] ; + p = argv[++i]; if (strcmp(p, "landscape") == 0) { if (hpapersize || vpapersize) error( - "both landscape and papersize specified; ignoring landscape") ; + "both landscape and papersize specified; ignoring landscape"); else - landscape = 1 ; + landscape = 1; } else - paperfmt = p ; - break ; + paperfmt = p; + break; case 'v': - printf ("%s %s\n", banner, banner2); + printf ("%s\n%s\n", banner, banner2); exit (0); break; case 'x' : case 'y' : if (*p == 0 && argv[i+1]) - p = argv[++i] ; + p = argv[++i]; if (sscanf(p, "%lg", &mag)==0 || mag < 1 || mag > 1000000) - error("! Bad magnification parameter (-x or -y).") ; - overridemag = (c == 'x' ? 1 : -1) ; - break ; + error("! Bad magnification parameter (-x or -y)."); + overridemag = (c == 'x' ? 1 : -1); + break; case 'C' : if (*p == 0 && argv[i+1]) - p = argv[++i] ; + p = argv[++i]; if (sscanf(p, "%d", &collatedcopies)==0) - error("! Bad number of collated copies option (-C).") ; - break ; + error("! Bad number of collated copies option (-C)."); + break; case 'D' : if (*p == 0 && argv[i+1]) - p = argv[++i] ; + p = argv[++i]; if (sscanf(p, "%d", &actualdpi)==0 || actualdpi < 10 || actualdpi > 10000) - error("! Bad dpi parameter (-D).") ; + error("! Bad dpi parameter (-D)."); vactualdpi = actualdpi; /* If we had the mode from config.ps, don't use it. If they specified one with -mode, keep it. */ if (!mfmode_option) mfmode = NULL; - break ; + break; case 'E' : - tryepsf = (*p != '0') ; + tryepsf = (*p != '0'); removecomments = disablecomments = 0; if (tryepsf && maxsecsize == 0) - maxsecsize = 1 ; - break ; + maxsecsize = 1; + break; case 'K' : - removecomments = (*p != '0') ; - break ; + removecomments = (*p != '0'); + break; case 'U' : - nosmallchars = (*p != '0') ; - break ; + nosmallchars = (*p != '0'); + break; case 'X' : if (*p == 0 && argv[i+1]) - p = argv[++i] ; + p = argv[++i]; if (sscanf(p, "%d", &actualdpi)==0 || actualdpi < 10 || actualdpi > 10000) - error("! Bad dpi parameter (-D).") ; - break ; + error("! Bad dpi parameter (-D)."); + break; case 'Y' : if (*p == 0 && argv[i+1]) - p = argv[++i] ; + p = argv[++i]; if (sscanf(p, "%d", &vactualdpi)==0 || vactualdpi < 10 || vactualdpi > 10000) - error("! Bad dpi parameter (-D).") ; + error("! Bad dpi parameter (-D)."); vactualdpi = vactualdpi; - break ; + break; case 'F' : - sendcontrolD = (*p != '0') ; - break ; + sendcontrolD = (*p != '0'); + break; case 'G' : shiftlowchars = (*p != '0'); break; case 'M': - dontmakefont = (*p != '0') ; + dontmakefont = (*p != '0'); #ifdef KPATHSEA kpse_set_program_enabled (kpse_pk_format, !dontmakefont, kpse_src_cmdline); #endif - break ; + break; case 'N' : - disablecomments = (*p != '0') ; - break ; + disablecomments = (*p != '0'); + break; case 'P' : { - struct papsiz *opapsiz = papsizes ; - struct papsiz *npapsiz ; - papsizes = 0 ; + struct papsiz *opapsiz = papsizes; + struct papsiz *npapsiz; + papsizes = 0; if (*p == 0 && argv[i+1]) - p = argv[++i] ; - printer = p ; - noenv = 1 ; + p = argv[++i]; + printer = p; + noenv = 1; if (!getdefaults("")) { /* If no config file, default the output name. */ oname = concat ("| lpr -P", printer); } - npapsiz = opapsiz ; + npapsiz = opapsiz; while (npapsiz && npapsiz->next) - npapsiz = npapsiz->next ; + npapsiz = npapsiz->next; if (npapsiz) { - npapsiz->next = papsizes ; - papsizes = opapsiz ; + npapsiz->next = papsizes; + papsizes = opapsiz; } } - break ; + break; case 's': - safetyenclose = (*p != '0') ; - break ; + safetyenclose = (*p != '0'); + break; case 'V': - downloadpspk = (*p != '0') ; - break ; + downloadpspk = (*p != '0'); + break; case 'Z': - compressed = (*p != '0') ; - break ; + compressed = (*p != '0'); + break; #ifdef HPS case 'z': - HPS_FLAG = (*p != '0') ; - break ; + HPS_FLAG = (*p != '0'); + break; #endif case '?': - break ; /* We print the banner and help msg below. */ + break; /* We print the banner and help msg below. */ default: #ifdef KPATHSEA error(concat3 ("! Invalid option `", argv[i], "'. Try --help for more information.")); #else error( - "! Bad option, not one of acdefhijklmnopqrstxyzABCDEFKMNOPSTUXYZ?") ; + "! Bad option, not one of acdefhijklmnopqrstxyzABCDEFKMNOPSTUXYZ?"); #endif } } else { if (*iname == 0) { - register char *p ; + register char *p; - lastext = 0 ; - iname = nextstring ; - p = argv[i] ; + lastext = 0; + iname = nextstring; + p = argv[i]; if (NAME_BEGINS_WITH_DEVICE(p)) { /* get past DOSISH drive */ - *nextstring++ = *p++ ; - *nextstring++ = *p++ ; + *nextstring++ = *p++; + *nextstring++ = *p++; } while (*p) { - *nextstring = *p++ ; + *nextstring = *p++; if (*nextstring == '.') - lastext = nextstring - iname ; + lastext = nextstring - iname; else if (IS_DIR_SEP(*nextstring)) - lastext = 0 ; - nextstring++ ; + lastext = 0; + nextstring++; } - *nextstring++ = '.' ; - *nextstring++ = 'd' ; - *nextstring++ = 'v' ; - *nextstring++ = 'i' ; - *nextstring++ = 0 ; + *nextstring++ = '.'; + *nextstring++ = 'd'; + *nextstring++ = 'v'; + *nextstring++ = 'i'; + *nextstring++ = 0; } else #ifdef KPATHSEA error(concat3("! Second input filename (", argv[i], - ") specified.")) ; + ") specified.")); #else - error("! Two input file names specified.") ; + error("! Two input file names specified."); #endif } } if (noenv == 0) { - register char *p ; - struct papsiz *opapsiz = papsizes ; - papsizes = 0 ; + register char *p; + struct papsiz *opapsiz = papsizes; + papsizes = 0; if (0 != (p = getenv("PRINTER"))) { #if defined(MSDOS) || defined(OS2) - strcpy(nextstring, p) ; - strcat(nextstring, ".cfg") ; + strcpy(nextstring, p); + strcat(nextstring, ".cfg"); #else - strcpy(nextstring, "config.") ; - strcat(nextstring, p) ; + strcpy(nextstring, "config."); + strcat(nextstring, p); #endif - getdefaults(nextstring) ; + getdefaults(nextstring); } { - struct papsiz *npapsiz = opapsiz ; + struct papsiz *npapsiz = opapsiz; while (npapsiz && npapsiz->next) - npapsiz = npapsiz->next ; + npapsiz = npapsiz->next; if (npapsiz) { - npapsiz->next = papsizes ; - papsizes = opapsiz ; + npapsiz->next = papsizes; + papsizes = opapsiz; } } } - papsizes = (struct papsiz *)revlist((void *)papsizes) ; + papsizes = (struct papsiz *)revlist((void *)papsizes); if (queryoptions != 0) { /* get new options */ - (void)fprintf(stderr, "%s %s\n", banner, banner2) ; - help(1) ; + (void)fprintf(stderr, "%s\n%s\n", banner, banner2); + help(1); queryargs(); if (qargc == 1) queryoptions = 0; @@ -1133,17 +1168,17 @@ argv=qargv; } } - } while (queryoptions != 0) ; + } while (queryoptions != 0); #endif -#if (defined(KPATHSEA) && defined(DEBUG)) /* this should really be part of a subroutine */ +#if defined(KPATHSEA) && defined(KPSE_DEBUG) && defined(DEBUG) /* this should really be part of a subroutine */ if (dd(D_FILES)) KPSE_DEBUG_SET (KPSE_DEBUG_FOPEN); if (dd(D_PATHS)) KPSE_DEBUG_SET (KPSE_DEBUG_PATHS); if (dd(D_STAT)) KPSE_DEBUG_SET (KPSE_DEBUG_STAT); if (dd(D_HASH)) KPSE_DEBUG_SET (KPSE_DEBUG_HASH); if (dd(D_EXPAND)) KPSE_DEBUG_SET (KPSE_DEBUG_EXPAND); if (dd(D_SEARCH)) KPSE_DEBUG_SET (KPSE_DEBUG_SEARCH); -#endif /* DEBUG */ - checkenv(1) ; +#endif /* KPATHSEA && KPSE_DEBUG && DEBUG */ + checkenv(1); #ifdef KPATHSEA kpse_init_prog ("DVIPS", actualdpi, mfmode, "cmr10"); kpse_make_tex_discard_errors = quiet; @@ -1156,42 +1191,42 @@ * the hash chain. We do this by reversing the lists, adding them * to the front, and then reversing them again. */ - revpslists() ; - getpsinfo((char *)NULL) ; - revpslists() ; + revpslists(); + getpsinfo((char *)NULL); + revpslists(); if (dvips_debug_flag) { if (!quiet) - (void)fprintf(stderr, "\n%s %s\n", banner, banner2) ; - prettycolumn = 0 ; + (void)fprintf(stderr, "\n%s\n%s\n", banner, banner2); + prettycolumn = 0; } else { if (!quiet) - (void)fprintf(stderr, "%s %s\n", banner, banner2) ; + (void)fprintf(stderr, "%s\n%s\n", banner, banner2); } if (*iname) { - dvifile = fopen(iname, READBIN) ; + dvifile = fopen(iname, READBIN); /* * Allow names like a.b. */ if (dvifile == 0) { - iname[strlen(iname)-4] = 0 ; /* remove the .dvi suffix */ - dvifile = fopen(iname, READBIN) ; + iname[strlen(iname)-4] = 0; /* remove the .dvi suffix */ + dvifile = fopen(iname, READBIN); } } if (oname[0] == '-' && oname[1] == 0) - oname[0] = 0 ; + oname = ""; else if (*oname == 0 && ! filter && *iname) { /* determine output name from input name */ - oname = nextstring ; + oname = nextstring; #ifndef VMCMS /* get stuff before LAST "." */ - lastext = strlen(iname) - 1 ; + lastext = strlen(iname) - 1; while (iname[lastext] != '.' && lastext > 0) - lastext-- ; + lastext--; if (iname[lastext] != '.') - lastext = strlen(iname) - 1 ; + lastext = strlen(iname) - 1; #else /* for VM/CMS we take the stuff before FIRST "." */ - lastext = strchr(iname,'.') - iname ; + lastext = strchr(iname,'.') - iname; if ( lastext <= 0 ) /* if no '.' in "iname" */ - lastext = strlen(iname) -1 ; + lastext = strlen(iname) -1; #endif #ifdef MVSXA /* IBM: MVS/XA */ if (strchr(iname, '(') != NULL && @@ -1203,7 +1238,7 @@ if (strrchr(iname, '.') != NULL) { lastext = strrchr(iname, '.') - iname - 1; } - else lastext = strlen(iname) - 1 ; + else lastext = strlen(iname) - 1; if (strchr(iname, '\'') != NULL) firstext = strchr(iname, '.') - iname + 1; else firstext = 0; @@ -1214,28 +1249,28 @@ #else for (i=0; i<=lastext; i++) #endif - *nextstring++ = iname[i] ; + *nextstring++ = iname[i]; if (iname[lastext] != '.') - *nextstring++ = '.' ; + *nextstring++ = '.'; #ifndef VMCMS - *nextstring++ = 'p' ; - *nextstring++ = 's' ; + *nextstring++ = 'p'; + *nextstring++ = 's'; #else /* might as well keep things uppercase */ - *nextstring++ = 'P' ; - *nextstring++ = 'S' ; + *nextstring++ = 'P'; + *nextstring++ = 'S'; #endif - *nextstring++ = 0 ; + *nextstring++ = 0; /* * Now we check the name, and `throw away' any prefix information. * This means throwing away anything before (and including) a colon * or slash. */ { - char *p = NAME_BEGINS_WITH_DEVICE(oname) ? oname + 2 : oname ; + const char *p = NAME_BEGINS_WITH_DEVICE(oname) ? oname + 2 : oname; for (oname=p; *p && p[1]; p++) if (IS_DIR_SEP(*p)) - oname = p + 1 ; + oname = p + 1; } } #ifdef DEBUG @@ -1245,15 +1280,15 @@ #else /* ~SHORTINT */ (void)fprintf(stderr,"input file %s output file %s swmem %d\n", #endif /* ~SHORTINT */ - iname, oname, swmem) ; + iname, oname, swmem); #ifndef KPATHSEA - (void)fprintf(stderr,"tfm path %s\npk path %s\n", tfmpath, pkpath) ; - (void)fprintf(stderr,"fig path %s\nvf path %s\n", figpath, vfpath) ; + (void)fprintf(stderr,"tfm path %s\npk path %s\n", tfmpath, pkpath); + (void)fprintf(stderr,"fig path %s\nvf path %s\n", figpath, vfpath); (void)fprintf(stderr,"config path %s\nheader path %s\n", - configpath, headerpath) ; + configpath, headerpath); #endif #ifdef FONTLIB - (void)fprintf(stderr,"fli path %s\nfli names %s\n", flipath, fliname) ; + (void)fprintf(stderr,"fli path %s\nfli names %s\n", flipath, fliname); #endif } /* dd(D_PATHS) */ #endif /* DEBUG */ @@ -1261,72 +1296,72 @@ * Now we try to open the dvi file. */ if (!quiet && warningmsg) - error(warningmsg) ; - headersready = 1 ; - headerfile = (char *) (compressed? CHEADERFILE : HEADERFILE) ; - (void)add_header(headerfile) ; + error(warningmsg); + headersready = 1; + headerfile = (const char *) (compressed? CHEADERFILE : HEADERFILE); + (void)add_header(headerfile); if (*iname != 0) { - fulliname = nextstring ; + fulliname = nextstring; #ifndef IGNORE_CWD if (!IS_DIR_SEP(*iname) && !NAME_BEGINS_WITH_DEVICE(iname)) { getcwd(nextstring, MAXPATHLEN + 2); - while (*nextstring++) ; + while (*nextstring++); #ifdef VMS /* VMS doesn't need the '/' character appended */ nextstring--; /* so just back up one byte. */ #else - *(nextstring-1) = '/' ; + *(nextstring-1) = '/'; #endif } #endif - strcpy(nextstring,iname) ; - while (*nextstring++) ; /* advance nextstring past iname */ + strcpy(nextstring,iname); + while (*nextstring++); /* advance nextstring past iname */ } else if (filter) { - dvifile = stdin ; + dvifile = stdin; if (O_BINARY && !isatty(fileno(stdin))) - SET_BINARY(fileno(stdin)) ; + SET_BINARY(fileno(stdin)); } else { #ifdef KPATHSEA fprintf (stderr, "dvips: Missing DVI file argument (or -f).\n"); fprintf (stderr, "dvips: Try --help for more information.\n"); #else - help(1) ; + help(1); #endif - exit(1) ; + exit(1); } if (dvifile==NULL) { error_with_perror("DVI file can't be opened:", iname); exit(1); } if (fseek(dvifile, 0L, 0) < 0) - error("! DVI file must not be a pipe.") ; + error("! DVI file must not be a pipe."); - initcolor() ; + initcolor(); #ifdef FONTLIB fliload(); /* read the font libaries */ #endif /* * Now we do our main work. */ - swmem += fontmem ; + swmem += fontmem; if (maxdrift < 0) { if (actualdpi <= 599) - maxdrift = actualdpi / 100 ; + maxdrift = actualdpi / 100; else if (actualdpi < 1199) - maxdrift = actualdpi / 200 + 3 ; + maxdrift = actualdpi / 200 + 3; else - maxdrift = actualdpi / 400 + 6 ; + maxdrift = actualdpi / 400 + 6; } if (vmaxdrift < 0) { if (vactualdpi <= 599) - vmaxdrift = vactualdpi / 100 ; + vmaxdrift = vactualdpi / 100; else if (vactualdpi < 1199) - vmaxdrift = vactualdpi / 200 + 3 ; + vmaxdrift = vactualdpi / 200 + 3; else - vmaxdrift = vactualdpi / 400 + 6 ; + vmaxdrift = vactualdpi / 400 + 6; } if (dopprescan) - pprescanpages() ; - prescanpages() ; + pprescanpages(); + prescanpages(); #if defined MSDOS || defined OS2 || defined(ATARIST) if (mfjobfile != (FILE*)NULL) { char answer[5]; @@ -1339,104 +1374,108 @@ } #endif if (includesfonts) - (void)add_header(IFONTHEADER) ; + (void)add_header(IFONTHEADER); if (usesPSfonts) - (void)add_header(PSFONTHEADER) ; + (void)add_header(PSFONTHEADER); if (usesspecial) - (void)add_header(SPECIALHEADER) ; + (void)add_header(SPECIALHEADER); if (usescolor) /* IBM: color */ - (void)add_header(COLORHEADER) ; + (void)add_header(COLORHEADER); #ifdef HPS if (HPS_FLAG) - (void)add_header(HPSHEADER) ; + (void)add_header(HPSHEADER); +#endif +#ifdef VFLIB + if (usesvflib) + (void)add_header(VFFONTHEADER); #endif - sects = sections ; - totalpages *= collatedcopies ; + sects = sections; + totalpages *= collatedcopies; if (sects == NULL || sects->next == NULL) { - sectioncopies = collatedcopies ; - collatedcopies = 1 ; + sectioncopies = collatedcopies; + collatedcopies = 1; } else { if (! sepfiles) - multiplesects = 1 ; + multiplesects = 1; } - totalpages *= pagecopies ; + totalpages *= pagecopies; if (tryepsf) { if (paperfmt || landscape || manualfeed || collatedcopies > 1 || numcopies > 1 || cropmarks || *iname == 0 || (totalpages > 1 && !(sepfiles && maxsecsize == 1))) { - error("Can't make it EPSF, sorry") ; - tryepsf = 0 ; + error("Can't make it EPSF, sorry"); + tryepsf = 0; } } #ifdef HPS if (HPS_FLAG) - set_bitfile("head.tmp", 0) ; + set_bitfile("head.tmp", 0); #endif if (! sepfiles) { - initprinter(sections) ; - outbangspecials() ; + initprinter(sections); + outbangspecials(); } for (i=0; i STDOUTSIZE) { - fprintf(stderr, "\n") ; - prettycolumn = 0 ; + fprintf(stderr, "\n"); + prettycolumn = 0; } - (void)fprintf(stderr, "(-> %s) ", oname) ; - prettycolumn += strlen(oname) + 6 ; + (void)fprintf(stderr, "(-> %s) ", oname); + prettycolumn += strlen(oname) + 6; } #ifdef HPS if (HPS_FLAG) - set_bitfile("head.tmp", 0) ; + set_bitfile("head.tmp", 0); #endif - initprinter(sects) ; - outbangspecials() ; + initprinter(sects); + outbangspecials(); } else if (! quiet) { if (prettycolumn > STDOUTSIZE) { - fprintf(stderr, "\n") ; - prettycolumn = 0 ; + fprintf(stderr, "\n"); + prettycolumn = 0; } - (void)fprintf(stderr, ". ") ; - prettycolumn += 2 ; + (void)fprintf(stderr, ". "); + prettycolumn += 2; } - (void)fflush(stderr) ; - dosection(sects, sectioncopies) ; - sects = sects->next ; + (void)fflush(stderr); + dosection(sects, sectioncopies); + sects = sects->next; if (sepfiles) { #ifdef HPS if (HPS_FLAG) - finish_hps() ; + finish_hps(); #endif - cleanprinter() ; + cleanprinter(); } } } - freememforpsnames() ; + freememforpsnames(); if (! sepfiles) { #ifdef HPS if (HPS_FLAG) - finish_hps() ; + finish_hps(); #endif - cleanprinter() ; + cleanprinter(); } if (! quiet) - (void)fprintf(stderr, "\n") ; + (void)fprintf(stderr, "\n"); #ifdef DEBUG if (dd(D_MEM)) { #ifdef SHORTINT - fprintf(stderr, "Total memory allocated: %ld\n", totalalloc) ; + fprintf(stderr, "Total memory allocated: %ld\n", totalalloc); #else - fprintf(stderr, "Total memory allocated: %d\n", totalalloc) ; + fprintf(stderr, "Total memory allocated: %d\n", totalalloc); #endif } #endif - return 0 ; + return 0; /*NOTREACHED*/ } #ifdef VMS diff -Nu dvipsk2009/dvips.h dvipsk/dvips.h --- dvipsk2009/dvips.h Tue Jun 23 18:46:14 2009 +++ dvipsk/dvips.h Mon Mar 29 23:28:10 2010 @@ -1,4 +1,4 @@ -/* $Id: dvips.h 13914 2009-06-23 09:46:14Z peter $ +/* $Id: dvips.h 16888 2010-02-01 01:41:41Z karl $ * This is dvips, a freely redistributable PostScript driver * for dvi files. It is (C) Copyright 1986-2008 by Tomas Rokicki. * You may freely use, modify and/or distribute this program or any @@ -6,11 +6,19 @@ */ /* This file is the header for dvips's global data structures. */ - #define CREATIONDATE + +#ifdef VFLIB +#define MAX_CODE 11280 +#else +#define MAX_CODE 65536 +#endif + #define BANNER \ -"This is dvips(k) 5.98 Copyright 2009 Radical Eye Software" -#define BANNER2 "(www.radicaleye.com)" +"This is pdvips(k) p1.7b Copyright 2010 ASCII MEDIA WORKS. (ptex-staff@ml.asciimw.jp)" +#define BANNER2 \ +"based on dvips(k) 5.98dev Copyright 2010 Radical Eye Software (www.radicaleye.com)" +#define WEBURL "(www.radicaleye.com)" #ifdef KPATHSEA #include "config.h" #include "debug.h" @@ -29,13 +37,17 @@ #endif #endif #if defined(lint) && defined(sun) -extern char *sprintf() ; +extern char *sprintf(); #endif #include "paths.h" #include "debug.h" #ifdef VMS #include "[.vms]vms.h" #endif /* VMS */ +#ifdef VFLIB +#include "VF.h" +#define CCTOJIS(x) (((x)/94+0x21)*256 + ((x)%94) + 0x21) +#endif #include /* * Is your malloc big? @@ -57,9 +69,9 @@ #define STRINGSIZE (200000) /* maximum total chars in strings in program */ #define RASTERCHUNK (8192) /* size of chunk of raster */ #define MINCHUNK (240) /* minimum size char to get own raster */ -#define STACKSIZE (350) /* maximum stack size for dvi files */ -#define MAXFRAME (10) /* maximum depth of virtual font recursion */ -#define MAXFONTHD (100) /* number of unique names of included fonts */ +#define STACKSIZE (500) /* maximum stack size for dvi files */ +#define MAXFRAME (50) /* maximum depth of virtual font recursion */ +#define MAXFONTHD (1024) /* number of unique names of included fonts */ #define STDOUTSIZE (75) /* width of a standard output line */ #define DOWNLOADEDPSSIZE (1000) /* max number of downloaded fonts to check */ /* @@ -92,14 +104,14 @@ typedef char boolean; #endif typedef double real; -typedef short shalfword ; -typedef unsigned short halfword ; -typedef unsigned char quarterword ; +typedef short shalfword; +typedef unsigned short halfword; +typedef unsigned char quarterword; #ifdef WIN32 #define Boolean boolean #else #ifndef __THINK__ -typedef short Boolean ; +typedef short Boolean; #endif #endif /* @@ -125,12 +137,15 @@ */ #define RESHASHPRIME (73) struct resfont { - struct resfont *next ; + struct resfont *next; char *Keyname, *PSname, *TeXname, *Fontfile, *Vectfile; - char *specialinstructions ; - char *downloadheader ; /* possibly multiple files */ - quarterword sent ; -} ; + char *specialinstructions; + char *downloadheader; /* possibly multiple files */ +#ifdef VFLIB + boolean vflib; +#endif + quarterword sent; +}; /* * A chardesc describes an individual character. Before the fonts are @@ -138,11 +153,11 @@ * with the following meanings: */ typedef struct tcd { - integer TFMwidth ; - quarterword *packptr ; - shalfword pixelwidth ; - quarterword flags, flags2 ; -} chardesctype ; + integer TFMwidth; + quarterword *packptr; + shalfword pixelwidth; + quarterword flags, flags2; +} chardesctype; #define EXISTS (1) #define PREVPAGE (2) #define THISPAGE (4) @@ -164,49 +179,57 @@ * psfile. It can be 0, PREVPAGE, THISPAGE, or EXISTS. */ typedef struct tfd { - integer checksum, scaledsize, designsize, thinspace ; - halfword dpi, loadeddpi ; - halfword alreadyscaled ; - halfword psname ; - halfword loaded ; + integer checksum, scaledsize, designsize, thinspace, dir; + halfword dpi, loadeddpi; + halfword alreadyscaled; + halfword psname; + halfword loaded; quarterword psflag; - quarterword codewidth ; - integer maxchars ; - char *name, *area ; - struct resfont *resfont ; - struct tft *localfonts ; - struct tfd *next ; + quarterword codewidth; + integer maxchars; + char *name, *area; + struct resfont *resfont; + struct tft *localfonts; + struct tfd *next; struct tfd *nextsize; char *scalename; - chardesctype *chardesc ; -} fontdesctype ; + chardesctype *chardesc; + int iswide; +#ifdef VFLIB + boolean vflib; +#endif +} fontdesctype; /* A fontmap associates a fontdesc with a font number. */ typedef struct tft { - integer fontnum ; - fontdesctype *desc ; - struct tft *next ; -} fontmaptype ; + integer fontnum; + fontdesctype *desc; + struct tft *next; +} fontmaptype; /* Virtual fonts require a `macro' capability that is implemented by * using a stack of `frames'. */ typedef struct { - quarterword *curp, *curl ; - fontdesctype *curf ; - fontmaptype *ff ; -} frametype ; + quarterword *curp, *curl; + fontdesctype *curf; + fontmaptype *ff; +} frametype; /* * The next type holds the font usage information in a 256-bit table; * there's a 1 for each character that was used in a section. */ typedef struct { - fontdesctype *fd ; - halfword psfused ; - halfword bitmap[16] ; -} charusetype ; + fontdesctype *fd; + halfword psfused; +#ifndef VFLIB + halfword bitmap[16]; +#else + halfword *bitmap; +#endif +} charusetype; /* Next we want to record the relevant data for a section. A section is * a largest portion of the document whose font usage does not overflow @@ -219,17 +242,17 @@ * the second phase. */ typedef struct t { - integer bos ; - struct t *next ; - halfword numpages ; -} sectiontype ; + integer bos; + struct t *next; + halfword numpages; +} sectiontype; /* * Sections are actually represented not by sectiontype but by a more * complex data structure of variable size, having the following layout: - * sectiontype sect ; - * charusetype charuse[numfonts] ; - * fontdesctype *sentinel = NULL ; + * sectiontype sect; + * charusetype charuse[numfonts]; + * fontdesctype *sentinel = NULL; * (Here numfonts is the number of bitmap fonts currently defined.) * Since we can't declare this or take a sizeof it, we build it and * manipulate it ourselves (see the end of the prescan routine). @@ -238,12 +261,12 @@ * This is how we build up headers and other lists. */ struct header_list { - struct header_list *next ; - char *Hname ; - char *precode ; - char *postcode ; - char name[1] ; -} ; + struct header_list *next; + const char *Hname; + char *precode; + char *postcode; + char name[1]; +}; /* * Some machines define putlong in their library. * We get around this here. @@ -253,11 +276,11 @@ * Information on available paper sizes is stored here. */ struct papsiz { - struct papsiz *next ; - integer xsize, ysize ; - char *name ; - char *specdat ; -} ; + struct papsiz *next; + integer xsize, ysize; + char *name; + char *specdat; +}; #ifdef MVSXA /* IBM: MVS/XA */ /* this is where we fix problems with conflicts for truncation of long names (we might only do this if LONGNAME not set but ...) */ @@ -265,7 +288,7 @@ # define flushDashedPath flshDshdPth /* conflict with flushDash */ # define PageList PgList /* re-definition conflict with pagelist */ /* adding ascii2ebcdic conversion table to extern */ - extern char ascii2ebcdic[] ; + extern char ascii2ebcdic[]; #endif /* IBM: MVS/XA */ #ifdef VMCMS /* IBM: VM/CMS */ /* this is where we fix problems with conflicts for truncation @@ -273,9 +296,9 @@ # define pprescanpages pprscnpgs /* confict with pprescan */ # define flushDashedPath flshDshdPth /* conflict with flushDash */ /* adding ascii2ebcdic conversion table to extern */ - extern char ascii2ebcdic[] ; + extern char ascii2ebcdic[]; /* redefining fopen for VMCMS, see DVIPSCMS.C */ - extern FILE *cmsfopen() ; + extern FILE *cmsfopen(); # ifdef fopen # undef fopen # endif @@ -322,8 +345,8 @@ #include #include #define O_BINARY _O_BINARY -#define popen _popen -#define pclose _pclose +#define popen win32_popen +#define pclose win32_pclose #define register #define SET_BINARY(fd) _setmode((fd), _O_BINARY) #else /* !WIN32 */ diff -Nu dvipsk2009/dvips.info dvipsk/dvips.info --- dvipsk2009/dvips.info Sun Sep 27 03:30:44 2009 +++ dvipsk/dvips.info Sat Jan 02 09:24:08 2010 @@ -1,7 +1,7 @@ This is ../../../texk/dvipsk/dvips.info, produced by makeinfo version 4.13 from ../../../texk/dvipsk/dvips.texi. -This manual documents Dvips version 5.98 (September 2009), a program to +This manual documents Dvips version 5.98 (December 2009), a program to translate a DVI file into PostScript. You may freely use, modify and/or distribute this file. @@ -18,7 +18,7 @@ Dvips ***** -This manual documents Dvips version 5.98 (September 2009), a program to +This manual documents Dvips version 5.98 (December 2009), a program to translate a DVI file into PostScript. You may freely use, modify and/or distribute this file. @@ -109,11 +109,9 @@ 2 Installation ************** -(A copy of this chapter is in the distribution file `dvipsk/INSTALL'.) - Installing Dvips is mostly the same as installing any Kpathsea-using program. Therefore, for the basic steps involved, *note Installation: -(kpathsea)Installation. (A copy is in the file `kpathsea/INSTALL'.) +(kpathsea)Installation. For solutions to common installation problems and information on how to report a bug, see the file `kpathsea/BUGS' (*note Bugs: @@ -180,7 +178,7 @@ % Partially download Type 1 fonts by default. Only reason not to do % this is if you encounter bugs. (Please report them to - % if you do.) + % if you do.) j % Also look for fonts at these resolutions. @@ -338,18 +336,16 @@ The `-d' flag to Dvips helps in tracking down certain errors. The parameter to this flag is an integer that tells what errors are currently being tracked. To track a certain class of debug messages, -simply provide the appropriate number given below; if you wish to track +specify the appropriate number given below; if you wish to track multiple classes, sum the numbers of the classes you wish to track. To -track all classes, you can use `-1'. Another useful value is `3650', -which tracks everything having to do with file searching and opening. - - You can also set the environment variable `KPATHSEA_DEBUG' to any of -these values. +track all classes, you can use `-1'. - Some of these debugging options are actually provided by Kpathsea -(*note Debugging: (kpathsea)Debugging.). + You can also set the environment variable `KPATHSEA_DEBUG' instead +of using `-d'. Some of these debugging options are actually provided +by Kpathsea (*note Debugging: (kpathsea)Debugging.). The classes are: + 1 specials @@ -372,24 +368,21 @@ files 128 - config files + (omitted) 256 - Partial Type 1 font encoding vectors + config files 512 - Partial Type 1 subr calls - -1024 Kpathsea `stat' calls -2048 +1024 Kpathsea hash table lookups -4096 +2048 Kpathsea path element expansion -8192 +4096 Kpathsea path searches  @@ -2742,14 +2735,14 @@ default encoding vector for a particular PostScript font. Examples of encodings: the `dvips.enc' encoding file that comes with -Dvips in the `reencode' directory is a good (but not perfect) -approximation to the TeX encoding for TeX's Computer Modern text fonts. -This is the encoding of the fonts that originated with Dvips, such as -`ptmr.tfm'. The distribution includes many other encoding files; for -example, `8r.enc', which is the base font for the current PostScript -font distribution, and three corresponding to the TeX mathematics -fonts: `texmext.enc' for math extensions, `texmital.enc' for math -italics, and `texmsym.enc' for math symbols. +the Fontname distribution (`http://tug.org/fontname') is a good (but +not perfect) approximation to the TeX encoding for TeX's Computer +Modern text fonts. This is the encoding of the fonts that originated +with Dvips, such as `ptmr.tfm'. The distribution includes many other +encoding files; for example, `8r.enc', which is the base font for the +current PostScript font distribution, and three corresponding to the +TeX mathematics fonts: `texmext.enc' for math extensions, +`texmital.enc' for math italics, and `texmsym.enc' for math symbols.  File: dvips.info, Node: PostScript typesetting, Prev: Encodings, Up: Font concepts @@ -4703,82 +4696,82 @@  Tag Table: -Node: Top564 -Node: Why Dvips1313 -Node: Installation4761 -Node: config.ps installation5899 -Node: PostScript font installation8441 -Node: Ghostscript installation11315 -Node: Diagnosing problems12412 -Node: Debug options13507 -Node: No output14710 -Node: Small or inverted16178 -Node: Printer errors16897 -Node: Long documents fail18229 -Node: Including graphics fails18570 -Node: Invoking Dvips19808 -Node: Basic usage20399 -Node: Command-line options21383 -Node: Option summary21832 -Node: Option details23994 -Node: Environment variables42998 -Node: Config files45957 -Node: Configuration file searching46640 -Node: Configuration file commands49940 -Node: Paper size and landscape57053 -Node: papersize special58651 -Node: Config file paper sizes60060 -Node: Paper trays64215 -Node: Interaction with PostScript65549 -Node: PostScript figures66202 -Node: Bounding box66928 -Node: \includegraphics70299 -Node: EPSF macros72590 -Node: EPSF scaling74560 -Node: EPSF clipping77130 -Node: psfile special77772 -Node: Dynamic creation of graphics80165 -Node: Fonts in figures81483 -Node: Header files83143 -Node: Including headers from TeX84349 -Node: Including headers from the command line86383 -Node: Headers and memory usage87483 -Node: Literal PS88193 -Node: " special88775 -Node: ps special89516 -Node: Literal headers91014 -Node: PostScript hooks91729 -Node: Literal examples93819 -Node: Hypertext95271 -Node: Hypertext caveats96829 -Node: Hypertext specials101226 -Node: PostScript fonts103860 -Node: Font concepts104976 -Node: Metric files106143 -Node: Glyph files108969 -Node: Virtual fonts111325 -Node: Encodings113215 -Node: PostScript typesetting115597 -Node: Making a font available118679 -Node: Invoking afm2tfm123709 -Node: Changing font encodings124679 -Node: Changing TeX encodings125469 -Node: Changing PostScript encodings126569 -Node: Changing both encodings127913 -Node: Reencoding with Afm2tfm128586 -Node: Encoding file format131690 -Node: Special font effects135893 -Node: Afm2tfm options138156 -Node: psfonts.map141141 -Node: Color145873 -Node: Color macro files146917 -Node: User-definable colors150115 -Node: Color subtleties151390 -Node: Ted Turner153041 -Node: Color device configuration154266 -Node: Color support details156708 -Node: Color specifications157086 -Node: Color specials158489 -Node: Index160618 +Node: Top563 +Node: Why Dvips1311 +Node: Installation4759 +Node: config.ps installation5780 +Node: PostScript font installation8317 +Node: Ghostscript installation11191 +Node: Diagnosing problems12288 +Node: Debug options13383 +Node: No output14409 +Node: Small or inverted15877 +Node: Printer errors16596 +Node: Long documents fail17928 +Node: Including graphics fails18269 +Node: Invoking Dvips19507 +Node: Basic usage20098 +Node: Command-line options21082 +Node: Option summary21531 +Node: Option details23693 +Node: Environment variables42697 +Node: Config files45656 +Node: Configuration file searching46339 +Node: Configuration file commands49639 +Node: Paper size and landscape56752 +Node: papersize special58350 +Node: Config file paper sizes59759 +Node: Paper trays63914 +Node: Interaction with PostScript65248 +Node: PostScript figures65901 +Node: Bounding box66627 +Node: \includegraphics69998 +Node: EPSF macros72289 +Node: EPSF scaling74259 +Node: EPSF clipping76829 +Node: psfile special77471 +Node: Dynamic creation of graphics79864 +Node: Fonts in figures81182 +Node: Header files82842 +Node: Including headers from TeX84048 +Node: Including headers from the command line86082 +Node: Headers and memory usage87182 +Node: Literal PS87892 +Node: " special88474 +Node: ps special89215 +Node: Literal headers90713 +Node: PostScript hooks91428 +Node: Literal examples93518 +Node: Hypertext94970 +Node: Hypertext caveats96528 +Node: Hypertext specials100925 +Node: PostScript fonts103559 +Node: Font concepts104675 +Node: Metric files105842 +Node: Glyph files108668 +Node: Virtual fonts111024 +Node: Encodings112914 +Node: PostScript typesetting115317 +Node: Making a font available118399 +Node: Invoking afm2tfm123429 +Node: Changing font encodings124399 +Node: Changing TeX encodings125189 +Node: Changing PostScript encodings126289 +Node: Changing both encodings127633 +Node: Reencoding with Afm2tfm128306 +Node: Encoding file format131410 +Node: Special font effects135613 +Node: Afm2tfm options137876 +Node: psfonts.map140861 +Node: Color145593 +Node: Color macro files146637 +Node: User-definable colors149835 +Node: Color subtleties151110 +Node: Ted Turner152761 +Node: Color device configuration153986 +Node: Color support details156428 +Node: Color specifications156806 +Node: Color specials158209 +Node: Index160338  End Tag Table diff -Nu dvipsk2009/dvips.texi dvipsk/dvips.texi --- dvipsk2009/dvips.texi Sun Sep 27 03:30:44 2009 +++ dvipsk/dvips.texi Sat Jan 02 09:24:08 2010 @@ -3,7 +3,7 @@ @settitle Dvips: A DVI-to-PostScript translator @set version 5.98 -@set month-year September 2009 +@set month-year December 2009 @copying This manual documents Dvips version @value{version} @@ -145,14 +145,13 @@ @cindex compilation @cindex installation, of Dvips -@ifset version -(A copy of this chapter is in the distribution file @file{dvipsk/INSTALL}.) -@end ifset +@c ifset version +@c (A copy of this chapter is in the distribution file @file{dvipsk/INSTALL}.) +@c end ifset Installing Dvips is mostly the same as installing any Kpathsea-using program. Therefore, for the basic steps involved, -@pxref{Installation,,, kpathsea, Kpathsea}. (A copy is in the file -@file{kpathsea/INSTALL}.) +@pxref{Installation,,, kpathsea, Kpathsea}. For solutions to common installation problems and information on how to report a bug, see the file @file{kpathsea/BUGS} (@pxref{Bugs,,, @@ -376,22 +375,19 @@ @cindex debugging options @cindex options, debugging -The @samp{-d} flag to Dvips helps in tracking down certain errors. The -parameter to this flag is an integer that tells what errors are +The @samp{-d} flag to Dvips helps in tracking down certain errors. +The parameter to this flag is an integer that tells what errors are currently being tracked. To track a certain class of debug messages, -simply provide the appropriate number given below; if you wish to track -multiple classes, sum the numbers of the classes you wish to track. To -track all classes, you can use @code{-1}. Another useful value is -@code{3650}, which tracks everything having to do with file searching -and opening. - -You can also set the environment variable @env{KPATHSEA_DEBUG} to any -of these values. - -Some of these debugging options are actually provided by Kpathsea -(@pxref{Debugging, , , kpathsea, Kpathsea}). +specify the appropriate number given below; if you wish to track +multiple classes, sum the numbers of the classes you wish to track. +To track all classes, you can use @code{-1}. + +You can also set the environment variable @env{KPATHSEA_DEBUG} instead +of using @samp{-d}. Some of these debugging options are actually +provided by Kpathsea (@pxref{Debugging, , , kpathsea, Kpathsea}). The classes are: + @table @asis @item 1 specials @@ -408,18 +404,16 @@ @item 64 files @item 128 -config files +(omitted) @item 256 -Partial Type 1 font encoding vectors +config files @item 512 -Partial Type 1 subr calls -@item 1024 Kpathsea @code{stat} calls -@item 2048 +@item 1024 Kpathsea hash table lookups -@item 4096 +@item 2048 Kpathsea path element expansion -@item 8192 +@item 4096 Kpathsea path searches @end table @@ -3398,15 +3392,15 @@ @flindex texmsym.enc @flindex reencode/*.enc Examples of encodings: the @file{dvips.enc} encoding file that comes -with Dvips in the @samp{reencode} directory is a good (but not perfect) -approximation to the @TeX{} encoding for @TeX{}'s Computer Modern text -fonts. This is the encoding of the fonts that originated with Dvips, -such as @file{ptmr.tfm}. The distribution includes many other encoding -files; for example, @file{8r.enc}, which is the base font for the -current PostScript font distribution, and three corresponding to the -@TeX{} mathematics fonts: @file{texmext.enc} for math extensions, -@file{texmital.enc} for math italics, and @file{texmsym.enc} for math -symbols. +with the Fontname distribution (@url{http://tug.org/fontname}) is a +good (but not perfect) approximation to the @TeX{} encoding for +@TeX{}'s Computer Modern text fonts. This is the encoding of the +fonts that originated with Dvips, such as @file{ptmr.tfm}. The +distribution includes many other encoding files; for example, +@file{8r.enc}, which is the base font for the current PostScript font +distribution, and three corresponding to the @TeX{} mathematics fonts: +@file{texmext.enc} for math extensions, @file{texmital.enc} for math +italics, and @file{texmsym.enc} for math symbols. @node PostScript typesetting diff -Nu dvipsk2009/emspecial.c dvipsk/emspecial.c --- dvipsk2009/emspecial.c Tue Jun 23 18:46:14 2009 +++ dvipsk/emspecial.c Mon Mar 29 23:28:22 2010 @@ -7,28 +7,10 @@ #include #include /* - * These are the external routines called: + * The external declarations: */ #include "protos.h" -extern char errbuf[] ; -extern shalfword linepos; -extern FILE *bitfile; -extern int actualdpi ; -extern int vactualdpi ; -extern integer hh, vv; -#ifndef KPATHSEA -extern char *figpath ; -#endif -extern int prettycolumn ; -extern int quiet; -extern Boolean disablecomments ; - -#ifdef DEBUG -extern integer debug_flag; -#endif - - #ifdef EMTEX /* emtex specials, added by rjl */ @@ -37,7 +19,7 @@ #define FALSE 0 #endif -static long emmax = 161 ; +static long emmax = 161; /* * We define these seek constants if they don't have their @@ -51,17 +33,17 @@ #endif struct empt { - struct empt *next ; + struct empt *next; shalfword point; integer x, y; }; -static struct empt **empoints = NULL ; +static struct empt **empoints = NULL; boolean emused = FALSE; /* true if em points used on this page */ integer emx, emy; struct emunit { - char *unit; + const char *unit; float factor; }; struct emunit emtable[] = { @@ -85,50 +67,50 @@ int i; if (emused && empoints) for (i=0; ipoint == point ) break; - p = p->next ; + p = p->next; } if (p == 0) { - p = (struct empt *)mymalloc(sizeof(struct empt)) ; - p->next = empoints[start] ; - empoints[start] = p ; + p = (struct empt *)mymalloc(sizeof(struct empt)); + p->next = empoints[start]; + empoints[start] = p; } p->point = point; p->x = x; p->y = y; - return(p) ; + return(p); } /* get an empoint from the empoints array */ struct empt * emptget(shalfword point) { - struct empt *p ; + struct empt *p; int start; start = point % emmax; if (emused == TRUE) { - p = empoints[start] ; + p = empoints[start]; while (p) { if (p->point == point) - return p ; - p = p->next ; + return p; + p = p->next; } } sprintf(errbuf,"!em: point %d not defined",point); @@ -158,14 +140,14 @@ float emwidth, emheight; shalfword empoint1, empoint2; struct empt *empoint; -char emunit[3]; -char emstr[80]; +char emunit[30]; +char emstr[250]; char *emp; #ifndef KPATHSEA void emgraph(); #endif - hvpos() ; + hvpos(); for (emp = p+3; *emp && isspace(*emp); emp++); /* skip blanks */ if (strncmp(emp, "linewidth", 9) == 0) { /* code for linewidth */ @@ -178,7 +160,7 @@ #ifdef DEBUG if (dd(D_SPECIAL)) (void)fprintf(stderr, "em special: Linewidth set to %.1f dots\n", - emwidth) ; + emwidth); #endif } else { sprintf(errbuf,"Unknown em: special width"); @@ -220,7 +202,7 @@ else if (strncmp(emp, "point", 5) == 0) { if (empoints == NULL) { empoints = - (struct empt **)mymalloc((integer)emmax * sizeof(struct empt *)) ; + (struct empt **)mymalloc((integer)emmax * sizeof(struct empt *)); emused = TRUE; emclear(); } @@ -234,7 +216,7 @@ #else (void)fprintf(stderr, "em special: Point %d is %d,%d\n", #endif - empoint->point, empoint->x, empoint->y) ; + empoint->point, empoint->x, empoint->y); #endif } else if (strncmp(emp, "line", 4) == 0) { @@ -261,14 +243,14 @@ #ifdef DEBUG if (dd(D_SPECIAL)) (void)fprintf(stderr, "em special: Line from point %d to point %d\n", - empoint1, empoint2) ; + empoint1, empoint2); #endif cmdout("np"); if (emwidth!=-1.0) { #ifdef DEBUG if (dd(D_SPECIAL)) (void)fprintf(stderr,"em special: Linewidth temporarily set to %.1f dots\n", - emwidth) ; + emwidth); #endif strcpy(emstr,"currentlinewidth"); cmdout(emstr); @@ -290,25 +272,30 @@ } } else if (strncmp(emp, "message", 7) == 0) { - (void)fprintf(stderr, "em message: %s\n", emp+7) ; + (void)fprintf(stderr, "em message: %s\n", emp+7); } else if (strncmp(emp, "graph", 5) == 0) { int i; for (emp = emp+5; *emp && isspace(*emp); emp++); /* skip blanks */ - for (i=0; *emp && !isspace(*emp) && !(*emp==',') ; emp++) + for (i=0; *emp && !isspace(*emp) && !(*emp==','); emp++) { + if (strlen(emstr) - 2 >= sizeof(emstr)) { + fprintf(stderr, "em:graph: special too long, truncating\n"); + break; + } emstr[i++] = *emp; /* copy filename */ + } emstr[i] = '\0'; /* now get optional width and height */ emwidth = emheight = -1.0; /* no dimension is <= 0 */ for (; *emp && ( isspace(*emp) || (*emp==',') ); emp++) - ; /* skip blanks and comma */ + ; /* skip blanks and comma */ if (*emp) { sscanf(emp, "%f%2s", &emwidth, emunit); /* read width */ emwidth = emunits(emwidth,emunit); /* convert to pixels */ for (; *emp && (*emp=='.'||isdigit(*emp)||isalpha(*emp)); emp++) - ; /* skip width dimension */ + ; /* skip width dimension */ for (; *emp && ( isspace(*emp) || (*emp==',') ); emp++) - ; /* skip blanks and comma */ + ; /* skip blanks and comma */ if (*emp) { sscanf(emp, "%f%2s", &emheight, emunit); /* read height */ emheight = emunits(emheight,emunit)*vactualdpi/actualdpi; @@ -318,13 +305,13 @@ emgraph(emstr,emwidth,emheight); } else { - (void)fprintf(stderr, "em:graph: no file given\n") ; + (void)fprintf(stderr, "em:graph: no file given\n"); } } else { sprintf(errbuf, "Unknown em: command (%s) in \\special will be ignored", p); - specerror(errbuf) ; + specerror(errbuf); } return; } @@ -670,15 +657,15 @@ imagehead(char *filename, int wide, int high, float emwidth, float emheight) { - char *fullname = NULL, *name ; + char *fullname = NULL, *name; if (!quiet) { #ifdef KPATHSEA - fullname = (char *)kpse_find_file (filename, pictpath, 0) ; + fullname = (char *)kpse_find_file (filename, pictpath, 0); #endif if (!fullname) - name = filename ; + name = filename; else - name = fullname ; + name = fullname; if (strlen(name) + prettycolumn > STDOUTSIZE) { fprintf(stderr,"\n"); prettycolumn = 0; @@ -689,7 +676,7 @@ if (fullname) free (fullname); } hvpos(); - nlcmdout("@beginspecial @setspecial") ; + nlcmdout("@beginspecial @setspecial"); if (!disablecomments) { cmdout("%%BeginDocument: em:graph"); cmdout(filename); @@ -718,10 +705,10 @@ imagetail(void) { if (!disablecomments) { - (void)fprintf(bitfile, "\n%%%%EndDocument\n") ; + (void)fprintf(bitfile, "\n%%%%EndDocument\n"); linepos = 0; } - nlcmdout("@endspecial") ; + nlcmdout("@endspecial"); if (!quiet) { (void)fprintf(stderr,">"); (void)fflush(stderr); @@ -946,7 +933,7 @@ sprintf(errbuf, "em:graph: Unknown MSP File Type"); specerror(errbuf); } - imagetail() ; + imagetail(); } /* ------------------------------------------------------------------------ */ @@ -1039,7 +1026,7 @@ } if (rle_dx) { - for ( ; rle_dx>1; rle_dx-=2) { + for (; rle_dx>1; rle_dx-=2) { s++; i++; } @@ -1077,12 +1064,12 @@ ch = ((ch>>4)&0x0f) | ((ch<<4)&0xf0); /* swap order */ i++; *s = (*s & 0xf0) | (ch & 0x0f); - s++ ; + s++; hi = TRUE; cnt--; } /* we are about to place the high 4 bits */ - for ( ; cnt>1 && i<=limit ; cnt-=2) { /* place the whole bytes */ + for (; cnt>1 && i<=limit; cnt-=2) { /* place the whole bytes */ i++; *s++ = ch; } @@ -1114,7 +1101,7 @@ } if (rle_dx) { - for ( ; rle_dx > 0; rle_dx--) { + for (; rle_dx > 0; rle_dx--) { s++; i++; } @@ -1143,7 +1130,7 @@ } } else { /* cnt is repeat count */ - for ( ; cnt>0 && i<=limit; cnt--) { + for (; cnt>0 && i<=limit; cnt--) { i++; *s++ = ch; } @@ -1331,10 +1318,10 @@ if (bmih.bitcount == 1) { if (isblack[0]) - for (j = 0; j < ewidth ; j++) + for (j = 0; j < ewidth; j++) pshexa[j] = line[j]; else - for (j = 0; j < ewidth ; j++) + for (j = 0; j < ewidth; j++) pshexa[j] = ~line[j]; pshexa[ewidth-1] |= emask; } @@ -1372,7 +1359,7 @@ newline(); mhexout((unsigned char *) pshexa,(long)tobyte(bmih.width)); } - imagetail() ; + imagetail(); free(pshexa); free(line); } @@ -1381,7 +1368,7 @@ #define PCX 0 #define MSP 1 #define BMP 2 -char *extarr[]= +const char *extarr[]= { ".pcx", ".msp", ".bmp", NULL }; void diff -Nu dvipsk2009/finclude.c dvipsk/finclude.c --- dvipsk2009/finclude.c Tue Jun 23 18:46:14 2009 +++ dvipsk/finclude.c Mon Mar 29 23:28:33 2010 @@ -15,7 +15,7 @@ #else #include #if !defined(SYSV) && !defined(WIN32) -extern char *strtok() ; /* some systems don't have this in strings.h */ +extern char *strtok(); /* some systems don't have this in strings.h */ #endif #define ISXGIGIT isxdigit #endif @@ -28,39 +28,11 @@ #endif /* - * These are the external routines we call. + * The external declarations: */ #include "protos.h" /* - * These are the external variables we access. - */ -extern struct header_list *ps_fonts_used; -extern char *infont ; -extern fontdesctype *curfnt ; -extern fontdesctype *fonthead ; -extern integer fontmem ; -extern fontdesctype *fonthd[MAXFONTHD] ; -extern int nextfonthd ; -extern char *nextstring ; -extern char xdig[256] ; -extern real conv ; -extern integer pagecost ; -extern int actualdpi ; -extern double mag ; -extern Boolean includesfonts ; -#ifndef KPATHSEA -extern char *figpath ; -#endif -extern int to_close ; -#ifdef DEBUG -extern integer debug_flag; -#endif /* DEBUG */ - -extern char *downloadedpsnames[]; -extern int unused_top_of_psnames; - -/* * Create a font descriptor for a font included in a psfile. There will be * no fontmaptype node for the resulting font descriptor until this font is * encountered by fontdef() (if that ever happens). @@ -73,8 +45,8 @@ fp = newfontdesc((integer)0, scsize, dssize, name, area); fp->scalename = scname; - fp->next = fonthead ; - fonthead = fp ; + fp->next = fonthead; + fonthead = fp; return fp; } /* @@ -84,7 +56,7 @@ void setfamily(fontdesctype *f) { - int i ; + int i; fontmem -= DICTITEMCOST; for (i=0; iname) + strlen(f->area) ; - fonthd[nextfonthd++] = f ; - f->nextsize = NULL ; + error("! Too many fonts in included psfiles"); + fontmem -= NAMECOST + strlen(f->name) + strlen(f->area); + fonthd[nextfonthd++] = f; + f->nextsize = NULL; } /* * Convert file name s to a pair of new strings in the string pool. @@ -113,13 +85,13 @@ a = NULL; for (p=s; *p!=0; p++) if (*p=='/') - a = p+1 ; - if (a==NULL) *nextstring++ = 0 ; - else { sav = *a ; - *a = 0 ; - (void) newstring(s) ; - *a = sav ; - s = a ; + a = p+1; + if (a==NULL) *nextstring++ = 0; + else { sav = *a; + *a = 0; + (void) newstring(s); + *a = sav; + s = a; } return newstring(s); } @@ -134,27 +106,27 @@ void includechars(fontdesctype *f, char *s) { - int b, c, d ; - int l = strlen(s) ; + int b, c, d; + int l = strlen(s); while (l > 0 && (s[l-1] == '\n' || s[l-1] == '\r')) - s[--l] = 0 ; + s[--l] = 0; if (!ISXDIGIT(s[0]) || !ISXDIGIT(s[1]) || s[2]!=':' || strspn(s+3,"0123456789ABCDEFabcdef") < l-3) { - fprintf(stderr, "%s\n", s) ; - error("Bad syntax in included font usage table") ; - return ; + fprintf(stderr, "%s\n", s); + error("Bad syntax in included font usage table"); + return; } - c = (xdig[(int)(s[0])] << 4) + xdig[(int)(s[1])] ; - s += 2 ; + c = (xdig[(int)(s[0])] << 4) + xdig[(int)(s[1])]; + s += 2; while (*++s) { - d = xdig[(int)*s] ; + d = xdig[(int)*s]; for (b=8; b!=0; b>>=1) { if ((d&b)!=0) { - pagecost ++ ; - (void) prescanchar(&f->chardesc[c]) ; + pagecost ++; + (void) prescanchar(&f->chardesc[c]); } - if (++c==256) return ; + if (++c==256) return; } } } @@ -186,13 +158,13 @@ DVIperBP = actualdpi/(72.0*conv) * (mag/1000.0); p = strtok(p, " "); if (p==NULL) return; - area = nextstring ; /* tentatively in the string pool */ + area = nextstring; /* tentatively in the string pool */ name = getname(p); q = strtok((char *)0, " "); if (p==NULL || (scsize=(integer)(atof(q)*DVIperBP))==0) { fprintf(stderr, "%s\n",p); error("No scaled size for included font"); - nextstring = area ; /* remove from string pool */ + nextstring = area; /* remove from string pool */ return; } scname = q; @@ -200,7 +172,7 @@ if (p==NULL || (dssize=(integer)(atof(q)*DVIperBP))==0) { fprintf(stderr, "%s\n",p); error("No design size for included font"); - nextstring = area ; + nextstring = area; return; } q = strtok((char *)0, " "); @@ -250,7 +222,7 @@ * is added with add_header. */ void -scan_fontnames(char *str, char *psfile) +scan_fontnames(char *str, const char *psfile) { char *p,*pe; struct resfont *re; @@ -290,31 +262,31 @@ if(re != NULL) { if (re->sent != 2) { if (re->Fontfile) { - add_header(re->Fontfile) ; + add_header(re->Fontfile); } else if (re->downloadheader) { /* this code borrowed from residentfont() in resident.c */ - char *cp = re->downloadheader ; - char *q ; + char *cp = re->downloadheader; + char *q; - infont = re->PSname ; + infont = re->PSname; while (1) { - q = cp ; + q = cp; while (*cp && *cp != ' ') - cp++ ; + cp++; if (*cp) { - *cp = 0 ; - add_header(q) ; - *cp++ = ' ' ; + *cp = 0; + add_header(q); + *cp++ = ' '; } else { - add_header(q) ; - break ; + add_header(q); + break; } - infont = 0 ; + infont = 0; } } - infont = 0 ; + infont = 0; } - re->sent = 2 ; + re->sent = 2; if (unused_top_of_psnames < DOWNLOADEDPSSIZE) { downloadedpsnames[unused_top_of_psnames] = xstrdup (re->PSname); unused_top_of_psnames++; @@ -349,12 +321,12 @@ static int check_atend = 0; void -scanfontusage(char *p, char *psfile) +scanfontusage(char *p, const char *psfile) { if (strncmp(p, "%%DocumentFonts: ",17) == 0) { - p += 17 ; + p += 17; while (*p && *p <= ' ') - p++ ; + p++; if(!strncmp(p,"(atend)",7)) { check_atend = 1; } else { @@ -362,9 +334,9 @@ fc_state = 1; } } else if (strncmp(p, "%%DocumentNeededFonts: ",23)==0) { - p += 23 ; + p += 23; while (*p && *p <= ' ') - p++ ; + p++; if(!strncmp(p,"(atend)",7)) { check_atend = 1; } else { @@ -375,9 +347,9 @@ scan_fontnames(p+3,psfile); fc_state = 1; } else if (strncmp(p, "%%DocumentNeededResources: ",27) == 0) { - p += 27 ; + p += 27; while (*p && *p <= ' ') - p++ ; + p++; if(!strncmp(p,"(atend)",7)) { check_atend = 1; } else { @@ -385,9 +357,9 @@ fc_state = 2; } } else if (fc_state == 2 && strncmp(p,"%%+",3) == 0) { - p += 3 ; + p += 3; while (*p && *p <= ' ') - p++ ; + p++; if(!strncmp(p,"font ",5)) scan_fontnames(p+5,psfile); fc_state = 2; } else { @@ -401,13 +373,13 @@ * usage specifications. This does not handle the "atend" construction. */ void -scanfontcomments(char *filename) +scanfontcomments(const char *filename) { char p[500]; char *r; FILE *f; - integer truecost = pagecost ; - Boolean trueknown = 0 ; + integer truecost = pagecost; + Boolean trueknown = 0; fontdesctype *oldcf = curfnt; #ifdef DEBUG @@ -420,13 +392,13 @@ /* * Allow scanning of ` commands. Better return same results both times. */ - f = popen(filename+1, "r") ; - to_close = USE_PCLOSE ; + f = popen(filename+1, "r"); + to_close = USE_PCLOSE; } else { - f = search(figpath, filename, READ) ; + f = search(figpath, filename, READ); } if (f) { - (void)SET_BINARY(fileno(f)) ; + (void)SET_BINARY(fileno(f)); fc_state = 0; check_atend = 0; while (fgets(p,500,f) && p[0]=='%' && @@ -434,13 +406,13 @@ if (strncmp(p, "%*Font:", 7) == 0) { scan1fontcomment(p+7); } else if (strncmp(p, "%%VMusage:", 9) == 0) { - truecost += scanvm(p+10) ; - trueknown = 1 ; + truecost += scanvm(p+10); + trueknown = 1; } scanfontusage(p,filename); } if (trueknown) - pagecost = truecost ; + pagecost = truecost; if(check_atend) { #ifdef DEBUG @@ -455,7 +427,7 @@ fgets(p,500,f); /* throw away a partial line. */ /* find %%Trailer */ - while((r=fgets(p,500,f)) && strncmp(p,"%%Trailer",9)) ; + while((r=fgets(p,500,f)) && strncmp(p,"%%Trailer",9)); /* look for specs that were deferred to the trailer. */ if(r != NULL) { @@ -472,7 +444,7 @@ } #endif /* DEBUG */ } - close_file(f) ; + close_file(f); } curfnt = oldcf; } @@ -483,13 +455,13 @@ Boolean okascmd(char *ss) { - register int c = 0 ; - register char *s = ss ; + register int c = 0; + register char *s = ss; while (*s) if (*s<' ' || *s>126 || ++c==30) - return(0) ; - return(strcspn(ss,"()<>[]{}%/") == c) ; + return(0); + return(strcspn(ss,"()<>[]{}%/") == c); } /* * Output font area and font name strings as a literal string @@ -497,19 +469,19 @@ void nameout(char *area, char *name) { - char buf[30] ; - char *s ; + char buf[30]; + char *s; if (*area==0 && okascmd(name)) { - (void)sprintf(buf, "/%s", name) ; + (void)sprintf(buf, "/%s", name); cmdout(name); } else { for (s=area; *s; s++) - scout(*s) ; + scout(*s); for (s=name; *s; s++) - scout(*s) ; + scout(*s); stringend(); - cmdout("cvn") ; + cmdout("cvn"); } } /* diff -Nu dvipsk2009/flib.c dvipsk/flib.c --- dvipsk2009/flib.c Tue Jun 23 18:46:14 2009 +++ dvipsk/flib.c Mon Mar 29 23:28:47 2010 @@ -6,12 +6,11 @@ #ifdef FONTLIB #include "dvips.h" /* The copyright notice in that file is included too! */ #include "paths.h" -#include "protos.h" -extern int debug_flag ; -extern char errbuf[] ; -extern char *flipath ; -extern char *fliname ; -extern FILE *pkfile ; +/* + * The external declarations: + */ +#include "protos_add.h" + /* * font library structures */ @@ -48,12 +47,11 @@ halfword pkdouble(void) { - register halfword i ; - i = pkbyte() ; - i = i * 256 + pkbyte() ; - return(i) ; + register halfword i; + i = pkbyte(); + i = i * 256 + pkbyte(); + return(i); } -extern char name[] ; /* * fliload opens each font library, then reads in its * directory for later use. @@ -62,15 +60,15 @@ void fliload(void) { - int i ; + int i; halfword version1, version2; Boolean needext; char fontname[50]; - char name[50] ; + char name[50]; char *fli; unsigned long dpi; halfword len, numsizes, numfonts; - halfword numflib = 0 ; + halfword numflib = 0; struct fli_lib *lib=NULL, *next_lib=NULL; struct fli_size *size; struct fli_entry *entry; @@ -138,7 +136,7 @@ lib->size = size; lib->next = (struct fli_lib *)NULL; - for ( ;numsizes>0; numsizes--, size++) { + for (;numsizes>0; numsizes--, size++) { /* for each font size in this library */ (void)pkdouble(); /* length of size entry - ignore */ numfonts = pkdouble(); /* number of fonts */ @@ -149,10 +147,10 @@ (void)fprintf(stderr,"Font library %s size %.5gdpi has %d font%s\n", name, dpi/65536.0, numfonts, numfonts!=1 ? "s" : ""); #endif /* DEBUG */ - size->size = dpi ; - size->entries = numfonts ; - size->entry = entry ; - for ( ;numfonts > 0; numfonts--, entry++) { + size->size = dpi; + size->entries = numfonts; + size->entry = entry; + for (;numfonts > 0; numfonts--, entry++) { /* read each entry */ (void)pkquad(); /* ignore length of font */ entry->offset = pkquad(); /* offset to font */ @@ -206,23 +204,23 @@ #endif /* DEBUG */ for (lib = firstlib; lib != (struct fli_lib *)NULL; lib = lib->next ) { /* for each font library */ - numsizes = lib->sizes ; - size = lib->size ; + numsizes = lib->sizes; + size = lib->size; #ifdef DEBUG if (dd(D_FONTS)) (void)fprintf(stderr," Searching %s\n", lib->name); #endif /* DEBUG */ for (; numsizes>0; numsizes--, size++) { /* for each font size in this library */ - dpi1 = (halfword)((size->size+32768L)/65536) ; + dpi1 = (halfword)((size->size+32768L)/65536); if ( dpi1 == dpi ) { /* if correct size then search for font */ #ifdef DEBUG if (dd(D_FONTS)) (void)fprintf(stderr, " Checking size %ddpi\n",dpi1); #endif /* DEBUG */ - entry = size->entry ; - for (numfonts=size->entries ;numfonts > 0; numfonts--, entry++) { + entry = size->entry; + for (numfonts=size->entries;numfonts > 0; numfonts--, entry++) { if (strcmp(entry->name,n)==0) { /* if correct font name then look for it in cache */ found = 0; @@ -253,9 +251,9 @@ fli_cache[0]->lib = lib; fli_cache[0]->fp = pkfile; } - flib = 1 ; /* tell loadfont() not to close it */ + flib = 1; /* tell loadfont() not to close it */ /* then seek font within library */ - (void)sprintf(name,"%s %s %ddpi",lib->name, n, dpi1) ; + (void)sprintf(name,"%s %s %ddpi",lib->name, n, dpi1); if ( fseek(pkfile,entry->offset,0) ) badpk("couldn't seek font"); /* make sure it is a PK font */ @@ -290,43 +288,43 @@ char * fliparse(char *path, char *name) { - char *p, *prevp ; /* pointers to path */ - char *n, *prevn ; /* pointers to name */ - char *s ; - - p = path ; - n = name ; - s = path ; + char *p, *prevp; /* pointers to path */ + char *n, *prevn; /* pointers to name */ + char *s; + + p = path; + n = name; + s = path; while (*s) { - prevp = p ; - prevn = n ; + prevp = p; + prevn = n; while (*s && *s != PATHSEP) { /* copy till PATHSEP */ *p++ = *s; *n++ = *s; s++; } - *n = '\0' ; + *n = '\0'; if (*s) s++; /* skip PATHSEP */ if ( *prevn=='\0' || prevn[strlen(prevn)-1] == DIRSEP ) { - n = prevn ; /* ignore name if it is dir */ + n = prevn; /* ignore name if it is dir */ if (*prevn) p--; /* backup over DIRSEP */ *p++ = PATHSEP; - prevp = p ; + prevp = p; } else { - p = prevp ; /* ignore path if it is library name */ + p = prevp; /* ignore path if it is library name */ *n++ = PATHSEP; - prevn = n ; + prevn = n; } } - *p = '\0' ; - *n = '\0' ; + *p = '\0'; + *n = '\0'; if (n!=name && *--n==PATHSEP) *n = '\0'; /* remove trailing PATHSEP from name */ if (p!=path && *--p==PATHSEP) diff -Nu dvipsk2009/fontdef.c dvipsk/fontdef.c --- dvipsk2009/fontdef.c Tue Jun 23 18:46:14 2009 +++ dvipsk/fontdef.c Mon Mar 29 23:28:58 2010 @@ -9,79 +9,69 @@ #endif /* - * These are the external routines we call. + * The external declarations: */ #include "protos.h" /* - * The external variables we use: - */ -extern char *nextstring, *maxstring ; -extern double mag ; -#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 ; -/* * newfontdesc creates a new font descriptor with the given parameters and * returns a pointer to the new object. */ fontdesctype* newfontdesc(integer cksum, integer scsize, integer dssize, - char *name, char *area) + char *name, char *area) { - register fontdesctype *fp ; + register fontdesctype *fp; - fp = (fontdesctype *)mymalloc((integer)sizeof(fontdesctype)) ; - fp->chardesc = (chardesctype *)mymalloc(256*(integer)sizeof(chardesctype)) ; - fp->maxchars = 256 ; - fp->psname = 0 ; - fp->loaded = 0 ; - fp->checksum = cksum ; - fp->scaledsize = scsize ; - fp->designsize = dssize ; - fp->thinspace = scsize / 6 ; - fp->scalename = NULL ; - fp->psflag = 0 ; - fp->codewidth = 1 ; + fp = (fontdesctype *)mymalloc((integer)sizeof(fontdesctype)); + fp->chardesc = (chardesctype *)mymalloc(256*(integer)sizeof(chardesctype)); + fp->maxchars = 256; + fp->iswide = 0; + fp->psname = 0; + fp->loaded = 0; + fp->checksum = cksum; + fp->scaledsize = scsize; + fp->designsize = dssize; + fp->thinspace = scsize / 6; + fp->scalename = NULL; + fp->psflag = 0; + fp->codewidth = 1; fp->name = name; #ifdef VMCMS /* IBM: VM/CMS */ { - int i ; - for ( i=0 ; fp->name[i] ; i++ ) - fp->name[i] = ascii2ebcdic[ fp->name[i] ] ; + int i; + for ( i=0; fp->name[i]; i++ ) + fp->name[i] = ascii2ebcdic[ fp->name[i] ]; } #else #ifdef MVSXA /* IBM: MVS/XA */ { - int i ; - for ( i=0 ; fp->name[i] ; i++ ) - fp->name[i] = ascii2ebcdic[ fp->name[i] ] ; + int i; + for ( i=0; fp->name[i]; i++ ) + fp->name[i] = ascii2ebcdic[ fp->name[i] ]; } #endif /* IBM: MVS/XA */ #endif /* IBM: VM/CMS */ fp->area = area; - fp->resfont = NULL ; - fp->localfonts = NULL ; + fp->resfont = NULL; + fp->localfonts = NULL; #ifdef KPATHSEA fp->dpi = kpse_magstep_fix ((halfword)(mag*(float)fp->scaledsize*DPI/ - ((float)fp->designsize*1000.0)+0.5), DPI, NULL) ; + ((float)fp->designsize*1000.0)+0.5), DPI, NULL); #else fp->dpi = dpicheck((halfword)(mag*fp->scaledsize*DPI/ - ((float)fp->designsize*1000.0)+0.5)) ; + ((float)fp->designsize*1000.0)+0.5)); +#endif + fp->loadeddpi = fp->dpi; +#ifdef VFLIB + fp->vflib = false; #endif - fp->loadeddpi = fp->dpi ; #ifdef DEBUG if (dd(D_FONTS)) (void)fprintf(stderr,"Defining font (%s) %s at %.1fpt\n", - area, name, (real)scsize/(alpha*0x100000)) ; + area, name, (real)scsize/(alpha*0x100000)); #endif /* DEBUG */ - return fp ; + return fp; } /* * Try to find a font with a given name and approximate scaled size, returning @@ -97,22 +87,22 @@ register fontdesctype *fp; register integer smin, smax; - smin = scsize - fsizetol ; - smax = scsize + fsizetol ; + smin = scsize - fsizetol; + smax = scsize + fsizetol; for (fp=fonthead; fp; fp=fp->next) if (smin < fp->scaledsize && fp->scaledsize < smax && strcmp(name,fp->name)==0 && strcmp(area,fp->area)==0) { if (scname == NULL) { if (fp->scalename!=NULL || scsize==fp->scaledsize) - break ; + break; } else { if (fp->scalename==NULL || strcmp(scname,fp->scalename)==0) - break ; + break; } } #ifdef DEBUG if (dd(D_FONTS) && fp) - (void)fprintf(stderr,"(Already known.)\n") ; + (void)fprintf(stderr,"(Already known.)\n"); #endif /* DEBUG */ return fp; } @@ -123,53 +113,52 @@ void fontdef(int siz) { - register integer i, j, fn ; - register fontdesctype *fp ; - register fontmaptype *cfnt ; - char *name, *area ; - integer cksum, scsize, dssize ; - extern void skipover(int) ; + register integer i, j, fn; + register fontdesctype *fp; + register fontmaptype *cfnt; + char *name, *area; + integer cksum, scsize, dssize; - fn = dvibyte() ; + fn = dvibyte(); while (siz-- > 1) - fn = (fn << 8) + dvibyte() ; + fn = (fn << 8) + dvibyte(); for (cfnt=ffont; cfnt; cfnt = cfnt->next) - if (cfnt->fontnum == fn) goto alreadydefined ; - cfnt = (fontmaptype *)mymalloc((integer)sizeof(fontmaptype)) ; - cfnt->next = ffont ; - ffont = cfnt ; - cfnt->fontnum = fn ; - cksum = signedquad() ; - scsize = signedquad() ; - dssize = signedquad() ; - i = dvibyte() ; j = dvibyte() ; + if (cfnt->fontnum == fn) goto alreadydefined; + cfnt = (fontmaptype *)mymalloc((integer)sizeof(fontmaptype)); + cfnt->next = ffont; + ffont = cfnt; + cfnt->fontnum = fn; + cksum = signedquad(); + scsize = signedquad(); + dssize = signedquad(); + i = dvibyte(); j = dvibyte(); if (nextstring + i + j > maxstring) - error("! out of string space") ; - area = nextstring ; + error("! out of string space"); + area = nextstring; for (; i>0; i--) - *nextstring++ = dvibyte() ; - *nextstring++ = 0 ; - name = nextstring ; + *nextstring++ = dvibyte(); + *nextstring++ = 0; + name = nextstring; for (; j>0; j--) - *nextstring++ = dvibyte() ; - *nextstring++ = 0 ; - fp = matchfont(name, area, scsize, (char *)0) ; + *nextstring++ = dvibyte(); + *nextstring++ = 0; + fp = matchfont(name, area, scsize, (char *)0); if (fp) { - nextstring = name ; - fp->checksum = cksum ; + nextstring = name; + fp->checksum = cksum; } else { - fp = newfontdesc(cksum, scsize, dssize, name, area) ; - fp->next = fonthead ; - fonthead = fp ; + fp = newfontdesc(cksum, scsize, dssize, name, area); + fp->next = fonthead; + fonthead = fp; } - cfnt->desc = fp ; - return ; + cfnt->desc = fp; + return; alreadydefined: /* A DVI file will not define a font twice; but we may be scanning * a font definition twice because a new section has started, * or because of collated copies. */ - skipover(12) ; - skipover(dvibyte()+dvibyte()) ; + skipover(12); + skipover(dvibyte()+dvibyte()); } /* @@ -181,17 +170,17 @@ int skipnop(void) { - register int cmd ; + register int cmd; while (1) { switch(cmd=dvibyte()) { -case 138: break ; -case 239: skipover((int)dvibyte()) ; break ; /* xxx1 */ -case 240: skipover((int)twobytes()) ; break ; /* xxx2 */ -case 241: skipover((int)threebytes()) ; break ; /* xxx3 */ -case 242: skipover((int)signedquad()) ; break ; /* xxx4 */ -case 243: case 244: case 245: case 246: fontdef(cmd-242) ; break ; -default: return cmd ; +case 138: break; +case 239: skipover((int)dvibyte()); break; /* xxx1 */ +case 240: skipover((int)twobytes()); break; /* xxx2 */ +case 241: skipover((int)threebytes()); break; /* xxx3 */ +case 242: skipover((int)signedquad()); break; /* xxx4 */ +case 243: case 244: case 245: case 246: fontdef(cmd-242); break; +default: return cmd; } } } diff -Nu dvipsk2009/header.c dvipsk/header.c --- dvipsk2009/header.c Tue Jun 23 18:46:14 2009 +++ dvipsk/header.c Mon Mar 29 23:29:07 2010 @@ -12,28 +12,14 @@ * headers down. */ #include "dvips.h" /* The copyright notice in that file is included too! */ -struct header_list *header_head ; +struct header_list *header_head; /* - * The external routines we use. + * The external declarations: */ #include "protos.h" -extern char errbuf[] ; -extern integer fontmem, swmem ; -#ifndef KPATHSEA -extern char *headerpath ; -#endif -extern char *infont ; -extern int headersready ; -#ifdef DEBUG -extern integer debug_flag ; -#endif -#ifdef HPS -extern Boolean noprocset ; -extern Boolean HPS_FLAG ; -#endif int -add_name(char *s, struct header_list **what) +add_name(const char *s, struct header_list **what) { return (int) add_name_general (s, what, NULL, NULL); } @@ -43,27 +29,27 @@ * names. */ int -add_name_general(char *s, struct header_list **what, char *pre, char *post) +add_name_general(const char *s, struct header_list **what, char *pre, char *post) { - struct header_list *p, *q ; + struct header_list *p, *q; - for (p = *what ; p != NULL; p = p->next) + for (p = *what; p != NULL; p = p->next) if (strcmp(p->name, s)==0) - return 0 ; + return 0; q = (struct header_list *)mymalloc((integer)(sizeof(struct header_list) - + strlen(s))) ; - q->Hname = infont ; - q->next = NULL ; - q->precode = pre ; - q->postcode = post ; - strcpy(q->name, s) ; + + strlen(s))); + q->Hname = infont; + q->next = NULL; + q->precode = pre; + q->postcode = post; + strcpy(q->name, s); if (*what == NULL) - *what = q ; + *what = q; else { - for (p = *what; p->next != NULL; p = p->next) ; - p->next = q ; + for (p = *what; p->next != NULL; p = p->next); + p->next = q; } - return 1 ; + return 1; } /* * This function checks the virtual memory usage of a header file. @@ -71,48 +57,53 @@ * length of the file. */ void -checkhmem(char *s, char *pre, char *post) +checkhmem(const char *s, char *pre, char *post) { - FILE *f ; + FILE *f; - f = search(headerpath, s, READBIN) ; + f = search(headerpath, s, READBIN); if (pre || post) { if (f==NULL) - f = search(figpath, s, READBIN) ; + f = search(figpath, s, READBIN); } if (f==0) { - (void)sprintf(errbuf, "! Couldn't find header file %s.\nNote that an absolute path or a relative path with .. are denied in -R2 mode.", s) ; - error(errbuf) ; + char *msg = concat ("! Couldn't find header file: ", s); + + if (secure == 2) { + msg = concat (msg, + "\nAbsolute and ../relative paths are denied in -R2 mode."); + } + error(msg); } else { - int len, i, j ; - long mem = -1 ; - char buf[1024] ; + int len, i, j; + long mem = -1; + char buf[1024]; - len = fread(buf, sizeof(char), 1024, f) ; + len = fread(buf, sizeof(char), 1024, f); for (i=0; i 0) { - mem += len ; - len = fread(buf, sizeof(char), 1024, f) ; + mem += len; + len = fread(buf, sizeof(char), 1024, f); } } if (mem < 0) - mem = DNFONTCOST ; - (*close_file) (f) ; + mem = DNFONTCOST; + (*close_file) (f); #ifdef DEBUG if (dd(D_HEADER)) (void)fprintf(stderr, "Adding header file \"%s\" %ld\n", - s, mem) ; + s, mem); #endif - fontmem -= mem ; + fontmem -= mem; if (fontmem > 0) /* so we don't count it twice. */ - swmem -= mem ; + swmem -= mem; } } /* @@ -121,67 +112,67 @@ * use that; otherwise, we use the length of the file. */ int -add_header(char *s) +add_header(const char *s) { return (int) add_header_general (s, NULL, NULL); } int -add_header_general(char *s, char *pre, char *post) +add_header_general(const char *s, char *pre, char *post) { - int r ; + int r; - r = add_name_general(s, &header_head, pre, post) ; + r = add_name_general(s, &header_head, pre, post); if (r) { if (headersready == 1) { - struct header_list *p = header_head ; + struct header_list *p = header_head; while (p) { - checkhmem(p->name, p->precode, p->postcode) ; - p = p->next ; + checkhmem(p->name, p->precode, p->postcode); + p = p->next; } - headersready = 2 ; + headersready = 2; } else if (headersready == 2) { - checkhmem(s, pre, post) ; + checkhmem(s, pre, post); } } - return r ; + return r; } /* * This routine runs down a list, returning each in order. */ -static struct header_list *CUR_head = NULL ; +static struct header_list *CUR_head = NULL; char * get_name(struct header_list **what) { if (what && *what) { - char *p = (*what)->name ; - infont = (*what)->Hname ; - CUR_head = *what ; - *what = (*what)->next ; - return p ; + char *p = (*what)->name; + infont = (*what)->Hname; + CUR_head = *what; + *what = (*what)->next; + return p; } else - return 0 ; + return 0; } /* * This routine actually sends the headers. */ void send_headers(void) { - struct header_list *p = header_head ; - char *q ; + struct header_list *p = header_head; + char *q; while (0 != (q=get_name(&p))) { #ifdef DEBUG if (dd(D_HEADER)) - (void)fprintf(stderr, "Sending header file \"%s\"\n", q) ; + (void)fprintf(stderr, "Sending header file \"%s\"\n", q); #endif #ifdef HPS if (HPS_FLAG) { - if (strcmp(q,"target.dct")==0) noprocset = 1 ; + if (strcmp(q,"target.dct")==0) noprocset = 1; } #endif - copyfile_general(q, CUR_head) ; + copyfile_general(q, CUR_head); } - infont = 0 ; + infont = NULL; } diff -Nu dvipsk2009/hps.c dvipsk/hps.c --- dvipsk2009/hps.c Tue Jun 23 18:46:14 2009 +++ dvipsk/hps.c Mon Mar 29 23:29:16 2010 @@ -4,6 +4,12 @@ * your heart's content. */ #include "dvips.h" + +/* + * The external declarations: + */ +#include "protos.h" + #ifdef HPS #include #ifdef KPATHSEA @@ -22,21 +28,19 @@ #endif #define NAME 0 #define HREF 1 -#define skip_space(s) for( ; *s == ' ' ; s++) ; +#define skip_space(s) for(; *s == ' '; s++); -Boolean inHTMLregion = 0 ; -Boolean NO_ERROR = 1 ; -Boolean HPS_ERROR = 0 ; -integer HREF_COUNT ; -Boolean ISHREF = 0 ; -Boolean POPPED = 0 ; -Boolean PUSHED = 0 ; - -char *current_name ; -int current_type ; -int current_pushcount ; -extern integer pushcount ; -extern shalfword linepos ; +Boolean inHTMLregion = 0; +Boolean NO_ERROR = 1; +Boolean HPS_ERROR = 0; +integer HREF_COUNT; +Boolean ISHREF = 0; +Boolean POPPED = 0; +Boolean PUSHED = 0; + +char *current_name; +int current_type; +int current_pushcount; #define GoTo 0 @@ -44,55 +48,48 @@ #define Launch 2 typedef struct rectangle { - double llx ; /* lower left x coor */ - double lly ; /* lower left y coor */ - double urx ; /* upper right x coor */ - double ury ; /* upper right y coor */ - } dvipsRectangle ; + double llx; /* lower left x coor */ + double lly; /* lower left y coor */ + double urx; /* upper right x coor */ + double ury; /* upper right y coor */ + } dvipsRectangle; typedef struct hps_link { - int action ; /* GoTo, GoToR, or Launch */ - char *file ; /* PDF-style system-independent filename - unused now */ - dvipsRectangle rect ; /* rectangle for location of link */ - int border[5] ; /* Border info --- with dashes*/ - int srcpg ; /* Page of location */ - int page ; /* Page of destination --- left out is same as srcpg */ - int vert_dest ; /* Vertical position of destination on page */ - double color[3] ; /* color: length of array gives colorspace (3 <=> RGB)*/ - char *title ; /* Title of link */ - } Hps_link ; + int action; /* GoTo, GoToR, or Launch */ + char *file; /* PDF-style system-independent filename - unused now */ + dvipsRectangle rect; /* rectangle for location of link */ + int border[5]; /* Border info --- with dashes*/ + int srcpg; /* Page of location */ + int page; /* Page of destination --- left out is same as srcpg */ + int vert_dest; /* Vertical position of destination on page */ + double color[3]; /* color: length of array gives colorspace (3 <=> RGB)*/ + char *title; /* Title of link */ + } Hps_link; struct nlist { /* hashtable entry */ - struct nlist *next ; /* next entry in chain */ - char *name ; /* defined name */ - Hps_link *defn ; /* Link associated with name */ - } ; + struct nlist *next; /* next entry in chain */ + char *name; /* defined name */ + Hps_link *defn; /* Link associated with name */ + }; typedef struct rect_list { /* linked list of rectangles */ - struct rect_list *next ; /* next rectangle in the chain */ - dvipsRectangle rect ; - } Rect_list ; + struct rect_list *next; /* next rectangle in the chain */ + dvipsRectangle rect; + } Rect_list; -Rect_list *current_rect_list ; +Rect_list *current_rect_list; #define HASHSIZE 1223 -static struct nlist *link_targets[HASHSIZE] ; /* names .... */ -static struct nlist *link_sources[HASHSIZE] ; /* hrefs .... */ +static struct nlist *link_targets[HASHSIZE]; /* names .... */ +static struct nlist *link_sources[HASHSIZE]; /* hrefs .... */ #ifdef KPATHSEA #define dup_str xstrdup #else -char *dup_str() ; /* duplicate a string */ +char *dup_str(); /* duplicate a string */ #endif -#include "protos.h" - -extern Boolean removecomments ; -Boolean noprocset ; /* Leave out BeginProc and EndProc comments */ -extern int vactualdpi ; -extern int pagecounter ; -extern integer hhmem, vvmem ; -extern integer vpapersize ; +Boolean noprocset; /* Leave out BeginProc and EndProc comments */ /* This was hardcoded to letter size. The denominator converts scaled points to big points (65536*72.27/72). */ #undef PAGESIZE /* HP-UX 10 defines for itself. */ @@ -104,71 +101,64 @@ /* For later use * static char *dest_key[9] = {"Fit", "FitB", "FitW", "FitH", "FitBH" - "FitR", "FitV", "FitBV", "XYZ"} ; + "FitR", "FitV", "FitBV", "XYZ"}; */ -extern FILE *bitfile ; -extern char *oname ; - -extern integer pagenum ; -extern integer hh ; -extern integer vv ; - -char *hs = NULL ; /* html string to be handled */ -char *url_name = NULL ; /* url between double quotes */ +char *hs = NULL; /* html string to be handled */ +char *url_name = NULL; /* url between double quotes */ /* parse anchor into link */ void do_html(char *s) { - Hps_link *nl ; - url_name = (char *)malloc(strlen(s)+1) ; - hs = s ; - HREF_COUNT = 0 ; - skip_space(hs) ; /* skip spaces */ + Hps_link *nl; + url_name = (char *)malloc(strlen(s)+1); + hs = s; + HREF_COUNT = 0; + skip_space(hs); /* skip spaces */ if ( TOLOWER(*hs) == 'a') { /* valid start */ - POPPED = FALSE ; + POPPED = FALSE; if (inHTMLregion) { error("previous html not closed with /A"); return; } else { - inHTMLregion = TRUE ; - current_rect_list = NULL ; + inHTMLregion = TRUE; + current_rect_list = NULL; } - hs++ ; - skip_space(hs) ; + hs++; + skip_space(hs); while(*hs != '\0') { /* parse for names and href */ if (!href_or_name()) { - error("Bad HMTL:") ; - error(s) ; - error("!") ; - break ; + error("Bad HMTL:"); + error(s); + error("!"); + break; } - skip_space(hs) ; + skip_space(hs); } } else if ( (*hs == '/') && (TOLOWER(hs[1]) == 'a') ) { if (!inHTMLregion) { - error("In html, /A found without previous A") ; + error("In html, /A found without previous A"); return; } else { - inHTMLregion = FALSE ; + inHTMLregion = FALSE; } if (current_type == HREF && current_name[0] != '#') { if ((nl = lookup_link(current_name, current_type)->defn)) { - nl->rect.urx = dvi_to_hps_conv(hh, HORIZONTAL) ; - nl->rect.ury = dvi_to_hps_conv(vv, VERTICAL)-FUDGE+12.0 ; + nl->rect.urx = dvi_to_hps_conv(hh, HORIZONTAL); + nl->rect.ury = dvi_to_hps_conv(vv, VERTICAL)-FUDGE+12.0; stamp_external(current_name,nl); /* Broken lines ? */ } else { error("!Null lookup"); } } else { if ((nl = lookup_link(current_name, current_type)->defn)) { - nl->rect.urx = dvi_to_hps_conv(hh, HORIZONTAL) ; - nl->rect.ury = dvi_to_hps_conv(vv, VERTICAL)-FUDGE+12.0 ; + nl->rect.urx = dvi_to_hps_conv(hh, HORIZONTAL); + nl->rect.ury = dvi_to_hps_conv(vv, VERTICAL)-FUDGE+12.0; if (current_type) { - stamp_hps(nl) ; /* Put link info right where special is */ - print_rect_list() ; /* print out rectangles */ + stamp_hps(nl); /* Put link info right where special is */ + print_rect_list(); /* print out rectangles */ } } else { error("!Null lookup"); @@ -176,71 +166,71 @@ } } else { - error( "No A in html special") ; - error(s) ; - /*error("!") ;*/ + error( "No A in html special"); + error(s); + /*error("!");*/ } - return ; + return; } int href_or_name(void) { if ((strncmp(hs, "href", 4) == 0) || (strncmp(hs, "HREF", 4) == 0)) { - ISHREF = TRUE ; + ISHREF = TRUE; } else if ((strncmp(hs, "name", 4) == 0) || (strncmp(hs, "NAME", 4) == 0)) { - ISHREF = FALSE ; + ISHREF = FALSE; } else { - error("Not valid href or name html reference") ; - return(HPS_ERROR) ; + error("Not valid href or name html reference"); + return(HPS_ERROR); } - if(!parseref()) return(HPS_ERROR) ; + if(!parseref()) return(HPS_ERROR); if (url_name) { if( ISHREF ) { - do_link(url_name, HREF) ; - } else do_link(url_name, NAME) ; + do_link(url_name, HREF); + } else do_link(url_name, NAME); } else { - error("No string in qoutes ") ; - return(HPS_ERROR) ; + error("No string in qoutes "); + return(HPS_ERROR); } - return(NO_ERROR) ; + return(NO_ERROR); } int parseref(void) { - int i = 0 ; - for(i=0 ; i++ < 4 ; hs++) ; /* skip href or name in html string */ - skip_space(hs) ; + int i = 0; + for(i=0; i++ < 4; hs++); /* skip href or name in html string */ + skip_space(hs); if (*hs == '=' ) { - hs++ ; + hs++; } else { - error("No equal sign") ; - return(HPS_ERROR) ; + error("No equal sign"); + return(HPS_ERROR); } - if(!get_string()) return(HPS_ERROR) ; - return(NO_ERROR) ; /* extract stuff between double quotes */ + if(!get_string()) return(HPS_ERROR); + return(NO_ERROR); /* extract stuff between double quotes */ } int get_string(void) { - char *v = url_name ; + char *v = url_name; - skip_space(hs) ; - /* hash_name() ; */ + skip_space(hs); + /* hash_name(); */ if (*hs == '"') { - for(hs++ ; *hs != '"' && *hs != '\0' ; *v++ = *hs++) ; /* need to esc " */ + for(hs++; *hs != '"' && *hs != '\0'; *v++ = *hs++); /* need to esc " */ if(*hs == '"') { - hs++ ; - *v++ = '\0' ; - return(NO_ERROR) ; + hs++; + *v++ = '\0'; + return(NO_ERROR); } else { - error("Improper href. Missing closing double quote") ; - return(HPS_ERROR) ; + error("Improper href. Missing closing double quote"); + return(HPS_ERROR); } } else { - error("Improper href. Missing opening double quote") ; - return(HPS_ERROR) ; + error("Improper href. Missing opening double quote"); + return(HPS_ERROR); } } @@ -248,47 +238,47 @@ do_link(char *s, int type) { - Hps_link *p ; + Hps_link *p; if (HREF_COUNT++ > 0) { - error("!HTML string contains more than one href") ; - return(HPS_ERROR) ; + error("!HTML string contains more than one href"); + return(HPS_ERROR); } - p = (Hps_link *)malloc(sizeof(*p)) ; - p->action = GoTo ; - p->title = (char *)malloc(strlen(s)+1) ; - p->title = s ; - p->srcpg = pagecounter ; - p->rect.llx = dvi_to_hps_conv(hh, HORIZONTAL) ; - p->rect.lly = dvi_to_hps_conv(vv, VERTICAL)-FUDGE ; - p->rect.urx = -1.0 ; - p->rect.ury = -1.0 ; - p->vert_dest = -1 ; - p->page = -1 ; - p->color[0] = 0 ; - p->color[1] = 0 ; /* Blue links */ - p->color[2] = 1 ; - p->border[0] = 1 ; /* horizontal corner radius */ - p->border[1] = 1 ; /* vertical corner radius */ - p->border[2] = 1 ; /* box line width */ - p->border[3] = 3 ; /* dash on size */ - p->border[4] = 3 ; /* dash off size */ - - current_name = (char *)malloc(strlen(s)+1) ; - current_name = s ; - current_type = type ; - current_pushcount = pushcount ; - install_link(s, p, type) ; - return(NO_ERROR) ; + p = (Hps_link *)malloc(sizeof(*p)); + p->action = GoTo; + p->title = (char *)malloc(strlen(s)+1); + p->title = s; + p->srcpg = pagecounter; + p->rect.llx = dvi_to_hps_conv(hh, HORIZONTAL); + p->rect.lly = dvi_to_hps_conv(vv, VERTICAL)-FUDGE; + p->rect.urx = -1.0; + p->rect.ury = -1.0; + p->vert_dest = -1; + p->page = -1; + p->color[0] = 0; + p->color[1] = 0; /* Blue links */ + p->color[2] = 1; + p->border[0] = 1; /* horizontal corner radius */ + p->border[1] = 1; /* vertical corner radius */ + p->border[2] = 1; /* box line width */ + p->border[3] = 3; /* dash on size */ + p->border[4] = 3; /* dash off size */ + + current_name = (char *)malloc(strlen(s)+1); + current_name = s; + current_type = type; + current_pushcount = pushcount; + install_link(s, p, type); + return(NO_ERROR); } unsigned int hash_string(char *s) { - unsigned hashval ; - for (hashval = 0 ; *s != '\0' ; s++) - hashval = *s + 31 * hashval ; - return hashval % HASHSIZE ; + unsigned hashval; + for (hashval = 0; *s != '\0'; s++) + hashval = *s + 31 * hashval; + return hashval % HASHSIZE; } /* lookup a hashed name */ @@ -296,75 +286,75 @@ struct nlist * lookup_link(char *s, int type) { - struct nlist *np ; + struct nlist *np; - for(np = type ? link_sources[hash_string(s)] : link_targets[hash_string(s)] ; - np != NULL ; np = np -> next) + for(np = type ? link_sources[hash_string(s)] : link_targets[hash_string(s)]; + np != NULL; np = np -> next) if (strcmp(s, np->name) == 0) - return np ; /* found */ - return NULL ; /* not found */ + return np; /* found */ + return NULL; /* not found */ } struct nlist * install_link(char *name, Hps_link *defn, int type) { - struct nlist *np ; - unsigned hashval ; - np = (struct nlist *)malloc(sizeof(*np)) ; + struct nlist *np; + unsigned hashval; + np = (struct nlist *)malloc(sizeof(*np)); if (np == NULL || (np->name = dup_str(name)) == NULL) - return NULL ; - hashval = hash_string(name) ; - np->next = type ? link_sources[hashval] : link_targets[hashval] ; - (type ? link_sources : link_targets)[hashval] = np ; + return NULL; + hashval = hash_string(name); + np->next = type ? link_sources[hashval] : link_targets[hashval]; + (type ? link_sources : link_targets)[hashval] = np; if ((np->defn = link_dup(defn)) == NULL) - return NULL ; - return np ; + return NULL; + return np; } #ifndef KPATHSEA char * dup_str(char *w) /* make a duplicate of s */ { - char *p ; - p = (char *)malloc(strlen(w)+1) ; + char *p; + p = (char *)malloc(strlen(w)+1); if (p != NULL) - strcpy(p,w) ; - return p ; + strcpy(p,w); + return p; } #endif Hps_link * link_dup(Hps_link *s) /* make a duplicate link */ { - Hps_link *p ; + Hps_link *p; - p = (Hps_link *) malloc(sizeof(*p)) ; + p = (Hps_link *) malloc(sizeof(*p)); if (p != NULL) - p = s ; - return p ; + p = s; + return p; } double dvi_to_hps_conv(int i, int dir) { - double hps_coor ; + double hps_coor; /* Convert dvi integers into proper hps coordinates Take into account magnification and resolution that dvi file was produced at */ - hps_coor = dir ? (((i * 72.0) / vactualdpi) +MARGIN) : (PAGESIZE - ((i * 72.0) / (vactualdpi)) - MARGIN ) ; - return(hps_coor) ; + hps_coor = dir ? (((i * 72.0) / vactualdpi) +MARGIN) : (PAGESIZE - ((i * 72.0) / (vactualdpi)) - MARGIN ); + return(hps_coor); } int vert_loc(int i) { - int return_value ; - return_value = (int) (i + (PAGESIZE / 4) + FUDGE) ; + int return_value; + return_value = (int) (i + (PAGESIZE / 4) + FUDGE); if ( return_value > PAGESIZE) { - return((int)PAGESIZE) ; + return((int)PAGESIZE); } else if (return_value < (PAGESIZE / 4.0)) { - return((PAGESIZE / 4)) ; - } else return(return_value) ; + return((PAGESIZE / 4)); + } else return(return_value); } Hps_link * @@ -374,45 +364,45 @@ Should be true for all legitimate papers. Also, assume prepending of # for names. */ - struct nlist *np ; + struct nlist *np; - s++ ; /* get rid of hashmark */ - for(np = link_targets[hash_string(s)] ; np != NULL ; np = np -> next) { + s++; /* get rid of hashmark */ + for(np = link_targets[hash_string(s)]; np != NULL; np = np -> next) { if ( href_name_match(s, np->name)) { - return (np->defn) ; /* found */ + return (np->defn); /* found */ } } - error("Oh no, link not found in target hashtable") ; - error(s) ; - error("!") ; - return NULL ; /* not found */ + error("Oh no, link not found in target hashtable"); + error(s); + error("!"); + return NULL; /* not found */ } int count_targets(void) { - int count=0 ; - int i ; - struct nlist *np ; - - for (i = 0 ; i < HASHSIZE ; i++) - for(np = link_targets[i] ; np != NULL ; np = np -> next) - count++ ; - return count ; + int count=0; + int i; + struct nlist *np; + + for (i = 0; i < HASHSIZE; i++) + for(np = link_targets[i] ; np != NULL; np = np -> next) + count++; + return count; } void do_targets(void) { - struct nlist *np ; - int i ; - Hps_link *dest ; + struct nlist *np; + int i; + Hps_link *dest; - for (i = 0 ; i < HASHSIZE ; i++) - for(np = link_sources[i] ; np != NULL ; np = np -> next) { + for (i = 0; i < HASHSIZE; i++) + for(np = link_sources[i] ; np != NULL; np = np -> next) { if (np->name[0] == '#') { - dest = dest_link(np->name) ; - np->defn->page = dest->srcpg ; - np->defn->vert_dest = vert_loc((int) dest->rect.lly) ; + dest = dest_link(np->name); + np->defn->page = dest->srcpg; + np->defn->vert_dest = vert_loc((int) dest->rect.lly); } } } @@ -420,37 +410,37 @@ void do_target_dict(void) { - struct nlist *np ; - int i ; - (void) fprintf(bitfile, "HPSdict begin\n") ; - (void)fprintf(bitfile, "/TargetAnchors\n") ; - (void)fprintf(bitfile, "%i dict dup begin\n",count_targets()) ; + struct nlist *np; + int i; + (void) fprintf(bitfile, "HPSdict begin\n"); + (void)fprintf(bitfile, "/TargetAnchors\n"); + (void)fprintf(bitfile, "%i dict dup begin\n",count_targets()); - for (i = 0 ; i < HASHSIZE ; i++) - for(np = link_targets[i] ; np != NULL ; np = np -> next) + for (i = 0; i < HASHSIZE; i++) + for(np = link_targets[i] ; np != NULL; np = np -> next) (void)fprintf(bitfile, "(%s) [%i [%.0f %.0f %.0f %.0f] %i] def\n", np->defn->title, np->defn->srcpg, np->defn->rect.llx, np->defn->rect.lly, np->defn->rect.urx, np->defn->rect.ury, - vert_loc((int) np->defn->rect.lly)) ; - (void)fprintf(bitfile,"end targetdump-hook def end\n") ; + vert_loc((int) np->defn->rect.lly)); + (void)fprintf(bitfile,"end targetdump-hook def end\n"); } int href_name_match(char *h, char *n) { - int count = 0 ; - int name_length = strlen(n) ; + int count = 0; + int name_length = strlen(n); while((*h == *n) & (*h != '\0') ) { - count++ ; - h++ ; - n++ ; + count++; + h++; + n++; } if (name_length == count) { - return 1 ; + return 1; } else { - /* printf(" count: %i \n", count) ; */ - return 0 ; + /* printf(" count: %i \n", count); */ + return 0; } } @@ -459,12 +449,12 @@ { char * tmpbuf; if (pl == NULL) { - error("stamp_hps: null pl pointer, oh no!") ; - return ; + error("stamp_hps: null pl pointer, oh no!"); + return; } if(pl->title == NULL) { - error("stamp_hps: null pl->title pointer, oh no!") ; - return ; + error("stamp_hps: null pl->title pointer, oh no!"); + return; } tmpbuf = (char *) xmalloc(strlen(pl->title)+200); @@ -475,8 +465,8 @@ " (%s) [[%.0f %.0f %.0f %.0f] [%i %i %i [%i %i]] [%.0f %.0f %.0f]] pdfm ", pl->title, pl->rect.llx, pl->rect.lly, pl->rect.urx, pl->rect.ury, pl->border[0], pl->border[1], pl->border[2], pl->border[3],pl->border[4], - pl->color[0], pl->color[1], pl->color[2]) ; - cmdout(tmpbuf) ; + pl->color[0], pl->color[1], pl->color[2]); + cmdout(tmpbuf); free(tmpbuf); @@ -490,13 +480,13 @@ { char *tmpbuf; if (pl == NULL) { - error("stamp_external: null pl pointer, oh no!") ; - return ; + error("stamp_external: null pl pointer, oh no!"); + return; } if (s == NULL) { - error("stamp_external: null s pointer, oh no!") ; - return ; + error("stamp_external: null s pointer, oh no!"); + return; } tmpbuf = (char *) xmalloc(strlen(s) + 200); @@ -506,28 +496,25 @@ (void)sprintf(tmpbuf," [[%.0f %.0f %.0f %.0f] [%i %i %i [%i %i]] [%.0f %.0f %.0f]] (%s) pdfm ", pl->rect.llx, pl->rect.lly, pl->rect.urx, pl->rect.ury, pl->border[0], pl->border[1], pl->border[2], pl->border[3],pl->border[4], - pl->color[0], pl->color[1], pl->color[2], s) ; - cmdout(tmpbuf) ; + pl->color[0], pl->color[1], pl->color[2], s); + cmdout(tmpbuf); free(tmpbuf); } void finish_hps(void) { - extern int dvips_debug_flag; - extern int debug_flag; - - fclose(bitfile) ; + fclose(bitfile); set_bitfile("head.tmp",1); - do_targets() ; + do_targets(); do_target_dict(); - (void)fprintf(bitfile, "TeXDict begin\n") ; - (void)fprintf(bitfile, "%%%%EndSetup\n") ; - fclose(bitfile) ; - open_output() ; - noprocset = 1 ; + (void)fprintf(bitfile, "TeXDict begin\n"); + (void)fprintf(bitfile, "%%%%EndSetup\n"); + fclose(bitfile); + open_output(); + noprocset = 1; removecomments = 0; - copyfile("head.tmp") ; - copyfile("body.tmp") ; + copyfile("head.tmp"); + copyfile("body.tmp"); if (dvips_debug_flag == 0 && debug_flag == 0) { unlink("head.tmp"); unlink("body.tmp"); @@ -535,83 +522,83 @@ } void -set_bitfile(char *s, int mode) +set_bitfile(const char *s, int mode) { if ((bitfile=fopen(s, mode ? FOPEN_ABIN_MODE : FOPEN_WBIN_MODE))==NULL) { - error(s) ; - error("!couldn't open file") ; + error(s); + error("!couldn't open file"); } - linepos = 0 ; + linepos = 0; } void vertical_in_hps(void) { - Rect_list *rl ; - /*printf("in vertical_in_hps") ; */ + Rect_list *rl; + /*printf("in vertical_in_hps"); */ if (current_type == NAME) return; /* Handle this case later */ if (!current_rect_list) { - current_rect_list = (Rect_list *)malloc(sizeof(Rect_list)) ; - current_rect_list->next = NULL ; + current_rect_list = (Rect_list *)malloc(sizeof(Rect_list)); + current_rect_list->next = NULL; } else { - rl = (Rect_list *)malloc(sizeof(Rect_list)) ; - rl->next = current_rect_list ; - current_rect_list = rl ; - } - current_rect_list->rect.llx = dvi_to_hps_conv(hh, HORIZONTAL) ; - current_rect_list->rect.lly = dvi_to_hps_conv(vv, VERTICAL)-FUDGE ; - current_rect_list->rect.urx = dvi_to_hps_conv(hhmem, HORIZONTAL) ; - current_rect_list->rect.ury = dvi_to_hps_conv(vvmem, VERTICAL)-FUDGE ; + rl = (Rect_list *)malloc(sizeof(Rect_list)); + rl->next = current_rect_list; + current_rect_list = rl; + } + current_rect_list->rect.llx = dvi_to_hps_conv(hh, HORIZONTAL); + current_rect_list->rect.lly = dvi_to_hps_conv(vv, VERTICAL)-FUDGE; + current_rect_list->rect.urx = dvi_to_hps_conv(hhmem, HORIZONTAL); + current_rect_list->rect.ury = dvi_to_hps_conv(vvmem, VERTICAL)-FUDGE; - if (POPPED) start_new_box() ; + if (POPPED) start_new_box(); } void print_rect_list(void) { - Rect_list *rl, *rln ; + Rect_list *rl, *rln; - for(rl = current_rect_list ; rl != NULL ; rl = rln) { + for(rl = current_rect_list; rl != NULL; rl = rln) { /* printf("Rectangle is %.0f, %.0f, %.0f, %.0f\n", rl->rect.llx, rl->rect.lly, - rl->rect.urx, rl->rect.ury) ; */ - rln = rl -> next ; - free(rl) ; + rl->rect.urx, rl->rect.ury); */ + rln = rl -> next; + free(rl); } } void end_current_box(void) { - Hps_link *nl ; + Hps_link *nl; - POPPED = TRUE ; - HREF_COUNT-- ; + POPPED = TRUE; + HREF_COUNT--; if (current_type == HREF && current_name[0] != '#') { if ((nl = lookup_link(current_name, current_type)->defn)) { - nl->rect.urx = dvi_to_hps_conv(hhmem, HORIZONTAL) ; - nl->rect.ury = dvi_to_hps_conv(vvmem, VERTICAL)-FUDGE+12.0 ; + nl->rect.urx = dvi_to_hps_conv(hhmem, HORIZONTAL); + nl->rect.ury = dvi_to_hps_conv(vvmem, VERTICAL)-FUDGE+12.0; stamp_external(current_name,nl); /* Broken lines ? */ } else { error("!Null lookup"); } } else { if ((nl = lookup_link(current_name, current_type)->defn)) { - nl->rect.urx = dvi_to_hps_conv(hhmem, HORIZONTAL) ; - nl->rect.ury = dvi_to_hps_conv(vvmem, VERTICAL)-FUDGE+12.0 ; + nl->rect.urx = dvi_to_hps_conv(hhmem, HORIZONTAL); + nl->rect.ury = dvi_to_hps_conv(vvmem, VERTICAL)-FUDGE+12.0; if (current_type) { - stamp_hps(nl) ; /* Put link info right where special is */ + stamp_hps(nl); /* Put link info right where special is */ } } else { error("!Null lookup"); } /* printf("Ended box %.0f, %.0f, %.0f, %.0f\n", nl->rect.llx, \ - nl->rect.lly,nl->rect.urx, nl->rect.ury) ; */ + nl->rect.lly,nl->rect.urx, nl->rect.ury); */ } } void start_new_box(void) { - POPPED = FALSE ; - do_link(current_name, current_type) ; + POPPED = FALSE; + do_link(current_name, current_type); } #else -int no_hypertex ; /* prevent an empty file */ +int no_hypertex; /* prevent an empty file */ #endif diff -Nu dvipsk2009/loadfont.c dvipsk/loadfont.c --- dvipsk2009/loadfont.c Tue Jun 23 18:46:14 2009 +++ dvipsk/loadfont.c Mon Mar 29 23:29:27 2010 @@ -8,6 +8,7 @@ #endif #ifdef KPATHSEA #include +#include #include #include #include @@ -22,78 +23,58 @@ #endif #endif /* - * These are the external routines we use. + * The external declarations: */ -#include "protos.h" -/* - * These are the external variables we use. - */ -#ifdef DEBUG -extern integer debug_flag; -#endif /* DEBUG */ -extern long bytesleft ; -extern quarterword *raster ; -extern real conv ; -extern int actualdpi, vactualdpi ; -extern real alpha ; -#ifndef KPATHSEA -extern char *pkpath ; -#endif -char errbuf[512] ; -int lastresortsizes[40] ; -extern integer fsizetol ; -extern Boolean nosmallchars ; -extern Boolean compressed ; -extern Boolean dopprescan ; -#ifdef FONTLIB -extern Boolean flib ; -#endif +#include "protos_add.h" + +char errbuf[1000]; +int lastresortsizes[40]; /* * Now we have some routines to get stuff from the PK file. * Subroutine pkbyte returns the next byte. */ -FILE *pkfile ; -char name[MAXPATHLEN] ; +FILE *pkfile; +char name[MAXPATHLEN]; void -badpk(char *s) +badpk(const char *s) { - (void)sprintf(errbuf,"! Bad PK file %s: %s",name,s) ; - error(errbuf); + char *msg = concatn ("! Bad PK file ", name, ": ", s, NULL); + error(msg); } shalfword pkbyte(void) { - register shalfword i ; + register shalfword i; if ((i=getc(pkfile))==EOF) - badpk("unexpected eof") ; - return(i) ; + badpk("unexpected eof"); + return(i); } integer pkquad(void) { - register integer i ; + register integer i; - i = pkbyte() ; + i = pkbyte(); if (i > 127) - i -= 256 ; - i = i * 256 + pkbyte() ; - i = i * 256 + pkbyte() ; - i = i * 256 + pkbyte() ; - return(i) ; + i -= 256; + i = i * 256 + pkbyte(); + i = i * 256 + pkbyte(); + i = i * 256 + pkbyte(); + return(i); } integer pktrio(void) { - register integer i ; + register integer i; - i = pkbyte() ; - i = i * 256 + pkbyte() ; - i = i * 256 + pkbyte() ; - return(i) ; + i = pkbyte(); + i = i * 256 + pkbyte(); + i = i * 256 + pkbyte(); + return(i); } @@ -104,45 +85,45 @@ #ifdef VMCMS /* IBM: VM/CMS - we let DVIPS EXEC handle this after the DVIPS MODULE has finished to avoid complications with system calls. */ -int dontmakefont = 0 ; +int dontmakefont = 0; #else #ifdef MVSXA /* IBM: MVS/XA - we let system administrator handle this on MVS/XA since some printers can't get to user fonts anyway */ -int dontmakefont = 1 ; +int dontmakefont = 1; #else -int dontmakefont = 0 ; /* if makefont fails once we won't try again */ +int dontmakefont = 0; /* if makefont fails once we won't try again */ #endif /* IBM: VM/CMS */ #endif void lectureuser(void) { - static int userwarned = 0 ; + static int userwarned = 0; if (! userwarned) { - error("Such scaling will generate extremely poor output.") ; - userwarned = 1 ; + error("Such scaling will generate extremely poor output."); + userwarned = 1; } } Boolean pkopen(register fontdesctype *fd) { - register char *d, *n ; - char *name_ret ; + register char *d, *n; + char *name_ret; #ifdef KPATHSEA - int dpi_ret ; + int dpi_ret; #else - int vdpi ; + int vdpi; #endif - d = fd->area ; - n = fd->name ; + d = fd->area; + n = fd->name; #ifndef KPATHSEA if (*d==0) - d = pkpath ; + d = pkpath; #endif #ifdef FONTLIB if (*(fd->area) == 0) { - int del ; + int del; for (del=0; del<=RES_TOLERANCE(fd->dpi); del=del>0?-del:-del+1) { if ((pkfile=flisearch(n, fd->dpi + del)) != (FILE *)NULL ) return(1); @@ -153,29 +134,27 @@ #ifdef KPATHSEA char *this_name = concat (d, n); - pkfile=pksearch(this_name, READBIN, fd->dpi, &name_ret, &dpi_ret); + pkfile = pksearch(this_name, READBIN, fd->dpi, &name_ret, &dpi_ret); - if (!pkfile || !FILESTRCASEEQ (this_name, name_ret)) - { - if (!pkfile) - (void)sprintf(errbuf, - "Font %s%s not found, characters will be left blank.", - fd->area, n) ; - else - sprintf(errbuf, "Font %s%s not found, using %s instead.", - fd->area, n, name_ret) ; - dontmakefont = 1; - error(errbuf) ; - } - else if (!kpse_bitmap_tolerance ((double) dpi_ret, (double) fd->dpi)) + if (!pkfile || !FILESTRCASEEQ (this_name, name_ret)) { + char *msg = concatn ("Font ", fd->area, n, " not found; ", NULL); + /* wasting some memory */ + if (!pkfile) + msg = concat (msg, "characters will be left blank."); + else + msg = concat3 (msg, "using ", name_ret); + dontmakefont = 1; + error (msg); + + } else if (!kpse_bitmap_tolerance ((double) dpi_ret, (double) fd->dpi)) { - fd->loadeddpi = dpi_ret ; - fd->alreadyscaled = 0 ; + fd->loadeddpi = dpi_ret; + fd->alreadyscaled = 0; (void)sprintf(errbuf, "Font %s at %d not found; scaling %d instead.", - n, fd->dpi, dpi_ret) ; - error(errbuf) ; - lectureuser() ; + n, fd->dpi, dpi_ret); + error(errbuf); + lectureuser(); } if (this_name != name_ret) @@ -184,39 +163,39 @@ return pkfile != NULL; } #else - int del ; + int del; for (del=0; del<=RES_TOLERANCE(fd->dpi); del=del>0?-del:-del+1) { if (actualdpi == vactualdpi) { - vdpi = 0 ; + vdpi = 0; } else { vdpi = (2 * ((long)vactualdpi) * (fd->dpi + del) + actualdpi) - / (2 * actualdpi) ; + / (2 * actualdpi); } #ifdef MVSXA - (void)sprintf(name, "pk%d(%s)", fd->dpi + del, n) ; + (void)sprintf(name, "pk%d(%s)", fd->dpi + del, n); #else - (void)sprintf(name, "%s.%dpk", n, fd->dpi + del) ; + (void)sprintf(name, "%s.%dpk", n, fd->dpi + del); #endif if (0 != (pkfile=pksearch(d, name, READBIN, n, fd->dpi + del, vdpi))) - return(1) ; + return(1); } } if (d == pkpath) { if (actualdpi == vactualdpi) { - vdpi = 0 ; + vdpi = 0; } else { vdpi = (2 * ((long)vactualdpi) * fd->dpi + actualdpi) - / (2 * actualdpi) ; + / (2 * actualdpi); } #ifdef MVSXA - (void)sprintf(name, "pk%d(%s)", fd->dpi, n) ; + (void)sprintf(name, "pk%d(%s)", fd->dpi, n); #else - (void)sprintf(name, "%s.%dpk", n, fd->dpi) ; + (void)sprintf(name, "%s.%dpk", n, fd->dpi); #endif - makefont(n, (int)fd->dpi, DPI) ; + makefont(n, (int)fd->dpi, DPI); if (dontmakefont == 0 && (pkfile = pksearch(d, name, READBIN, n, fd->dpi, vdpi))) - return(1) ; + return(1); #ifndef MSDOS #ifdef OS2 if (_osmode == OS2_MODE) @@ -224,7 +203,7 @@ but do try for MSDOS */ #else #ifndef ATARIST - dontmakefont = 1 ; + dontmakefont = 1; #endif #endif #endif @@ -239,21 +218,21 @@ * and then work down. */ { - int i, j ; + int i, j; if (lastresortsizes[0] && fd->dpi < 30000) { - for (i=0; lastresortsizes[i] < fd->dpi; i++) ; + for (i=0; lastresortsizes[i] < fd->dpi; i++); for (j = i-1; j >= 0; j--) { if (actualdpi == vactualdpi) { - vdpi = 0 ; + vdpi = 0; } else { vdpi = (2 * ((long)vactualdpi) * lastresortsizes[j] + actualdpi) - / (2 * actualdpi) ; + / (2 * actualdpi); } #ifdef MVSXA - (void)sprintf(name, "pk%d(%s)", lastresortsizes[j], n) ; + (void)sprintf(name, "pk%d(%s)", lastresortsizes[j], n); #else - (void)sprintf(name, "%s.%dpk", n, lastresortsizes[j]) ; + (void)sprintf(name, "%s.%dpk", n, lastresortsizes[j]); #endif #ifdef FONTLIB if (0 != (pkfile=flisearch(n,(halfword)lastresortsizes[j])) @@ -263,24 +242,24 @@ if (0 != (pkfile=pksearch(d, name, READBIN, n, (halfword)lastresortsizes[j], vdpi))) { #endif - fd->loadeddpi = lastresortsizes[j] ; - fd->alreadyscaled = 0 ; + fd->loadeddpi = lastresortsizes[j]; + fd->alreadyscaled = 0; (void)sprintf(errbuf, "Font %s at %d dpi not found; scaling %d instead.", - n, fd->dpi, lastresortsizes[j]) ; - error(errbuf) ; - lectureuser() ; - return 1 ; + n, fd->dpi, lastresortsizes[j]); + error(errbuf); + lectureuser(); + return 1; } } for (j = i; lastresortsizes[j] < 30000; j++) { if (actualdpi == vactualdpi) { - vdpi = 0 ; + vdpi = 0; } else { vdpi = (2 * ((long)vactualdpi) * lastresortsizes[j] + actualdpi) - / (2 * actualdpi) ; + / (2 * actualdpi); } - (void)sprintf(name, "%s.%dpk", n, lastresortsizes[j]) ; + (void)sprintf(name, "%s.%dpk", n, lastresortsizes[j]); #ifdef FONTLIB if (0 != (pkfile=flisearch(n, (halfword)lastresortsizes[j])) || 0 != (pkfile=pksearch(d, name, READBIN, n, @@ -289,28 +268,28 @@ if (0 != (pkfile=pksearch(d, name, READBIN, n, (halfword)lastresortsizes[j], vdpi))) { #endif - fd->loadeddpi = lastresortsizes[j] ; - fd->alreadyscaled = 0 ; + fd->loadeddpi = lastresortsizes[j]; + fd->alreadyscaled = 0; (void)sprintf(errbuf, "Font %s at %d dpi not found; scaling %d instead.", - name, fd->dpi, lastresortsizes[j]) ; - error(errbuf) ; - lectureuser() ; - return 1 ; + name, fd->dpi, lastresortsizes[j]); + error(errbuf); + lectureuser(); + return 1; } } } } #ifdef MVSXA - (void)sprintf(name, "%s.pk%d", n, fd->dpi) ; + (void)sprintf(name, "%s.pk%d", n, fd->dpi); #else - (void)sprintf(name, "%s.%dpk", n, fd->dpi) ; + (void)sprintf(name, "%s.%dpk", n, fd->dpi); #endif (void)sprintf(errbuf, "Font %s%s not found, characters will be left blank.", - fd->area, name) ; - error(errbuf) ; - return(0) ; + fd->area, name); + error(errbuf); + return(0); #endif /* KPATHSEA */ } @@ -323,77 +302,78 @@ void loadfont(register fontdesctype *curfnt) { - register integer i ; - register shalfword cmd ; - register integer k ; - register integer length = 0 ; - register shalfword cc = 0 ; - register integer scaledsize = curfnt->scaledsize ; - register quarterword *tempr ; - register chardesctype *cd = 0 ; - int maxcc = 0 ; - int munged = 0 ; - extern int prettycolumn ; - extern int quiet ; - extern char *realnameoffile ; + register integer i; + register shalfword cmd; + register integer k; + register integer length = 0; + register shalfword cc = 0; + register integer scaledsize = curfnt->scaledsize; + register quarterword *tempr; + register chardesctype *cd = 0; + int maxcc = 0; + int munged = 0; /* * We clear out some pointers: */ if (curfnt->loaded == 3) { for (i=0; i<256; i++) { - curfnt->chardesc[i].TFMwidth = 0 ; - curfnt->chardesc[i].packptr = NULL ; - curfnt->chardesc[i].pixelwidth = 0 ; - curfnt->chardesc[i].flags &= EXISTS ; - curfnt->chardesc[i].flags2 = 0 ; + curfnt->chardesc[i].TFMwidth = 0; + curfnt->chardesc[i].packptr = NULL; + curfnt->chardesc[i].pixelwidth = 0; + curfnt->chardesc[i].flags &= EXISTS; + curfnt->chardesc[i].flags2 = 0; } } else { for (i=0; i<256; i++) { - curfnt->chardesc[i].TFMwidth = 0 ; - curfnt->chardesc[i].packptr = NULL ; - curfnt->chardesc[i].pixelwidth = 0 ; - curfnt->chardesc[i].flags = 0 ; - curfnt->chardesc[i].flags2 = 0 ; + curfnt->chardesc[i].TFMwidth = 0; + curfnt->chardesc[i].packptr = NULL; + curfnt->chardesc[i].pixelwidth = 0; + curfnt->chardesc[i].flags = 0; + curfnt->chardesc[i].flags2 = 0; } } - curfnt->maxchars = 256 ; /* just in case we return before the end */ + curfnt->maxchars = 256; /* just in case we return before the end */ if (!pkopen(curfnt)) { - tfmload(curfnt) ; - return ; + tfmload(curfnt); + return; } + curfnt->dir = 0; if (!quiet) { if (strlen(realnameoffile) + prettycolumn > STDOUTSIZE) { - fprintf(stderr, "\n") ; - prettycolumn = 0 ; + fprintf(stderr, "\n"); + prettycolumn = 0; } (void)fprintf(stderr, "<%s>", realnameoffile); - prettycolumn += strlen(realnameoffile) + 2 ; + prettycolumn += strlen(realnameoffile) + 2; } + #ifdef DEBUG if (dd(D_FONTS)) (void)fprintf(stderr,"Loading pk font %s at %.1fpt\n", - curfnt->name, (real)scaledsize/(alpha*0x100000)) ; + curfnt->name, (real)scaledsize/(alpha*0x100000)); #endif /* DEBUG */ if (pkbyte()!=247) - badpk("expected pre") ; + badpk("expected pre"); if (pkbyte()!=89) - badpk("wrong id byte") ; + badpk("wrong id byte"); for(i=pkbyte(); i>0; i--) - (void)pkbyte() ; - k = (integer)(alpha * (real)pkquad()) ; - if (k > curfnt->designsize + fsizetol || - k < curfnt->designsize - fsizetol) { - (void)sprintf(errbuf,"Design size mismatch in font %s", curfnt->name) ; - error(errbuf) ; + (void)pkbyte(); + k = (integer)(alpha * (real)pkquad()); + if (k > curfnt->designsize + fsizetol + || k < curfnt->designsize - fsizetol) { + char *msg = concat ("Design size mismatch in font ", curfnt->name); + error (msg); + free (msg); } - k = pkquad() ; + k = pkquad(); if (k && curfnt->checksum) if (k!=curfnt->checksum) { - (void)sprintf(errbuf,"Checksum mismatch in font %s", curfnt->name) ; - error(errbuf) ; + char *msg = concat ("Checksum mismatch in font ", curfnt->name); + error (msg); + free (msg); } - k = pkquad() ; /* assume that hppp is correct in the PK file */ - k = pkquad() ; /* assume that vppp is correct in the PK file */ + k = pkquad(); /* assume that hppp is correct in the PK file */ + k = pkquad(); /* assume that vppp is correct in the PK file */ /* * Now we get down to the serious business of reading character definitions. */ @@ -401,135 +381,135 @@ if (cmd < 240) { switch (cmd & 7) { case 0: case 1: case 2: case 3: - length = (cmd & 7) * 256 + pkbyte() - 3 ; - cc = pkbyte() ; - cd = curfnt->chardesc+cc ; + length = (cmd & 7) * 256 + pkbyte() - 3; + cc = pkbyte(); + cd = curfnt->chardesc+cc; if (nosmallchars || curfnt->dpi != curfnt->loadeddpi) - cd->flags |= BIGCHAR ; - cd->TFMwidth = scalewidth(pktrio(), scaledsize) ; - cd->pixelwidth = pkbyte() ; - break ; + cd->flags |= BIGCHAR; + cd->TFMwidth = scalewidth(pktrio(), scaledsize); + cd->pixelwidth = pkbyte(); + break; case 4: case 5: case 6: - length = (cmd & 3) * 65536L + pkbyte() * 256L ; - length = length + pkbyte() - 4L ; - cc = pkbyte() ; - cd = curfnt->chardesc+cc ; - cd->TFMwidth = scalewidth(pktrio(), scaledsize) ; - cd->flags |= BIGCHAR ; - i = pkbyte() ; - cd->pixelwidth = i * 256 + pkbyte() ; - break ; + length = (cmd & 3) * 65536L + pkbyte() * 256L; + length = length + pkbyte() - 4L; + cc = pkbyte(); + cd = curfnt->chardesc+cc; + cd->TFMwidth = scalewidth(pktrio(), scaledsize); + cd->flags |= BIGCHAR; + i = pkbyte(); + cd->pixelwidth = i * 256 + pkbyte(); + break; case 7: - length = pkquad() - 11 ; - cc = pkquad() ; - if (cc<0 || cc>255) badpk("character code out of range") ; - cd = curfnt->chardesc + cc ; - cd->flags |= BIGCHAR ; - cd->TFMwidth = scalewidth(pkquad(), scaledsize) ; - cd->pixelwidth = (pkquad() + 32768) >> 16 ; - k = pkquad() ; + length = pkquad() - 11; + cc = pkquad(); + if (cc<0 || cc>255) badpk("character code out of range"); + cd = curfnt->chardesc + cc; + cd->flags |= BIGCHAR; + cd->TFMwidth = scalewidth(pkquad(), scaledsize); + cd->pixelwidth = (pkquad() + 32768) >> 16; + k = pkquad(); } if (cd->pixelwidth == 0 && cd->TFMwidth != 0) { if (cd->TFMwidth > 0) - k = (integer)(cd->TFMwidth * conv + 0.5) ; + k = (integer)(cd->TFMwidth * conv + 0.5); else - k = -(integer)(-cd->TFMwidth * conv + 0.5) ; + k = -(integer)(-cd->TFMwidth * conv + 0.5); if (k != 0) { - cd->pixelwidth = k ; - munged++ ; + cd->pixelwidth = k; + munged++; } } if (length <= 0) - badpk("packet length too small") ; + badpk("packet length too small"); if (dopprescan && ((cd->flags & EXISTS) == 0)) { for (length--; length>0; length--) - (void)pkbyte() ; + (void)pkbyte(); } else { if (cc > maxcc) - maxcc = cc ; + maxcc = cc; if (bytesleft < length || (length > MINCHUNK && compressed)) { #ifdef DEBUG if (dd(D_MEM)) (void)fprintf(stderr, #ifdef SHORTINT "Allocating new raster memory (%ld req, %ld left)\n", - length, bytesleft) ; + length, bytesleft); #else "Allocating new raster memory (%d req, %d left)\n", - (int)length, (int)bytesleft) ; + (int)length, (int)bytesleft); #endif #endif /* DEBUG */ if (length > MINCHUNK) { - tempr = (quarterword *)mymalloc((integer)length) ; + tempr = (quarterword *)mymalloc((integer)length); } else { - raster = (quarterword *)mymalloc((integer)RASTERCHUNK) ; - tempr = raster ; - bytesleft = RASTERCHUNK - length ; - raster += length ; + raster = (quarterword *)mymalloc((integer)RASTERCHUNK); + tempr = raster; + bytesleft = RASTERCHUNK - length; + raster += length; } } else { - tempr = raster ; - bytesleft -= length ; - raster += length ; + tempr = raster; + bytesleft -= length; + raster += length; } - cd->packptr = tempr ; - *tempr++ = cmd ; + cd->packptr = tempr; + *tempr++ = cmd; for (length--; length>0; length--) - *tempr++ = pkbyte() ; + *tempr++ = pkbyte(); } - cd->flags2 |= EXISTS ; + cd->flags2 |= EXISTS; } else { - k = 0 ; + k = 0; switch (cmd) { case 243: - k = pkbyte() ; + k = pkbyte(); if (k > 127) - k -= 256 ; + k -= 256; case 242: - k = k * 256 + pkbyte() ; + k = k * 256 + pkbyte(); case 241: - k = k * 256 + pkbyte() ; + k = k * 256 + pkbyte(); case 240: - k = k * 256 + pkbyte() ; + k = k * 256 + pkbyte(); while (k-- > 0) - i = pkbyte() ; - break ; + i = pkbyte(); + break; case 244: - k = pkquad() ; - break ; + k = pkquad(); + break; case 246: - break ; + break; default: - badpk("! unexpected command") ; + badpk("! unexpected command"); } } } #ifdef FONTLIB if (flib) - flib = 0 ; + flib = 0; else #endif - (void)fclose(pkfile) ; - curfnt->loaded = 1 ; - curfnt->maxchars = maxcc + 1 ; + (void)fclose(pkfile); + curfnt->loaded = 1; + curfnt->maxchars = maxcc + 1; if (munged > 0) { - static int seen = 0 ; + static int seen = 0; sprintf(errbuf, "Font %s at %d dpi has most likely been made improperly;", - curfnt->name, curfnt->dpi) ; - error(errbuf) ; + curfnt->name, curfnt->dpi); + error(errbuf); if (seen) - return ; - seen = 1 ; + return; + seen = 1; sprintf(errbuf, - "%d characters have 0 escapements but non-trivial TFM widths.", munged) ; - error(errbuf) ; + "%d characters have 0 escapements but non-trivial TFM widths.", munged); + error(errbuf); error( - "I'm stumbling along as best I can, but I recommend regenerating") ; + "I'm stumbling along as best I can, but I recommend regenerating"); error( - "these fonts; the problem is probably that they are non-CM fonts") ; + "these fonts; the problem is probably that they are non-CM fonts"); error( - "(such as circle10 or line10) created with a MF with the CM base") ; - error("preloaded .") ; + "(such as circle10 or line10) created with a MF with the CM base"); + error("preloaded ."); } } diff -Nu dvipsk2009/makefont.c dvipsk/makefont.c --- dvipsk2009/makefont.c Tue Jun 23 18:46:14 2009 +++ dvipsk/makefont.c Mon Mar 29 23:29:36 2010 @@ -1,12 +1,10 @@ /* makefont.c */ #include "dvips.h" /* The copyright notice in that file is included too! */ #include +/* + * The external declarations: + */ #include "protos.h" -extern int quiet ; -extern int filter ; -extern int dontmakefont ; -extern int secure ; -extern char *mfmode ; #ifdef OS2 #include #endif @@ -15,11 +13,6 @@ extern int system(); #endif #if defined MSDOS || defined OS2 -extern char *mfjobname ; -extern FILE *mfjobfile ; -extern char *pkpath ; -extern int actualdpi ; -extern int vactualdpi ; /* * Write mfjob file */ @@ -53,7 +46,7 @@ strcpy(pkout+i,"%"); break; default: - sprintf(pkout+i, "%%%c", *p) ; + sprintf(pkout+i, "%%%c", *p); fprintf(stderr,"Unknown option %%%c in pk path\n",*p); } i += strlen(pkout+i); @@ -62,7 +55,7 @@ pkout[i++] = *p; } /* *p='\0'; Could some DOS person explain to me what this does? */ - pkout[i] = 0 ; + pkout[i] = 0; mfjobfile = fopen(mfjobname,"w"); if (mfjobfile == (FILE *)NULL) return; @@ -75,7 +68,7 @@ } fprintf(mfjobfile,"{font=%s; mag=%f;}\n",font,mag); (void)fprintf(stderr, - "Appending {font=%s; mag=%f;} to %s\n",font,mag,mfjobname) ; + "Appending {font=%s; mag=%f;} to %s\n",font,mag,mfjobname); } #endif /* @@ -84,93 +77,93 @@ static int magstep(register int n, register int bdpi) { - register float t ; - int neg = 0 ; + register float t; + int neg = 0; if (n < 0) { - neg = 1 ; - n = -n ; + neg = 1; + n = -n; } if (n & 1) { - n &= ~1 ; - t = 1.095445115 ; + n &= ~1; + t = 1.095445115; } else - t = 1.0 ; + t = 1.0; while (n > 8) { - n -= 8 ; - t = t * 2.0736 ; + n -= 8; + t = t * 2.0736; } while (n > 0) { - n -= 2 ; - t = t * 1.2 ; + n -= 2; + t = t * 1.2; } if (neg) - return((int)floor(0.5 + bdpi / t)) ; + return((int)floor(0.5 + bdpi / t)); else - return((int)floor(0.5 + bdpi * t)) ; + return((int)floor(0.5 + bdpi * t)); } #ifdef MAKEPKCMD -static char *defcommand = MAKEPKCMD " %n %d %b %m" ; +static char *defcommand = MAKEPKCMD " %n %d %b %m"; #else #ifdef OS2 -static char *doscommand = "command /c MakeTeXP %n %d %b %m" ; -static char *os2command = "MakeTeXP %n %d %b %m" ; +static char *doscommand = "command /c MakeTeXP %n %d %b %m"; +static char *os2command = "MakeTeXP %n %d %b %m"; #define defcommand ( _osmode==OS2_MODE ? os2command : doscommand ) #else #ifdef MSDOS -static char *defcommand = "command /c MakeTeXP %n %d %b %m" ; +static char *defcommand = "command /c MakeTeXP %n %d %b %m"; #else #ifdef VMCMS -static char *defcommand = "EXEC MakeTeXPK %n %d %b %m" ; +static char *defcommand = "EXEC MakeTeXPK %n %d %b %m"; #else #ifdef ATARIST -static char *defcommand = "maketexp %n %d %b %m" ; +static char *defcommand = "maketexp %n %d %b %m"; #else -static char *defcommand = "MakeTeXPK %n %d %b %m" ; +static char *defcommand = "MakeTeXPK %n %d %b %m"; #endif #endif #endif #endif #endif -char *command = 0 ; +char *command = 0; /* * This routine tries to create a font by executing a command, and * then opening the font again if possible. */ -static char buf[125] ; +static char buf[125]; void makefont(char *name, int dpi, int bdpi) { - register char *p, *q ; - register int m, n ; - int modegiven = 0 ; + register char *p, *q; + register int m, n; + int modegiven = 0; #if defined MSDOS || defined OS2 || defined(ATARIST) double t; #endif if (command == 0) if (secure == 0 && (command=getenv("MAKETEXPK"))) - command = newstring(command) ; + command = newstring(command); else - command = defcommand ; + command = defcommand; for (p=command, q=buf; *p; p++) if (*p != '%') - *q++ = *p ; + *q++ = *p; else { switch (*++p) { case 'n' : case 'N' : - (void)strcpy(q, name) ; - break ; + (void)strcpy(q, name); + break; case 'd' : case 'D' : - (void)sprintf(q, "%d", dpi) ; - break ; + (void)sprintf(q, "%d", dpi); + break; case 'b' : case 'B' : - (void)sprintf(q, "%d", bdpi) ; - break ; + (void)sprintf(q, "%d", bdpi); + break; case 'o' : case 'O' : - (void)sprintf(q, "%s", mfmode ? mfmode : "default") ; - modegiven = 1 ; - break ; + (void)sprintf(q, "%s", mfmode ? mfmode : "default"); + modegiven = 1; + break; case 'm' : case 'M' : /* * Here we want to return a string. If we can find some integer @@ -181,27 +174,27 @@ * We do this for the very slight improvement in accuracy that * magstep() gives us over the rounded dpi/bdpi. */ - m = 0 ; + m = 0; if (dpi < bdpi) { while (1) { - m-- ; - n = magstep(m, bdpi) ; + m--; + n = magstep(m, bdpi); if (n == dpi) - break ; + break; if (n < dpi || m < -40) { - m = 9999 ; - break ; + m = 9999; + break; } } } else if (dpi > bdpi) { while (1) { - m++ ; - n = magstep(m, bdpi) ; + m++; + n = magstep(m, bdpi); if (n == dpi) - break ; + break; if (n > dpi || m > 40) { - m = 9999 ; - break ; + m = 9999; + break; } } } @@ -215,55 +208,56 @@ else n = m; if (n & 1) { - n &= ~1 ; - t = 1.095445115 ; + n &= ~1; + t = 1.095445115; } else - t = 1.0 ; + t = 1.0; while (n > 0) { - n -= 2 ; - t = t * 1.2 ; + n -= 2; + t = t * 1.2; } if (m < 0) - t = 1 / t ; + t = 1 / t; } - (void)sprintf(q, "%12.9f", t) ; + (void)sprintf(q, "%12.9f", t); #else #ifndef ATARIST if (m == 9999) { #else { #endif - (void)sprintf(q, "%d+%d/%d", dpi/bdpi, dpi%bdpi, bdpi) ; + (void)sprintf(q, "%d+%d/%d", dpi/bdpi, dpi%bdpi, bdpi); } else if (m >= 0) { - (void)sprintf(q, "magstep\\(%d.%d\\)", m/2, (m&1)*5) ; + (void)sprintf(q, "magstep\\(%d.%d\\)", m/2, (m&1)*5); } else { - (void)sprintf(q, "magstep\\(-%d.%d\\)", (-m)/2, (m&1)*5) ; + (void)sprintf(q, "magstep\\(-%d.%d\\)", (-m)/2, (m&1)*5); } #endif - break ; -case 0 : *q = 0 ; - break ; -default: *q++ = *p ; - *q = 0 ; - break ; + break; +case 0 : *q = 0; + break; +default: *q++ = *p; + *q = 0; + break; } - q += strlen(q) ; + q += strlen(q); } - *q = 0 ; + *q = 0; if (mfmode && !modegiven) { - strcpy(q, " ") ; - strcat(q, mfmode) ; + strcpy(q, " "); + strcat(q, mfmode); } + #ifdef OS2 if ((_osmode == OS2_MODE) && filter) - (void)strcat(buf, quiet ? " >nul" : " 1>&2") ; + (void)strcat(buf, quiet ? " >nul" : " 1>&2"); #else #ifndef VMCMS /* no filters and no need to print to stderr */ #ifndef MVSXA #ifndef MSDOS #ifndef ATARIST if (filter) - (void)strcat(buf, quiet ? " >/dev/null" : " 1>&2") ; + (void)strcat(buf, quiet ? " >/dev/null" : " 1>&2"); #endif #endif #endif @@ -272,36 +266,36 @@ #if defined MSDOS || defined OS2 if (! quiet && mfjobname == (char *)NULL) - (void)fprintf(stderr, "- %s\n", buf) ; + (void)fprintf(stderr, "- %s\n", buf); if (dontmakefont == 0) { if (mfjobname != (char *)NULL) mfjobout(name,t); else - (void)system(buf) ; + (void)system(buf); } #else if (! quiet) - (void)fprintf(stderr, "- %s\n", buf) ; + (void)fprintf(stderr, "- %s\n", buf); if (dontmakefont == 0) - (void)system(buf) ; + (void)system(buf); #endif else { - static FILE *fontlog = 0 ; + static FILE *fontlog = 0; if (fontlog == 0) { - fontlog = fopen("missfont.log", "a") ; + fontlog = fopen("missfont.log", "a"); if (fontlog != 0) { (void)fprintf(stderr, #ifndef VMCMS - "Appending font creation commands to missfont.log\n") ; + "Appending font creation commands to missfont.log\n"); #else "\nMissing font data will be passed to DVIPS EXEC via MISSFONT LOG\n"); #endif } } if (fontlog != 0) { - (void)fprintf(fontlog, "%s\n", buf) ; - (void)fflush(fontlog) ; + (void)fprintf(fontlog, "%s\n", buf); + (void)fflush(fontlog); } } } diff -Nu dvipsk2009/output.c dvipsk/output.c --- dvipsk2009/output.c Tue Jun 23 18:46:14 2009 +++ dvipsk/output.c Mon Mar 29 23:29:46 2010 @@ -9,12 +9,11 @@ #include "dvips.h" /* The copyright notice in that file is included too! */ #include #include +void print_composefont(void); -#ifdef OS2 #ifdef _MSC_VER -#define popen(pcmd, pmode) _popen(pcmd, pmode) -#define pclose(pstream) _pclose(pstream) -#endif +#define popen(pcmd, pmode) _popen(pcmd, pmode) +#define pclose(pstream) _pclose(pstream) #endif #ifdef __DJGPP__ @@ -22,77 +21,38 @@ #endif /* - * The external routines called here: + * The external declarations: */ #include "protos.h" -/* - * These are the external variables used by these routines. - */ -extern integer hh, vv ; -extern fontdesctype *curfnt ; -extern FILE *bitfile ; -extern char *oname ; -extern int secure ; -extern Boolean reverse ; -extern Boolean removecomments ; -extern Boolean sendcontrolD, disablecomments, multiplesects ; -extern Boolean shiftlowchars ; -extern Boolean usesPSfonts, headers_off ; -extern Boolean safetyenclose ; -extern Boolean cropmarks ; -extern Boolean tryepsf ; -extern Boolean compressed ; -extern Boolean sepfiles ; -extern int numcopies ; -extern int collatedcopies ; -extern integer pagecopies ; -extern int totalpages ; -extern integer pagenum ; -extern Boolean manualfeed ; -extern int landscape ; -extern int quiet ; -extern int prettycolumn ; -extern int actualdpi, vactualdpi ; -extern char *iname, *nextstring ; -extern char *paperfmt ; -#ifndef KPATHSEA -extern char *headerpath ; -extern char *figpath ; -#endif -extern char errbuf[] ; -extern shalfword linepos ; -extern struct header_list *ps_fonts_used ; -extern char banner[], banner2[] ; -extern int gargc ; -extern char **gargv ; -extern struct papsiz *papsizes ; -extern integer hpapersize, vpapersize ; -char preamblecomment[256] ; /* usually "TeX output ..." */ -#ifdef HPS -extern Boolean noprocset, HPS_FLAG ; -#endif +char preamblecomment[256]; /* usually "TeX output ..." */ /* * We need a few statics to take care of things. */ -static integer rhh, rvv ; -static int instring ; -static Boolean lastspecial = 1 ; -static shalfword d ; -static Boolean popened = 0 ; -int lastfont ; /* exported to dospecial to fix rotate.tex problem */ +integer rdir = 0, fdir = 0; +static Boolean jflag = 0; +static integer rhh, rvv; +static int instring; +static Boolean lastspecial = 1; +static shalfword d; +static Boolean popened = 0; +int lastfont; /* exported to dospecial to fix rotate.tex problem */ static void chrcmd(char c); /* just a forward declaration */ -static char strbuffer[LINELENGTH + 20], *strbp = strbuffer ; -static struct papsiz *finpapsiz ; +static char strbuffer[LINELENGTH + 20], *strbp = strbuffer; +static struct papsiz *finpapsiz; static struct papsiz defpapsiz = { 0, 40258437L, 52099154L, "letter", "" -} ; +}; #ifdef CREATIONDATE #if (!defined(VMS) && !defined(MSDOS) && !(defined(OS2) && defined(_MSC_VER)) && !defined(ATARIST)) /* VAXC/MSDOS don't like/need this !! */ #include +#ifdef WIN32 +#include /* time(), at least on BSD Unix */ +#else #include /* time(), at least on BSD Unix */ #endif +#endif #include /* asctime() and localtime(), at least on BSD Unix */ static time_t jobtime; #endif @@ -105,37 +65,39 @@ * Format: 80 {01,02} four byte length in littleendian order data * repeated possibly multiple times. */ -static char *hxdata = "0123456789ABCDEF" ; -static int infigure ; -extern char *infont ; +static const char *hxdata = "0123456789ABCDEF"; +static int infigure; static char possibleDSCLine[81], - *dscLinePointer = possibleDSCLine, *dscLineEnd = possibleDSCLine + 80 ; + *dscLinePointer = possibleDSCLine, *dscLineEnd = possibleDSCLine + 80; + +void setdir(int d); +void cmddir(void); + void -copyfile_general(char *s, struct header_list *cur_header) +copyfile_general(const char *s, struct header_list *cur_header) { - extern char *realnameoffile ; - FILE *f = NULL ; - int c, prevc = '\n' ; - long len ; + FILE *f = NULL; + int c, prevc = '\n'; + long len; /* begin DOS EPS code */ int doseps = 0; unsigned long dosepsbegin, dosepsend = 0; - int removingBytes = 0 ; - char *scanForEnd = 0 ; + int removingBytes = 0; + const char *scanForEnd = 0; int scanningFont = 0; /* end DOS EPS code */ #ifdef VMCMS - register char *lastdirsep ; - register char *trunc_s ; - trunc_s = s ; + register char *lastdirsep; + register char *trunc_s; + trunc_s = s; #endif #ifdef MVSXA - register char *lastdirsep ; - register char *trunc_s ; - trunc_s = s ; + register char *lastdirsep; + register char *trunc_s; + trunc_s = s; #endif - dscLinePointer = possibleDSCLine ; + dscLinePointer = possibleDSCLine; switch (infigure) { case 1: @@ -143,25 +105,25 @@ * Look in headerpath too, just in case. This allows common header * or figure files to be installed in the .../ps directory. */ - f = search(figpath, s, READBIN) ; + f = search(figpath, s, READBIN); if (f == 0) - f = search(headerpath, s, READBIN) ; + f = search(headerpath, s, READBIN); #ifdef VMCMS - lastdirsep = strrchr(s, '/') ; - if ( NULL != lastdirsep ) trunc_s = lastdirsep + 1 ; + lastdirsep = strrchr(s, '/'); + if ( NULL != lastdirsep ) trunc_s = lastdirsep + 1; (void)sprintf(errbuf, - "Couldn't find figure file %s with CMS name %s; continuing.\nNote that an absolute path or a relative path with .. are denied in -R2 mode.", s, trunc_s) ; + "Couldn't find figure file %s with CMS name %s; continuing.\nNote that an absolute path or a relative path with .. are denied in -R2 mode.", s, trunc_s); #else #ifdef MVSXA - lastdirsep = strrchr(s, '/') ; - if ( NULL != lastdirsep ) trunc_s = lastdirsep + 1 ; + lastdirsep = strrchr(s, '/'); + if ( NULL != lastdirsep ) trunc_s = lastdirsep + 1; (void)sprintf(errbuf, - "Couldn't find figure file %s with MVS name %s; continuing.\nNote that an absolute path or a relative path with .. are denied in -R2 mode.", s, trunc_s) ; + "Couldn't find figure file %s with MVS name %s; continuing.\nNote that an absolute path or a relative path with .. are denied in -R2 mode.", s, trunc_s); #else - (void)sprintf(errbuf, "Could not find figure file %s; continuing.\nNote that an absolute path or a relative path with .. are denied in -R2 mode.", s) ; + (void)sprintf(errbuf, "Could not find figure file %s; continuing.\nNote that an absolute path or a relative path with .. are denied in -R2 mode.", s); #endif #endif - break ; + break; #ifndef VMCMS #ifndef MVSXA #ifndef VMS @@ -170,19 +132,19 @@ #ifndef __THINK__ case 2: #ifdef SECURE - (void)sprintf(errbuf, "<%s>: Tick filename execution disabled", s) ; + (void)sprintf(errbuf, "<%s>: Tick filename execution disabled", s); #else #ifdef OS2 if (_osmode == OS2_MODE) { #endif if (secure == 0) { - (void)sprintf(errbuf, "Execution of <%s> failed ", s) ; - f = popen(s, "r") ; + (void)sprintf(errbuf, "Execution of <%s> failed ", s); + f = popen(s, "r"); if (f != 0) - (void)SET_BINARY(fileno(f)) ; + (void)SET_BINARY(fileno(f)); } else { - (void)sprintf(errbuf,"Secure mode is %d so execute <%s> will not run", secure,s) ; + (void)sprintf(errbuf,"Secure mode is %d so execute <%s> will not run", secure,s); } #ifdef OS2 } @@ -196,16 +158,16 @@ #endif #endif default: - f = search(headerpath, s, READBIN) ; + f = search(headerpath, s, READBIN); if(cur_header && (cur_header->precode || cur_header->postcode)) { if(f==NULL) - f = search(figpath, s, READBIN) ; + f = search(figpath, s, READBIN); } - (void)sprintf(errbuf, "! Could not find header file %s.\nNote that an absolute path or a relative path with .. are denied in -R2 mode.", s) ; - break ; + (void)sprintf(errbuf, "! Could not find header file %s.\nNote that an absolute path or a relative path with .. are denied in -R2 mode.", s); + break; } if (f==NULL) - error(errbuf) ; + error(errbuf); else { if (! quiet) { #if defined(VMCMS) || defined (MVSXA) @@ -213,131 +175,131 @@ #else if (strlen(realnameoffile) + prettycolumn > STDOUTSIZE) { #endif - fprintf(stderr, "\n") ; - prettycolumn = 0 ; + fprintf(stderr, "\n"); + prettycolumn = 0; } #ifdef VMCMS - (void)fprintf(stderr, "<%s>", trunc_s) ; + (void)fprintf(stderr, "<%s>", trunc_s); #else #ifdef MVSXA - (void)fprintf(stderr, "<%s>", trunc_s) ; + (void)fprintf(stderr, "<%s>", trunc_s); #else - (void)fprintf(stderr, "<%s>", realnameoffile) ; + (void)fprintf(stderr, "<%s>", realnameoffile); #endif #endif - (void)fflush(stderr) ; + (void)fflush(stderr); #if defined(VMCMS) || defined (MVSXA) - prettycolumn += 2 + strlen(s) ; + prettycolumn += 2 + strlen(s); #else - prettycolumn += 2 + strlen(realnameoffile) ; + prettycolumn += 2 + strlen(realnameoffile); #endif } if (linepos != 0) - (void)putc('\n', bitfile) ; + (void)putc('\n', bitfile); /* * Suggested by Andrew Trevorrow; don't ever BeginFont a file ending in .enc */ if (infont && strstr(s,".enc")) - infont = 0 ; + infont = 0; if (! disablecomments) { if (infigure) - (void)fprintf(bitfile, "%%%%BeginDocument: %s\n", s) ; + (void)fprintf(bitfile, "%%%%BeginDocument: %s\n", s); else if (infont) - (void)fprintf(bitfile, "%%%%BeginFont: %s\n", infont) ; + (void)fprintf(bitfile, "%%%%BeginFont: %s\n", infont); #ifdef HPS else if (noprocset) {} #endif else - (void)fprintf(bitfile, "%%%%BeginProcSet: %s 0 0\n", s) ; + (void)fprintf(bitfile, "%%%%BeginProcSet: %s 0 0\n", s); } if (cur_header && cur_header->precode) { - (void)fprintf(bitfile, "%s\n", cur_header->precode) ; - free(cur_header->precode) ; + (void)fprintf(bitfile, "%s\n", cur_header->precode); + free(cur_header->precode); } - c = getc(f) ; + c = getc(f); if (c == 0x80) { while (1) { - c = getc(f) ; + c = getc(f); switch(c) { case 1: case 2: - len = getc(f) ; - len += getc(f) * 256L ; - len += getc(f) * 65536L ; - len += getc(f) * 256L * 65536 ; + len = getc(f); + len += getc(f) * 256L; + len += getc(f) * 65536L; + len += getc(f) * 256L * 65536; if (c == 1) { while (len > 0) { - c = getc(f) ; + c = getc(f); if (c == EOF) { - error("premature EOF in MS-DOS font file") ; - len = 0 ; + error("premature EOF in MS-DOS font file"); + len = 0; } else { if (c == '\r') { /* Mac- or DOS-style text file */ - (void)putc('\n', bitfile) ; + (void)putc('\n', bitfile); if ((c = getc(f)) == '\n') /* DOS-style text */ len--; /* consume, but don't generate NL */ else ungetc(c, f); } else - (void)putc(c, bitfile) ; - len-- ; + (void)putc(c, bitfile); + len--; } } } else { - putc('\n', bitfile) ; - prevc = 0 ; + putc('\n', bitfile); + prevc = 0; while (len > 0) { - c = getc(f) ; + c = getc(f); if (c == EOF) { - error("premature EOF in MS-DOS font file") ; - len = 0 ; + error("premature EOF in MS-DOS font file"); + len = 0; } else { - (void)putc(hxdata[c >> 4], bitfile) ; - (void)putc(hxdata[c & 15], bitfile) ; - len-- ; - prevc += 2 ; + (void)putc(hxdata[c >> 4], bitfile); + (void)putc(hxdata[c & 15], bitfile); + len--; + prevc += 2; if (prevc >= 76) { - putc('\n', bitfile) ; - prevc = 0 ; + putc('\n', bitfile); + prevc = 0; } } } } - break ; + break; case 3: - goto msdosdone ; + goto msdosdone; default: - error("saw type other than 1, 2, or 3 in MS-DOS font file") ; - break ; + error("saw type other than 1, 2, or 3 in MS-DOS font file"); + break; } - c = getc(f) ; + c = getc(f); if (c == EOF) - break ; + break; if (c != 0x80) { - error("saw non-MSDOS header in MSDOS font file") ; - break ; + error("saw non-MSDOS header in MSDOS font file"); + break; } } msdosdone: - prevc = 0 ; + prevc = 0; } else { /* begin DOS EPS code */ if (c == 'E'+0x80) { if ((getc(f)=='P'+0x80) && (getc(f)=='S'+0x80) && (getc(f)=='F'+0x80)) { doseps = 1; - dosepsbegin = getc(f) ; - dosepsbegin += getc(f) * 256L ; - dosepsbegin += getc(f) * 65536L ; - dosepsbegin += getc(f) * 256L * 65536 ; - dosepsend = getc(f) ; - dosepsend += getc(f) * 256L ; - dosepsend += getc(f) * 65536L ; - dosepsend += getc(f) * 256L * 65536 ; + dosepsbegin = getc(f); + dosepsbegin += getc(f) * 256L; + dosepsbegin += getc(f) * 65536L; + dosepsbegin += getc(f) * 256L * 65536; + dosepsend = getc(f); + dosepsend += getc(f) * 256L; + dosepsend += getc(f) * 65536L; + dosepsend += getc(f) * 256L * 65536; fseek(f, dosepsbegin, 0); c = getc(f); - dosepsend-- ; + dosepsend--; } else { rewind(f); @@ -348,17 +310,19 @@ if (c != EOF) { while (1) { if (c == '\n') { /* end or beginning of line; check DSC */ - *dscLinePointer = 0 ; /* make sure we terminate! + *dscLinePointer = 0; /* make sure we terminate! * might be a new empty line! */ if (strncmp(possibleDSCLine, "%%BeginBinary:", 14) == 0 || strncmp(possibleDSCLine, "%%BeginData:", 12) == 0 || strncmp(possibleDSCLine, "%%BeginFont:", 12) == 0) { - integer size = 0 ; - char *p = possibleDSCLine ; - *dscLinePointer = 0 ; - *dscLineEnd = 0 ; - if (scanForEnd == 0 && removecomments) - (void)fputs(possibleDSCLine, bitfile) ; + integer size = 0; + char *p = possibleDSCLine; + *dscLinePointer = 0; + *dscLineEnd = 0; + if (scanForEnd == 0 && removecomments) { + (void)fputs(possibleDSCLine, bitfile); + (void)putc('\n', bitfile); + } if (strncmp(possibleDSCLine, "%%BeginFont:", 12) == 0) { @@ -377,26 +341,26 @@ } else { scanningFont = 0; - scanForEnd = 0 ; + scanForEnd = 0; while (*p != ':') - p++ ; - p++ ; + p++; + p++; while (*p && *p <= ' ') - p++ ; + p++; if ('0' > *p || *p > '9') { /* * No byte count! We need to scan for end binary * or end data, and hope we get it right. Really * the file is malformed. */ - scanForEnd = "Yes" ; + scanForEnd = "Yes"; } while ('0' <= *p && *p <= '9') { - size = size * 10 + *p - '0' ; - p++ ; + size = size * 10 + *p - '0'; + p++; } while (*p && *p <= ' ') - p++ ; + p++; if (*p == 'h' || *p == 'H') /* * Illustrator 8 and 9 have bogus byte counts @@ -404,55 +368,55 @@ * that it is safe to use ASCII scanning, so * we do so. */ - scanForEnd = "Yes" ; + scanForEnd = "Yes"; while (*p > ' ') /* ignore Hex/Binary/ASCII */ - p++ ; + p++; while (*p && *p <= ' ') - p++ ; - (void)putc(c, bitfile) ; + p++; + (void)putc(c, bitfile); if (c == '\r') { /* maybe we have a DOS-style text file */ c = getc(f); if (c == '\n') { (void)putc(c, bitfile); - dosepsend-- ; + dosepsend--; } else ungetc(c, f); } if (scanForEnd != 0) { if (strncmp(possibleDSCLine, "%%BeginBinary", 13) == 0) - scanForEnd = "%%EndBinary" ; + scanForEnd = "%%EndBinary"; else - scanForEnd = "%%EndData" ; + scanForEnd = "%%EndData"; } } if (scanForEnd == 0) { if (strncmp(p, "lines", 5) != 0 && strncmp(p, "Lines", 5) != 0) { for (; size>0; size--) { - c = getc(f) ; - dosepsend-- ; + c = getc(f); + dosepsend--; if (c == EOF) error( - "! premature end of file in binary section") ; - (void)putc(c, bitfile) ; + "! premature end of file in binary section"); + (void)putc(c, bitfile); } } else { /* * Count both newlines and returns, and when either * goes over the count, we are done. */ - int newlines=0, returns=0 ; + int newlines=0, returns=0; while (newlines < size && returns < size) { - c = getc(f) ; - dosepsend-- ; + c = getc(f); + dosepsend--; if (c == EOF) error( - "! premature end of file in binary section") ; - (void)putc(c, bitfile) ; + "! premature end of file in binary section"); + (void)putc(c, bitfile); if (c == '\n') - newlines++ ; + newlines++; else if (c == '\r') - returns++ ; + returns++; } /* * If we've seen precisely one too few newlines, @@ -460,28 +424,28 @@ */ if (returns == newlines + 1) { if ((c = getc(f)) == '\n') { - putc(c, bitfile) ; - dosepsend-- ; + putc(c, bitfile); + dosepsend--; } else { ungetc(c, f); } } } - c = getc(f) ; - dosepsend-- ; + c = getc(f); + dosepsend--; if (c == '\n' || c == '\r') { - (void)putc(c, bitfile) ; + (void)putc(c, bitfile); if (c == '\r') { /* DOS-style text file? */ c = getc(f); - dosepsend-- ; + dosepsend--; if (c == '\n') { putc(c, bitfile); c = getc(f); - dosepsend-- ; + dosepsend--; } } else { - c = getc(f) ; - dosepsend-- ; + c = getc(f); + dosepsend--; } } if (c != '%') { @@ -489,29 +453,29 @@ in the rest of the file, and pretend it worked; this works around various Illustrator bugs. -tgr, 14 June 2003 */ - char *m1 = "%%EndData" ; - char *m2 = "%%EndBinary" ; - char *p1 = m1 ; - char *p2 = m2 ; + const char *m1 = "%%EndData"; + const char *m2 = "%%EndBinary"; + const char *p1 = m1; + const char *p2 = m2; error( - " expected to see %%EndBinary at end of data; struggling on") ; + " expected to see %%EndBinary at end of data; struggling on"); while (1) { - (void)putc(c, bitfile) ; + (void)putc(c, bitfile); if (c == '\r' || c == '\n') { if (c == '\r') { /* DOS-style text file? */ c = getc(f); if (c != '\n') ungetc(c, f); else - dosepsend-- ; + dosepsend--; } - break ; + break; } - c = getc(f) ; - dosepsend-- ; + c = getc(f); + dosepsend--; if (c == EOF) error( - "! premature end of file in binary section") ; + "! premature end of file in binary section"); /* * By the way, this code can be fooled by things like %%%EndBinary * or even %%EndBi%%EndBinary, but this isn't valid DSC anyway. @@ -519,62 +483,62 @@ * this code when doing stream-based substring matching. */ if (c == *p1) { - p1++ ; + p1++; if (*p1 == 0) - break ; + break; } else { - p1 = m1 ; + p1 = m1; } if (c == *p2) { - p2++ ; + p2++; if (*p2 == 0) - break ; + break; } else { - p2 = m2 ; + p2 = m2; } } } while (1) { - (void)putc(c, bitfile) ; + (void)putc(c, bitfile); if (c == '\r' || c == '\n') { if (c == '\r') { /* DOS-style text file? */ c = getc(f); if (c != '\n') ungetc(c, f); else { - (void)putc(c, bitfile) ; - dosepsend-- ; + (void)putc(c, bitfile); + dosepsend--; } } - break ; + break; } - c = getc(f) ; + c = getc(f); removingBytes = 0; - dosepsend-- ; + dosepsend--; if (c == EOF) error( - "! premature end of file in binary section") ; + "! premature end of file in binary section"); } - c = getc(f) ; - dosepsend-- ; + c = getc(f); + dosepsend--; } } else if (scanForEnd && strncmp(possibleDSCLine, scanForEnd, strlen(scanForEnd))==0) { - scanForEnd = 0 ; + scanForEnd = 0; scanningFont = 0; } - dscLinePointer = possibleDSCLine ; + dscLinePointer = possibleDSCLine; } else if (dscLinePointer < dscLineEnd) { - *dscLinePointer++ = c ; + *dscLinePointer++ = c; if (removecomments && scanForEnd == 0 && c == '%' && dscLinePointer == possibleDSCLine + 1) { /* % is first char */ - c = getc(f) ; + c = getc(f); if (c == '%' || c == '!') - removingBytes = 1 ; + removingBytes = 1; if (c != EOF) - ungetc(c, f) ; - c = '%' ; + ungetc(c, f); + c = '%'; } } #ifdef VMCMS @@ -587,34 +551,34 @@ #endif #endif if (!removingBytes) - (void)putc(c, bitfile) ; + (void)putc(c, bitfile); } - prevc = c ; + prevc = c; /* begin DOS EPS code */ if (doseps && (dosepsend <= 0)) break; /* stop at end of DOS EPS PostScript section */ /* end DOS EPS code */ - c = getc(f) ; - dosepsend-- ; + c = getc(f); + dosepsend--; if (c == EOF) - break ; + break; else if (c == '\r' && ! scanningFont) { c = getc(f); if (c == '\n') { /* DOS-style text file? */ if (!removingBytes) (void)putc('\r', bitfile); - dosepsend-- ; + dosepsend--; } else ungetc(c, f); - c = '\n' ; + c = '\n'; } if (prevc == '\n') - removingBytes = 0 ; + removingBytes = 0; } } } if (prevc != '\n') - (void)putc('\n', bitfile) ; - linepos = 0 ; + (void)putc('\n', bitfile); + linepos = 0; #ifndef VMCMS #ifndef MVSXA #ifndef VMS @@ -625,10 +589,10 @@ #ifdef OS2 { if (_osmode == OS2_MODE) - (void)pclose(f) ; + (void)pclose(f); } #else - (void)pclose(f) ; + (void)pclose(f); #endif else #endif @@ -637,29 +601,29 @@ #endif #endif #endif - (void)fclose(f) ; + (void)fclose(f); if (cur_header && cur_header->postcode) { - (void)fprintf(bitfile, "\n%s", cur_header->postcode) ; - free(cur_header->postcode) ; + (void)fprintf(bitfile, "\n%s", cur_header->postcode); + free(cur_header->postcode); } if (!disablecomments) { if (infigure) - (void)fprintf(bitfile, "\n%%%%EndDocument\n") ; + (void)fprintf(bitfile, "\n%%%%EndDocument\n"); else if (infont) - (void)fprintf(bitfile, "\n%%%%EndFont\n") ; + (void)fprintf(bitfile, "\n%%%%EndFont\n"); #ifdef HPS else if (noprocset) {} #endif else - (void)fprintf(bitfile, "\n%%%%EndProcSet\n") ; + (void)fprintf(bitfile, "\n%%%%EndProcSet\n"); } } } void -copyfile(char *s) +copyfile(const char *s) { - copyfile_general(s, NULL) ; + copyfile_general(s, NULL); } /* @@ -669,9 +633,9 @@ void figcopyfile(char *s, int systemtype) { - infigure = systemtype ? 2 : 1 ; - copyfile(s) ; - infigure = 0 ; + infigure = systemtype ? 2 : 1; + copyfile(s); + infigure = 0; } /* * This next routine writes out a `special' character. In this case, @@ -682,29 +646,29 @@ specialout(char c) { if (linepos >= LINELENGTH) { - (void)putc('\n', bitfile) ; - linepos = 0 ; + (void)putc('\n', bitfile); + linepos = 0; } - (void)putc(c, bitfile) ; - linepos++ ; - lastspecial = 1 ; + (void)putc(c, bitfile); + linepos++; + lastspecial = 1; } void stringend(void) { if (linepos + instring >= LINELENGTH - 2) { - (void)putc('\n', bitfile) ; - linepos = 0 ; + (void)putc('\n', bitfile); + linepos = 0; } - (void)putc('(', bitfile) ; - *strbp = 0 ; - (void)fputs(strbuffer, bitfile) ; - (void)putc(')', bitfile) ; - linepos += instring + 2 ; - lastspecial = 1 ; - instring = 0 ; - strbp = strbuffer ; + (void)putc('(', bitfile); + *strbp = 0; + (void)fputs(strbuffer, bitfile); + (void)putc(')', bitfile); + linepos += instring + 2; + lastspecial = 1; + instring = 0; + strbp = strbuffer; } #ifdef SHIFTLOWCHARS @@ -730,7 +694,7 @@ } } if (curfnt->chardesc[tmpchr].flags2 & EXISTS) - tmpchr = c ; + tmpchr = c; return tmpchr; } #endif @@ -743,9 +707,10 @@ * need room for (, ), and a possible four-byte string \000, for * instance. If it is too long, we send out the string. */ + jflag = 0; if (instring > LINELENGTH-6) { - stringend() ; - chrcmd('p') ; + stringend(); + chrcmd('p'); } #ifdef SHIFTLOWCHARS c=T1Char(c); @@ -754,11 +719,11 @@ if (c<' ' || c > 126 || c=='%' ) { */ if ( c<0x20 || c>= 0x7F || c==0x25 ) { - *strbp++ = '\\' ; - *strbp++ = '0' + ((c >> 6) & 3) ; - *strbp++ = '0' + ((c >> 3) & 7) ; - *strbp++ = '0' + (c & 7) ; - instring += 4 ; + *strbp++ = '\\'; + *strbp++ = '0' + ((c >> 6) & 3); + *strbp++ = '0' + ((c >> 3) & 7); + *strbp++ = '0' + (c & 7); + instring += 4; } else { #ifdef VMCMS c = ascii2ebcdic[c]; @@ -768,12 +733,12 @@ #endif #endif if (c == '(' || c == ')' || c == '\\') { - *strbp++ = '\\' ; - *strbp++ = c ; - instring += 2 ; + *strbp++ = '\\'; + *strbp++ = c; + instring += 2; } else { - *strbp++ = c ; - instring++ ; + *strbp++ = c; + instring++; } } } @@ -781,35 +746,59 @@ static void scout2(int c) { - char s[64] ; + char s[64]; - sprintf(s, "<%04x>p", c) ; - cmdout(s) ; + sprintf(s, "<%04x>p", c); + cmdout(s); +} + +void +jscout(c) /* string character out */ +halfword c; +{ + char s[64]; + + if (!dir) { + numout(hh); + numout(vv); + } else { + numout(vv); + numout(-hh); + } +#if !defined(VFLIB) + if (SJIS && c > 0x2120) c = JIStoSJIS(c); +#endif + sprintf(s, "a<%04x>p", c); + cmdout(s); + lastspecial = 1; + instring = 0; + jflag = 1; + strbuffer[0] = '\0'; } void -cmdout(char *s) +cmdout(const char *s) { - int l ; + int l; /* hack added by dorab */ - if (instring) { + if (instring && !jflag) { stringend(); chrcmd('p'); } - l = strlen(s) ; + l = strlen(s); if ((! lastspecial && linepos >= LINELENGTH - 20) || linepos + l >= LINELENGTH) { - (void)putc('\n', bitfile) ; - linepos = 0 ; - lastspecial = 1 ; - } else if (! lastspecial) { - (void)putc(' ', bitfile) ; - linepos++ ; - } - (void)fputs(s, bitfile) ; - linepos += l ; - lastspecial = 0 ; + (void)putc('\n', bitfile); + linepos = 0; + lastspecial = 1; + } else if (! lastspecial || linepos > 0) { + (void)putc(' ', bitfile); + linepos++; + } + (void)fputs(s, bitfile); + linepos += l; + lastspecial = 0; } @@ -818,70 +807,70 @@ { if ((! lastspecial && linepos >= LINELENGTH - 20) || linepos + 2 > LINELENGTH) { - (void)putc('\n', bitfile) ; - linepos = 0 ; - lastspecial = 1 ; + (void)putc('\n', bitfile); + linepos = 0; + lastspecial = 1; } else if (! lastspecial) { - (void)putc(' ', bitfile) ; - linepos++ ; + (void)putc(' ', bitfile); + linepos++; } - (void)putc(c, bitfile) ; - linepos++ ; - lastspecial = 0 ; + (void)putc(c, bitfile); + linepos++; + lastspecial = 0; } void floatout(float n) { - char buf[20] ; + char buf[20]; - (void)sprintf(buf, "%.2f", n) ; - cmdout(buf) ; + (void)sprintf(buf, "%.2f", n); + cmdout(buf); } void doubleout(double n) { - char buf[40] ; + char buf[40]; - (void)sprintf(buf, "%g", n) ; - cmdout(buf) ; + (void)sprintf(buf, "%g", n); + cmdout(buf); } void numout(integer n) { - char buf[10] ; + char buf[10]; #ifdef SHORTINT - (void)sprintf(buf, "%ld", n) ; + (void)sprintf(buf, "%ld", n); #else - (void)sprintf(buf, "%d", n) ; + (void)sprintf(buf, "%d", n); #endif - cmdout(buf) ; + cmdout(buf); } void mhexout(register unsigned char *p, register long len) { - register char *hexchar = hxdata ; - register int n, k ; + register const char *hexchar = hxdata; + register int n, k; while (len > 0) { if (linepos > LINELENGTH - 2) { - (void)putc('\n', bitfile) ; - linepos = 0 ; + (void)putc('\n', bitfile); + linepos = 0; } - k = (LINELENGTH - linepos) >> 1 ; + k = (LINELENGTH - linepos) >> 1; if (k > len) - k = len ; - len -= k ; - linepos += (k << 1) ; + k = len; + len -= k; + linepos += (k << 1); while (k--) { - n = *p++ ; - (void)putc(hexchar[n >> 4], bitfile) ; - (void)putc(hexchar[n & 15], bitfile) ; + n = *p++; + (void)putc(hexchar[n >> 4], bitfile); + (void)putc(hexchar[n & 15], bitfile); } } } @@ -889,69 +878,116 @@ void fontout(int n) { - char buf[6] ; + char buf[6]; - if (instring) { - stringend() ; - chrcmd('p') ; + if (instring && !jflag) { + stringend(); + chrcmd('p'); } - makepsname(buf, n) ; - cmdout(buf) ; + makepsname(buf, n); + cmdout(buf); } void hvpos(void) { - if (rvv != vv) { - if (instring) { - stringend() ; - numout(hh) ; - numout(vv) ; - chrcmd('y') ; - } else if (rhh != hh) { - numout(hh) ; - numout(vv) ; - chrcmd('a') ; - } else { /* hard to get this case, but it's there when you need it! */ - numout(vv - rvv) ; - chrcmd('x') ; - } - rvv = vv ; - } else if (rhh != hh) { - if (instring) { - stringend() ; - if (hh - rhh < 5 && rhh - hh < 5) { + if (!dir) { + if (rvv != vv || jflag) { + if (instring) { + stringend(); + numout(hh); + numout(vv); + chrcmd('y'); + } else { + numout(hh); + numout(vv); + chrcmd('a'); + } + rvv = vv; + } else if (rhh != hh || jflag) { + if (instring) { + stringend(); + if (hh - rhh < 5 && rhh - hh < 5) { #ifdef VMCMS /* should replace 'p' in non-VMCMS line as well */ - chrcmd(ascii2ebcdic[(char)(112 + hh - rhh)]) ; + chrcmd(ascii2ebcdic[(char)(112 + hh - rhh)]); #else #ifdef MVSXA /* should replace 'p' in non-MVSXA line as well */ - chrcmd(ascii2ebcdic[(char)(112 + hh - rhh)]) ; + chrcmd(ascii2ebcdic[(char)(112 + hh - rhh)]); #else - chrcmd((char)('p' + hh - rhh)) ; + chrcmd((char)('p' + hh - rhh)); #endif #endif - } else if (hh - rhh < d + 5 && rhh - hh < 5 - d) { + } else if (hh - rhh < d + 5 && rhh - hh < 5 - d) { #ifdef VMCMS /* should replace 'g' in non-VMCMS line as well */ - chrcmd(ascii2ebcdic[(char)(103 + hh - rhh - d)]) ; + chrcmd(ascii2ebcdic[(char)(103 + hh - rhh - d)]); #else #ifdef MVSXA /* should replace 'g' in non-MVSXA line as well */ - chrcmd(ascii2ebcdic[(char)(103 + hh - rhh - d)]) ; + chrcmd(ascii2ebcdic[(char)(103 + hh - rhh - d)]); #else - chrcmd((char)('g' + hh - rhh - d)) ; + chrcmd((char)('g' + hh - rhh - d)); #endif #endif - d = hh - rhh ; + d = hh - rhh; + } else { + numout(hh - rhh); + chrcmd('b'); + d = hh - rhh; + } } else { - numout(hh - rhh) ; - chrcmd('b') ; - d = hh - rhh ; + numout(hh - rhh); + chrcmd('w'); + } + } + rhh = hh; + } else { + if (rhh != hh || jflag) { + if (instring) { + stringend(); + numout(vv); + numout(-hh); + chrcmd('y'); + } else { + numout(vv); + numout(-hh); + chrcmd('a'); + } + rhh = hh; + } else if (rvv != vv || jflag) { + if (instring) { + stringend(); + if (vv - rvv < 5 && rvv - vv < 5) { +#ifdef VMCMS /* should replace 'p' in non-VMCMS line as well */ + chrcmd(ascii2ebcdic[(char)(112 + vv - rvv)]); +#else +#ifdef MVSXA /* should replace 'p' in non-MVSXA line as well */ + chrcmd(ascii2ebcdic[(char)(112 + vv - rvv)]); +#else + chrcmd((char)('p' + vv - rvv)); +#endif +#endif + } else if (vv - rvv < d + 5 && rvv - vv < 5 - d) { +#ifdef VMCMS /* should replace 'g' in non-VMCMS line as well */ + chrcmd(ascii2ebcdic[(char)(103 + vv - rvv - d)]); +#else +#ifdef MVSXA /* should replace 'g' in non-MVSXA line as well */ + chrcmd(ascii2ebcdic[(char)(103 + vv - rvv - d)]); +#else + chrcmd((char)('g' + vv - rvv - d)); +#endif +#endif + d = vv - rvv; + } else { + numout(vv - rvv); + chrcmd('b'); + d = vv - rvv; + } + } else { + numout(vv - rvv); + chrcmd('w'); } - } else { - numout(hh - rhh) ; - chrcmd('w') ; } + rvv = vv; } - rhh = hh ; } /* @@ -962,29 +998,30 @@ newline(void) { if (linepos != 0) { - (void)fprintf(bitfile, "\n") ; - linepos = 0 ; + (void)fprintf(bitfile, "\n"); + linepos = 0; } - lastspecial = 1 ; + lastspecial = 1; } void -nlcmdout(char *s) +nlcmdout(const char *s) { - newline() ; - cmdout(s) ; - newline() ; + newline(); + cmdout(s); + newline(); } /* - * Is the dimension close enough for a match? We use 5bp + * Is the dimension close enough for a match? We use a 5bp * as a match; this is 65536*72.27*5/72 or 328909 scaled points. */ static int indelta(integer i) { if (i < 0) - i = -i ; - return (i <= 328909) ; + i = -i; + return (i <= 328909); +/* return (i <= 1184072); */ } /* * A case-irrelevant string compare. @@ -993,20 +1030,20 @@ mlower(int c) { if ('A' <= c && c <= 'Z') - return c - 'A' + 'a' ; + return c - 'A' + 'a'; else - return c ; + return c; } int -ncstrcmp(char *a, char *b) +ncstrcmp(const char *a, const char *b) { while (*a && (*a == *b || mlower(*a) == mlower(*b))) - a++, b++ ; + a++, b++; if (*a == 0 && *b == 0) - return 0 ; + return 0; else - return 1 ; + return 1; } /* * Find the paper size. @@ -1014,16 +1051,16 @@ void findpapersize(void) { if (finpapsiz == 0) { - struct papsiz *ps ; - struct papsiz *fps = 0 ; - int ih, iv, it ; - int mindiff = 0x7fffffff ; + struct papsiz *ps; + struct papsiz *fps = 0; + int ih, iv, it; + int mindiff = 0x7fffffff; if (tryepsf && !landscape) { - finpapsiz = &defpapsiz ; - hpapersize = defpapsiz.xsize ; - vpapersize = defpapsiz.ysize ; - return ; + finpapsiz = &defpapsiz; + hpapersize = defpapsiz.xsize; + vpapersize = defpapsiz.ysize; + return; } if (cropmarks) { /* @@ -1032,92 +1069,92 @@ */ if (hpapersize == 0 || vpapersize == 0) { error( - "warning: -k crop marks wanted, but no paper size specified; using default") ; + "warning: -k crop marks wanted, but no paper size specified; using default"); if (landscape) { - hpapersize = defpapsiz.ysize ; - vpapersize = defpapsiz.xsize ; + hpapersize = defpapsiz.ysize; + vpapersize = defpapsiz.xsize; } else { - hpapersize = defpapsiz.xsize ; - vpapersize = defpapsiz.ysize ; + hpapersize = defpapsiz.xsize; + vpapersize = defpapsiz.ysize; } } - hpapersize += 2368143L ; - vpapersize += 2368143L ; - add_header(CROPHEADER) ; + hpapersize += 2368143L; + vpapersize += 2368143L; + add_header(CROPHEADER); } if (paperfmt && *paperfmt) { for (ps = papsizes; ps; ps = ps->next) if (ncstrcmp(paperfmt, ps->name)==0) - finpapsiz = ps ; + finpapsiz = ps; if (finpapsiz == 0) - error("no match for papersize") ; + error("no match for papersize"); } if (finpapsiz == 0 && hpapersize > 0 && vpapersize > 0) { for (ps=papsizes; ps; ps = ps->next) { - ih = ps->xsize-hpapersize ; - iv = ps->ysize-vpapersize ; - if (ih < 0) ih = -ih ; - if (iv < 0) iv = -iv ; - it = ih ; - if (it < iv) it = iv ; + ih = ps->xsize-hpapersize; + iv = ps->ysize-vpapersize; + if (ih < 0) ih = -ih; + if (iv < 0) iv = -iv; + it = ih; + if (it < iv) it = iv; if (it < mindiff) { - mindiff = it ; - fps = ps ; + mindiff = it; + fps = ps; } - } + } if (indelta(mindiff)) - landscape = 0 ; + landscape = 0; else - fps = 0 ; - mindiff = 0x7fffffff ; + fps = 0; + mindiff = 0x7fffffff; if (fps == 0) { for (ps=papsizes; ps; ps = ps->next) { - iv = ps->ysize-hpapersize ; - ih = ps->xsize-vpapersize ; - if (ih < 0) ih = -ih ; - if (iv < 0) iv = -iv ; - it = ih ; - if (it < iv) it = iv ; + iv = ps->ysize-hpapersize; + ih = ps->xsize-vpapersize; + if (ih < 0) ih = -ih; + if (iv < 0) iv = -iv; + it = ih; + if (it < iv) it = iv; if (it < mindiff) { - mindiff = it ; - fps = ps ; - } - } + mindiff = it; + fps = ps; + } + } if (indelta(mindiff)) - landscape = 1 ; + landscape = 1; else - fps = 0 ; + fps = 0; if (fps == 0) { for (ps=papsizes; ps; ps = ps->next) { if (ps->ysize == 0 && ps->xsize == 0) { - fps = ps ; - break ; - } + fps = ps; + break; + } } if (fps == 0) { - landscape = (hpapersize > vpapersize) ; + landscape = (hpapersize > vpapersize); error( - "no match for special paper size found; using default") ; + "no match for special paper size found; using default"); } } } - finpapsiz = fps ; + finpapsiz = fps; } if (finpapsiz == 0) { if (papsizes) - finpapsiz = papsizes ; + finpapsiz = papsizes; else - finpapsiz = &defpapsiz ; + finpapsiz = &defpapsiz; /* * But change xsize/ysize to match so bounding box works. */ if (hpapersize && vpapersize) { if (landscape) { - finpapsiz->ysize = hpapersize ; - finpapsiz->xsize = vpapersize ; + finpapsiz->ysize = hpapersize; + finpapsiz->xsize = vpapersize; } else { - finpapsiz->xsize = hpapersize ; - finpapsiz->ysize = vpapersize ; + finpapsiz->xsize = hpapersize; + finpapsiz->ysize = vpapersize; } } } @@ -1128,15 +1165,15 @@ */ if (hpapersize == 0 || vpapersize == 0) { if (finpapsiz->xsize == 0 || finpapsiz->ysize == 0) { - finpapsiz->xsize = defpapsiz.xsize ; - finpapsiz->ysize = defpapsiz.ysize ; + finpapsiz->xsize = defpapsiz.xsize; + finpapsiz->ysize = defpapsiz.ysize; } if (landscape) { - vpapersize = finpapsiz->xsize ; - hpapersize = finpapsiz->ysize ; + vpapersize = finpapsiz->xsize; + hpapersize = finpapsiz->ysize; } else { - hpapersize = finpapsiz->xsize ; - vpapersize = finpapsiz->ysize ; + hpapersize = finpapsiz->xsize; + vpapersize = finpapsiz->ysize; } /* * Here, there was a papersize special, but the selected paper @@ -1144,8 +1181,8 @@ * bounding box works. */ } else if (finpapsiz->xsize == 0 || finpapsiz->ysize == 0) { - finpapsiz->xsize = hpapersize ; - finpapsiz->ysize = vpapersize ; + finpapsiz->xsize = hpapersize; + finpapsiz->ysize = vpapersize; /* * Here, the user specified a size with -t, and there was a * papersize special, and its sizes were greater than zero. @@ -1158,18 +1195,18 @@ !indelta(hpapersize - finpapsiz->ysize)) { if (vpapersize > finpapsiz->xsize || hpapersize > finpapsiz->ysize) - error("warning: -t selected paper may be too small") ; + error("warning: -t selected paper may be too small"); else - error("note: -t selected paper may be too large") ; + error("note: -t selected paper may be too large"); } } else { if (!indelta(hpapersize - finpapsiz->xsize) || !indelta(vpapersize - finpapsiz->ysize)) { if (hpapersize > finpapsiz->xsize || vpapersize > finpapsiz->ysize) - error("warning: -t selected paper may be too small") ; + error("warning: -t selected paper may be too small"); else - error("note: -t selected paper may be too large") ; + error("note: -t selected paper may be too large"); } } } @@ -1183,35 +1220,35 @@ static int topoints(integer i) { - i += 65780L ; - return (i / 6578176L)*100 + (i % 6578176) * 100 / 6578176 ; + i += 65780L; + return (i / 6578176L)*100 + (i % 6578176) * 100 / 6578176; } /* * Send out the special paper stuff. If `hed' is non-zero, only * send out lines starting with `!' else send all other lines out. */ void -paperspec(char *s, int hed) +paperspec(const char *s, int hed) { - int sendit ; + int sendit; while (*s) { - s++ ; + s++; if (*s == '\0') - return ; + return; if (*s == '!') { - s++ ; - while (*s == ' ') s++ ; - sendit = hed ; + s++; + while (*s == ' ') s++; + sendit = hed; } else - sendit = ! hed ; + sendit = ! hed; if (sendit) { while (*s && *s != '\n') - (void)putc(*s++, bitfile) ; - putc('\n', bitfile) ; + (void)putc(*s++, bitfile); + putc('\n', bitfile); } else { while (*s && *s != '\n') - s++ ; + s++; } } } @@ -1219,13 +1256,13 @@ epsftest(integer bop) { if (tryepsf && paperfmt == 0 && *iname) { - findbb(bop+44) ; - return nextstring ; + findbb(bop+44); + return nextstring; } - return 0 ; + return 0; } -static char *isepsf = 0 ; -static int endprologsent ; +static char *isepsf = 0; +static int endprologsent; void open_output(void) { FILE * pf = NULL; @@ -1236,58 +1273,32 @@ */ if (*oname == '!' || *oname == '|') { #if defined (MSDOS) && !defined (__DJGPP__) - error("! can't open output pipe") ; + error("! can't open output pipe"); #else #ifdef VMS - error("! can't open output pipe") ; + error("! can't open output pipe"); #else #ifdef VMCMS - error("! can't open output pipe") ; + error("! can't open output pipe"); #else #ifdef MVSXA - error("! can't open output pipe") ; + error("! can't open output pipe"); #else #ifdef __THINK__ - error("! can't open output pipe") ; + error("! can't open output pipe"); #else #ifdef ATARIST - error("! can't open output pipe") ; + error("! can't open output pipe"); #else #ifdef OS2 if (_osmode != OS2_MODE) { - error("! can't open output pipe") ; + error("! can't open output pipe"); } else { #endif -#ifdef __DJGPP__ - /* Feature: if they pipe to "lpr" and there's no executable by - that name anywhere in sight, write to local printer instead. - - We do this up front, before even trying to popen, because on - MS-DOS popen always succeeds for writing (it only opens a - temporary file), and by the time we get to actually run the - (possibly nonexistent) program in pclose, it's too late to - fall back. - - We don't use kpathsea functions here because they don't - know about DOS-specific executable extensions, while we - want to be able to find "lpr.exe", "lpr.com", "lpr.bat" etc. */ - extern char *__dosexec_find_on_path(const char *, - char **, char *) ; - extern char **environ ; - char *p = oname + 1 ; - char found[FILENAME_MAX] ; - - while (ISSPACE(*p)) - p++ ; - if (strncmp(p, "lpr", 3) == 0 && (ISSPACE(p[3]) || p[3] == '\0') - && !__dosexec_find_on_path(oname+1, (char **)0, found) - && !__dosexec_find_on_path(oname+1, environ, found)) - pf = fopen("PRN", "w") ; -#endif - if (pf == NULL && (pf = popen(oname+1, "w")) != NULL) + if (pf == NULL && (pf = popen(oname+1, "w")) != NULL) popened = 1; if (pf == NULL) - error("! couldn't open output pipe") ; + error("! couldn't open output pipe"); bitfile = pf; #ifdef OS2 } @@ -1299,54 +1310,59 @@ #endif #endif } else { +#ifdef WIN32 + if ((bitfile=fopen(oname,"wb"))==NULL) +#else if ((bitfile=fopen(oname,"w"))==NULL) - error("! couldn't open PostScript file") ; +#endif + error("! couldn't open PostScript file"); } } else { - bitfile = stdout ; + bitfile = stdout; } /* Even PostScript output may include binary characters, so switch bitfile to binary mode. */ if (O_BINARY && !isatty(fileno(bitfile))) - SET_BINARY(fileno(bitfile)) ; + SET_BINARY(fileno(bitfile)); } void initprinter(sectiontype *sect) { - void tell_needed_fonts() ; - int n = sect->numpages * pagecopies * collatedcopies ; + void tell_needed_fonts(); + int n = sect->numpages * pagecopies * collatedcopies; #ifdef HPS if (!HPS_FLAG) #endif - open_output() ; + open_output(); - findpapersize() ; + findpapersize(); if (disablecomments) { (void)fprintf(bitfile, - "%%!PS (but not EPSF; comments have been disabled)\n") ; - (void)fprintf(stderr, "Warning: no %%%%Page comments generated.\n") ; + "%%!PS (but not EPSF; comments have been disabled)\n"); + (void)fprintf(stderr, "Warning: no %%%%Page comments generated.\n"); } else { if (multiplesects) { (void)fprintf(bitfile, - "%%!PS (but not EPSF because of memory limits)\n") ; - (void)fprintf(stderr, "Warning: no %%%%Page comments generated.\n") ; + "%%!PS (but not EPSF because of memory limits)\n"); + (void)fprintf(stderr, "Warning: no %%%%Page comments generated.\n"); } else { - isepsf = epsftest(sect->bos) ; + isepsf = epsftest(sect->bos); if (isepsf) - (void)fprintf(bitfile, "%%!PS-Adobe-2.0 EPSF-2.0\n") ; + (void)fprintf(bitfile, "%%!PS-Adobe-2.0 EPSF-2.0\n"); else - (void)fprintf(bitfile, "%%!PS-Adobe-2.0\n") ; + (void)fprintf(bitfile, "%%!PS-Adobe-2.0\n"); } if (tryepsf && isepsf == 0) - error("We tried, but couldn't make it EPSF.") ; - (void)fprintf(bitfile, "%%%%Creator: %s\n", banner + 8) ; + error("We tried, but couldn't make it EPSF."); + (void)fprintf(bitfile, "%%%%Creator: %s\n", banner + 8); + (void)fprintf(bitfile, "%%%%+ %s\n", banner2); if (*iname) - (void)fprintf(bitfile, "%%%%Title: %s\n", iname) ; + (void)fprintf(bitfile, "%%%%Title: %s\n", iname); #ifdef CREATIONDATE jobtime=time(0); (void)fprintf(bitfile, "%%%%CreationDate: %s", - asctime(localtime(&jobtime))) ; + asctime(localtime(&jobtime))); #endif if (! isepsf) { /* @@ -1356,133 +1372,134 @@ * spoolers. */ (void)fprintf(bitfile, "%%%%Pages: %d%s\n", (sepfiles ? n : totalpages), - (reverse?" -1":"")) ; + (reverse?" -1":"")); (void)fprintf(bitfile, "%%%%PageOrder: %sscend\n", reverse?"De":"A"); } if (landscape) { - fprintf(bitfile, "%%%%Orientation: Landscape\n") ; + fprintf(bitfile, "%%%%Orientation: Landscape\n"); fprintf(bitfile, "%%%%BoundingBox: 0 0 %d %d\n", - topoints(finpapsiz->xsize), topoints(finpapsiz->ysize)) ; + topoints(finpapsiz->xsize), topoints(finpapsiz->ysize)); } else if (isepsf) - fprintf(bitfile, "%%%%BoundingBox: %s\n", isepsf) ; + fprintf(bitfile, "%%%%BoundingBox: %s\n", isepsf); else fprintf(bitfile, "%%%%BoundingBox: 0 0 %d %d\n", - topoints(finpapsiz->xsize), topoints(finpapsiz->ysize)) ; - tell_needed_fonts() ; - paperspec(finpapsiz->specdat, 1) ; - (void)fprintf(bitfile, "%%%%EndComments\n") ; + topoints(finpapsiz->xsize), topoints(finpapsiz->ysize)); + tell_needed_fonts(); + paperspec(finpapsiz->specdat, 1); + (void)fprintf(bitfile, "%%%%EndComments\n"); } { - int i, len ; - char *p ; + int i, len; + char *p; /* * Here, too, we have to be careful not to exceed the line length * limitation, if possible. */ - (void)fprintf(bitfile, "%%DVIPSWebPage: %s\n", banner2) ; - (void)fprintf(bitfile, "%%DVIPSCommandLine:") ; - len = 18 ; + (void)fprintf(bitfile, "%%DVIPSWebPage: %s\n", weburl); + (void)fprintf(bitfile, "%%DVIPSCommandLine:"); + len = 18; for (i=0; i ' ') - p++ ; + p++; if (*p) - len += 2 ; - len += strlen(gargv[i]) + 1 ; + len += 2; + len += strlen(gargv[i]) + 1; if (len > LINELENGTH) { - (void)fprintf(bitfile, "\n%%+") ; - len = strlen(gargv[i]) + 3 ; + (void)fprintf(bitfile, "\n%%+"); + len = strlen(gargv[i]) + 3; if (*p) - len += 2 ; + len += 2; } - (void)fprintf(bitfile, (*p ? " \"%s\"" : " %s"), gargv[i]) ; + (void)fprintf(bitfile, (*p ? " \"%s\"" : " %s"), gargv[i]); } - (void)fprintf(bitfile, "\n%%DVIPSParameters: dpi=%d", actualdpi) ; + (void)fprintf(bitfile, "\n%%DVIPSParameters: dpi=%d", actualdpi); if (actualdpi != vactualdpi) - (void)fprintf(bitfile, "x%d", vactualdpi) ; + (void)fprintf(bitfile, "x%d", vactualdpi); if (compressed) - (void)fprintf(bitfile, ", compressed") ; + (void)fprintf(bitfile, ", compressed"); if (removecomments) - (void)fprintf(bitfile, ", comments removed") ; - (void)fputc('\n', bitfile) ; + (void)fprintf(bitfile, ", comments removed"); + (void)fputc('\n', bitfile); } #ifdef VMCMS /* convert preamblecomment to ebcdic so we can read it */ { - int i ; - for ( i=0 ; preamblecomment[i] ; i++ ) - preamblecomment[i] = ascii2ebcdic[preamblecomment[i]] ; + int i; + for ( i=0; preamblecomment[i]; i++ ) + preamblecomment[i] = ascii2ebcdic[preamblecomment[i]]; } #else #ifdef MVSXA /* IBM: MVS/XA */ { - int i ; - for ( i=0 ; preamblecomment[i] ; i++ ) - preamblecomment[i] = ascii2ebcdic[preamblecomment[i]] ; + int i; + for ( i=0; preamblecomment[i]; i++ ) + preamblecomment[i] = ascii2ebcdic[preamblecomment[i]]; } #endif /* VMCMS */ #endif - (void)fprintf(bitfile, "%%DVIPSSource: %s\n", preamblecomment) ; - linepos = 0 ; - endprologsent = 0 ; + (void)fprintf(bitfile, "%%DVIPSSource: %s\n", preamblecomment); + linepos = 0; + endprologsent = 0; if (safetyenclose) - (void)fprintf(bitfile, "/SafetyEnclosure save def\n") ; + (void)fprintf(bitfile, "/SafetyEnclosure save def\n"); + print_composefont(); if (! headers_off) - send_headers() ; + send_headers(); } void setup(void) { - newline() ; + newline(); if (endprologsent == 0 && !disablecomments) { - (void)fprintf(bitfile, "%%%%EndProlog\n") ; - (void)fprintf(bitfile, "%%%%BeginSetup\n") ; + (void)fprintf(bitfile, "%%%%EndProlog\n"); + (void)fprintf(bitfile, "%%%%BeginSetup\n"); if (vactualdpi == actualdpi) (void)fprintf(bitfile, "%%%%Feature: *Resolution %ddpi\n", - actualdpi) ; + actualdpi); else (void)fprintf(bitfile, "%%%%Feature: *Resolution %dx%ddpi\n", - actualdpi, vactualdpi) ; + actualdpi, vactualdpi); if (multiplesects && *(finpapsiz->specdat)) { - (void)fprintf(bitfile, "TeXDict begin\n") ; - paperspec(finpapsiz->specdat, 0) ; - (void)fprintf(bitfile, "end\n") ; + (void)fprintf(bitfile, "TeXDict begin\n"); + paperspec(finpapsiz->specdat, 0); + (void)fprintf(bitfile, "end\n"); } if (manualfeed) - (void)fprintf(bitfile, "%%%%Feature: *ManualFeed True\n") ; + (void)fprintf(bitfile, "%%%%Feature: *ManualFeed True\n"); #ifdef HPS if (!HPS_FLAG) #endif if (multiplesects) - (void)fprintf(bitfile, "%%%%EndSetup\n") ; + (void)fprintf(bitfile, "%%%%EndSetup\n"); } if (multiplesects && ! disablecomments) - (void)fprintf(bitfile, "%%DVIPSBeginSection\n") ; - cmdout("TeXDict") ; - cmdout("begin") ; + (void)fprintf(bitfile, "%%DVIPSBeginSection\n"); + cmdout("TeXDict"); + cmdout("begin"); if (endprologsent || disablecomments || multiplesects == 0) { - (void)fprintf(bitfile, "\n") ; - paperspec(finpapsiz->specdat, 0) ; + (void)fprintf(bitfile, "\n"); + paperspec(finpapsiz->specdat, 0); } - if (manualfeed) cmdout("@manualfeed") ; - if (landscape) cmdout("@landscape") ; + if (manualfeed) cmdout("@manualfeed"); + if (landscape) cmdout("@landscape"); if (numcopies != 1) { - numout((integer)numcopies) ; - cmdout("@copies") ; + numout((integer)numcopies); + cmdout("@copies"); } - cmdout("end") ; + cmdout("end"); if (endprologsent == 0 && !disablecomments) { - newline() ; - endprologsent = 1 ; + newline(); + endprologsent = 1; #ifdef HPS if (!HPS_FLAG) #endif if (! multiplesects) - (void)fprintf(bitfile, "%%%%EndSetup\n") ; + (void)fprintf(bitfile, "%%%%EndSetup\n"); } #ifdef HPS if (HPS_FLAG) { - fclose(bitfile) ; - set_bitfile("body.tmp",0) ; + fclose(bitfile); + set_bitfile("body.tmp",0); } #endif } @@ -1492,16 +1509,16 @@ void cleanprinter(void) { - (void)fprintf(bitfile, "\n") ; - (void)fprintf(bitfile, "userdict /end-hook known{end-hook}if\n") ; + (void)fprintf(bitfile, "\n"); + (void)fprintf(bitfile, "userdict /end-hook known{end-hook}if\n"); if (safetyenclose) - (void)fprintf(bitfile, "SafetyEnclosure restore\n") ; + (void)fprintf(bitfile, "SafetyEnclosure restore\n"); if (!disablecomments) - (void)fprintf(bitfile, "%%%%EOF\n") ; + (void)fprintf(bitfile, "%%%%EOF\n"); if (sendcontrolD) - (void)putc(4, bitfile) ; + (void)putc(4, bitfile); if (ferror(bitfile)) - error("Problems with file writing; probably disk full.") ; + error("Problems with file writing; probably disk full."); #if !defined(MSDOS) || defined(__DJGPP__) #ifndef VMS #ifndef MVSXA @@ -1512,7 +1529,7 @@ if (_osmode == OS2_MODE) #endif if (popened) - (void)pclose(bitfile) ; + (void)pclose(bitfile); #endif #endif #endif @@ -1520,17 +1537,17 @@ #endif #endif if (popened == 0) - (void)fclose(bitfile) ; - bitfile = NULL ; + (void)fclose(bitfile); + bitfile = NULL; } /* this tells dvips that it has no clue where it is. */ -static int thispage = 0 ; -static integer rulex, ruley ; +static int thispage = 0; +static integer rulex, ruley; void psflush(void) { - rulex = ruley = rhh = rvv = -314159265 ; - lastfont = -1 ; + rulex = ruley = rhh = rvv = -314159265; + lastfont = -1; } /* * pageinit initializes the output variables. @@ -1538,35 +1555,35 @@ void pageinit(void) { - psflush() ; - newline() ; - thispage++ ; + psflush(); + newline(); + thispage++; if (!disablecomments) { if (multiplesects) #ifdef SHORTINT - (void)fprintf(bitfile, "%%DVIPSSectionPage: %ld\n", pagenum) ; + (void)fprintf(bitfile, "%%DVIPSSectionPage: %ld\n", pagenum); else if (! isepsf) - (void)fprintf(bitfile, "%%%%Page: %ld %d\n", pagenum, thispage) ; + (void)fprintf(bitfile, "%%%%Page: %ld %d\n", pagenum, thispage); #else - (void)fprintf(bitfile, "%%DVIPSSectionPage: %d\n", pagenum) ; + (void)fprintf(bitfile, "%%DVIPSSectionPage: %d\n", pagenum); else if (! isepsf) - (void)fprintf(bitfile, "%%%%Page: %d %d\n", pagenum, thispage) ; + (void)fprintf(bitfile, "%%%%Page: %d %d\n", pagenum, thispage); #endif } - linepos = 0 ; - cmdout("TeXDict") ; - cmdout("begin") ; + linepos = 0; + cmdout("TeXDict"); + cmdout("begin"); #ifdef HPS if (HPS_FLAG) { - cmdout("HPSdict") ; - cmdout("begin") ; + cmdout("HPSdict"); + cmdout("begin"); } #endif - if (landscape) cmdout("@landscape") ; - numout((integer)pagenum) ; - numout((integer)thispage-1) ; - cmdout("bop") ; - d = 0 ; + if (landscape) cmdout("@landscape"); + numout((integer)pagenum); + numout((integer)thispage-1); + cmdout("bop"); + d = 0; } @@ -1578,14 +1595,17 @@ pageend(void) { if (instring) { - stringend() ; - chrcmd('p') ; + stringend(); + chrcmd('p'); } - cmdout("eop") ; - cmdout("end") ; + if (dir) + cmdout("-90 rotate"); + cmdout("dyy"); + cmdout("eop"); + cmdout("end"); #ifdef HPS if (HPS_FLAG) - cmdout("end") ; + cmdout("end"); #endif } @@ -1599,16 +1619,21 @@ void drawrule(integer rw, integer rh) { - numout((integer)hh) ; - numout((integer)vv) ; + if (!dir) { + numout((integer)hh); + numout((integer)vv); + } else { + numout((integer)vv); + numout((integer)-hh); + } if (rw == rulex && rh == ruley) - chrcmd('V') ; + chrcmd('V'); else { - numout((integer)rw) ; - numout((integer)rh) ; - chrcmd('v') ; - rulex = rw ; - ruley = rh ; + numout((integer)rw); + numout((integer)rh); + chrcmd('v'); + rulex = rw; + ruley = rh; } } @@ -1618,38 +1643,155 @@ void drawchar(chardesctype *c, int cc) { - hvpos() ; + if (rdir != dir || fdir != curfnt->dir) { + if (curfnt->dir == 9) + setdir(dir+2); + else + setdir(dir); + rdir = dir; + fdir = curfnt->dir; + } + if (lastfont != curfnt->psname) { - fontout((int)curfnt->psname) ; - lastfont = curfnt->psname ; + fontout((int)curfnt->psname); + lastfont = curfnt->psname; } - if (curfnt->codewidth==1) scout((unsigned char)cc) ; - else scout2(cc) ; - rhh = hh + c->pixelwidth ; /* rvv = rv */ + if (curfnt->iswide == 0 && curfnt->codewidth == 2) { + hvpos(); + scout2(cc); + } + else if (curfnt->iswide) { + jscout(cc); + } + else { + if (jflag) { + if (!dir){ + numout(hh); + numout(vv); + } + else { + numout(vv); + numout(-hh); + } + chrcmd('a'); + rhh = hh; + rvv = vv; + } + else hvpos(); + scout((unsigned char)cc); + } + if (!dir) + rhh = hh + c->pixelwidth; /* rvv = rv */ + else + rvv = vv + c->pixelwidth; /* rhh = rh */ } /* * This routine sends out the document fonts comment. */ void tell_needed_fonts(void) { - struct header_list *hl = ps_fonts_used ; - char *q ; - int roomleft = -1 ; + struct header_list *hl = ps_fonts_used; + char *q; + int roomleft = -1; if (hl == 0) - return ; + return; while (0 != (q=get_name(&hl))) { if ((int)strlen(q) >= roomleft) { if (roomleft != -1) { - fprintf(bitfile, "\n%%%%+") ; - roomleft = LINELENGTH - 3 ; + fprintf(bitfile, "\n%%%%+"); + roomleft = LINELENGTH - 3; } else { - fprintf(bitfile, "%%%%DocumentFonts:") ; - roomleft = LINELENGTH - 16 ; + fprintf(bitfile, "%%%%DocumentFonts:"); + roomleft = LINELENGTH - 16; } } - fprintf(bitfile, " %s", q) ; - roomleft -= strlen(q) + 1 ; + fprintf(bitfile, " %s", q); + roomleft -= strlen(q) + 1; + } + fprintf(bitfile, "\n"); +} + +void print_composefont(void) +{ + struct header_list *hl = ps_fonts_used; + int len; + char *q, *p; + + if (hl == 0) + return; + while (0 != (q=get_name(&hl))) { + len = strlen(q); + if(len > 11 && (!strncmp(q+len-10, "Identity-H", 10) || + !strncmp(q+len-10, "Identity-V", 10))) { + fprintf(bitfile, "%%%%BeginFont: %s\n", q); + fprintf(bitfile, "/%s ", q); + fprintf(bitfile, "/%s ", q+len-10); + fprintf(bitfile, "[/"); + for(p=q; p <= q+len-12; p++) + fprintf(bitfile, "%c", *p); + fprintf(bitfile, "] composefont pop\n"); + fprintf(bitfile, "%%%%EndFont\n"); + } + } +} + +void setdir(int d) +{ + if (instring) { + stringend(); + chrcmd('p'); + } + switch(d) { + case 1 : + cmdout("dyt"); + break; + case 2 : + cmdout("dty"); + break; + case 3 : + cmdout("dtt"); + break; + default : + cmdout("dyy"); + break; } - fprintf(bitfile, "\n") ; + linepos += 4; +} + +void cmddir(void) +{ + if (dir != rdir) { + if (dir) + cmdout("90 rotate"); + else + cmdout("-90 rotate"); + rdir = dir; + } +} + +#if !defined(VFLIB) +int JIStoSJIS(int c) +{ + int high, low; + int nh,nl; + + high = (c>>8) & 0xff; + low = c & 0xff; + nh = ((high-0x21)>>1) + 0x81; + if (nh>0x9f) + nh += 0x40; + if (high & 1) { + nl = low + 0x1f; + if (low>0x5f) + nl++; + } + else + nl = low + 0x7e; + if (((nh >= 0x81 && nh <= 0x9f) || (nh >= 0xe0 && nh <= 0xfc)) + && (nl >= 0x40 && nl <= 0xfc && nl != 0x7f)) + return((nh<<8) | nl); + else + return(0x813f); } +#endif /* ! VFLIB */ diff -Nu dvipsk2009/papersiz.c dvipsk/papersiz.c --- dvipsk2009/papersiz.c Tue Jun 23 18:46:14 2009 +++ dvipsk/papersiz.c Mon Mar 29 23:29:55 2010 @@ -12,18 +12,21 @@ * 0 <= whole */ #include "dvips.h" /* The copyright notice in that file is included too! */ +/* + * The external declarations: + */ #include "protos.h" static long scale(long whole, long num, long den, long sf) { - long v ; + long v; - v = whole * sf + num * (sf / den) ; + v = whole * sf + num * (sf / den); if (v / sf != whole || v < 0 || v > 0x40000000L) - error("! arithmetic overflow in parameter") ; - sf = sf % den ; - v += (sf * num * 2 + den) / (2 * den) ; - return(v) ; + error("! arithmetic overflow in parameter"); + sf = sf % den; + v += (sf * num * 2 + den) / (2 * den); + return(v); } /* * Convert a sequence of digits into a long; return -1 if no digits. @@ -32,28 +35,28 @@ static long myatol(char **s) { - register char *p ; - register long result ; + register char *p; + register long result; - result = 0 ; - p = *s ; + result = 0; + p = *s; while ('0' <= *p && *p <= '9') { if (result > 100000000) - error("! arithmetic overflow in parameter") ; - result = 10 * result + *p++ - '0' ; + error("! arithmetic overflow in parameter"); + result = 10 * result + *p++ - '0'; } if (p == *s && *p == '.') { return 0; } else if (p == *s) { #ifdef KPATHSEA - error(concat3 ("expected number in ", *s, ", returning 10")) ; + error(concat3 ("expected number in ", *s, ", returning 10")); #else - error("expected number! returning 10") ; + error("expected number! returning 10"); #endif - return 10 ; + return 10; } else { - *s = p ; - return(result) ; + *s = p; + return(result); } } /* @@ -61,60 +64,60 @@ * defaults. Returns a value in scaled points. */ static long scalevals[] = { 1864680L, 65536L, 786432L, 186468L, - 1L, 65782L, 70124L, 841489L, 4736286L } ; -static char *scalenames = "cmptpcmmspbpddccin" ; + 1L, 65782L, 70124L, 841489L, 4736286L }; +static const char *scalenames = "cmptpcmmspbpddccin"; long myatodim(char **s) { - register long w, num, den, sc ; - register char *q ; - char *p ; - int negative = 0, i ; + register long w, num, den, sc; + register const char *q; + char *p; + int negative = 0, i; - p = *s ; + p = *s; if (**s == '-') { - p++ ; - negative = 1 ; + p++; + negative = 1; } - w = myatol(&p) ; + w = myatol(&p); if (w < 0) { - error("number too large; 1000 used") ; - w = 1000 ; + error("number too large; 1000 used"); + w = 1000; } - num = 0 ; - den = 1 ; + num = 0; + den = 1; if (*p == '.') { - p++ ; + p++; while ('0' <= *p && *p <= '9') { if (den <= 1000) { - den *= 10 ; - num = num * 10 + *p - '0' ; + den *= 10; + num = num * 10 + *p - '0'; } else if (den == 10000) { - den *= 2 ; - num = num * 2 + (*p - '0') / 5 ; + den *= 2; + num = num * 2 + (*p - '0') / 5; } - p++ ; + p++; } } while (*p == ' ') - p++ ; - for (i=0, q=scalenames; ; i++, q += 2) + p++; + for (i=0, q=scalenames;; i++, q += 2) if (*q == 0) { #ifdef KPATHSEA - error(concat3 ("expected units in ", *s, ", assuming inches.")) ; + error(concat3 ("expected units in ", *s, ", assuming inches.")); #else - error("expected units! assuming inches.") ; + error("expected units! assuming inches."); #endif - sc = scalevals[8] ; - break ; + sc = scalevals[8]; + break; } else if (*p == *q && p[1] == q[1]) { - sc = scalevals[i] ; - p += 2 ; - break ; + sc = scalevals[i]; + p += 2; + break; } - w = scale(w, num, den, sc) ; - *s = p ; - return(negative?-w:w) ; + w = scale(w, num, den, sc); + *s = p; + return(negative?-w:w); } /* * The routine where we handle the paper size special. We need to pass in @@ -124,9 +127,9 @@ handlepapersize(char *p, integer *x, integer *y) { while (*p == ' ') - p++ ; - *x = myatodim(&p) ; + p++; + *x = myatodim(&p); while (*p == ' ' || *p == ',') - p++ ; - *y = myatodim(&p) ; + p++; + *y = myatodim(&p); } diff -Nu dvipsk2009/paths.h dvipsk/paths.h --- dvipsk2009/paths.h Mon Mar 19 02:18:44 2007 +++ dvipsk/paths.h Tue Nov 10 19:29:34 2009 @@ -79,8 +79,6 @@ #endif #endif -extern void error() ; - /* paths are all in the Makefile; by not supplying defaults, we force the installer to set them up. */ #endif /* ! KPATHSEA */ diff -Nu dvipsk2009/pprescan.c dvipsk/pprescan.c --- dvipsk2009/pprescan.c Tue Jun 23 18:46:14 2009 +++ dvipsk/pprescan.c Mon Mar 29 23:30:15 2010 @@ -4,35 +4,14 @@ #include "dvips.h" /* The copyright notice in that file is included too! */ /* - * These are all the external routines it calls: + * The external declarations: */ #include "protos.h" /* - * These are the globals it accesses. - */ -#ifdef DEBUG -extern integer debug_flag; -#endif /* DEBUG */ -extern fontdesctype *fonthead ; -extern integer firstpage, lastpage ; -extern integer firstseq, lastseq ; -extern Boolean notfirst, notlast ; -extern Boolean evenpages, oddpages, pagelist ; -extern integer maxpages ; -extern Boolean abspage ; -extern FILE *dvifile ; -extern fontdesctype *curfnt ; -extern fontmaptype *ffont ; -extern quarterword *curpos, *curlim ; -extern integer pagenum ; -extern char errbuf[] ; -extern frametype frames[] ; -extern Boolean noomega ; -/* * We declare this to tell everyone we are prescanning early. */ -Boolean pprescan ; +Boolean pprescan; /* * When a font is selected during the pre-prescan, this routine makes sure * that the tfm or vf (but not pk) file is loaded. @@ -40,15 +19,15 @@ static void ppreselectfont(fontdesctype *f) { - int i ; + int i; - curfnt = f ; + curfnt = f; if (curfnt->loaded == 0) { if (!residentfont(curfnt)) if (!virtualfont(curfnt)) { for (i=0; i<256; i++) - curfnt->chardesc[i].flags = 0 ; - curfnt->loaded = 3 ; /* we're scanning for sizes */ + curfnt->chardesc[i].flags = 0; + curfnt->loaded = 3; /* we're scanning for sizes */ } } } @@ -58,90 +37,98 @@ static void pscanpage(void) { - register shalfword cmd ; - register chardesctype *cd ; - register fontmaptype *cfnt = 0 ; - integer fnt ; - integer mychar ; - register frametype *frp = frames ; + register shalfword cmd; + register chardesctype *cd; + register fontmaptype *cfnt = 0; + integer fnt; + integer mychar; +#ifdef VFLIB + integer rawchar; +#endif + register frametype *frp = frames; #ifdef DEBUG if (dd(D_PAGE)) #ifdef SHORTINT - (void)fprintf(stderr,"PPrescanning page %ld\n", pagenum) ; + (void)fprintf(stderr,"PPrescanning page %ld\n", pagenum); #else /* ~SHORTINT */ - (void)fprintf(stderr,"PPrescanning page %d\n", pagenum) ; + (void)fprintf(stderr,"PPrescanning page %d\n", pagenum); #endif /* ~SHORTINT */ #endif /* DEBUG */ - curfnt = NULL ; - curpos = NULL ; - bopcolor(0) ; + curfnt = NULL; + curpos = NULL; + bopcolor(0); while (1) { switch (cmd=dvibyte()) { 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 */ +case 254: /* unimplemented or illegal commands */ (void)sprintf(errbuf, - "! DVI file contains unexpected command (%d)",cmd) ; - error(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() ; + (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() ; + (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() ; + (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() ; + (void)dvibyte(); +case 143: case 148: case 153: case 157: case 162: case 167: case 255: + /* one-byte commands right1, w1, x1, down1, y1, z1, dir */ + (void)dvibyte(); case 147: case 152: case 161: case 166: /* w0, x0, y0, z0 */ case 138: case 141: case 142: /* nop, push, pop */ - break ; + break; 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 */ + mychar = dvibyte(); mychar = (mychar << 8) + dvibyte(); +#ifdef VFLIB + rawchar = mychar; + if (mychar>=256) mychar = ((mychar>>8)-0x21)*94 + (mychar&0xff)-0x21; +#endif + 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 ; + mychar = cmd; dochar: if (curfnt==NULL) - error("! Bad DVI file: no font selected") ; + 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) ; + (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 ; - frp->ff = ffont ; - frp->curf = curfnt ; + frp->curp = curpos; + frp->curl = curlim; + frp->ff = ffont; + frp->curf = curfnt; if (++frp == &frames[MAXFRAME] ) - error("! virtual recursion stack overflow") ; + error("! virtual recursion stack overflow"); cd = curfnt->chardesc + mychar; - if (cd->packptr == 0) - error("! a non-existent virtual char is being used; check vf/tfm files") ; - curpos = cd->packptr + 2 ; - curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1))) ; - ffont = curfnt->localfonts ; + if (cd->packptr == 0) { +#ifdef VFLIB + fprintf(stderr, "Wrong char code: %04X\n", rawchar); +#else + fprintf(stderr, "Wrong char code: %04X\n", mychar); +#endif + error("! a non-existent virtual char is being used; check vf/tfm files"); + } + curpos = cd->packptr + 2; + curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1))); + ffont = curfnt->localfonts; if (ffont==NULL) - curfnt = NULL ; + curfnt = NULL; else - ppreselectfont(ffont->desc) ; + ppreselectfont(ffont->desc); } else if (curfnt->loaded == 3) - curfnt->chardesc[mychar].flags = EXISTS ; - break ; + curfnt->chardesc[mychar].flags = EXISTS; + 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: case 185: case 186: case 187: case 188: case 189: case 190: case 191: @@ -152,51 +139,51 @@ case 220: case 221: case 222: case 223: case 224: case 225: case 226: case 227: case 228: case 229: case 230: case 231: case 232: case 233: case 234: case 235: case 236: case 237: case 238: /* font selection commands */ - if (cmd < 235) fnt = cmd - 171 ; /* fntnum0 thru fntnum63 */ + if (cmd < 235) fnt = cmd - 171; /* fntnum0 thru fntnum63 */ else { - fnt = dvibyte() ; /* fnt1 */ + fnt = dvibyte(); /* fnt1 */ while (cmd-- > 235) - fnt = (fnt << 8) + dvibyte() ; + fnt = (fnt << 8) + dvibyte(); } for (cfnt=ffont; cfnt; cfnt = cfnt->next) - if (cfnt->fontnum == fnt) goto fontfound ; - error("! no font selected") ; -fontfound: curfnt = cfnt->desc ; - 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 */ -case 242: predospecial(signedquad(), 1) ; break ; /* xxx4 */ -case 243: case 244: case 245: case 246: fontdef(cmd-242) ; break ; /* fntdef1 */ + if (cfnt->fontnum == fnt) goto fontfound; + error("! no font selected"); +fontfound: curfnt = cfnt->desc; + 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 */ +case 242: predospecial(signedquad(), 1); break; /* xxx4 */ +case 243: case 244: case 245: case 246: fontdef(cmd-242); break; /* fntdef1 */ case 140: /* eop or end of virtual char */ if (curpos) { - --frp ; - curfnt = frp->curf ; - ffont = frp->ff ; - curlim = frp->curl ; - curpos = frp->curp ; - break ; + --frp; + curfnt = frp->curf; + ffont = frp->ff; + curlim = frp->curl; + curpos = frp->curp; + break; } - return ; + return; } } } /* * Finally, here's our main pprescan routine. */ -static integer firstmatch = -1, lastmatch = -1 ; +static integer firstmatch = -1, lastmatch = -1; void pprescanpages(void) { - register int cmd ; - integer lmaxpages = maxpages ; - integer mpagenum ; - integer pageseq = 0 ; - int ntfirst = notfirst ; + register int cmd; + integer lmaxpages = maxpages; + integer mpagenum; + integer pageseq = 0; + int ntfirst = notfirst; - pprescan = 1 ; - readpreamble() ; + pprescan = 1; + readpreamble(); /* * Now we look for the first page to process. If we get to the end of * the file before the page, we complain (fatally). @@ -205,29 +192,29 @@ * header that might be in skipped pages. */ while (1) { - cmd = skipnop() ; + cmd = skipnop(); if (cmd==248) - error("! End of document before first specified page") ; + error("! End of document before first specified page"); if (cmd!=139) - error("! Bad DVI file: expected bop") ; - pagenum = signedquad() ; - pageseq++ ; - mpagenum = abspage ? pageseq : pagenum ; + error("! Bad DVI file: expected bop"); + pagenum = signedquad(); + pageseq++; + mpagenum = abspage ? pageseq : pagenum; if (mpagenum == firstpage && ntfirst) - firstmatch++ ; + firstmatch++; if (mpagenum == lastpage && notlast) - lastmatch++ ; + lastmatch++; if (ntfirst && mpagenum == firstpage && firstmatch == firstseq) - ntfirst = 0 ; + ntfirst = 0; if (ntfirst || - ((evenpages && (pagenum & 1)) || (oddpages && (pagenum & 1)==0) || - (pagelist && !InPageList(pagenum)))) { - skipover(40) ; - skippage() ; + ((evenpages && (pagenum & 1)) || (oddpages && (pagenum & 1)==0) || + (pagelist && !InPageList(pagenum)))) { + skipover(40); + skippage(); } else { if (notlast && mpagenum == lastpage) - lastmatch-- ; - break ; + lastmatch--; + break; } } /* @@ -235,28 +222,28 @@ * the variables we need. We don't have to be as smart as before in * skipping pages. */ - skipover(40) ; + skipover(40); while (lmaxpages > 0) { if (!(evenpages && (pagenum & 1)) && !(oddpages && (pagenum & 1)==0) && !(pagelist && !InPageList(pagenum))) { - pscanpage() ; - lmaxpages-- ; + pscanpage(); + lmaxpages--; } else - skippage() ; - mpagenum = abspage ? pageseq : pagenum ; + skippage(); + mpagenum = abspage ? pageseq : pagenum; if (mpagenum == lastpage && notlast) - lastmatch++ ; + lastmatch++; if (notlast && mpagenum == lastpage && lastmatch == lastseq) - lmaxpages = -1 ; /* we are done after this page. */ - cmd=skipnop() ; - if (cmd==248) break ; + lmaxpages = -1; /* we are done after this page. */ + cmd=skipnop(); + if (cmd==248) break; if (cmd!=139) - error("! Bad DVI file: expected bop") ; - pagenum = signedquad() ; - skipover(40) ; - pageseq++ ; + error("! Bad DVI file: expected bop"); + pagenum = signedquad(); + skipover(40); + pageseq++; } - fseek(dvifile, 0L, 0) ; - pprescan = 0 ; + fseek(dvifile, 0L, 0); + pprescan = 0; } diff -Nu dvipsk2009/prescan.c dvipsk/prescan.c --- dvipsk2009/prescan.c Tue Jun 23 18:46:14 2009 +++ dvipsk/prescan.c Mon Mar 29 23:30:24 2010 @@ -4,103 +4,68 @@ #include "dvips.h" /* The copyright notice in that file is included too! */ /* - * These are all the external routines it calls: + * The external declarations: */ #include "protos.h" /* - * These are the globals it accesses. - */ -#ifdef DEBUG -extern integer debug_flag; -#endif /* DEBUG */ -extern fontdesctype *fonthead ; -extern real conv ; -extern real vconv ; -extern real alpha ; -extern integer firstpage, lastpage ; -extern integer firstseq, lastseq ; -extern integer maxsecsize ; -extern Boolean notfirst, notlast ; -extern Boolean evenpages, oddpages, pagelist ; -extern integer fontmem ; -extern integer pagecount ; -extern integer pagenum ; -extern integer maxpages ; -extern sectiontype *sections ; -extern FILE *dvifile ; -extern integer num, den ; -extern double mag ; -extern int overridemag ; -extern integer swmem ; -extern int quiet ; -extern int actualdpi ; -extern int vactualdpi ; -extern Boolean reverse ; -extern int totalpages ; -extern integer fsizetol ; -extern char *oname ; -extern Boolean pprescan ; -extern Boolean abspage ; -extern char preamblecomment[] ; -/* * This routine handles the processing of the preamble in the dvi file. */ void readpreamble(void) { - register int i ; - char *p ; + register int i; + char *p; - if (dvibyte()!=247) error("! Bad DVI file: first byte not preamble") ; - if (dvibyte()!=2) error("! Bad DVI file: id byte not 2") ; - num = signedquad() ; - den = signedquad() ; - if (overridemag > 0) (void)signedquad() ; - else if (overridemag < 0) mag = (mag * signedquad()) / 1000.0 ; - else mag = signedquad() ; - conv = (real) num * DPI * mag / ( den * 254000000.0 ) ; - vconv = (real) num * VDPI * mag / ( den * 254000000.0 ) ; - alpha = (((real)den / 7227.0) / 0x100000) * (25400000.0 / (real) num) ; - fsizetol = 1 + (integer)(DPI/(72270.0 * conv)) ; + if (dvibyte()!=247) error("! Bad DVI file: first byte not preamble"); + if (dvibyte()!=2) error("! Bad DVI file: id byte not 2"); + num = signedquad(); + den = signedquad(); + if (overridemag > 0) (void)signedquad(); + else if (overridemag < 0) mag = (mag * signedquad()) / 1000.0; + else mag = signedquad(); + conv = (real) num * DPI * mag / ( den * 254000000.0 ); + vconv = (real) num * VDPI * mag / ( den * 254000000.0 ); + alpha = (((real)den / 7227.0) / 0x100000) * (25400000.0 / (real) num); + fsizetol = 1 + (integer)(DPI/(72270.0 * conv)); if (!pprescan) { - for (i=dvibyte(),p=preamblecomment;i>0;i--,p++) *p=dvibyte() ; - *p='\0' ; + for (i=dvibyte(),p=preamblecomment;i>0;i--,p++) *p=dvibyte(); + *p='\0'; if (!quiet) { - (void)fprintf(stderr, "'") ; + (void)fprintf(stderr, "'"); #ifdef VMCMS /* IBM: VM/CMS */ - for(p=preamblecomment;*p;p++) (void)putc(ascii2ebcdic[*p], stderr) ; + for(p=preamblecomment;*p;p++) (void)putc(ascii2ebcdic[*p], stderr); #else #ifdef MVSXA /* IBM: MVS/XA */ - for(p=preamblecomment;*p;p++) (void)putc(ascii2ebcdic[*p], stderr) ; + for(p=preamblecomment;*p;p++) (void)putc(ascii2ebcdic[*p], stderr); #else - for(p=preamblecomment;*p;p++) (void)putc(*p, stderr) ; + for(p=preamblecomment;*p;p++) (void)putc(*p, stderr); #endif /* IBM: VM/CMS */ #endif - (void)fprintf(stderr, "' -> %s\n", oname) ; + (void)fprintf(stderr, "' -> %s\n", oname); } } else - skipover(dvibyte()) ; + skipover(dvibyte()); } /* * Finally, here's our main prescan routine. */ -static integer firstmatch = -1, lastmatch = -1 ; +static integer firstmatch = -1, lastmatch = -1; void prescanpages(void) { - register int cmd ; - short ret = 0 ; - register integer thispageloc, thissecloc ; - register fontdesctype *f ; - register shalfword c ; - register long thissectionmem = 0 ; - integer mpagenum ; - integer pageseq = 0 ; - int ntfirst = notfirst ; + register int cmd; + short ret = 0; + register integer thispageloc, thissecloc; + register fontdesctype *f; + register shalfword c; + register long thissectionmem = 0; + integer mpagenum; + integer pageseq = 0; + int ntfirst = notfirst; - readpreamble() ; + readpreamble(); /* * Now we look for the first page to process. If we get to the end of * the file before the page, we complain (fatally). @@ -109,38 +74,38 @@ * header that might be in skipped pages. */ while (1) { - cmd = skipnop() ; + cmd = skipnop(); if (cmd==248) - error("! End of document before first specified page") ; + error("! End of document before first specified page"); if (cmd!=139) - error("! Bad DVI file: expected bop") ; - thispageloc = ftell(dvifile) ; /* the location FOLLOWING the bop */ + error("! Bad DVI file: expected bop"); + thispageloc = ftell(dvifile); /* the location FOLLOWING the bop */ #ifdef DEBUG if (dd(D_PAGE)) #ifdef SHORTINT - (void)fprintf(stderr,"bop at %ld\n", thispageloc) ; + (void)fprintf(stderr,"bop at %ld\n", thispageloc); #else /* ~SHORTINT */ - (void)fprintf(stderr,"bop at %d\n", (int)thispageloc) ; + (void)fprintf(stderr,"bop at %d\n", (int)thispageloc); #endif /* ~SHORTINT */ #endif /* DEBUG */ - pagenum = signedquad() ; - pageseq++ ; - mpagenum = abspage ? pageseq : pagenum ; + pagenum = signedquad(); + pageseq++; + mpagenum = abspage ? pageseq : pagenum; if (mpagenum == firstpage && ntfirst) - firstmatch++ ; + firstmatch++; if (mpagenum == lastpage && notlast) - lastmatch++ ; + lastmatch++; if (ntfirst && mpagenum == firstpage && firstmatch == firstseq) - ntfirst = 0 ; + ntfirst = 0; if (ntfirst || - ((evenpages && (pagenum & 1)) || (oddpages && (pagenum & 1)==0) || - (pagelist && !InPageList(pagenum)))) { - skipover(40) ; - skippage() ; + ((evenpages && (pagenum & 1)) || (oddpages && (pagenum & 1)==0) || + (pagelist && !InPageList(pagenum)))) { + skipover(40); + skippage(); } else { if (notlast && mpagenum == lastpage) - lastmatch-- ; - break ; + lastmatch--; + break; } } /* @@ -149,23 +114,27 @@ */ while (maxpages > 0 && cmd != 248) { for (f=fonthead; f; f=f->next) { - f->psname = 0 ; + f->psname = 0; if (f->loaded==1) +#ifdef VFLIB + for (c=(f->vflib)? MAX_CODE-1: 255; c>=0; c--) +#else for (c=255; c>=0; c--) - f->chardesc[c].flags &= (STATUSFLAGS) ; +#endif + f->chardesc[c].flags &= (STATUSFLAGS); } - fontmem = swmem - OVERCOST ; + fontmem = swmem - OVERCOST; if (fontmem <= 1000) - error("! Too little VM in printer") ; + error("! Too little VM in printer"); /* The section begins at the bop command just before thispageloc (which may * be a page that was aborted because the previous section overflowed memory). */ - pagecount = 0 ; - (void)fseek(dvifile, (long)thispageloc, 0) ; - pagenum = signedquad() ; - skipover(40) ; - thissecloc = thispageloc ; + pagecount = 0; + (void)fseek(dvifile, (long)thispageloc, 0); + pagenum = signedquad(); + skipover(40); + thissecloc = thispageloc; /* * Now we have the loop that actually scans the pages. The scanpage routine * returns 1 if the page scans okay; it returns 2 if the memory ran out @@ -174,53 +143,57 @@ * of memory. After each page, we mark the characters seen on that page * as seen for this section so that they will be downloaded. */ - ret = 0 ; + ret = 0; while (maxpages>0) { - if (!(evenpages && (pagenum & 1)) && + if (!(evenpages && (pagenum & 1)) && !(oddpages && (pagenum & 1)==0) && !(pagelist && !InPageList(pagenum))) { - ret = scanpage() ; + ret = scanpage(); if (ret == 0) - break ; - pagecount++ ; - maxpages-- ; - } else - skippage() ; - thissectionmem = swmem - fontmem - OVERCOST ; - mpagenum = abspage ? pageseq : pagenum ; - pageseq++ ; + break; + pagecount++; + maxpages--; + } else + skippage(); + thissectionmem = swmem - fontmem - OVERCOST; + mpagenum = abspage ? pageseq : pagenum; + pageseq++; if (mpagenum == lastpage && notlast) - lastmatch++ ; + lastmatch++; if (notlast && mpagenum == lastpage && lastmatch == lastseq) - maxpages = -1 ; /* we are done after this page. */ + maxpages = -1; /* we are done after this page. */ if (reverse) - thissecloc = thispageloc ; + thissecloc = thispageloc; for (f=fonthead; f; f=f->next) if (f->loaded==1) { if (f->psflag & THISPAGE) - f->psflag = PREVPAGE ; + f->psflag = PREVPAGE; +#ifdef VFLIB + for (c=(f->vflib)? MAX_CODE-1: 255; c>=0; c--) +#else for (c=255; c>=0; c--) +#endif if (f->chardesc[c].flags & THISPAGE) f->chardesc[c].flags = PREVPAGE | - (f->chardesc[c].flags & (STATUSFLAGS)) ; + (f->chardesc[c].flags & (STATUSFLAGS)); } - cmd=skipnop() ; - if (cmd==248) break ; + cmd=skipnop(); + if (cmd==248) break; if (cmd!=139) - error("! Bad DVI file: expected bop") ; - thispageloc = ftell(dvifile) ; + error("! Bad DVI file: expected bop"); + thispageloc = ftell(dvifile); #ifdef DEBUG if (dd(D_PAGE)) #ifdef SHORTINT - (void)fprintf(stderr,"bop at %ld\n", thispageloc) ; + (void)fprintf(stderr,"bop at %ld\n", thispageloc); #else /* ~SHORTINT */ - (void)fprintf(stderr,"bop at %d\n", (int)thispageloc) ; + (void)fprintf(stderr,"bop at %d\n", (int)thispageloc); #endif /* ~SHORTINT */ #endif /* DEBUG */ - pagenum = signedquad() ; - skipover(40) ; + pagenum = signedquad(); + skipover(40); if (ret==2 || (maxsecsize && pagecount >= maxsecsize)) - break ; + break; } /* * Now we have reached the end of a section for some reason. @@ -228,32 +201,32 @@ * and continue. */ if (pagecount>0) { - register int fc = 0 ; - register sectiontype *sp ; - register charusetype *cp ; + register int fc = 0; + register sectiontype *sp; + register charusetype *cp; - totalpages += pagecount ; + totalpages += pagecount; for (f=fonthead; f; f=f->next) if (f->loaded==1 && f->psname) - fc++ ; + fc++; sp = (sectiontype *)mymalloc((integer)(sizeof(sectiontype) + - fc * sizeof(charusetype) + sizeof(fontdesctype *))) ; - sp->bos = thissecloc ; + fc * sizeof(charusetype) + sizeof(fontdesctype *))); + sp->bos = thissecloc; if (reverse) { - sp->next = sections ; - sections = sp ; + sp->next = sections; + sections = sp; } else { - register sectiontype *p ; + register sectiontype *p; - sp->next = NULL ; + sp->next = NULL; if (sections == NULL) - sections = sp ; + sections = sp; else { - for (p=sections; p->next != NULL; p = p->next) ; - p->next = sp ; + for (p=sections; p->next != NULL; p = p->next); + p->next = sp; } } - sp->numpages = pagecount ; + sp->numpages = pagecount; #ifdef DEBUG if (dd(D_PAGE)) #ifdef SHORTINT @@ -261,29 +234,49 @@ #else /* ~SHORTINT */ (void)fprintf(stderr,"Have a section: %d pages at %d fontmem %d\n", #endif /* ~SHORTINT */ - (integer)pagecount, (integer)thissecloc, (integer)thissectionmem) ; + (integer)pagecount, (integer)thissecloc, (integer)thissectionmem); #endif /* DEBUG */ - cp = (charusetype *) (sp + 1) ; - fc = 0 ; + cp = (charusetype *) (sp + 1); + fc = 0; for (f=fonthead; f; f=f->next) if (f->loaded==1 && f->psname) { - register halfword b, bit ; + register halfword b, bit; +#ifdef VFLIB + register halfword bmax; + register shalfword cmax; +#endif - cp->psfused = (f->psflag & PREVPAGE) ; - f->psflag = 0 ; - cp->fd = f ; - c = 0 ; + cp->psfused = (f->psflag & PREVPAGE); + f->psflag = 0; + cp->fd = f; + c = 0; +#ifdef VFLIB + if (f->vflib) { + bmax = 553; + cmax = MAX_CODE; + } else { + bmax = 16; + cmax = 256; + } + if ((cp->bitmap = + (halfword *)malloc(sizeof(halfword)*bmax)) == NULL) + error("! Can not allocate memory for charuse info"); + for (b=0; bbitmap[b] = 0; + for (bit=32768; bit!=0 && c>=1) { +#else for (b=0; b<16; b++) { - cp->bitmap[b] = 0 ; + cp->bitmap[b] = 0; for (bit=32768; bit!=0; bit>>=1) { +#endif if (f->chardesc[c].flags & PREVPAGE) - cp->bitmap[b] |= bit ; - c++ ; + cp->bitmap[b] |= bit; + c++; } } - cp++ ; + cp++; } - cp->fd = NULL ; + cp->fd = NULL; } } } diff -Nu dvipsk2009/protos.h dvipsk/protos.h --- dvipsk2009/protos.h Tue Jun 23 18:46:14 2009 +++ dvipsk/protos.h Mon Mar 29 23:30:34 2010 @@ -9,9 +9,11 @@ struct String; struct tcd; +/******* prototypes for functions *******/ + /* prototypes for functions from bbox.c */ extern void bbtfmload(fontdesctype *curfnt); -extern void bbspecial(int h, int v, int nbytes); +extern void bbspecial(int h, int v, int dir, int nbytes); extern void bbdopage(void); extern void findbb(int bop); @@ -24,7 +26,6 @@ extern void pushcolor(char *p, Boolean outtops); extern void popcolor(Boolean outtops); - /* prototypes for functions from dopage.c */ extern void dopage(void); @@ -35,14 +36,13 @@ extern int ParsePages(char *s); /* prototypes for functions from dospecial.c */ -extern void specerror(char *s); +extern void specerror(const char *s); extern void outbangspecials(void); -extern int IsSame(char *a, char *b); +extern int IsSame(const char *a, const char *b); extern char *GetKeyVal(char *str, int *tno); extern void predospecial(int numbytes, Boolean scanning); extern int maccess(char *s); extern void dospecial(int numbytes); -extern void fil2ps(char *task, char *iname); extern float *bbdospecial(int nbytes); /* prototypes for functions from download.c */ @@ -84,14 +84,14 @@ /* prototypes for functions from dvips.c */ extern void help(int status); -extern void error_with_perror(char *s, char *fname); -extern void error(char *s); +extern void error_with_perror(const char *s, const char *fname); +extern void error(const char *s); extern void check_checksum(unsigned int c1, unsigned int c2, const char *name); extern char *mymalloc(int n); extern void morestrings(void); extern void checkstrings(void); extern void initialize(void); -extern char *newstring(char *s); +extern char *newstring(const char *s); extern void newoutname(void); extern void *revlist(void *p); extern void queryargs(void); @@ -125,9 +125,9 @@ extern void includechars(fontdesctype *f, char *s); extern void scan1fontcomment(char *p); extern int scanvm(char *p); -extern void scan_fontnames(char *str, char *psfile); -extern void scanfontusage(char *p, char *psfile); -extern void scanfontcomments(char *filename); +extern void scan_fontnames(char *str, const char *psfile); +extern void scanfontusage(char *p, const char *psfile); +extern void scanfontcomments(const char *filename); extern Boolean okascmd(char *ss); extern void nameout(char *area, char *name); extern void fonttableout(void); @@ -135,6 +135,7 @@ /* prototypes for functions from flib.c */ #ifdef FONTLIB extern void fliload(void); +extern char *fliparse(char *path, char *name) #endif /* prototypes for functions from fontdef.c */ @@ -144,12 +145,12 @@ extern int skipnop(void); /* prototypes for functions from header.c */ -extern int add_name(char *s, struct header_list **what ); -extern int add_name_general(char *s, struct header_list **what, +extern int add_name(const char *s, struct header_list **what ); +extern int add_name_general(const char *s, struct header_list **what, char *pre, char *post); -extern void checkhmem(char *s, char *p, char *q); -extern int add_header(char *s); -extern int add_header_general(char *s, char *pre, char* post); +extern void checkhmem(const char *s, char *p, char *q); +extern int add_header(const char *s); +extern int add_header_general(const char *s, char *pre, char* post); extern char *get_name(struct header_list **what ); extern void send_headers(void); @@ -174,7 +175,7 @@ extern void stamp_hps(struct hps_link *pl); extern void stamp_external(char *s, struct hps_link *pl); extern void finish_hps(void); -extern void set_bitfile(char *s, int mode); +extern void set_bitfile(const char *s, int mode); extern void vertical_in_hps(void); extern void print_rect_list(void); extern void end_current_box(void); @@ -182,7 +183,7 @@ #endif /* HPS */ /* prototypes for functions from loadfont.c */ -extern void badpk(char *s); +extern void badpk(const char *s); extern short pkbyte(void); extern int pkquad(void); extern int pktrio(void); @@ -194,8 +195,8 @@ extern void makefont(char *name, int dpi, int bdpi); /* prototypes for functions from output.c */ -extern void copyfile(char *s); -extern void copyfile_general(char *s, struct header_list *h); +extern void copyfile(const char *s); +extern void copyfile_general(const char *s, struct header_list *h); extern void figcopyfile(char *s, int systemtype); extern void specialout(char c); extern void stringend(void); @@ -203,7 +204,7 @@ extern int T1Char(int c); #endif extern void scout(unsigned char c); -extern void cmdout(char *s); +extern void cmdout(const char *s); extern void floatout(float n); extern void doubleout(double n); extern void numout(int n); @@ -211,11 +212,11 @@ extern void fontout(int n); extern void hvpos(void); extern void newline(void); -extern void nlcmdout(char *s); +extern void nlcmdout(const char *s); extern int mlower(int c); -extern int ncstrcmp(char *a, char *b); +extern int ncstrcmp(const char *a, const char *b); extern void findpapersize(void); -extern void paperspec(char *s, int hed); +extern void paperspec(const char *s, int hed); extern char *epsftest(int bop); extern void open_output(void); extern void initprinter(sectiontype *sect); @@ -248,17 +249,23 @@ extern void repack(struct tcd *cp); /* prototypes for functions from resident.c */ -extern int hash(char *s); +extern unsigned int hash(char *s); extern void revpslists(void); extern void cleanres(void); extern struct resfont *lookup(char *name); extern struct resfont *findPSname(char *name); +#ifdef VFLIB +extern void add_entry(char *TeXname, char *PSname, char *Fontfile, + char *Vectfile, char *specinfo, char *downloadinfo, + boolean vflib); +#else extern void add_entry(char *TeXname, char *PSname, char *Fontfile, char *Vectfile, char *specinfo, char *downloadinfo); +#endif extern int residentfont(fontdesctype *curfnt); -extern void bad_config(char *err); +extern void bad_config(const char *err); extern char *configstring(char *s, int nullok); -extern Boolean getdefaults(char *s); -extern void getpsinfo(char *name); +extern Boolean getdefaults(const char *s); +extern void getpsinfo(const char *name); extern void checkenv(int which); /* prototypes for functions from scalewidth.c */ @@ -271,23 +278,18 @@ /* prototypes for functions from search.c */ #ifdef KPATHSEA -extern FILE *search(kpse_file_format_type format, char *file, char *mode); -extern FILE *pksearch(char *file, char *mode, halfword dpi, char **name_ret, int *dpi_ret); +extern FILE *search(kpse_file_format_type format, const char *file, const char *mode); +extern FILE *pksearch(const char *file, const char *mode, halfword dpi, char **name_ret, int *dpi_ret); #else /* !KPATSHEA */ -extern FILE *search(char *path, char *file, char *mode); -extern FILE *pksearch(char *path, char *file, char *mode, char *n, halfword dpi, halfword vdpi); +extern FILE *search(char *path, const char *file, const char *mode); +extern FILE *pksearch(char *path, const char *file, const char *mode, char *n, halfword dpi, halfword vdpi); #endif /* KPATHSEA */ -extern FILE *my_real_fopen(char *n, char *t); +extern FILE *my_real_fopen(const char *n, const char *t); extern int close_file(FILE *f); /* prototypes for functions from skippage.c */ extern void skippage(void); -/* prototypes for functions from squeeze.c */ -extern void specialout(char c); -extern void strout(char *s); -extern void cmdout(char *s); - /* prototypes for functions from t1part.c */ extern int DefTypeFont(unsigned char *name); extern int GetZeroLine(unsigned char *str); @@ -343,7 +345,7 @@ extern void NameOfProgram(void); /* prototypes for functions from tfmload.c */ -extern void badtfm(char *s); +extern void badtfm(const char *s); extern void tfmopen(fontdesctype *fd); extern short tfmbyte(void); extern unsigned short tfm16(void); @@ -355,10 +357,11 @@ extern Boolean getbit(void); extern long pkpackednum(void); extern void flip(char *s, long howmany); -extern long unpack(unsigned char *pack, unsigned short *raster, unsigned short cwidth, unsigned short cheight, unsigned short cmd); +extern long unpack(unsigned char *pack, unsigned short *raster, + unsigned short cwidth, unsigned short cheight, unsigned short cmd); /* prototypes for functions from virtualfont.c */ -extern void badvf(char *s); +extern void badvf(const char *s); extern short vfbyte(void); extern int vfquad(void); extern int vftrio(void); @@ -367,10 +370,199 @@ extern Boolean virtualfont(fontdesctype *curfnt); /* prototypes for functions from writet1.c */ -extern void load_enc(char *, char **); +extern void load_enc(char *, const char **); extern void writet1(void); extern void t1_free(void); extern boolean t1_subset(char *, char *, unsigned char *); extern boolean t1_subset_2(char *, unsigned char *, char *); + +/*********** global variables ***********/ + +/* global variables from dopage.c */ +#ifdef HPS +extern integer hhmem, vvmem; +extern integer pushcount; +extern Boolean PAGEUS_INTERUPPTUS; +extern Boolean NEED_NEW_BOX; +#endif +extern integer rdir, fdir; + +/* global variables from dosection.c */ +#ifdef HPS +extern int pagecounter; +#endif + +/* global variables from drawPS.c */ +extern integer dir; + +/* global variables from dvips.c */ +extern char *downloadedpsnames[]; +extern int unused_top_of_psnames; +extern fontdesctype *fonthead; +extern fontdesctype *curfnt; +extern sectiontype *sections; +extern Boolean partialdownload; +extern Boolean manualfeed; +extern Boolean compressed; +extern Boolean downloadpspk; +extern Boolean safetyenclose; +extern Boolean removecomments; +extern Boolean nosmallchars; +extern Boolean cropmarks; +extern Boolean abspage; +extern Boolean tryepsf; +extern int secure; +extern int secure_option; +extern int collatedcopies; +extern integer pagecopies; +extern shalfword linepos; +extern integer maxpages; +extern Boolean notfirst, notlast; +extern Boolean evenpages, oddpages, pagelist; +extern Boolean sendcontrolD; +extern Boolean shiftlowchars; +extern integer firstpage, lastpage; +extern integer firstseq, lastseq; +extern integer hpapersize, vpapersize; +extern integer hoff, voff; +extern integer maxsecsize; +extern integer firstboploc; +extern Boolean sepfiles; +extern int numcopies; +extern const char *oname; +extern char *iname; +extern char *fulliname; +extern char *nextstring, *maxstring; +extern FILE *dvifile, *bitfile; +extern quarterword *curpos, *curlim; +extern fontmaptype *ffont; +extern real conv; +extern real vconv; +extern real alpha; +extern double mag; +extern integer num, den; +extern int overridemag; +extern int actualdpi, vactualdpi; +extern int maxdrift, vmaxdrift; +extern char *paperfmt; +extern int landscape; +extern integer fontmem; +extern integer pagecount; +extern integer pagenum; +extern long bytesleft; +extern quarterword *raster; +extern integer hh, vv; +extern Boolean noomega; +extern const char *infont; +#ifndef KPATHSEA +extern char *tfmpath; +extern char *pkpath; +extern char *vfpath; +extern char *figpath; +extern char *headerpath; +extern char *configpath; +extern char *pictpath; +#ifdef SEARCH_SUBDIRECTORIES +extern char *fontsubdirpath; +#endif +#endif /* ! KPATHSEA */ +#ifdef FONTLIB +extern char *flipath; +extern char *fliname; +#endif +extern integer swmem; +extern int quiet; +extern int filter; +extern int dvips_debug_flag; +extern int prettycolumn; +extern int gargc; +extern char **gargv; +extern int totalpages; +extern Boolean reverse; +extern Boolean usesPSfonts; +extern Boolean usesspecial; +extern Boolean headers_off; +extern Boolean usescolor; +extern char *warningmsg; +extern Boolean multiplesects; +extern Boolean disablecomments; +extern char *printer; +extern char *mfmode; +extern char *mflandmode; +extern int mfmode_option; +extern int oname_option; +extern frametype frames[]; +extern integer pagecost; +extern integer fsizetol; +extern Boolean includesfonts; +extern fontdesctype *fonthd[MAXFONTHD]; +extern int nextfonthd; +extern char xdig[256]; +extern char banner[], banner2[]; +extern Boolean noenv; +extern Boolean dopprescan; +extern int dontmakefont; +extern struct papsiz *papsizes; +extern int headersready; +#if defined(MSDOS) || defined(OS2) || defined(ATARIST) +extern char *mfjobname; +extern FILE *mfjobfile; +#endif +#ifdef DEBUG +extern integer debug_flag; +#endif +#ifdef HPS +extern Boolean HPS_FLAG; +#endif + +/* global variables from flib.c */ +#ifdef FONTLIB +extern Boolean flib; +#endif + +/* global variables from hps.c */ +#ifdef HPS +extern Boolean inHTMLregion; +extern integer HREF_COUNT; +extern int current_pushcount; +extern Boolean noprocset; +#endif + +/* global variables from loadfont.c */ +extern char errbuf[1000]; +extern int lastresortsizes[40]; +extern FILE *pkfile; + +/* global variables from output.c */ +extern char preamblecomment[256]; +#if !defined(VFLIB) +extern Boolean SJIS; +#endif +extern char weburl[]; + +/* global variables from pprescan.c */ +extern Boolean pprescan; + +/* global variables from repack.c */ +extern long mbytesleft; +extern quarterword *mraster; + +/* global variables from resident.c */ +extern struct header_list *ps_fonts_used; +extern const char *psmapfile; +#ifdef VFLIB +extern Boolean usesvflib; +#endif + +/* global variables from search.c */ +extern int to_close; +#ifdef KPATHSEA +extern char *realnameoffile; +#else +extern char realnameoffile[]; +#endif + +/* global variables from tfmload.c */ +extern FILE *tfmfile; #endif diff -Nu dvipsk2009/protos_add.h dvipsk/protos_add.h --- dvipsk2009/protos_add.h Thu Jan 01 09:00:00 1970 +++ dvipsk/protos_add.h Mon Mar 29 23:30:49 2010 @@ -0,0 +1,21 @@ +#ifndef _PROTOS_ADD_H +#define _PROTOS_ADD_H + +#include "protos.h" + +/****** additional global variables ****** + * + * We can declare 'dvistack' and 'name' only in some files, because + * otherwise they would conflict with equally named static variables. + */ + +/* global variables from dopage.c */ +extern struct dvistack { + integer hh, vv; + integer h, v, w, x, y, z, dir; +} stack[]; + +/* global variables from loadfont.c */ +extern char name[]; + +#endif diff -Nu dvipsk2009/psfonts_jp.map dvipsk/psfonts_jp.map --- dvipsk2009/psfonts_jp.map Thu Jan 01 09:00:00 1970 +++ dvipsk/psfonts_jp.map Sat Jan 16 10:37:12 2010 @@ -0,0 +1,52 @@ +% psfonts_jp.map -- PostScript Fontname for Japanese. +% + +% +% Japanese (JIS encoding) +% +rmlsl ".167 SlantFont" Ryumin-Light-H +gbmsl ".167 SlantFont" GothicBBB-Medium-H +%% +rml Ryumin-Light-H +rmlv Ryumin-Light-V +gbm GothicBBB-Medium-H +gbmv GothicBBB-Medium-V +%% +%rml Ryumin-Light-Ext-H +%rmlv Ryumin-Light-Ext-V +%gbm GothicBBB-Medium-Ext-H +%gbmv GothicBBB-Medium-Ext-V +% +% Morisawa +% +ryumin-l Ryumin-Light-H +ryumin-l-v Ryumin-Light-V +gtbbb-m GothicBBB-Medium-H +gtbbb-m-v GothicBBB-Medium-V +futomin-b FutoMinA101-Bold-H +futomin-b-v FutoMinA101-Bold-V +futogo-b FutoGoB101-Bold-H +futogo-b-v FutoGoB101-Bold-V +jun101-l Jun101-Light-H +jun101-l-v Jun101-Light-V +% +% ums package + virtual fonts +% +unimin Ryumin-Light-UniJIS-UCS2-H +unigoth GothicBBB-Medium-UniJIS-UCS2-H +% +% utf package (S. Saito) +% +unijmin-h Ryumin-Light-UniJIS-UTF16-H +unijmin-v Ryumin-Light-UniJIS-UTF16-V +unijgoth-h GothicBBB-Medium-UniJIS-UTF16-H +unijgoth-v GothicBBB-Medium-UniJIS-UTF16-V +%% +cidmin-h Ryumin-Light-Identity-H +cidmin-v Ryumin-Light-Identity-V +cidgoth-h GothicBBB-Medium-Identity-H +cidgoth-v GothicBBB-Medium-Identity-V +% +% Local variables: +% page-delimiter: "^% \f" +% End: diff -Nu dvipsk2009/quotecmd-test.pl dvipsk/quotecmd-test.pl --- dvipsk2009/quotecmd-test.pl Thu Jan 01 09:00:00 1970 +++ dvipsk/quotecmd-test.pl Fri Feb 19 03:03:20 2010 @@ -0,0 +1,31 @@ +#!/usr/bin/env perl +# $Id: bibtex-openout-test.pl 16507 2009-12-25 01:19:05Z karl $ +# Public domain. Originally written 2010, Karl Berry. +# Check that dvips quotes external command arguments. + +BEGIN { chomp ($srcdir = $ENV{"srcdir"} || `dirname $0`); } +require "$srcdir/../tests/common-test.pl"; + +exit (&main ()); + +sub main +{ + # create the weirdly-named file which dvips executes with popen. + # quotecmd.tex itself also creates it, but we don't want to run TeX in + # this test, nor do we want such a weirdly-named file in our + # repository, so create it here. Leave it in place, so we can run the + # program under the debugging if we need to. + my $weirdf = ' 2>&1 | echo badnews >pwned.txt #.gz'; + unlink ($weirdf); # ensure no leftover + open (WEIRDF, ">", $weirdf); + close (WEIRDF) || die "open(weird file name) failed: $!"; + + $badfile = "pwned.txt"; # will be created if program is broken + unlink ($badfile); # ensure no leftover from previous test + + my @args = ("$srcdir/testdata/quotecmd.dvi", qw(-o /dev/null)); + my $ret = &test_run ("./dvips", @args); + + my $bad = -f $badfile; # file should not have been created + return $bad; +} diff -Nu dvipsk2009/repack.c dvipsk/repack.c --- dvipsk2009/repack.c Tue Jun 23 18:46:14 2009 +++ dvipsk/repack.c Mon Mar 29 23:31:12 2010 @@ -4,9 +4,10 @@ * (Slight mods by Don Knuth in December 89.) */ #include "dvips.h" /* The copyright notice in that file is included too! */ -#ifdef DEBUG -extern integer debug_flag; -#endif /* DEBUG */ +/* + * The external declarations: + */ +#include "protos.h" /* Given a raster that has been unpacked from PK format, * we compress it by another scheme that is suitable for @@ -33,26 +34,24 @@ #define ADVXCHG2END CMD(13) #define END CMD(14) -#include "protos.h" - -static int rowlength = -1 ; -static unsigned char *specdata ; -static long tslen = 0 ; -static unsigned char *tempstore, *tsp, *tsend ; +static int rowlength = -1; +static unsigned char *specdata; +static long tslen = 0; +static unsigned char *tempstore, *tsp, *tsend; void putlong(register char *a, long i) { - a[0] = i >> 24 ; - a[1] = i >> 16 ; - a[2] = i >> 8 ; - a[3] = i ; + a[0] = i >> 24; + a[1] = i >> 16; + a[2] = i >> 8; + a[3] = i; } long getlong(register unsigned char *a) { - return ((((((a[0] << 8L) + a[1]) << 8L) + a[2]) << 8L) + a[3]) ; + return ((((((a[0] << 8L) + a[1]) << 8L) + a[2]) << 8L) + a[3]); } /* First, a routine that appends one byte to the compressed output. */ @@ -62,25 +61,25 @@ static void addts(register unsigned char what) { - register unsigned char *p, *q ; + register unsigned char *p, *q; if (tsp >= tsend) { if (tempstore == NULL) { - tslen = 2020 ; - tempstore = (unsigned char *)mymalloc((integer)tslen) ; - tsp = tempstore ; + tslen = 2020; + tempstore = (unsigned char *)mymalloc((integer)tslen); + tsp = tempstore; } else { - tslen = 2 * tslen ; - tsp = (unsigned char *)mymalloc((integer)tslen) ; + tslen = 2 * tslen; + tsp = (unsigned char *)mymalloc((integer)tslen); for (p=tempstore, q=tsp; p rowlength) { if (rowlength > 0) - free((char *)specdata) ; - rowlength = widthc + 30 ; - specdata = (unsigned char *)mymalloc((integer)(rowlength + 15)) ; + free((char *)specdata); + rowlength = widthc + 30; + specdata = (unsigned char *)mymalloc((integer)(rowlength + 15)); } for (i= -15, t=specdata; i<=widthc; i++, t++) - *t = 0 ; - repeatcount = 0 ; - f = specdata + 2 ; + *t = 0; + repeatcount = 0; + f = specdata + 2; for (j=0; j MAXOUT) { - addts((unsigned char)(REPX+MAXOUT)) ; - repeatcount -= MAXOUT ; + addts((unsigned char)(REPX+MAXOUT)); + repeatcount -= MAXOUT; } - addts((unsigned char)(REPX+repeatcount)) ; - repeatcount = 0 ; + addts((unsigned char)(REPX+repeatcount)); + repeatcount = 0; } - pos = 0 ; + pos = 0; for (i=0, d=specdata, f=t-width; i MAXOUT) { - addts((unsigned char)(ADVX+MAXOUT)) ; - pos += MAXOUT ; + addts((unsigned char)(ADVX+MAXOUT)); + pos += MAXOUT; } if (0 != (k = (e - d))) { if (lit) { if (k > 2) { if (i > pos) { - addts((unsigned char)(ADVX + i - pos)) ; - pos = i ; + addts((unsigned char)(ADVX + i - pos)); + pos = i; } while (k > MAXOUT) { - addts((unsigned char)(CHGX + MAXOUT)) ; + addts((unsigned char)(CHGX + MAXOUT)); for (kk=0; kk d) { if (*d & LSHPOSSIB) { if (i == pos+MAXOUT) { - addts((unsigned char)(ADVX + MAXOUT)) ; - pos = i ; + addts((unsigned char)(ADVX + MAXOUT)); + pos = i; } - addtse((unsigned char)(ADVXLSH + i - pos)) ; + addtse((unsigned char)(ADVXLSH + i - pos)); } else if (*d & RSHPOSSIB) { if (i == pos+MAXOUT) { - addts((unsigned char)(ADVX + MAXOUT)) ; - pos = i ; + addts((unsigned char)(ADVX + MAXOUT)); + pos = i; } - addtse((unsigned char)(ADVXRSH + i - pos)) ; + addtse((unsigned char)(ADVXRSH + i - pos)); } else if (*d & WHTPOSSIB) { /* i==pos */ - addts((unsigned char)(CLRX + 1)) ; lcm = -1 ; + addts((unsigned char)(CLRX + 1)); lcm = -1; } else if (*d & BLKPOSSIB) { /* i==pos */ - addts((unsigned char)(SETX + 1)) ; lcm = -1 ; + addts((unsigned char)(SETX + 1)); lcm = -1; } else - error("! bug") ; /* why wasn't lit true? */ - d++ ; - f++ ; - i++ ; - pos = i ; + error("! bug"); /* why wasn't lit true? */ + d++; + f++; + i++; + pos = i; } /* end 'while e>d' */ } } /* end 'if e>d' */ if (accum > 0) { if (i > pos) { - addts((unsigned char)(ADVX + i - pos)) ; - pos = i ; + addts((unsigned char)(ADVX + i - pos)); + pos = i; } - i += accum ; - d += accum ; - f += accum ; + i += accum; + d += accum; + f += accum; while (accum > MAXOUT) { - addts((unsigned char)(cmd + MAXOUT)) ; - accum -= MAXOUT ; - pos += MAXOUT ; + addts((unsigned char)(cmd + MAXOUT)); + accum -= MAXOUT; + pos += MAXOUT; } - lcm = -1 ; - addts((unsigned char)(cmd + accum)) ; - pos += accum ; + lcm = -1; + addts((unsigned char)(cmd + accum)); + pos += accum; } } /* end 'else DIFFERENT' */ } /* end 'for i' */ if (lcm != -1) { - tempstore[lcm] += MAXOUT ; /* append END */ - lcm = -1 ; + tempstore[lcm] += MAXOUT; /* append END */ + lcm = -1; } else { - addts((unsigned char)(END)) ; + addts((unsigned char)(END)); } } /* end 'else rows different' */ #ifdef DEBUG if (d != specdata + width) - error("! internal inconsistency in repack") ; + error("! internal inconsistency in repack"); #endif } /* end 'for j' */ if (repeatcount) { while (repeatcount > MAXOUT) { - addts((unsigned char)(REPX+MAXOUT)) ; - repeatcount -= MAXOUT ; + addts((unsigned char)(REPX+MAXOUT)); + repeatcount -= MAXOUT; } - addts((unsigned char)(REPX+repeatcount)) ; - repeatcount = 0 ; + addts((unsigned char)(REPX+repeatcount)); + repeatcount = 0; } } -extern long bytesleft ; -extern quarterword *raster ; -long mbytesleft ; -quarterword *mraster ; +long mbytesleft; +quarterword *mraster; char * makecopy(register unsigned char *what, register long len, register unsigned char *p) { - register unsigned char *q ; + register unsigned char *q; if (p == NULL) { if (len > MINCHUNK) - p = (unsigned char *)mymalloc((integer)len) ; + p = (unsigned char *)mymalloc((integer)len); else { if (bytesleft < len) { - raster = (quarterword *)mymalloc((integer)RASTERCHUNK) ; - bytesleft = RASTERCHUNK ; + raster = (quarterword *)mymalloc((integer)RASTERCHUNK); + bytesleft = RASTERCHUNK; } - p = (unsigned char *)raster ; - bytesleft -= len ; - raster += len ; + p = (unsigned char *)raster; + bytesleft -= len; + raster += len; } } - q = p ; + q = p; while (len > 0) { - *p++ = *what++ ; - len -- ; + *p++ = *what++; + len --; } - return ((char *)q) ; + return ((char *)q); } /* Now the main routine, which is called when a character is used @@ -357,95 +354,95 @@ void repack(register chardesctype *cp) { - register long i, j ; - register unsigned char *p ; - register int width, height ; - register int wwidth ; - char startbytes ; - int smallchar ; + register long i, j; + register unsigned char *p; + register int width, height; + register int wwidth; + char startbytes; + int smallchar; - p = cp->packptr ; + p = cp->packptr; if (p == NULL) - error("! no raster?") ; - tsp = tempstore ; - tsend = tempstore + tslen ; - addts(*p) ; /* copy the PK flag byte */ + error("! no raster?"); + tsp = tempstore; + tsend = tempstore + tslen; + addts(*p); /* copy the PK flag byte */ if (*p & 4) { if ((*p & 7) == 7) { - startbytes = 17 ; - width = getlong(p + 1) ; - height = getlong(p + 5) ; + startbytes = 17; + width = getlong(p + 1); + height = getlong(p + 5); for (i=0; i<12; i++) - addts(*++p) ; + addts(*++p); } else { - startbytes = 9 ; - width = p[1] * 256 + p[2] ; - height = p[3] * 256 + p[4] ; - addts(*++p) ; - addts(*++p) ; - addts(*++p) ; - addts(*++p) ; + startbytes = 9; + width = p[1] * 256 + p[2]; + height = p[3] * 256 + p[4]; + addts(*++p); + addts(*++p); + addts(*++p); + addts(*++p); } } else { - startbytes = 5 ; - width = p[1] ; - height = p[2] ; + startbytes = 5; + width = p[1]; + height = p[2]; } - addts(*++p) ; - addts(*++p) ; - addts(*++p) ; - addts(*++p) ; - p++ ; /* OK, p now points to beginning of the nibbles */ - addts((unsigned char)0) ; - addts((unsigned char)0) ; - addts((unsigned char)0) ; - addts((unsigned char)0) ; /* leave room to stick in a new length field */ - wwidth = (width + 15) / 16 ; - i = 2 * height * (long)wwidth ; + addts(*++p); + addts(*++p); + addts(*++p); + addts(*++p); + p++; /* OK, p now points to beginning of the nibbles */ + addts((unsigned char)0); + addts((unsigned char)0); + addts((unsigned char)0); + addts((unsigned char)0); /* leave room to stick in a new length field */ + wwidth = (width + 15) / 16; + i = 2 * height * (long)wwidth; if (i <= 0) - i = 2 ; + i = 2; if ((cp->flags & BIGCHAR) == 0) - smallchar = 5 ; + smallchar = 5; else - smallchar = 0 ; - i += smallchar ; + smallchar = 0; + i += smallchar; if (mbytesleft < i) { if (mbytesleft >= RASTERCHUNK) - (void) free((char *) mraster) ; + (void) free((char *) mraster); if (RASTERCHUNK > i) { - mraster = (quarterword *)mymalloc((integer)RASTERCHUNK) ; - mbytesleft = RASTERCHUNK ; + mraster = (quarterword *)mymalloc((integer)RASTERCHUNK); + mbytesleft = RASTERCHUNK; } else { - i += i / 4 ; - mraster = (quarterword *)mymalloc((integer)(i + 3)) ; - mbytesleft = i ; + i += i / 4; + mraster = (quarterword *)mymalloc((integer)(i + 3)); + mbytesleft = i; } } while (i > 0) - mraster[--i] = 0 ; + mraster[--i] = 0; i = startbytes + unpack(p, (halfword *)mraster, (halfword)width, - (halfword)height, *(cp->packptr)) ; - dochar(mraster, (width + 7) >> 3, height) ; + (halfword)height, *(cp->packptr)); + dochar(mraster, (short)((width + 7) >> 3), (short)height); if (smallchar) { - addts((unsigned char)0) ; - addts((unsigned char)0) ; - addts((unsigned char)0) ; - addts((unsigned char)0) ; - addts((unsigned char)0) ; + addts((unsigned char)0); + addts((unsigned char)0); + addts((unsigned char)0); + addts((unsigned char)0); + addts((unsigned char)0); } - j = tsp - tempstore ; + j = tsp - tempstore; #ifdef DEBUG if (dd(D_COMPRESS)) (void)fprintf(stderr,"PK %ld bytes, unpacked %ld, compressed %ld\n", - i-(long)startbytes, (long)((width+7L)/8)*height, j-(long)startbytes-4) ; + i-(long)startbytes, (long)((width+7L)/8)*height, j-(long)startbytes-4); #endif /* DEBUG */ if ( i < j ) { if (i > MINCHUNK) - free(cp->packptr) ; + free(cp->packptr); cp->packptr = - (unsigned char *)makecopy(tempstore, j, (unsigned char *)0) ; + (unsigned char *)makecopy(tempstore, j, (unsigned char *)0); } else - makecopy(tempstore, j, (unsigned char *)cp->packptr) ; - putlong((char *)(cp->packptr+startbytes), j-startbytes-4-smallchar) ; - cp->flags |= REPACKED ; + makecopy(tempstore, j, (unsigned char *)cp->packptr); + putlong((char *)(cp->packptr+startbytes), j-startbytes-4-smallchar); + cp->flags |= REPACKED; } diff -Nu dvipsk2009/resident.c dvipsk/resident.c --- dvipsk2009/resident.c Tue Jun 23 18:46:14 2009 +++ dvipsk/resident.c Tue May 04 21:12:42 2010 @@ -18,110 +18,43 @@ #include #include #endif + /* * This is the structure definition for resident fonts. We use * a small and simple hash table to handle these. We don't need * a big hash table. */ -struct resfont *reshash[RESHASHPRIME] ; +struct resfont *reshash[RESHASHPRIME]; /* - * These are the external routines we use. + * The external declarations: */ #include "protos.h" -/* - * These are the external variables we use. - */ -extern char *realnameoffile ; -extern int prettycolumn ; -extern int dvips_debug_flag ; -#ifdef DEBUG -extern integer debug_flag; -#endif /* DEBUG */ -extern integer pagecopies ; -extern int overridemag ; -extern long bytesleft ; -extern quarterword *raster ; -extern FILE *pkfile ; -extern char *oname ; -extern integer swmem, fontmem ; -#ifndef KPATHSEA -extern char *tfmpath, *pictpath ; -extern char *pkpath ; -extern char *vfpath ; -extern char *figpath ; -extern char *configpath ; -extern char *headerpath ; -#ifdef SEARCH_SUBDIRECTORIES -extern char *fontsubdirpath ; -#endif -#endif -extern Boolean noenv ; -extern Boolean downloadpspk ; -#ifdef FONTLIB -extern char *flipath, *fliname ; -#endif -extern char *paperfmt ; -extern char *nextstring ; -extern char *maxstring ; -extern char *warningmsg ; -extern Boolean disablecomments ; -extern Boolean compressed ; -extern Boolean partialdownload ; -extern int quiet ; -extern int filter ; -extern Boolean reverse ; -extern Boolean usesPSfonts ; -extern Boolean nosmallchars ; -extern Boolean removecomments ; -extern Boolean safetyenclose ; -extern Boolean dopprescan ; -extern integer maxsecsize ; -extern double mag ; -extern Boolean sepfiles ; -extern int actualdpi ; -extern int vactualdpi ; -extern int maxdrift ; -extern int vmaxdrift ; -extern char *printer ; -extern char *mfmode, *mflandmode ; -extern int mfmode_option; -extern int secure_option; -extern int oname_option; -extern Boolean sendcontrolD ; -#ifdef SHIFTLOWCHARS -extern Boolean shiftlowchars ; -#endif -extern unsigned lastresortsizes[] ; -extern integer hoff, voff ; -extern struct papsiz *papsizes ; -extern int secure ; -extern integer hpapersize, vpapersize ; -extern int landscape ; + /* * To maintain a list of document fonts, we use the following * pointer. */ -struct header_list *ps_fonts_used ; +struct header_list *ps_fonts_used; /* * Our hash routine. */ -int +unsigned int hash(char *s) { - int h = 12 ; + unsigned int h = 12; while (*s != 0) - h = (h + h + *s++) % RESHASHPRIME ; - return(h) ; + h = (h + h + (unsigned char)(*s++)) % RESHASHPRIME; + return(h); } /* * Reverse the hash chains. */ void revpslists(void) { - register int i ; + register int i; for (i=0; inext) if (p->sent == 1) - p->sent = 0 ; + p->sent = 0; } /* * The routine that looks up a font name. @@ -143,19 +76,19 @@ struct resfont * lookup(char *name) { - struct resfont *p ; + struct resfont *p; for (p=reshash[hash(name)]; p!=NULL; p=p->next) if (strcmp(p->Keyname, name)==0) - return(p) ; - return(NULL) ; + return(p); + return(NULL); } struct resfont * findPSname(char *name) { - register int i ; - register struct resfont *p ; + register int i; + register struct resfont *p; for (i=0; inext) { if (strcmp(p->PSname, name)==0) @@ -168,47 +101,55 @@ * This routine adds an entry. */ void +#ifdef VFLIB +add_entry(char *TeXname, char *PSname, char *Fontfile, + char *Vectfile, char *specinfo, char *downloadinfo, + boolean vflib) +#else add_entry(char *TeXname, char *PSname, char *Fontfile, - char *Vectfile, char *specinfo, char *downloadinfo) + char *Vectfile, char *specinfo, char *downloadinfo) +#endif { - struct resfont *p ; - int h ; + struct resfont *p; + int h; if (PSname == NULL) - PSname = TeXname ; - p = (struct resfont *)mymalloc((integer)sizeof(struct resfont)) ; - p->Keyname = TeXname ; - p->PSname = PSname ; + PSname = TeXname; + p = (struct resfont *)mymalloc((integer)sizeof(struct resfont)); + p->Keyname = TeXname; + p->PSname = PSname; p->Fontfile = Fontfile; p->Vectfile = Vectfile; - p->TeXname = TeXname ; - p->specialinstructions = specinfo ; + p->TeXname = TeXname; + p->specialinstructions = specinfo; if (downloadinfo && *downloadinfo) - p->downloadheader = downloadinfo ; + p->downloadheader = downloadinfo; else - p->downloadheader = 0 ; - h = hash(TeXname) ; - p->next = reshash[h] ; - p->sent = 0 ; - reshash[h] = p ; + p->downloadheader = 0; +#ifdef VFLIB + p->vflib = vflib; +#endif + h = hash(TeXname); + p->next = reshash[h]; + p->sent = 0; + reshash[h] = p; } /* * Now our residentfont routine. Returns the number of characters in * this font, based on the TFM file. */ -extern char *infont ; int residentfont(register fontdesctype *curfnt) { - int i ; - struct resfont *p ; + int i; + struct resfont *p; /* * First we determine if we can find this font in the resident list. */ if (*curfnt->area) - return 0 ; /* resident fonts never have a nonstandard font area */ + return 0; /* resident fonts never have a nonstandard font area */ if ((p=lookup(curfnt->name))==NULL) - return 0 ; + return 0; /* * This is not yet the correct way to do things, but it is useful as it * is so we leave it in. The problem: if resident Times-Roman is @@ -221,9 +162,9 @@ #ifdef DEBUG if (dd(D_FONTS)) (void)fprintf(stderr,"Using PK font %s for <%s>.\n", - curfnt->name, p->PSname) ; + curfnt->name, p->PSname); #endif /* DEBUG */ - return 0 ; + return 0; } /* * We clear out some pointers: @@ -231,64 +172,74 @@ #ifdef DEBUG if (dd(D_FONTS)) (void)fprintf(stderr,"Font %s <%s> is resident.\n", - curfnt->name, p->PSname) ; + curfnt->name, p->PSname); #endif /* DEBUG */ - curfnt->resfont = p ; - curfnt->name = p->TeXname ; + curfnt->resfont = p; + curfnt->name = p->TeXname; for (i=0; i<256; i++) { - curfnt->chardesc[i].TFMwidth = 0 ; - curfnt->chardesc[i].packptr = NULL ; - curfnt->chardesc[i].pixelwidth = 0 ; - curfnt->chardesc[i].flags = 0 ; - curfnt->chardesc[i].flags2 = 0 ; + curfnt->chardesc[i].TFMwidth = 0; + curfnt->chardesc[i].packptr = NULL; + curfnt->chardesc[i].pixelwidth = 0; + curfnt->chardesc[i].flags = 0; + curfnt->chardesc[i].flags2 = 0; } - add_name(p->PSname, &ps_fonts_used) ; +#ifdef VFLIB + curfnt->vflib = false; + if (p->vflib) { + curfnt->vflib = p->vflib; + } +#endif + add_name(p->PSname, &ps_fonts_used); /* * We include the font here. But we only should need to include the * font if we have a stupid spooler; smart spoolers should be able * to supply it automatically. */ if (p->downloadheader) { - char *cp = p->downloadheader ; - char *q ; + char *cp = p->downloadheader; + char *q; - infont = p->PSname ; + infont = p->PSname; while (1) { - q = cp ; + q = cp; while (*cp && *cp != ' ') - cp++ ; + cp++; if (*cp) { - *cp = 0 ; - add_header(q) ; - *cp++ = ' ' ; + *cp = 0; + add_header(q); + *cp++ = ' '; } else { /* if (strstr(q,".pfa")||strstr(q,".pfb")|| strstr(q,".PFA")||strstr(q,".PFB")) - break ; + break; else */ { - add_header(q) ; + add_header(q); break; } } - infont = 0 ; + infont = 0; } - infont = 0 ; + infont = 0; } - i = tfmload(curfnt) ; + i = tfmload(curfnt); if (i < 0) - i = 1 ; - usesPSfonts = 1 ; - return(i) ; + i = 1; +#ifdef VFLIB + if (p->vflib) + usesvflib = 1; +#endif + usesPSfonts = 1; + return(i); } #define INLINE_SIZE (2000) -static char was_inline[INLINE_SIZE] ; +static char was_inline[INLINE_SIZE]; static unsigned c_lineno; void -bad_config(char *err) +bad_config(const char *err) { fprintf (stderr, "%s:%d:", realnameoffile, c_lineno); error (err); - fprintf(stderr, " (%s)\n", was_inline) ; + fprintf(stderr, " (%s)\n", was_inline); } #ifndef KPATHSEA @@ -297,34 +248,33 @@ * We substitute everything of the form ::, ^: or :$ with default, * so a user can easily build on to the existing paths. */ -static char * -getpath(char *who, char *what) +static char *getpath(char *who, char *what) { if (who) { - register char *pp, *qq ; - int lastsep = 1 ; + register char *pp, *qq; + int lastsep = 1; for (pp=nextstring, qq=who; *qq;) { if (*qq == PATHSEP) { if (lastsep) { - strcpy(pp, what) ; - pp = pp + strlen(pp) ; + strcpy(pp, what); + pp = pp + strlen(pp); } - lastsep = 1 ; + lastsep = 1; } else - lastsep = 0 ; - *pp++ = *qq++ ; + lastsep = 0; + *pp++ = *qq++; } if (lastsep) { - strcpy(pp, what) ; - pp = pp + strlen(pp) ; + strcpy(pp, what); + pp = pp + strlen(pp); } - *pp = 0 ; - qq = nextstring ; - nextstring = pp + 1 ; - return qq ; + *pp = 0; + qq = nextstring; + nextstring = pp + 1; + return qq; } else - return what ; + return what; } #endif /* @@ -332,28 +282,27 @@ * double quotes with spaces in them. We also accept strings * with spaces in them, but kill off any spaces at the end. */ -char * -configstring(char *s, int nullok) +char *configstring(char *s, int nullok) { - char tstr[INLINE_SIZE] ; - char *p = tstr ; + char tstr[INLINE_SIZE]; + char *p = tstr; while (*s && *s <= ' ') - s++ ; + s++; if (*s == '"') { - s++ ; + s++; while (*s != 10 && *s != 0 && *s != '"' && p < tstr+290) - *p++ = *s++ ; + *p++ = *s++; } else { while (*s && p < tstr+290) - *p++ = *s++ ; + *p++ = *s++; while (*(p-1) <= ' ' && p > tstr) - p-- ; + p--; } - *p = 0 ; + *p = 0; if (p == tstr && ! nullok) - bad_config("bad string") ; - return newstring(tstr) ; + bad_config("bad string"); + return newstring(tstr); } #ifdef KPATHSEA /* We use this in `getdefaults' to modify the kpathsea structure for the @@ -364,23 +313,23 @@ /* * Now we have the getdefaults routine. */ -char *psmapfile = PSMAPFILE ; +const char *psmapfile = PSMAPFILE; Boolean -getdefaults(char *s) +getdefaults(const char *s) { - FILE *deffile ; - char PSname[INLINE_SIZE] ; - register char *p ; - integer hsiz, vsiz ; + FILE *deffile; + char PSname[INLINE_SIZE]; + register char *p; + integer hsiz, vsiz; #ifndef KPATHSEA - char *d = configpath ; - int i, j ; + char *d = configpath; + int i, j; #endif - int canaddtopaper = 0 ; + int canaddtopaper = 0; if (printer == NULL) { if (s) { - strcpy(PSname, s) ; + strcpy(PSname, s); } else { #ifdef KPATHSEA char *dvipsrc = kpse_var_value ("DVIPSRC"); @@ -406,7 +355,7 @@ can show up: c:\/.dvipsrc and so on ... */ { char *p, *q; - for (p = q = PSname; *p && (p - PSname < INLINE_SIZE) ; + for (p = q = PSname; *p && (p - PSname < INLINE_SIZE); p++, q++) { if (IS_DIR_SEP(*p)) { *q = DIR_SEP; p++; q++; @@ -417,27 +366,27 @@ *q = '\0'; } #else - if(!dvipsrc) dvipsrc = kpse_var_expand(DVIPSRC) ; - strcpy(PSname, dvipsrc ? dvipsrc : "~/.dvipsrc") ; - if(dvipsrc) free(dvipsrc) ; + if(!dvipsrc) dvipsrc = kpse_var_expand(DVIPSRC); + strcpy(PSname, dvipsrc ? dvipsrc : "~/.dvipsrc"); + if(dvipsrc) free(dvipsrc); #endif /* WIN32 */ #else /* ! KPATHSEA */ #ifndef VMCMS /* IBM: VM/CMS - don't have home directory on VMCMS */ #ifndef MVSXA - d = "~" ; + d = "~"; #endif #endif /* IBM: VM/CMS */ - strcpy(PSname, DVIPSRC) ; + strcpy(PSname, DVIPSRC); #endif /* KPATHSEA */ } } else { #if defined(MSDOS) || defined(OS2) - strcpy(PSname, printer) ; - strcat(PSname, ".cfg") ; + strcpy(PSname, printer); + strcat(PSname, ".cfg"); #else - strcpy(PSname, "config.") ; - strcat(PSname, printer) ; + strcpy(PSname, "config."); + strcat(PSname, printer); #endif } #ifdef KPATHSEA @@ -447,11 +396,11 @@ #endif if (dvips_debug_flag && !quiet) { if (strlen(realnameoffile) + prettycolumn > STDOUTSIZE) { - fprintf(stderr, "\n") ; - prettycolumn = 0 ; + fprintf(stderr, "\n"); + prettycolumn = 0; } (void)fprintf(stderr, "{%s}", realnameoffile); - prettycolumn += strlen(realnameoffile) + 2 ; + prettycolumn += strlen(realnameoffile) + 2; } #ifdef DEBUG if (dd (D_CONFIG)) { @@ -469,12 +418,12 @@ /* * We need to get rid of the newline. */ - for (p=was_inline; *p; p++) ; + for (p=was_inline; *p; p++); while (p > was_inline && (*(p-1) == '\n' || *(p-1) == '\r')) { - *--p = '\0' ; + *--p = '\0'; } if (was_inline[0] != '@') - canaddtopaper = 0 ; + canaddtopaper = 0; switch (was_inline[0]) { /* * Handling paper size information: @@ -487,185 +436,192 @@ * If it is `name hsize vsize', then we start a new definition. */ case '@' : - p = was_inline + 1 ; - while (*p && *p <= ' ') p++ ; + p = was_inline + 1; + while (*p && *p <= ' ') p++; if (*p == 0) { - papsizes = 0 ; /* throw away memory */ + papsizes = 0; /* throw away memory */ } else if (*p == '+') { if (canaddtopaper == 0) error( - " @+ in config files must immediately following a @ lines") ; + " @+ in config files must immediately following a @ lines"); else { - *(nextstring-1) = '\n' ;/* IBM: VM/CMS - changed 10 to "\n" */ - p++ ; - while (*p && *p == ' ') p++ ; - strcpy(nextstring, p) ; - nextstring += strlen(p) + 1 ; + *(nextstring-1) = '\n';/* IBM: VM/CMS - changed 10 to "\n" */ + p++; + while (*p && *p == ' ') p++; + strcpy(nextstring, p); + nextstring += strlen(p) + 1; } } else { - struct papsiz *ps ; - - ps = (struct papsiz *)mymalloc((integer)sizeof(struct papsiz)) ; - ps->next = papsizes ; - papsizes = ps ; - ps->name = p ; + struct papsiz *ps; + char *q; + + ps = (struct papsiz *)mymalloc((integer)sizeof(struct papsiz)); + ps->next = papsizes; + papsizes = ps; + q = p; while (*p && *p > ' ') - p++ ; - *p++ = 0 ; - ps->name = newstring(ps->name) ; - while (*p && *p <= ' ') p++ ; - handlepapersize(p, &hsiz, &vsiz) ; - ps->xsize = hsiz ; - ps->ysize = vsiz ; - ps->specdat = nextstring++ ; - *(ps->specdat) = 0 ; - canaddtopaper = 1 ; + p++; + *p++ = 0; + ps->name = newstring(q); + while (*p && *p <= ' ') p++; + handlepapersize(p, &hsiz, &vsiz); + ps->xsize = hsiz; + ps->ysize = vsiz; + ps->specdat = newstring(""); + canaddtopaper = 1; } - break ; + break; case 'a' : - dopprescan = (was_inline[1] != '0') ; - break ; + dopprescan = (was_inline[1] != '0'); + break; case 'b': #ifdef SHORTINT if (sscanf(was_inline+1, "%ld", &pagecopies) != 1) - bad_config("missing pagecopies to b") ; + bad_config("missing pagecopies to b"); #else if (sscanf(was_inline+1, "%d", &pagecopies) != 1) - bad_config("missing pagecopies to b") ; + bad_config("missing pagecopies to b"); #endif if (pagecopies < 1 || pagecopies > 1000) - bad_config("pagecopies not between 1 and 1000") ; - break ; + bad_config("pagecopies not between 1 and 1000"); + break; case 'm' : #ifdef SHORTINT if (sscanf(was_inline+1, "%ld", &swmem) != 1) - bad_config("missing swmem to m") ; + bad_config("missing swmem to m"); #else /* ~SHORTINT */ if (sscanf(was_inline+1, "%d", &swmem) != 1) - bad_config("missing swmem to m") ; + bad_config("missing swmem to m"); #endif /* ~SHORTINT */ - swmem += fontmem ; /* grab headers we've seen already */ - break ; + swmem += fontmem; /* grab headers we've seen already */ + break; case 'M' : /* If the user specified a -mode, don't replace it. */ if (!mfmode_option) - mfmode = configstring(was_inline+1, 0) ; - mflandmode = 0 ; + mfmode = configstring(was_inline+1, 0); + mflandmode = 0; { - char *pp ; - for (pp=mfmode; pp && *pp>' '; pp++) ; + char *pp; + for (pp=mfmode; pp && *pp>' '; pp++); if (pp && *pp == ' ') { - *pp++ = 0 ; + *pp++ = 0; while (*pp && *pp <= ' ') - pp++ ; + pp++; if (*pp) - mflandmode = pp ; + mflandmode = pp; } } - break ; + break; case 'o' : if (!oname_option) { struct stat st_buf; - oname = configstring(was_inline+1, 1) ; - if ((*oname && oname[strlen(oname)-1] == ':') - || (stat(oname, &st_buf) == 0 && S_ISCHR(st_buf.st_mode))) { - sendcontrolD = 1 ; /* if we send to a device, *we* are spooler */ + char *tmp_oname; + tmp_oname = configstring(was_inline+1, 1); + if ((*tmp_oname && tmp_oname[strlen(tmp_oname)-1] == ':') + || (stat(tmp_oname, &st_buf) == 0 && S_ISCHR(st_buf.st_mode))) { + sendcontrolD = 1; /* if we send to a device, *we* are spooler */ #if defined(MSDOS) || defined(OS2) - oname[strlen(oname)-1] = 0 ; + tmp_oname[strlen(tmp_oname)-1] = 0; #endif } + oname = tmp_oname; } - break ; + break; case 'F' : - sendcontrolD = (was_inline[1] != '0') ; - break ; + sendcontrolD = (was_inline[1] != '0'); + break; case 'O' : - p = was_inline + 1 ; - handlepapersize(p, &hoff, &voff) ; - break ; + p = was_inline + 1; + handlepapersize(p, &hoff, &voff); + break; #ifdef FONTLIB case 'L' : { - char tempname[INLINE_SIZE] ; - extern char *fliparse() ; - if (sscanf(was_inline+1, "%s", PSname) != 1) bad_config("missing arg to L") ; + char tempname[INLINE_SIZE]; + if (sscanf(was_inline+1, "%s", PSname) != 1) bad_config("missing arg to L"); else { flipath = getpath(fliparse(PSname,tempname), flipath); - fliname = newstring(tempname) ; + fliname = newstring(tempname); } } - break ; + break; #endif case 'T' : if (sscanf(was_inline+1, "%s", PSname) != 1) - bad_config("missing arg to T") ; + bad_config("missing arg to T"); else #ifdef KPATHSEA SET_CLIENT_PATH (kpse_tfm_format, PSname); #else - tfmpath = getpath(PSname, tfmpath) ; + tfmpath = getpath(PSname, tfmpath); #endif - break ; + break; case 'P' : - if (sscanf(was_inline+1, "%s", PSname) != 1) bad_config("missing arg to P") ; + if (sscanf(was_inline+1, "%s", PSname) != 1) bad_config("missing arg to P"); else #ifdef KPATHSEA SET_CLIENT_PATH (kpse_pk_format, PSname); #else - pkpath = getpath(PSname, pkpath) ; + pkpath = getpath(PSname, pkpath); #endif - break ; + break; case 'p' : - p = was_inline + 1 ; + p = was_inline + 1; while (*p && *p <= ' ') - p++ ; + p++; if (*p == '+') { if (sscanf(p+1, "%s", PSname) != 1) - bad_config("missing arg to p") ; - getpsinfo(PSname) ; + bad_config("missing arg to p"); + getpsinfo(PSname); } else { - psmapfile = configstring(was_inline+1, 0) ; + psmapfile = configstring(was_inline+1, 0); } - break ; + break; case 'v' : case 'V' : if (sscanf(was_inline+1, "%s", PSname) != 1) - bad_config("missing arg to V") ; + bad_config("missing arg to V"); else #ifdef KPATHSEA SET_CLIENT_PATH (kpse_vf_format, PSname); #else - vfpath = getpath(PSname, vfpath) ; + vfpath = getpath(PSname, vfpath); #endif - break ; + break; case 'S' : - if (sscanf(was_inline+1, "%s", PSname) != 1) - bad_config("missing arg to S") ; +#if !defined(VFLIB) + if (!strncmp(was_inline, "SJIS", 4)) SJIS = (was_inline[4] != '0'); + else if (sscanf(was_inline+1, "%s", PSname) != 1) + bad_config("missing arg to S"); +#else + if (sscanf(was_inline+1, "%s", PSname) != 1) + bad_config("missing arg to S"); +#endif else #ifdef KPATHSEA SET_CLIENT_PATH (kpse_pict_format, PSname); #else - figpath = getpath(PSname, figpath) ; + figpath = getpath(PSname, figpath); #endif - break ; + break; case 's': - safetyenclose = 1 ; - break ; + safetyenclose = 1; + break; case 'H' : if (sscanf(was_inline+1, "%s", PSname) != 1) - bad_config("missing arg to H") ; + bad_config("missing arg to H"); else #ifdef KPATHSEA SET_CLIENT_PATH (headerpath, PSname); #else - headerpath = getpath(PSname, headerpath) ; + headerpath = getpath(PSname, headerpath); #endif - break ; + break; case '%': case ' ' : case '*' : case '#' : case ';' : case '=' : case 0 : case '\n' : - break ; + break; case 'r' : - reverse = (was_inline[1] != '0') ; - break ; + reverse = (was_inline[1] != '0'); + break; /* * This case is for last resort font scaling; I hate this, but enough * people have in no uncertain terms demanded it that I'll go ahead and @@ -680,27 +636,27 @@ */ case 'R': #ifndef KPATHSEA - i = 0 ; - p = was_inline + 1 ; + i = 0; + p = was_inline + 1; while (*p) { while (*p && *p <= ' ') - p++ ; + p++; if ('0' <= *p && *p <= '9') { - j = 0 ; + j = 0; while ('0' <= *p && *p <= '9') - j = 10 * j + (*p++ - '0') ; + j = 10 * j + (*p++ - '0'); if (i > 0) if (lastresortsizes[i-1] > j) { - bad_config("last resort sizes (R) must be sorted") ; + bad_config("last resort sizes (R) must be sorted"); } - lastresortsizes[i++] = j ; + lastresortsizes[i++] = j; } else { if (*p == 0) - break ; - bad_config("only numbers expected on `R' line") ; + break; + bad_config("only numbers expected on `R' line"); } } - lastresortsizes[i] = 32000 ; + lastresortsizes[i] = 32000; #else /* KPATHSEA */ for (p = was_inline + 1; *p; p++) { if (isblank (*p)) { @@ -709,64 +665,64 @@ } kpse_fallback_resolutions_string = xstrdup (was_inline + 1); #endif - break ; + break; case 'D' : if (sscanf(was_inline+1, "%d", &actualdpi) != 1) - bad_config("missing arg to D") ; + bad_config("missing arg to D"); if (actualdpi < 10 || actualdpi > 10000) - bad_config("dpi must be between 10 and 10000") ; + bad_config("dpi must be between 10 and 10000"); vactualdpi = actualdpi; - break ; + break; /* * Execute a command. This can be dangerous, but can also be very useful. */ case 'E' : #ifdef SECURE - error("dvips was compiled with SECURE, which disables E in config") ; + error("dvips was compiled with SECURE, which disables E in config"); #else if (secure) { - error("E in config is disabled. To enable E, set z0 before E") ; - break ; + error("E in config is disabled. To enable E, set z0 before E"); + break; } - (void)system(was_inline+1) ; + (void)system(was_inline+1); #endif - break ; + break; case 'K': - removecomments = (was_inline[1] != '0') ; - break ; + removecomments = (was_inline[1] != '0'); + break; case 'U': - nosmallchars = (was_inline[1] != '0') ; - break ; + nosmallchars = (was_inline[1] != '0'); + break; case 'W': - for (p=was_inline+1; *p && *p <= ' '; p++) ; + for (p=was_inline+1; *p && *p <= ' '; p++); if (*p) - warningmsg = newstring(p) ; + warningmsg = newstring(p); else - warningmsg = 0 ; - break ; + warningmsg = 0; + break; case 'X' : if (sscanf(was_inline+1, "%d", &actualdpi) != 1) - bad_config("missing numeric arg to X") ; + bad_config("missing numeric arg to X"); if (actualdpi < 10 || actualdpi > 10000) - bad_config("X arg must be between 10 and 10000") ; - break ; + bad_config("X arg must be between 10 and 10000"); + break; case 'Y' : if (sscanf(was_inline+1, "%d", &vactualdpi) != 1) - bad_config("missing numeric arg to Y") ; + bad_config("missing numeric arg to Y"); if (vactualdpi < 10 || vactualdpi > 10000) - bad_config("Y arg must be between 10 and 10000") ; - break ; + bad_config("Y arg must be between 10 and 10000"); + break; case 'x': case 'y': if (sscanf(was_inline+1, "%lg", &mag) != 1) - bad_config("missing arg to x or y") ; - overridemag = (was_inline[0] == 'x') ? 1 : -1 ; - break ; + bad_config("missing arg to x or y"); + overridemag = (was_inline[0] == 'x') ? 1 : -1; + break; case 'e' : if (sscanf(was_inline+1, "%d", &maxdrift) != 1) - bad_config("missing arg to e") ; - if (maxdrift < 0) bad_config("bad argument to e") ; + bad_config("missing arg to e"); + if (maxdrift < 0) bad_config("bad argument to e"); vmaxdrift = maxdrift; - break ; + break; case 'z' : if (secure_option && secure && was_inline[1] == '0') { fprintf (stderr, @@ -774,70 +730,70 @@ realnameoffile); /* Never happen */ } else { if (was_inline[1] == '0') { - secure = 0 ; + secure = 0; } else if (was_inline[1] == '2') { - secure = 2 ; + secure = 2; } else { - secure = 1 ; + secure = 1; } } - break ; + break; case 'q' : case 'Q' : - quiet = (was_inline[1] != '0') ; - break ; + quiet = (was_inline[1] != '0'); + break; case 'f' : - filter = (was_inline[1] != '0') ; + filter = (was_inline[1] != '0'); if (filter) oname = ""; /* noenv has already been tested, so no point in setting. */ sendcontrolD = 0; - break ; + break; #ifdef SHIFTLOWCHARS case 'G': - shiftlowchars = (was_inline[1] != '0') ; - break ; + shiftlowchars = (was_inline[1] != '0'); + break; #endif case 'h' : if (sscanf(was_inline+1, "%s", PSname) != 1) - bad_config("missing arg to h") ; - else (void)add_header(PSname) ; - break ; + bad_config("missing arg to h"); + else (void)add_header(PSname); + break; case 'i' : if (sscanf(was_inline+1, "%d", &maxsecsize) != 1) - maxsecsize = 0 ; - sepfiles = 1 ; - break ; + maxsecsize = 0; + sepfiles = 1; + break; case 'I': - noenv = (was_inline[1] != '0') ; - break ; + noenv = (was_inline[1] != '0'); + break; case 'N' : - disablecomments = (was_inline[1] != '0') ; - break ; + disablecomments = (was_inline[1] != '0'); + break; case 'Z' : - compressed = (was_inline[1] != '0') ; - break ; + compressed = (was_inline[1] != '0'); + break; case 'j': - partialdownload = (was_inline[1] != '0') ; - break ; + partialdownload = (was_inline[1] != '0'); + break; case 't' : if (sscanf(was_inline+1, "%s", PSname) != 1) - bad_config("missing arg to t") ; + bad_config("missing arg to t"); else { if (strcmp(PSname, "landscape") == 0) { if (hpapersize || vpapersize) error( - "both landscape and papersize specified; ignoring landscape") ; + "both landscape and papersize specified; ignoring landscape"); else - landscape = 1 ; + landscape = 1; } else - paperfmt = newstring(PSname) ; + paperfmt = newstring(PSname); } - break ; + break; default: - bad_config("strange line") ; + bad_config("strange line"); } } - (void)fclose(deffile) ; + (void)fclose(deffile); } else { if (printer) { @@ -856,57 +812,61 @@ * default (possibly set) name, psfonts.map. */ void -getpsinfo(char *name) +getpsinfo(const char *name) { - FILE *deffile ; - register char *p ; - char *specinfo, *downloadinfo ; - char downbuf[500] ; - char specbuf[500] ; - int slen ; + FILE *deffile; + register char *p; + char *specinfo, *downloadinfo; + char downbuf[500]; + char specbuf[500]; + int slen; if (name == 0) - name = psmapfile ; + name = psmapfile; + if ((deffile=search(mappath, name, READ))!=NULL) { if (dvips_debug_flag && !quiet) { if (strlen(realnameoffile) + prettycolumn > STDOUTSIZE) { - fprintf(stderr, "\n") ; - prettycolumn = 0 ; + fprintf(stderr, "\n"); + prettycolumn = 0; } (void)fprintf(stderr, "{%s}", realnameoffile); - prettycolumn += strlen(realnameoffile) + 2 ; + prettycolumn += strlen(realnameoffile) + 2; } while (fgets(was_inline, INLINE_SIZE, deffile)!=NULL) { - p = was_inline ; + p = was_inline; if (*p > ' ' && *p != '*' && *p != '#' && *p != ';' && *p != '%') { - char *TeXname = NULL ; - char *PSname = NULL ; + char *TeXname = NULL; + char *PSname = NULL; char *Fontfile = NULL; char *Vectfile = NULL; char *hdr_name = NULL; boolean nopartial_p = false; boolean encoding_p = false; - specinfo = NULL ; - downloadinfo = NULL ; - downbuf[0] = 0 ; - specbuf[0] = 0 ; +#ifdef VFLIB + boolean vflib_p = false; +#endif + specinfo = NULL; + downloadinfo = NULL; + downbuf[0] = 0; + specbuf[0] = 0; while (*p) { - encoding_p = false ; + encoding_p = false; while (*p && *p <= ' ') - p++ ; + p++; if (*p) { if (*p == '"') { /* PostScript instructions? */ if (specinfo) { - strcat(specbuf, specinfo) ; - strcat(specbuf, " ") ; + strcat(specbuf, specinfo); + strcat(specbuf, " "); } - specinfo = p + 1 ; + specinfo = p + 1; } else if (*p == '<') { /* Header to download? */ /* If had previous downloadinfo, save it. */ if (downloadinfo) { - strcat(downbuf, downloadinfo) ; - strcat(downbuf, " ") ; + strcat(downbuf, downloadinfo); + strcat(downbuf, " "); downloadinfo = NULL; } if (p[1] == '<') { /* << means always full download */ @@ -916,41 +876,53 @@ p++; encoding_p = true; } - p++ ; +#ifdef VFLIB + else if (p[1] == '`') { /* <` means VFlib */ + p++; + vflib_p = true; + } +#endif + p++; /* skip whitespace after < */ while (*p && *p <= ' ') p++; /* save start of header name */ - hdr_name = p ; + hdr_name = p; } else if (TeXname) /* second regular word on line? */ - PSname = p ; + PSname = p; else /* first regular word? */ - TeXname = p ; + TeXname = p; if (*p == '"') { - p++ ; /* find end of "..." word */ + p++; /* find end of "..." word */ while (*p != '"' && *p) - p++ ; + p++; } else while (*p > ' ') /* find end of anything else */ - p++ ; + p++; if (*p) - *p++ = 0 ; + *p++ = 0; /* If we had a header we were downloading, figure out what to do; couldn't do this above since we want to check the suffix. */ if (hdr_name) { char *suffix = find_suffix (hdr_name); +#ifdef VFLIB + if (vflib_p) { + /* Partial downloading of a VFlib font. */ + Fontfile = hdr_name; + } else +#endif if (encoding_p || STREQ (suffix, "enc")) { /* (SPQR) if it is a reencoding, pass on to FontPart, and download as usual */ Vectfile = downloadinfo = hdr_name; } else if (nopartial_p) { - downloadinfo = hdr_name ; + downloadinfo = hdr_name; } else if (FILESTRCASEEQ (suffix, "pfa") || FILESTRCASEEQ (suffix, "pfb") || STREQ (suffix, "PFA") @@ -963,28 +935,32 @@ } } if (specinfo) - strcat(specbuf, specinfo) ; + strcat(specbuf, specinfo); if (downloadinfo) - strcat(downbuf, downloadinfo) ; + strcat(downbuf, downloadinfo); slen = strlen(downbuf) - 1; if (slen > 0 && downbuf[slen] == ' ') { downbuf[slen] = 0; } if (TeXname) { - TeXname = newstring(TeXname) ; - PSname = newstring(PSname) ; + TeXname = newstring(TeXname); + PSname = newstring(PSname); Fontfile = newstring(Fontfile); Vectfile = newstring(Vectfile); - specinfo = newstring(specbuf) ; - downloadinfo = newstring(downbuf) ; + specinfo = newstring(specbuf); + downloadinfo = newstring(downbuf); add_entry(TeXname, PSname, Fontfile, Vectfile, - specinfo, downloadinfo) ; +#ifdef VFLIB + specinfo, downloadinfo, vflib_p); +#else + specinfo, downloadinfo); +#endif } } } - (void)fclose(deffile) ; + (void)fclose(deffile); } - checkstrings() ; + checkstrings(); } #ifndef KPATHSEA /* @@ -992,50 +968,48 @@ * We substitute everything of the form ::, ^: or :$ with default, * so a user can easily build on to the existing paths. */ -static char * -getenvup(char *who, char *what) +static char *getenvup(char *who, char *what) { - return getpath(getenv(who), what) ; + return getpath(getenv(who), what); } #endif #if !defined(KPATHSEA) && defined(SEARCH_SUBDIRECTORIES) static char *concat3(); #endif -void -checkenv(int which) +void checkenv(int which) { #ifndef KPATHSEA if (which) { - tfmpath = getenvup(FONTPATH, tfmpath) ; - vfpath = getenvup("VFFONTS", vfpath) ; - pictpath = getenvup("TEXPICTS", pictpath) ; - figpath = getenvup("TEXINPUTS", figpath) ; - headerpath = getenvup("DVIPSHEADERS", headerpath) ; + tfmpath = getenvup(FONTPATH, tfmpath); + vfpath = getenvup("VFFONTS", vfpath); + pictpath = getenvup("TEXPICTS", pictpath); + figpath = getenvup("TEXINPUTS", figpath); + headerpath = getenvup("DVIPSHEADERS", headerpath); if (getenv("TEXPKS")) - pkpath = getenvup("TEXPKS", pkpath) ; + pkpath = getenvup("TEXPKS", pkpath); else if (getenv("TEXPACKED")) - pkpath = getenvup("TEXPACKED", pkpath) ; + pkpath = getenvup("TEXPACKED", pkpath); else if (getenv("PKFONTS")) - pkpath = getenvup("PKFONTS", pkpath) ; + pkpath = getenvup("PKFONTS", pkpath); #ifdef SEARCH_SUBDIRECTORIES else if (getenv(FONTPATH)) - pkpath = getenvup(FONTPATH, pkpath) ; + pkpath = getenvup(FONTPATH, pkpath); if (getenv ("TEXFONTS_SUBDIR")) fontsubdirpath = getenvup ("TEXFONTS_SUBDIR", fontsubdirpath); { - char pathsep[2] ; + char pathsep[2]; char *do_subdir_path(); char *dirs = do_subdir_path (fontsubdirpath); /* If the paths were in dynamic storage before, that memory is wasted now. */ - pathsep[0] = PATHSEP ; - pathsep[1] = '\0' ; + pathsep[0] = PATHSEP; + pathsep[1] = '\0'; tfmpath = concat3 (tfmpath, pathsep, dirs); pkpath = concat3 (pkpath, pathsep, dirs); } #endif } else - configpath = getenvup("TEXCONFIG", configpath) ; + configpath = getenvup("TEXCONFIG", configpath); #endif } @@ -1072,8 +1046,8 @@ #include /* for MAXPATHLEN */ #endif -extern void exit() ; -extern int chdir() ; +extern void exit(); +extern int chdir(); /* Memory operations: variants of malloc(3) and realloc(3) that just give up the ghost when they fail. */ @@ -1170,10 +1144,10 @@ unsigned len; char *result = xmalloc ((unsigned)1); char *temp = dir_list; - char dirsep[2] ; + char dirsep[2]; - dirsep[0] = DIRSEP ; - dirsep[1] = '\0' ; + dirsep[0] = DIRSEP; + dirsep[1] = '\0'; /* Make a copy in writable memory. */ dir_list = xmalloc (strlen (temp) + 1); diff -Nu dvipsk2009/scalewidth.c dvipsk/scalewidth.c --- dvipsk2009/scalewidth.c Tue Jun 23 18:46:14 2009 +++ dvipsk/scalewidth.c Mon Mar 29 23:31:33 2010 @@ -14,20 +14,23 @@ * place in the program where such accuracy is required. */ #include "dvips.h" /* The copyright notice in that file is included too! */ +/* + * The external declarations: + */ #include "protos.h" integer scalewidth(register integer a, register integer b) { - register integer al, bl ; + register integer al, bl; if (a < 0) - return -scalewidth(-a, b) ; + return -scalewidth(-a, b); if (b < 0) - return -scalewidth(a, -b) ; - al = a & 32767 ; - bl = b & 32767 ; - a >>= 15 ; - b >>= 15 ; - return ( ((al*bl/32768) + a*bl+al*b)/32 + a*b*1024) ; + return -scalewidth(a, -b); + al = a & 32767; + bl = b & 32767; + a >>= 15; + b >>= 15; + return ( ((al*bl/32768) + a*bl+al*b)/32 + a*b*1024); } diff -Nu dvipsk2009/scanpage.c dvipsk/scanpage.c --- dvipsk2009/scanpage.c Tue Jun 23 18:46:14 2009 +++ dvipsk/scanpage.c Mon Mar 29 23:31:43 2010 @@ -8,29 +8,10 @@ #include "dvips.h" /* The copyright notice in that file is included too! */ /* - * These are the external routines we need. + * The external declarations: */ #include "protos.h" -extern integer firstboploc ; -/* - * And, of course, the globals it uses. - */ -#ifdef DEBUG -extern integer debug_flag; -#endif /* DEBUG */ -extern fontdesctype *curfnt ; -extern fontmaptype *ffont ; -extern quarterword *curpos, *curlim ; -extern integer fontmem ; -extern integer pagecount ; -extern integer pagenum ; -extern Boolean compressed ; -extern FILE *dvifile ; -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. @@ -41,52 +22,52 @@ Boolean prescanchar(chardesctype *cd) { - register quarterword *cras ; - register integer thischar ; + register quarterword *cras; + register integer thischar; if ((cd->flags & (PREVPAGE | THISPAGE)) == 0) { /* the character hasn't been used before in the current section */ - cras = cd->packptr ; + cras = cd->packptr; if (curfnt->resfont) { - thischar = PSCHARCOST ; - cd->flags |= THISPAGE ; + thischar = PSCHARCOST; + cd->flags |= THISPAGE; } else if (cras != NULL) { - thischar = CHARCOST ; + thischar = CHARCOST; if (cd->flags & BIGCHAR) - thischar += 43 ; + thischar += 43; if (compressed) { if ((cd->flags & REPACKED) == 0) { - repack(cd) ; - cras = cd->packptr ; + repack(cd); + cras = cd->packptr; } if ((*cras & 4)) if ((*cras & 7) == 7) - thischar += getlong(cras + 17) ; + thischar += getlong(cras + 17); else - thischar += getlong(cras + 9) ; + thischar += getlong(cras + 9); else - thischar += getlong(cras + 5) ; + thischar += getlong(cras + 5); } else { if ((*cras & 4)) if ((*cras & 7) == 7) thischar += getlong(cras + 1) - * ((getlong(cras + 5) + 7) >> 3) ; + * ((getlong(cras + 5) + 7) >> 3); else thischar += (cras[3] * 256L + cras[4]) * - ((cras[1] * 256L + cras[2] + 7) >> 3) ; + ((cras[1] * 256L + cras[2] + 7) >> 3); else - thischar += ((long)(cras[2] * ((cras[1] + 7) >> 3))) ; + thischar += ((long)(cras[2] * ((cras[1] + 7) >> 3))); } - cd->flags |= THISPAGE ; + cd->flags |= THISPAGE; } else - thischar = 0 ; - fontmem -= thischar ; + thischar = 0; + fontmem -= thischar; if (fontmem <= pagecost) { if (pagecount > 0) - return(0) ; + return(0); } } - return(1) ; + return(1); } /* * When a font is selected during the prescan, this routine makes sure that @@ -97,29 +78,28 @@ Boolean preselectfont(fontdesctype *f) { - curfnt = f ; + curfnt = f; if (curfnt->loaded == 0 || curfnt->loaded == 3) { if (!residentfont(curfnt)) if (!virtualfont(curfnt)) - loadfont(curfnt) ; + loadfont(curfnt); } if (curfnt->psname == 0) { - if (curfnt->loaded < 2) { /* virtual font costs nothing (yet) */ + if (curfnt->loaded < 2) /* virtual font costs nothing (yet) */ if (curfnt->resfont) - fontmem -= PSFONTCOST ; + fontmem -= PSFONTCOST; else { - fontmem -= FONTCOST + curfnt->maxchars ; + fontmem -= FONTCOST + curfnt->maxchars; if (curfnt->loadeddpi != curfnt->dpi) - fontmem -= 48 ; /* for the new font matrix */ + fontmem -= 48; /* for the new font matrix */ } - } - curfnt->psname = 1 ; + curfnt->psname = 1; if (fontmem <= pagecost) { if (pagecount > 0) - return(0) ; + return(0); } } - return(1) ; + return(1); } /* * Now our scanpage routine. @@ -127,102 +107,110 @@ short scanpage(void) { - register shalfword cmd ; - register chardesctype *cd ; - register fontmaptype *cfnt = 0 ; - integer fnt ; - integer mychar ; - register frametype *frp = frames ; + register shalfword cmd; + register chardesctype *cd; + register fontmaptype *cfnt = 0; + integer fnt; + integer mychar; +#ifdef VFLIB + integer rawchar; +#endif + register frametype *frp = frames; if (firstboploc == 0) - firstboploc = ftell(dvifile) ; - pagecost = 0 ; + firstboploc = ftell(dvifile); + pagecost = 0; #ifdef DEBUG if (dd(D_PAGE)) #ifdef SHORTINT - (void)fprintf(stderr,"Scanning page %ld\n", pagenum) ; + (void)fprintf(stderr,"Scanning page %ld\n", pagenum); #else /* ~SHORTINT */ - (void)fprintf(stderr,"Scanning page %d\n", pagenum) ; + (void)fprintf(stderr,"Scanning page %d\n", pagenum); #endif /* ~SHORTINT */ #endif /* DEBUG */ - curfnt = NULL ; - curpos = NULL ; + curfnt = NULL; + curpos = NULL; - bopcolor(0) ; /* IBM: color - put current colorstack to bopstackdepth */ + bopcolor(0); /* IBM: color - put current colorstack to bopstackdepth */ while (1) { switch (cmd=dvibyte()) { 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 */ +case 254: /* unimplemented or illegal commands */ (void)sprintf(errbuf, - "! DVI file contains unexpected command (%d)",cmd) ; - error(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() ; + (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() ; + (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() ; + (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() ; + (void)dvibyte(); +case 143: case 148: case 153: case 157: case 162: case 167: case 255: + /* one-byte commands right1, w1, x1, down1, y1, z1, dir */ + (void)dvibyte(); case 147: case 152: case 161: case 166: /* w0, x0, y0, z0 */ case 138: case 141: case 142: /* nop, push, pop */ - break ; + break; 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 commands drops through */ + mychar = dvibyte(); mychar = (mychar << 8) + dvibyte(); +#ifdef VFLIB + rawchar = mychar; + if (mychar>=256) mychar = ((mychar>>8)-0x21)*94 + (mychar&0xff)-0x21; +#endif + goto dochar; +case 133: case 128: cmd = dvibyte(); /* set1 commands drops through */ default: /* these are commands 0 (setchar0) thru 127 (setchar 127) */ - mychar = cmd ; + mychar = cmd; dochar: /* * We are going to approximate that each string of consecutive characters * requires (length of string) bytes of PostScript VM. */ if (curfnt==NULL) - error("! Bad DVI file: no font selected") ; + 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) ; + (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 ; - frp->ff = ffont ; - frp->curf = curfnt ; + frp->curp = curpos; + frp->curl = curlim; + frp->ff = ffont; + frp->curf = curfnt; if (++frp == &frames[MAXFRAME] ) - error("! virtual recursion stack overflow") ; - cd = curfnt->chardesc + mychar ; - if (cd->packptr == 0) - error("! a non-existent virtual character is being used; check vf/tfm files") ; - curpos = cd->packptr + 2 ; - curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1))) ; - ffont = curfnt->localfonts ; + error("! virtual recursion stack overflow"); + cd = curfnt->chardesc + mychar; + if (cd->packptr == 0) { +#ifdef VFLIB + fprintf(stderr, "Wrong char code: %04X\n", rawchar); +#else + fprintf(stderr, "Wrong char code: %04X\n", mychar); +#endif + error("! a non-existent virtual character is being used; check vf/tfm files"); + } + curpos = cd->packptr + 2; + curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1))); + ffont = curfnt->localfonts; if (ffont==NULL) - curfnt = NULL ; + curfnt = NULL; else if (!preselectfont(ffont->desc)) - goto outofmem ; + goto outofmem; } else { - pagecost++ ; + pagecost++; if (!prescanchar(curfnt->chardesc + mychar)) - goto outofmem ; + goto outofmem; } - break ; + 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: case 185: case 186: case 187: case 188: case 189: case 190: case 191: @@ -233,59 +221,59 @@ case 220: case 221: case 222: case 223: case 224: case 225: case 226: case 227: case 228: case 229: case 230: case 231: case 232: case 233: case 234: case 235: case 236: case 237: case 238: /* font selection commands */ - if (cmd < 235) fnt = cmd - 171 ; /* fntnum0 thru fntnum63 */ + if (cmd < 235) fnt = cmd - 171; /* fntnum0 thru fntnum63 */ else { - fnt = dvibyte() ; /* fnt1 */ + fnt = dvibyte(); /* fnt1 */ while (cmd-- > 235) - fnt = (fnt << 8) + dvibyte() ; + fnt = (fnt << 8) + dvibyte(); } 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 ; + if (cfnt->fontnum == fnt) goto fontfound; + printf("Font number %d not found\n", fnt); + error("! no font selected"); +fontfound: curfnt = cfnt->desc; if (!preselectfont(curfnt)) - goto outofmem ; - break ; -case 239: predospecial((integer)dvibyte(), 1) ; break ; /* xxx1 */ -case 240: predospecial((integer)twobytes(), 1) ; break ; /* xxx2 */ -case 241: predospecial(threebytes(), 1) ; break ; /* xxx3 */ -case 242: predospecial(signedquad(), 1) ; break ; /* xxx4 */ -case 243: case 244: case 245: case 246: fontdef(cmd-242) ; break ; /* fntdef1 */ + goto outofmem; + break; +case 239: predospecial((integer)dvibyte(), 1); break; /* xxx1 */ +case 240: predospecial((integer)twobytes(), 1); break; /* xxx2 */ +case 241: predospecial(threebytes(), 1); break; /* xxx3 */ +case 242: predospecial(signedquad(), 1); break; /* xxx4 */ +case 243: case 244: case 245: case 246: fontdef(cmd-242); break; /* fntdef1 */ case 140: /* eop or end of virtual char */ if (curpos) { - --frp ; - curfnt = frp->curf ; - ffont = frp->ff ; - curlim = frp->curl ; - curpos = frp->curp ; - break ; + --frp; + curfnt = frp->curf; + ffont = frp->ff; + curlim = frp->curl; + curpos = frp->curp; + break; } - goto endofpage ; /* eop */ + goto endofpage; /* eop */ } } endofpage: if (fontmem > pagecost) - return(1) ; + return(1); if (pagecount > 0) { - return(0) ; + return(0); } /* IBM: color */ #ifdef SHORTINT - (void)fprintf(stderr, "Page %ld may be too complex to print\n", pagenum) ; + (void)fprintf(stderr, "Page %ld may be too complex to print\n", pagenum); #else /* ~SHORTINT */ - (void)fprintf(stderr, "Page %d may be too complex to print\n", pagenum) ; + (void)fprintf(stderr, "Page %d may be too complex to print\n", pagenum); #endif /* ~SHORTINT */ /* * This case should be rare indeed. Even with only 200K of virtual memory, * at 11 bytes per char, you can have 18K characters on a page. */ - return(2) ; + return(2); outofmem: if (frp != frames) { - curpos = frames->curp ; - curlim = frames->curl ; - ffont = frames->ff ; - curfnt = frames->curf ; + curpos = frames->curp; + curlim = frames->curl; + ffont = frames->ff; + curfnt = frames->curf; } - return 0 ; + return 0; } diff -Nu dvipsk2009/search.c dvipsk/search.c --- dvipsk2009/search.c Tue Jun 23 18:46:14 2009 +++ dvipsk/search.c Mon Mar 29 23:31:52 2010 @@ -3,83 +3,101 @@ * tries to open a file. Null directory components indicate current * directory. In an environment variable, null directory components * indicate substitution of the default path list at that point. + * This source file assumes KPATHSEA is defined. */ #include "dvips.h" /* The copyright notice in that file is included too! */ -#include "protos.h" -#ifdef KPATHSEA +#ifndef KPATHSEA +"goodbye, search.c can only be compiled with -DKPATHSEA" +#endif + +#include "protos_add.h" /* external declarations */ + #include #include #include #include #include -extern char name[]; -#else -#include -#if !defined(WIN32) -extern int fclose(); /* these added to keep SunOS happy */ -extern int pclose(); -extern char *getenv(); -#endif -#ifdef OS2 -#include -FILE *fat_fopen(); +#include + +#ifndef GUNZIP +#define GUNZIP "gzip -d" #endif -#if defined(SYSV) || defined(VMS) || defined(__THINK__) || defined(MSDOS) || defined(OS2) || defined(ATARIST) || defined(WIN32) -#define MAXPATHLEN (2000) +int to_close; /* use fclose or pclose? */ +char *realnameoffile; + +/* Return safely quoted version of NAME. That means using "..." on + Windows and '...' on Unix, with any occurrences of the quote char + quoted with a \. Result is always in new memory; NAME is unchanged. + This is a generic function; if we end up needing it in other + programs, we should move it to kpathsea. */ + +#ifdef WIN32 +#define QUOTE '"' #else -#include /* for MAXPATHLEN */ -#endif -#if !defined(MSDOS) && !defined(OS2) && !defined(WIN32) -#ifndef VMS -#ifndef MVSXA -#ifndef VMCMS /* IBM: VM/CMS */ -#ifndef __THINK__ -#ifndef ATARIST -#include -#endif +#define QUOTE '\'' #endif -#endif -#endif /* IBM: VM/CMS */ -#endif -#endif -#endif /* KPATHSEA */ -/* - * - * We hope MAXPATHLEN is enough -- only rudimentary checking is done! - */ -#ifndef SECURE -extern int secure ; -#endif -#ifdef DEBUG -extern integer debug_flag; -#endif /* DEBUG */ -extern char *mfmode ; -extern int actualdpi ; -int to_close ; - -#ifdef KPATHSEA -#ifndef UNCOMPRESS -#define UNCOMPRESS "uncompress" -#endif +static char * +quote_name (const char *name) +{ + char *quoted = xmalloc (strlen (name) * 2 + 3); + char *q = quoted; + const char *p = name; + + *q++ = QUOTE; + while (*p) { + if (*p == QUOTE) + *q++ = QUOTE; + *q++ = *p++; + } + *q++ = QUOTE; + *q = 0; + + return quoted; +} -#ifndef GUNZIP -#define GUNZIP "gzip -d" -#endif + +/* On Windows, return PROG with SELFAUTOLOC prepended, and / separators + changed to \. On Unix, return a copy of PROG. Result is always in + new memory. No safeness or other quoting is done on PROG. + + This is necessary because Windows likes to run programs out of the + current directory. So for security, we want to ensure that we are + invoking programs from our own binary directory, not via PATH. -#ifndef BUNZIP2 -#define BUNZIP2 "bzip2 -d" -#endif + This is a generic function; if we end up needing it in other + programs, we should move it to kpathsea. */ +static char * +selfautoloc_prog (const char *prog) +{ + char *ret; +#ifdef WIN32 + char *p; + /* Get value of SELFAUTOLOC, but \ works better for path separator. */ + char *selfautoloc = (char *)kpse_var_value ("SELFAUTOLOC"); + for (p = selfautoloc; *p; p++) { + if (*p == '/') + *p = '\\'; + } + + /* Prepend that to PROG. */ + ret = concat3 (selfautoloc, "\\", prog); + free (selfautoloc); + +#else /* not WIN32 */ + ret = xstrdup (prog); #endif -#ifdef KPATHSEA -char *realnameoffile ; + return ret; +} + + FILE * -search(kpse_file_format_type format, char *file, char *mode) +search(kpse_file_format_type format, const char *file, const char *mode) { FILE *ret; string found_name; @@ -90,14 +108,15 @@ if (secure == 2) { #endif /* an absolute path is denied */ - if (kpse_absolute_p (file, false)) return NULL; + if (kpse_absolute_p (file, false)) + return NULL; if (file[0] == '.' && file[1] == '.' && IS_DIR_SEP(file[2])) { /* a relative path starting with ../ is denied */ return NULL; } else { /* a relative path containing /../ is denied */ - char *p; + const char *p; if (file[0] != '\0') { for(p = file + 1; *p && ((p = strstr(p, "..")) != NULL); p += 2) { @@ -114,32 +133,39 @@ #endif /* Most file looked for through here must exist -- the exception is VF's. Bitmap fonts go through pksearch. */ - found_name = kpse_find_file (file, format, format != vfpath && - format != ofmpath); + found_name = kpse_find_file (file, format, + format != vfpath && format != ofmpath); if (found_name) { unsigned len = strlen (found_name); -#ifndef AMIGA if ((format == figpath || format == headerpath) && ((len > 2 && FILESTRCASEEQ (found_name + len - 2, ".Z")) || (len > 3 && FILESTRCASEEQ (found_name + len - 3, ".gz")))) { -/* FIXME : use zlib instead of gzip ! */ - char *cmd = concat3 (GUNZIP, " -c ", found_name); + /* automatically but safely decompress. */ + char *quoted_name = quote_name (found_name); + char *cmd; + char *prog = selfautoloc_prog (GUNZIP); + cmd = concat3 (prog, " -c ", quoted_name); ret = popen (cmd, "r"); - to_close = USE_PCLOSE ; +#ifdef WIN32 + SET_BINARY(fileno(ret)); +#endif + to_close = USE_PCLOSE; + free (cmd); + free (quoted_name); + free (prog); } else { -#endif /* not AMIGA */ ret = fopen (found_name, mode); - to_close = USE_FCLOSE ; -#ifndef AMIGA + to_close = USE_FCLOSE; } -#endif /* not AMIGA */ if (!ret) FATAL_PERROR (found_name); + /* Free result of previous search. */ if (realnameoffile) free (realnameoffile); + /* Save in `name' and `realnameoffile' because other routines - access those globals. Sigh. */ + access those globals. */ realnameoffile = found_name; strcpy(name, realnameoffile); } else @@ -148,386 +174,36 @@ return ret; } /* end search */ + FILE * -pksearch(char *file, char *mode, halfword dpi, char **name_ret, int *dpi_ret) +pksearch(const char *file, const char *mode, halfword dpi, + char **name_ret, int *dpi_ret) { FILE *ret; kpse_glyph_file_type font_file; string found_name = kpse_find_pk (file, dpi, &font_file); - if (found_name) - { - ret = fopen (found_name, mode); - if (!ret) - FATAL_PERROR (name); + if (found_name) { + ret = fopen (found_name, mode); + if (!ret) + FATAL_PERROR (name); - /* Free result of previous search. */ - if (realnameoffile) - free (realnameoffile); - /* Save in `name' and `realnameoffile' because other routines - access those globals. Sigh. */ - realnameoffile = found_name; - strcpy(name, realnameoffile); - *name_ret = font_file.name; - *dpi_ret = font_file.dpi; - } - else + /* Free result of previous search. */ + if (realnameoffile) + free (realnameoffile); + /* Save in `name' and `realnameoffile' because other routines + access those globals. Sigh. */ + realnameoffile = found_name; + strcpy(name, realnameoffile); + *name_ret = font_file.name; + *dpi_ret = font_file.dpi; + } else ret = NULL; return ret; } /* end search */ -#else /* ! KPATHSEA */ -char realnameoffile[MAXPATHLEN] ; - -extern char *figpath, *pictpath, *headerpath ; -FILE * -search(char *path, char *file, char *mode) -{ - register char *nam ; /* index into fname */ - register FILE *fd ; /* file desc of file */ - char fname[MAXPATHLEN] ; /* to store file name */ - static char *home = 0 ; /* home is where the heart is */ - int len = strlen(file) ; - int tryz = 0 ; - if (len>=3 && - ((file[len-2] == '.' && file[len-1] == 'Z') || - (file[len-3] == '.' && file[len-2] == 'g' && file[len-1] == 'z')) && - (path==figpath || path==pictpath || path==headerpath)) - tryz = file[len-1] ; - to_close = USE_FCLOSE ; -#ifdef MVSXA -char fname_safe[256]; -register int i, firstext, lastext, lastchar; -#endif -#ifdef VMCMS /* IBM: VM/CMS - we don't have paths or dirsep's but we strip off - filename if there is a Unix path dirsep */ - register char *lastdirsep ; - lastdirsep = strrchr(file, '/') ; - if ( NULL != lastdirsep ) file = lastdirsep + 1 ; - if ((fd=fopen(file,mode)) != NULL) { - return(fd) ; - } else { - return(NULL) ; - } -#else - if (*file == DIRSEP - || NAME_BEGINS_WITH_DEVICE(file)) { /* if full path name */ - if ((fd=fopen(file,mode)) != NULL) { - strcpy(realnameoffile, file) ; - if (tryz) { - char *cmd = mymalloc(strlen(file) + 20) ; - strcpy(cmd, (tryz=='z' ? "gzip -d <" : "compress -d <")) ; - strcat(cmd, file) ; - fclose(fd) ; - fd = popen(cmd, "r") ; - to_close = USE_PCLOSE ; - free(cmd) ; - } - return(fd) ; - } else - return(NULL) ; - } -#endif /* IBM: VM/CMS */ - -#if defined MSDOS || defined OS2 || defined(ATARIST) || defined(WIN32) - if ( isalpha(file[0]) && file[1]==':' ) { /* if full path name */ - if ((fd=fopen(file,mode)) != NULL) { - strcpy(realnameoffile, file) ; - return(fd) ; - } else - return(NULL) ; - } - if (*file == '/') {/* if full path name with unix DIRSEP less drive code */ - if ((fd=fopen(file,mode)) != NULL) { - strcpy(realnameoffile, file) ; - return(fd) ; - } else - return(NULL) ; - } -#endif - - do { - /* copy the current directory into fname */ - nam = fname; - /* copy till PATHSEP */ - if (*path == '~') { - char *p = nam ; - path++ ; - while (*path && *path != PATHSEP && *path != DIRSEP) - *p++ = *path++ ; - *p = 0 ; - if (*nam == 0) { - if (home == 0) { - if (0 != (home = getenv("HOME"))) - home = newstring(home) ; - else - home = "." ; - } - strcpy(fname, home) ; - } else { -#if defined MSDOS || defined OS2 - error("! ~username in path???") ; -#else -#ifdef WIN32 - /* FIXME: at least under NT, it should be possible to - retrieve the HOME DIR for a given user */ - error("! ~username in path???") ; -#else -#ifdef VMS - error("! ~username in path???") ; -#else -#ifdef ATARIST - error("! ~username in path???") ; -#else -#ifdef VMCMS /* IBM: VM/CMS */ - error("! ~username in path???") ; -#else -#ifdef MVSXA /* IBM: MVS/XA */ - error("! ~username in path???") ; -#else -#ifdef __THINK__ - error("! ~username in path???") ; -#else - struct passwd *pw = getpwnam(fname) ; - if (pw) - strcpy(fname, pw->pw_dir) ; - else - error("no such user") ; -#endif -#endif /* IBM: VM/CMS */ -#endif -#endif -#endif -#endif -#endif - } - nam = fname + strlen(fname) ; - } - while (*path != PATHSEP && *path) *nam++ = *path++; - *nam = 0 ; -#ifndef VMS -#ifndef __THINK__ - if (nam == fname) *nam++ = '.'; /* null component is current dir */ - - if (*file != '\0') { - if ((nam != fname) && *(nam-1) != DIRSEP) /* GNW 1992.07.09 */ - *nam++ = DIRSEP; /* add separator */ - (void)strcpy(nam,file); /* tack the file on */ - } - else - *nam = '\0' ; -#else - (void)strcpy(nam,file); /* tack the file on */ -#endif -#else - (void)strcpy(nam,file); /* tack the file on */ -#endif -#ifdef MVSXA -nam = fname; -if (strchr(nam,'=') != NULL) { - (void) strcpy(fname_safe,fname); /* save fname */ - firstext = strchr(nam, '=') - nam + 2; - lastext = strrchr(nam, '.') - nam + 1; - lastchar = strlen(nam) - 1; - - (void) strcpy(fname,"dd:"); /* initialize fname */ - nam=&fname[3]; - for (i=lastext; i<=lastchar; i++) *nam++ = fname_safe[i] ; - *nam++ = '(' ; - for (i=firstext; i MAXPATHLEN) - error("! overran allocated storage in search()"); - -#ifdef DEBUG - if (dd(D_PATHS)) - (void)fprintf(stderr,"search: Trying to open %s\n", fname) ; -#endif - if ((fd=fopen(fname,mode)) != NULL) { - strcpy(realnameoffile, fname) ; - if (tryz) { - char *cmd = mymalloc(strlen(file) + 20) ; - strcpy(cmd, (tryz=='z' ? "gzip -d <" : "compress -d <")) ; - strcat(cmd, file) ; - fclose(fd) ; - fd = popen(cmd, "r") ; - to_close = USE_PCLOSE ; - } - return(fd); - } - - /* skip over PATHSEP and try again */ - } while (*(path++)); - - return(NULL); - -} /* end search */ - -FILE * -pksearch(char *path, char *file, char *mode, - char *n, halfword dpi, halfword vdpi) -{ - register char *nam ; /* index into fname */ - register FILE *fd ; /* file desc of file */ - char fname[MAXPATHLEN] ; /* to store file name */ - static char *home = 0 ; /* home is where the heart is */ - int sub ; - - if (*file == DIRSEP) { /* if full path name */ - if ((fd=fopen(file,mode)) != NULL) - return(fd) ; - else - return(NULL) ; - } -#if defined MSDOS || defined OS2 || defined(WIN32) - if ( isalpha(file[0]) && file[1]==':' ) { /* if full path name */ - if ((fd=fopen(file,mode)) != NULL) - return(fd) ; - else - return(NULL) ; - } -#endif - do { - /* copy the current directory into fname */ - nam = fname; - sub = 0 ; - /* copy till PATHSEP */ - if (*path == '~') { - char *p = nam ; - path++ ; - while (*path && *path != PATHSEP && *path != DIRSEP) - *p++ = *path++ ; - *p = 0 ; - if (*nam == 0) { - if (home == 0) { - if (0 != (home = getenv("HOME"))) - home = newstring(home) ; - else - home = "." ; - } - strcpy(fname, home) ; - } else { -#if defined MSDOS || defined OS2 - error("! ~username in path???") ; -#else -#ifdef WIN32 - error("! ~username in path???") ; -#else -#ifdef VMS - error("! ~username in path???") ; -#else -#ifdef ATARIST - error("! ~username in path???") ; -#else -#ifdef VMCMS /* IBM: VM/CMS */ - error("! ~username in path???") ; -#else -#ifdef MVSXA /* IBM: MVS/XA */ - error("! ~username in path???") ; -#else -#ifdef __THINK__ - error("! ~username in path???") ; -#else - struct passwd *pw = getpwnam(fname) ; - if (pw) - strcpy(fname, pw->pw_dir) ; - else - error("no such user") ; -#endif -#endif /* IBM: VM/CMS */ -#endif -#endif -#endif -#endif -#endif - } - nam = fname + strlen(fname) ; - } - /* copy till PATHSEP */ - while (*path != PATHSEP && *path) { - if (*path == '%') { - sub = 1 ; - path++ ; - switch(*path) { - case 'b': sprintf(nam, "%d", actualdpi) ; break ; - case 'd': sprintf(nam, "%d", dpi) ; break ; - case 'f': strcpy(nam, n) ; break ; - case 'm': if (mfmode == 0) - if (actualdpi == 300) mfmode = "imagen" ; - else if (actualdpi == 400) mfmode = "nexthi" ; - else if (actualdpi == 635) mfmode = "linolo" ; - else if (actualdpi == 1270) mfmode = "linohi" ; - else if (actualdpi == 2540) mfmode = "linosuper" ; - if (mfmode == 0) - error("! MF mode not set, but used in pk path") ; - strcpy(nam, mfmode) ; - break ; - case 'p': strcpy(nam, "pk") ; break ; - case '%': strcpy(nam, "%") ; break ; - default: fprintf(stderr, "Format character: %c\n", *path) ; - error("! bad format character in pk path") ; - } - nam = fname + strlen(fname) ; - if (*path) - path++ ; - } else - *nam++ = *path++; - } -#ifndef VMS -#ifndef __THINK__ - if (nam == fname) *nam++ = '.'; /* null component is current dir */ -#endif -#endif /* VMS */ - if (sub == 0 && *file) { -#ifndef VMS - /* change suggested by MG */ - if ((nam != fname) && *(nam-1) != DIRSEP) /* GNW 1992.07.09 */ - *nam++ = DIRSEP ; -#endif - strcpy(nam, file) ; - } else - *nam = 0 ; - -#ifdef MVSXA /* IBM: MVS/XA */ - if (fname[0] == '/') { - fname[0] = '\''; - strcat(&fname[strlen(fname)],"\'"); - } - if (fname[0] == '.') fname[0] = ' '; - if (fname[1] == '.') fname[1] = ' '; -#endif /* IBM: MVS/XA */ - /* belated check -- bah! */ - if (strlen(fname) + 1 > MAXPATHLEN) - error("! overran allocated storage in search()"); - -#ifdef DEBUG - if (dd(D_PATHS)) - (void)fprintf(stderr,"pksearch: Trying to open %s\n", fname) ; -#endif - if ((fd=fopen(fname,mode)) != NULL) - return(fd); - - /* skip over PATHSEP and try again */ - } while (*(path++)); - - return(NULL); - -} /* end search */ -#endif /* KPATHSEA */ + /* do we report file openings? */ #ifdef DEBUG @@ -538,23 +214,23 @@ # define fopen cmsfopen # endif /* IBM: VM/CMS */ FILE * -my_real_fopen(register char *n, register char *t) +my_real_fopen(register const char *n, register const char *t) { - FILE *tf ; + FILE *tf; if (dd(D_FILES)) { - fprintf(stderr, "<%s(%s)> ", n, t) ; - tf = fopen(n, t) ; + fprintf(stderr, "<%s(%s)> ", n, t); + tf = fopen(n, t); if (tf == 0) - fprintf(stderr, "failed\n") ; + fprintf(stderr, "failed\n"); else - fprintf(stderr, "succeeded\n") ; + fprintf(stderr, "succeeded\n"); } else - tf = fopen(n, t) ; + tf = fopen(n, t); #ifdef OS2 if (tf == (FILE *)NULL) tf = fat_fopen(n, t); /* try again with filename truncated to 8.3 */ #endif - return tf ; + return tf; } #endif @@ -616,15 +292,15 @@ strcpy(np,nbuf); /* now code copied from my_real_fopen() */ if (dd(D_FILES)) { - fprintf(stderr, "<%s(%s)> ", n, t) ; - tf = fopen(n, t) ; + fprintf(stderr, "<%s(%s)> ", n, t); + tf = fopen(n, t); if (tf == 0) - fprintf(stderr, "failed\n") ; + fprintf(stderr, "failed\n"); else - fprintf(stderr, "succeeded\n") ; + fprintf(stderr, "succeeded\n"); } else - tf = fopen(n, t) ; + tf = fopen(n, t); return tf; } return (FILE *)NULL; @@ -635,8 +311,8 @@ close_file(FILE *f) { switch(to_close) { -case USE_PCLOSE: return pclose(f) ; -case USE_FCLOSE: return fclose(f) ; -default: return -1 ; +case USE_PCLOSE: return pclose(f); +case USE_FCLOSE: return fclose(f); +default: return -1; } } diff -Nu dvipsk2009/skippage.c dvipsk/skippage.c --- dvipsk2009/skippage.c Tue Jun 23 18:46:14 2009 +++ dvipsk/skippage.c Mon Mar 29 23:32:03 2010 @@ -6,78 +6,69 @@ #include "dvips.h" /* The copyright notice in that file is included too! */ /* - * These are the external routines called. + * The external declarations: */ #include "protos.h" /* - * These are the external variables accessed. - */ -#ifdef DEBUG -extern integer debug_flag; -#endif /* DEBUG */ -extern integer pagenum ; -extern char errbuf[] ; -extern FILE *dvifile ; -/* * And now the big routine. */ void skippage(void) { - register shalfword cmd ; - register integer i ; + register shalfword cmd; + register integer i; #ifdef DEBUG if (dd(D_PAGE)) #ifdef SHORTINT - (void)fprintf(stderr,"Skipping page %ld\n", pagenum) ; + (void)fprintf(stderr,"Skipping page %ld\n", pagenum); #else /* ~SHORTINT */ - (void)fprintf(stderr,"Skipping page %d\n", pagenum) ; + (void)fprintf(stderr,"Skipping page %d\n", pagenum); #endif /* ~SHORTINT */ #endif /* DEBUG */ -/* skipover(40) ; skip rest of bop command? how did this get in here? */ - bopcolor(0) ; +/* skipover(40); skip rest of bop command? how did this get in here? */ + bopcolor(0); while ((cmd=dvibyte())!=140) { switch (cmd) { /* illegal options */ 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: +case 252: case 253: case 254: (void)sprintf(errbuf, - "! DVI file contains unexpected command (%d)",cmd) ; - error(errbuf) ; + "! DVI file contains unexpected command (%d)",cmd); + error(errbuf); /* eight byte commands */ case 132: case 137: - cmd = dvibyte() ; - cmd = dvibyte() ; - cmd = dvibyte() ; - cmd = dvibyte() ; + cmd = dvibyte(); + cmd = dvibyte(); + cmd = dvibyte(); + cmd = dvibyte(); /* four byte commands */ case 146: case 151: case 156: case 160: case 165: case 170: case 238: - cmd = dvibyte() ; + cmd = dvibyte(); /* three byte commands */ case 145: case 150: case 155: case 159: case 164: case 169: case 237: - cmd = dvibyte() ; + cmd = dvibyte(); /* two byte commands */ -case 129: case 134: case 144: case 149: case 154: case 158: case 163: -case 168: case 236: - cmd = dvibyte() ; +case 129: case 134: +case 144: case 149: case 154: case 158: case 163: case 168: case 236: + cmd = dvibyte(); /* one byte commands */ case 128: case 133: case 143: case 148: case 153: case 157: case 162: -case 167: case 235: - cmd = dvibyte() ; - break ; +case 167: case 235: case 255: + cmd = dvibyte(); + break; /* specials */ -case 239: i = dvibyte() ; predospecial(i, 0) ; break ; -case 240: i = twobytes() ; predospecial(i, 0) ; break ; -case 241: i = threebytes() ; predospecial(i, 0) ; break ; -case 242: i = signedquad() ; predospecial(i, 0) ; break ; +case 239: i = dvibyte(); predospecial(i, 0); break; +case 240: i = twobytes(); predospecial(i, 0); break; +case 241: i = threebytes(); predospecial(i, 0); break; +case 242: i = signedquad(); predospecial(i, 0); break; /* font definition */ case 243: case 244: case 245: case 246: - fontdef(cmd - 242) ; - break ; -default: ; + fontdef(cmd - 242); + break; +default:; } } } diff -Nu dvipsk2009/t1part.c dvipsk/t1part.c --- dvipsk2009/t1part.c Tue Jun 23 18:46:14 2009 +++ dvipsk/t1part.c Mon Mar 29 23:32:14 2010 @@ -16,7 +16,7 @@ #ifdef BORLANDC void huge *UniGetMem(size) -ub4 size ; +ub4 size; { void huge *tmp; if ((tmp =(void huge*) farcalloc(1L, size)) == NULL) @@ -65,8 +65,8 @@ int GridCount; int ind_ref; -int LoadVector(int, CHAR *) ; -int Afm(void) ; +int LoadVector(int, CHAR *); +int Afm(void); typedef struct { @@ -209,7 +209,7 @@ typedef struct { - char *command; + const char *command; int code; } tablecommand; @@ -222,7 +222,7 @@ typedef struct { - char *extension; + const char *extension; int num; } typefonts; @@ -256,7 +256,7 @@ typedef struct { - char *name; + const char *name; int num; } type_key; @@ -359,7 +359,7 @@ } if(isalpha(*line)) { - *tmp++ = *line++ ; + *tmp++ = *line++; while(!isspace(*line) && *line != '/') *tmp++= *line++; *tmp = '\0'; @@ -695,14 +695,14 @@ * O'Neill; bugs in application of fix due to me. */ if (NextChar == 0) { - NextChar = (CHAR *) getmem(sizeof(CHAR)) ; - NextChar->name = (unsigned char *) getmem(length + 1) ; - strcpy((char *) NextChar->name, (char *) name) ; - NextChar->length = length ; - NextChar->num = -1 ; - NextChar->NextChar = 0 ; - NextChar->choose = 1 ; - ThisChar->NextChar = NextChar ; + NextChar = (CHAR *) getmem(sizeof(CHAR)); + NextChar->name = (unsigned char *) getmem(length + 1); + strcpy((char *) NextChar->name, (char *) name); + NextChar->length = length; + NextChar->num = -1; + NextChar->NextChar = 0; + NextChar->choose = 1; + ThisChar->NextChar = NextChar; } ThisChar = NextChar; } @@ -911,7 +911,7 @@ len_dup = strlen(Dup); - for( ; number < keyword[i].oldnum + keyword[i].offset;) + for(; number < keyword[i].oldnum + keyword[i].offset;) { if((word_type=GetToken())>0) { @@ -925,7 +925,7 @@ err_num=GetNum(); if(err_num<0) - ; + ; else { if(err_num<4) @@ -1038,7 +1038,7 @@ { unsigned int loccr; unsigned char byte; - static int j ; + static int j; int i; unsigned char jj,k; int tmpnum; @@ -1546,7 +1546,7 @@ label[number].select = FLG_BINARY; offset= ++number; - for (current=0, FirstKey=current ; ; current++) + for (current=0, FirstKey=current;; current++) { i=FindKeyWord(firstnum,lastnum); switch(i) @@ -1670,7 +1670,7 @@ int flg_get_word=0; - static char *RefKey[] = + static const char *RefKey[] = { "readonly", "getinterval", @@ -1769,7 +1769,7 @@ { int err_token=0; int num=0; - int seen = 0 ; + int seen = 0; while (1) { err_token=GetWord(token); @@ -1794,8 +1794,8 @@ FirstChar=AddChar(FirstChar,token, num); keep_num=num; keep_flg=1; - seen++ ; - err_token = GetWord(token) ; + seen++; + err_token = GetWord(token); } } else { @@ -1810,7 +1810,7 @@ } } } else - return seen ; + return seen; } } @@ -1959,12 +1959,12 @@ static char * KillUnique(char *s) { - char *r = strstr(s, "/UniqueID") ; + char *r = strstr(s, "/UniqueID"); if (r) { - r[7] = 'X' ; - r[8] = 'X' ; + r[7] = 'X'; + r[8] = 'X'; } - return s ; + return s; } void @@ -2311,7 +2311,7 @@ { int i=0; int num; - static char *hexstr = "0123456789abcdef" ; + static const char *hexstr = "0123456789abcdef"; int bin; line=tmpline; @@ -2366,21 +2366,21 @@ int i,j,k,num=0; unsigned char name[40]; - static char *AfmKey[] = + static const char *AfmKey[] = { "StartCharMetrics", "EndCharMetrics", "" }; - static char *InfoKey[] = + static const char *InfoKey[] = { "C", "N", "" }; - for(i=0; psfontfile[i] ; i++) + for(i=0; psfontfile[i]; i++) { if(psfontfile[i] == '.') break; diff -Nu dvipsk2009/t1part.h dvipsk/t1part.h --- dvipsk2009/t1part.h Wed Jan 18 06:41:51 2006 +++ dvipsk/t1part.h Mon Mar 29 23:32:23 2010 @@ -37,7 +37,7 @@ #ifdef DVIPS extern FILE *search(); #ifndef KPATHSEA -extern char *headerpath ; +extern char *headerpath; #endif /* not KPATHSEA */ #define psfopen(A,B) search(headerpath,A,B) #else @@ -142,6 +142,6 @@ #define FLG_LOAD_BASE (1) extern unsigned char grid[]; -extern unsigned char *line, *tmpline ; -extern int loadbase ; +extern unsigned char *line, *tmpline; +extern int loadbase; extern struct Char *FirstCharB; diff -Nu dvipsk2009/tex.lpro dvipsk/tex.lpro --- dvipsk2009/tex.lpro Mon Mar 19 02:18:44 2007 +++ dvipsk/tex.lpro Sat Jan 16 10:37:12 2010 @@ -258,7 +258,22 @@ 65781.76 div /hsize X } N -/p {show} N % the main character setting routine +/dir 0 def +/dyy {/dir 0 def +} B +/dyt {/dir 1 def +} B +/dty {/dir 2 def +} B +/dtt {/dir 3 def +} B + +%/p {show} N % the main character setting routine +/p {dir 2 eq + {-90 rotate show 90 rotate} + {dir 3 eq {-90 rotate show 90 rotate} + {show} ifelse} ifelse +} N /RMat [ 1 0 0 -1 0 0 ] N % things we need for rules /BDot 260 string N diff -Nu dvipsk2009/tfmload.c dvipsk/tfmload.c --- dvipsk2009/tfmload.c Tue Jun 23 18:46:14 2009 +++ dvipsk/tfmload.c Mon Mar 29 23:32:35 2010 @@ -4,34 +4,25 @@ #include "dvips.h" /* The copyright notice in that file is included too! */ #ifdef KPATHSEA #include +#include #endif /* - * These are the external routines it calls: + * The external declarations: */ #include "protos.h" -/* - * Here are the external variables we use: - */ -extern real conv ; -extern real vconv ; -extern real alpha ; -#ifndef KPATHSEA -extern char *tfmpath ; -#endif -extern char errbuf[] ; -extern integer fsizetol ; -extern Boolean noomega ; + +FILE *tfmfile; + /* * Our static variables: */ -FILE *tfmfile ; -static char name[50] ; +static char name[50]; void -badtfm(char *s) +badtfm(const char *s) { - (void)sprintf(errbuf,"! Bad TFM file %s: %s",name,s) ; - error(errbuf); + char *msg = concatn ("! Bad TFM file ", name, ": ", s, NULL); + error(msg); } /* @@ -41,191 +32,270 @@ void tfmopen(register fontdesctype *fd) { - register char *n; + register char *n; #ifdef KPATHSEA - kpse_file_format_type d ; + kpse_file_format_type d; #else register char *d; #endif - n = fd->name ; + n = fd->name; if (!noomega) { #ifdef KPATHSEA d = ofmpath; #else - d = fd->area ; + d = fd->area; if (*d==0) - d = ofmpath ; + d = ofmpath; #endif #ifdef MVSXA /* IBM: MVS/XA */ - (void)sprintf(name, "ofm(%s)", n) ; + (void)sprintf(name, "ofm(%s)", n); #else - (void)sprintf(name, "%s.ofm", n) ; + (void)sprintf(name, "%s.ofm", n); #endif if ((tfmfile=search(d, name, READBIN))!=NULL) - return ; + return; } #ifdef KPATHSEA d = tfmpath; #else - d = fd->area ; + d = fd->area; if (*d==0) - d = tfmpath ; + d = tfmpath; #endif #ifdef MVSXA /* IBM: MVS/XA */ - (void)sprintf(name, "tfm(%s)", n) ; + (void)sprintf(name, "tfm(%s)", n); #else - (void)sprintf(name, "%s.tfm", n) ; + (void)sprintf(name, "%s.tfm", n); #endif if ((tfmfile=search(d, name, READBIN))!=NULL) - return ; + return; (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.") ; + 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) #else if ((tfmfile=search(d, "cmr10.tfm", READBIN))!=NULL) #endif - return ; - error("! I can't find cmr10.tfm; please reinstall me with proper paths") ; + return; + error("! I can't find cmr10.tfm; please reinstall me with proper paths"); } shalfword tfmbyte(void) { - return(getc(tfmfile)) ; + return(getc(tfmfile)); } halfword tfm16(void) { - register halfword a ; - a = tfmbyte () ; - return ( a * 256 + tfmbyte () ) ; + register halfword a; + a = tfmbyte (); + return ( a * 256 + tfmbyte () ); } integer tfm32(void) { - register integer a ; - a = tfm16 () ; - if (a > 32767) a -= 65536 ; - return ( a * 65536 + tfm16 () ) ; + register integer a; + a = tfm16 (); + if (a > 32767) a -= 65536; + return ( a * 65536 + tfm16 () ); } int tfmload(register fontdesctype *curfnt) { - register integer i, j ; - register integer li, cd=0 ; - integer scaledsize ; - integer nw, hd ; - integer bc, ec ; - integer nco=0, ncw=0, npc=0, no_repeats = 0 ; - integer *scaled ; - integer *chardat ; - int font_level ; - integer pretend_no_chars ; - int charcount = 0 ; + register integer i, j; + register integer li, cd=0; + integer scaledsize; + integer id, nt, lf; + integer nw, hd; + integer bc, ec; + integer nco=0, ncw=0, npc=0, no_repeats = 0; + halfword *index; + halfword *chartype; + integer *scaled; + integer *chardat; + int font_level; + integer pretend_no_chars; + int charcount = 0; - tfmopen(curfnt) ; + tfmopen(curfnt); /* * Next, we read the font data from the tfm file, and store it in * our own arrays. */ - li = tfm16() ; - if (li!=0) { - font_level = -1 ; - hd = tfm16() ; - 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") ; + curfnt->dir = 0; + curfnt->iswide = 0; + curfnt->codewidth = 1; + id = tfm16(); + if (id!=0) { + font_level = -1; + if (id == 9 || id == 11) { + if (id == 9) curfnt->dir = id; + nt = tfm16(); lf = tfm16(); + curfnt->iswide = 1; + curfnt->maxchars = MAX_CODE; + curfnt->chardesc = (chardesctype *)realloc(curfnt->chardesc, + sizeof(chardesctype)*(MAX_CODE)); + for (i=256; ichardesc[i].TFMwidth = 0; + curfnt->chardesc[i].packptr = NULL; + curfnt->chardesc[i].pixelwidth = 0; + curfnt->chardesc[i].flags = 0; + } + } + hd = tfm16(); + bc = tfm16(); ec = tfm16(); + nw = tfm16(); + li = tfm32(); li = tfm32(); li = tfm32(); li = tfm16(); + if (id != 9 && id != 11) { + 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() ; + 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") ; + badtfm("header"); if (font_level==1) { - nco = tfm32() ; - ncw = tfm32() ; - npc = tfm32() ; + nco = tfm32(); + ncw = tfm32(); + npc = tfm32(); for (i=0; i<12; i++) li=tfm32(); } } - li = tfm32() ; + li = tfm32(); check_checksum (li, curfnt->checksum, curfnt->name); - li = (integer)(alpha * (real)tfm32()) ; + li = (integer)(alpha * (real)tfm32()); if (li > curfnt->designsize + fsizetol || li < curfnt->designsize - fsizetol) { - (void)sprintf(errbuf,"Design size mismatch in %s", name) ; - error(errbuf) ; + char *msg = concat ("Design size mismatch in font ", curfnt->name); + error(msg); + } + if (id == 9 || id == 11) { + chardat = (integer *)xmalloc(256*sizeof(integer)); + for (i=2; i>8)-0x21)*94 + (li&0xff)-0x21; +#else + index[i] = li; +#endif + chartype[i] = tfm16(); + } + for (i=0; i<256; i++) + chardat[i] = 256; + + for (i=bc; i<=ec; i++) { + chardat[i] = tfmbyte(); + li = tfm16(); + li |= tfmbyte(); + if (li || chardat[i]) + charcount++; + } } - pretend_no_chars=ec+1 ; - if (pretend_no_chars<256) pretend_no_chars=256 ; else { - curfnt->chardesc = (chardesctype *) - xrealloc(curfnt->chardesc, sizeof(chardesctype)*pretend_no_chars) ; - curfnt->maxchars = 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; i0) { - no_repeats-- ; - } else if (font_level>=0) { - cd = tfm16() ; - li = tfm32() ; - li = tfm16() ; - if (font_level==1) { - no_repeats = tfm16() ; - for (j=0; j<(npc|1); j++) tfm16() ; - ncw -= 3 + npc/2 ; + pretend_no_chars=ec+1; + if (pretend_no_chars<256) pretend_no_chars = 256; + else { + curfnt->chardesc = (chardesctype *) + xrealloc(curfnt->chardesc, sizeof(chardesctype)*pretend_no_chars); + curfnt->maxchars = 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; i0) { + no_repeats--; + } else if (font_level>=0) { + cd = tfm16(); + li = tfm32(); + li = tfm16(); + if (font_level==1) { + no_repeats = tfm16(); + for (j=0; j<(npc|1); j++) tfm16(); + ncw -= 3 + npc/2; + } + } else { + cd = tfmbyte(); + li = tfm16(); + li = tfmbyte(); } - } else { - cd = tfmbyte() ; - li = tfm16() ; - li = tfmbyte() ; - } - if (cd>=nw) badtfm("char info") ; - if (cd) { - chardat[i] = cd ; - charcount++ ; - } - } - if (font_level==1&&ncw!=0) { - sprintf(errbuf, "Table size mismatch in %s", curfnt->name) ; - error(errbuf) ; + if (cd>=nw) badtfm("char info"); + if (cd) { + chardat[i] = cd; + charcount++; + } + } + if (font_level==1&&ncw!=0) { + char *msg = concat ("Table size mismatch in ", curfnt->name); + error (msg); + } } - scaledsize = curfnt->scaledsize ; - scaled = (integer *) xmalloc(nw*sizeof(integer)) ; + scaledsize = curfnt->scaledsize; + scaled = (integer *) xmalloc(nw*sizeof(integer)); for (i=0; ichardesc[i].TFMwidth = li ; + scaled[i] = scalewidth(tfm32(), scaledsize); + (void)fclose(tfmfile); + + if (id == 9 || id == 11) { + for (i=0; ichardesc[i].TFMwidth = li; + if (li >= 0) + curfnt->chardesc[i].pixelwidth = ((integer)(conv*li+0.5)); + else + curfnt->chardesc[i].pixelwidth = -((integer)(conv*-li+0.5)); + curfnt->chardesc[i].flags = (curfnt->resfont ? EXISTS : 0); + curfnt->chardesc[i].flags2 = EXISTS; + } + for (i=1; ichardesc[index[i]].TFMwidth = li; if (li >= 0) - curfnt->chardesc[i].pixelwidth = ((integer)(conv*li+0.5)) ; + curfnt->chardesc[index[i]].pixelwidth = ((integer)(conv*li+0.5)); else - curfnt->chardesc[i].pixelwidth = -((integer)(conv*-li+0.5)) ; - curfnt->chardesc[i].flags = (curfnt->resfont ? EXISTS : 0) ; - curfnt->chardesc[i].flags2 = EXISTS ; - } 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 */ - curfnt->loaded = 1 ; - return charcount ; + curfnt->chardesc[index[i]].pixelwidth = -((integer)(conv*-li+0.5)); + curfnt->chardesc[index[i]].flags = (curfnt->resfont ? EXISTS : 0); + curfnt->chardesc[index[i]].flags2 = EXISTS; + } + free(index); + free(chartype); + } + else { + for (i=0; ichardesc[i].TFMwidth = li; + if (li >= 0) + curfnt->chardesc[i].pixelwidth = ((integer)(conv*li+0.5)); + else + curfnt->chardesc[i].pixelwidth = -((integer)(conv*-li+0.5)); + curfnt->chardesc[i].flags = (curfnt->resfont ? EXISTS : 0); + curfnt->chardesc[i].flags2 = EXISTS; + } + if (ec>=256) curfnt->codewidth = 2; /* XXX: 2byte-code can have ec<256 */ + } + free(chardat); + free(scaled); + curfnt->loaded = 1; + return charcount; } diff -Nu dvipsk2009/unpack.c dvipsk/unpack.c --- dvipsk2009/unpack.c Tue Jun 23 18:46:14 2009 +++ dvipsk/unpack.c Mon Mar 29 23:32:44 2010 @@ -7,19 +7,19 @@ #include "dvips.h" /* The copyright notice in that file is included too! */ /* - * external procedures + * The external declarations: */ #include "protos.h" /* * Some statics for use here. */ -static halfword bitweight ; -static halfword dynf ; +static halfword bitweight; +static halfword dynf; static halfword gpower[17] = { 0 , 1 , 3 , 7 , 15 , 31 , 63 , 127 , - 255 , 511 , 1023 , 2047 , 4095 , 8191 , 16383 , 32767 , 65535 } ; -static long repeatcount ; -static quarterword *p ; + 255 , 511 , 1023 , 2047 , 4095 , 8191 , 16383 , 32767 , 65535 }; +static long repeatcount; +static quarterword *p; /* * We need procedures to get a nybble, bit, and packed word from the @@ -30,152 +30,152 @@ getnyb(void) { if ( bitweight == 0 ) - { bitweight = 16 ; - return(*p++ & 15) ; + { bitweight = 16; + return(*p++ & 15); } else { - bitweight = 0 ; - return(*p >> 4) ; + bitweight = 0; + return(*p >> 4); } } Boolean getbit(void) { - bitweight >>= 1 ; + bitweight >>= 1; if ( bitweight == 0 ) - { p++ ; - bitweight = 128 ; + { p++; + bitweight = 128; } - return(*p & bitweight) ; + return(*p & bitweight); } long pkpackednum(void) { register halfword i; - register long j ; - i = getnyb () ; + register long j; + i = getnyb (); if ( i == 0 ) { - do { j = getnyb () ; - i++ ; - } while ( j == 0 ) ; + do { j = getnyb (); + i++; + } while ( j == 0 ); while ( i != 0 ) { - j = j * 16 + ((long) getnyb ()) ; - i-- ; + j = j * 16 + ((long) getnyb ()); + i--; } - return ( j - 15 + ( 13 - dynf ) * 16 + dynf ) ; + return ( j - 15 + ( 13 - dynf ) * 16 + dynf ); } - else if ( i <= dynf ) return ( i ) ; - else if ( i < 14 ) return ( ( i - dynf - 1 )*16 + getnyb() + dynf + 1 ) ; + else if ( i <= dynf ) return ( i ); + else if ( i < 14 ) return ( ( i - dynf - 1 )*16 + getnyb() + dynf + 1 ); else { if (repeatcount != 0) - error("! recursive repeat count in pk file") ; - repeatcount = 1 ; - if ( i == 14 ) repeatcount = pkpackednum () ; - return ( pkpackednum() ) ; + error("! recursive repeat count in pk file"); + repeatcount = 1; + if ( i == 14 ) repeatcount = pkpackednum (); + return ( pkpackednum() ); } } void flip(register char *s, register long howmany) { - register char t ; + register char t; while (howmany > 0) { - t = *s ; - *s = s[1] ; - s[1] = t ; - howmany-- ; - s += 2 ; + t = *s; + *s = s[1]; + s[1] = t; + howmany--; + s += 2; } } /* * And now we have our main routine. */ -static halfword bftest = 1 ; +static halfword bftest = 1; long unpack(quarterword *pack, halfword *raster, halfword cwidth, halfword cheight, halfword cmd) { - register integer i, j ; - shalfword wordwidth ; - register halfword word, wordweight ; - shalfword rowsleft ; - Boolean turnon ; - shalfword hbit, ww ; - long count ; - halfword *oraster ; - - oraster = raster ; - p = pack ; - dynf = cmd / 16 ; - turnon = cmd & 8 ; - wordwidth = (cwidth + 15)/16 ; + register integer i, j; + shalfword wordwidth; + register halfword word, wordweight; + shalfword rowsleft; + Boolean turnon; + shalfword hbit, ww; + long count; + halfword *oraster; + + oraster = raster; + p = pack; + dynf = cmd / 16; + turnon = cmd & 8; + wordwidth = (cwidth + 15)/16; if ( dynf == 14 ) - { bitweight = 256 ; - for ( i = 1 ; i <= cheight ; i ++ ) - { word = 0 ; - wordweight = 32768 ; - for ( j = 1 ; j <= cwidth ; j ++ ) - { if ( getbit () ) word += wordweight ; - wordweight >>= 1 ; + { bitweight = 256; + for ( i = 1; i <= cheight; i ++ ) + { word = 0; + wordweight = 32768; + for ( j = 1; j <= cwidth; j ++ ) + { if ( getbit () ) word += wordweight; + wordweight >>= 1; if ( wordweight == 0 ) - { *raster++ = word ; - word = 0 ; - wordweight = 32768 ; + { *raster++ = word; + word = 0; + wordweight = 32768; } } if ( wordweight != 32768 ) - *raster++ = word ; + *raster++ = word; } } else { - rowsleft = cheight ; - hbit = cwidth ; - repeatcount = 0 ; - ww = 16 ; - word = 0 ; - bitweight = 16 ; + rowsleft = cheight; + hbit = cwidth; + repeatcount = 0; + ww = 16; + word = 0; + bitweight = 16; while ( rowsleft > 0 ) - { count = pkpackednum() ; + { count = pkpackednum(); while ( count != 0 ) { if ( ( count <= ww ) && ( count < hbit ) ) { if ( turnon ) word += gpower [ ww ] - gpower - [ ww - count ] ; - hbit -= count ; - ww -= count ; - count = 0 ; + [ ww - count ]; + hbit -= count; + ww -= count; + count = 0; } else if ( ( count >= hbit ) && ( hbit <= ww ) ) { if ( turnon ) - word += gpower[ww] - gpower[ww-hbit] ; - *raster++ = word ; - for ( i = 1 ; i <= repeatcount ; i ++ ) { - for ( j = 1 ; j <= wordwidth ; j ++ ) { - *raster = *(raster - wordwidth) ; - raster++ ; + word += gpower[ww] - gpower[ww-hbit]; + *raster++ = word; + for ( i = 1; i <= repeatcount; i ++ ) { + for ( j = 1; j <= wordwidth; j ++ ) { + *raster = *(raster - wordwidth); + raster++; } } - rowsleft -= repeatcount + 1 ; - repeatcount = 0 ; - word = 0 ; - ww = 16 ; - count -= hbit ; - hbit = cwidth ; + rowsleft -= repeatcount + 1; + repeatcount = 0; + word = 0; + ww = 16; + count -= hbit; + hbit = cwidth; } else - { if ( turnon ) word += gpower [ ww ] ; - *raster++ = word ; - word = 0 ; - count -= ww ; - hbit -= ww ; - ww = 16 ; + { if ( turnon ) word += gpower [ ww ]; + *raster++ = word; + word = 0; + count -= ww; + hbit -= ww; + ww = 16; } } - turnon = ! turnon ; + turnon = ! turnon; } if ( ( rowsleft != 0 ) || ( (unsigned)hbit != cwidth ) ) - error ( "! error while unpacking; more bits than required" ) ; + error ( "! error while unpacking; more bits than required" ); } if (*(char *)&bftest) /* is the hardware LittleEndian? */ - flip((char *)oraster, ((cwidth + 15) >> 4) * (long)cheight) ; - return(p-pack) ; + flip((char *)oraster, ((cwidth + 15) >> 4) * (long)cheight); + return(p-pack); } diff -Nu dvipsk2009/virtualfont.c dvipsk/virtualfont.c --- dvipsk2009/virtualfont.c Tue Jun 23 18:46:14 2009 +++ dvipsk/virtualfont.c Mon Mar 29 23:32:53 2010 @@ -5,113 +5,97 @@ #include "dvips.h" /* The copyright notice in that file is included too! */ #ifdef KPATHSEA #include +#include #endif /* - * These are the external routines we use. + * The external declarations: */ #include "protos.h" /* - * These are the external variables we use. - */ -#ifdef DEBUG -extern integer debug_flag; -#endif /* DEBUG */ -extern long bytesleft ; -extern quarterword *raster ; -#ifndef KPATHSEA -extern char *vfpath ; -#endif -extern char errbuf[200] ; -extern real conv ; -extern real vconv ; -extern real alpha ; -extern int actualdpi ; -extern int vactualdpi ; -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. */ -static FILE *vffile ; -static char name[50] ; +static FILE *vffile; +static char name[500]; void -badvf(char *s) +badvf(const char *s) { - (void)sprintf(errbuf,"! Bad VF file %s: %s",name,s) ; - error(errbuf); + char *msg = concatn("! Bad VF file ", name, ": ", s, NULL); + error(msg); } shalfword vfbyte(void) { - register shalfword i ; + register shalfword i; if ((i=getc(vffile))==EOF) - badvf("unexpected eof") ; - return(i) ; + badvf("unexpected eof"); + return(i); } integer vfquad(void) { - register integer i ; + register integer i; - i = vfbyte() ; + i = vfbyte(); if (i > 127) - i -= 256 ; - i = i * 256 + vfbyte() ; - i = i * 256 + vfbyte() ; - i = i * 256 + vfbyte() ; - return(i) ; + i -= 256; + i = i * 256 + vfbyte(); + i = i * 256 + vfbyte(); + i = i * 256 + vfbyte(); + return(i); } integer vftrio(void) { - register integer i ; + register integer i; - i = vfbyte() ; - i = i * 256 + vfbyte() ; - i = i * 256 + vfbyte() ; - return(i) ; + i = vfbyte(); + i = i * 256 + vfbyte(); + i = i * 256 + vfbyte(); + return(i); } int vfopen(register fontdesctype *fd) { - register char *n ; + register char *n; #ifndef KPATHSEA - register char *d ; + register char *d; #endif - n = fd->name ; + n = fd->name; #ifndef KPATHSEA - d = fd->area ; + d = fd->area; if (*d==0) - d = vfpath ; + d = vfpath; #endif + if (strlen(n) + 5 >= sizeof (name)) { + /* 5 for vf() + null */ + error("! VF file name too long in vfopen"); + } #ifdef MVSXA /* IBM: MVS/XA */ - (void)sprintf(name, "vf(%s)", n) ; + (void)sprintf(name, "vf(%s)", n); #else - (void)sprintf(name, "%s.vf", n) ; + (void)sprintf(name, "%s.vf", n); #endif #ifdef KPATHSEA if (0 != (vffile=search(vfpath, name, READBIN))) #else if (0 != (vffile=search(d, name, READBIN))) #endif - return(1) ; + return(1); if (!noomega) #ifdef KPATHSEA if (0 != (vffile=search(ovfpath, n, READBIN))) #else if (0 != (vffile=search(d, n, READBIN))) #endif - return(2) ; - return(0) ; + return(2); + return(0); } /* @@ -120,140 +104,167 @@ fontmaptype * vfontdef(integer s, int siz) { - register integer i, j, fn ; - register fontdesctype *fp ; - register fontmaptype *cfnt ; - char *nam, *area ; - integer cksum, scsize, dssize ; + register integer i, j, fn; + register fontdesctype *fp; + register fontmaptype *cfnt; + char *nam, *area; + integer cksum, scsize, dssize; - fn = vfbyte() ; + fn = vfbyte(); while (siz-- > 1) - fn = (fn << 8) + vfbyte() ; - cfnt = (fontmaptype *)mymalloc((integer)sizeof(fontmaptype)) ; - cfnt->fontnum = fn ; - cksum = vfquad() ; - scsize = scalewidth(s, vfquad()) ; - dssize = (integer)(alpha * (real)vfquad()) ; - i = vfbyte() ; j = vfbyte() ; + fn = (fn << 8) + vfbyte(); + cfnt = (fontmaptype *)mymalloc((integer)sizeof(fontmaptype)); + cfnt->fontnum = fn; + cksum = vfquad(); + scsize = scalewidth(s, vfquad()); + dssize = (integer)(alpha * (real)vfquad()); + i = vfbyte(); j = vfbyte(); if (nextstring + i + j > maxstring) - error("! out of string space") ; - area = nextstring ; + error("! out of string space"); + area = nextstring; for (; i>0; i--) - *nextstring++ = vfbyte() ; - *nextstring++ = 0 ; - nam = nextstring ; + *nextstring++ = vfbyte(); + *nextstring++ = 0; + nam = nextstring; for (; j>0; j--) - *nextstring++ = vfbyte() ; - *nextstring++ = 0 ; - fp = matchfont(nam, area, scsize, (char *)0) ; + *nextstring++ = vfbyte(); + *nextstring++ = 0; + fp = matchfont(nam, area, scsize, (char *)0); if (fp) { - nextstring = nam ; - fp->checksum = cksum ; + nextstring = nam; + fp->checksum = cksum; } else { - fp = newfontdesc(cksum, scsize, dssize, nam, area) ; - fp->next = fonthead ; - fonthead = fp ; + fp = newfontdesc(cksum, scsize, dssize, nam, area); + fp->next = fonthead; + fonthead = fp; } - cfnt->desc = fp ; - return (cfnt) ; + cfnt->desc = fp; + return (cfnt); } /* * Now our virtualfont routine. */ + Boolean virtualfont(register fontdesctype *curfnt) { - register integer i ; - register shalfword cmd ; - register integer k ; - register integer length ; - register integer cc ; - register chardesctype *cd ; - integer scaledsize = curfnt->scaledsize ; - integer no_of_chars=256 ; - integer maxcc=255 ; - register quarterword *tempr ; - fontmaptype *fm, *newf ; - int kindfont ; - kindfont = vfopen(curfnt) ; /* 1 for TeX, 2 for Omega */ + register integer i; + register shalfword cmd; + register integer k; + register integer length; + register integer cc; + register chardesctype *cd; + integer scaledsize = curfnt->scaledsize; + integer no_of_chars=256; + integer maxcc=255; + register quarterword *tempr; + fontmaptype *fm, *newf; + int kindfont; + int id; + kindfont = vfopen(curfnt); /* 1 for TeX, 2 for Omega */ if (!kindfont) - return (0) ; + return (0); #ifdef DEBUG if (dd(D_FONTS)) (void)fprintf(stderr,"Loading virtual font %s at %.1fpt\n", - name, (real)scaledsize/(alpha*0x100000)) ; + name, (real)scaledsize/(alpha*0x100000)); #endif /* DEBUG */ /* + * We check if parent is jfm or not + */ + tfmopen(curfnt); + id = tfm16(); + (void)fclose(tfmfile); + +/* * We clear out some pointers: */ if (kindfont==2) { - no_of_chars = 65536; - curfnt->maxchars=65536; + no_of_chars = MAX_CODE; + curfnt->maxchars=MAX_CODE; free(curfnt->chardesc); curfnt->chardesc = (chardesctype *) - mymalloc(65536 * (integer)sizeof(chardesctype)); + mymalloc(MAX_CODE * (integer)sizeof(chardesctype)); } for (i=0; ichardesc[i].TFMwidth = 0 ; - curfnt->chardesc[i].packptr = NULL ; - curfnt->chardesc[i].pixelwidth = 0 ; - curfnt->chardesc[i].flags = 0 ; - curfnt->chardesc[i].flags2 = 0 ; + curfnt->chardesc[i].TFMwidth = 0; + curfnt->chardesc[i].packptr = NULL; + curfnt->chardesc[i].pixelwidth = 0; + curfnt->chardesc[i].flags = 0; + curfnt->chardesc[i].flags2 = 0; } if (vfbyte()!=247) - badvf("expected pre") ; + badvf("expected pre"); if (vfbyte()!=202) - badvf("wrong id byte") ; + badvf("wrong id byte"); for(i=vfbyte(); i>0; i--) - (void)vfbyte() ; - k = vfquad() ; + (void)vfbyte(); + k = vfquad(); check_checksum (k, curfnt->checksum, curfnt->name); - k = (integer)(alpha * (real)vfquad()) ; - if (k > curfnt->designsize + 2 || k < curfnt->designsize - 2) { - (void)sprintf(errbuf,"Design size mismatch in font %s", name) ; - error(errbuf) ; + k = (integer)(alpha * (real)vfquad()); + if ((id != 9 && id != 11) && + (k > curfnt->designsize + 2 || k < curfnt->designsize - 2)) { + char *msg = concat("Design size mismatch in font ", name); + error(msg); + free(msg); } /* * Now we look for font definitions. */ - fm = NULL ; + fm = NULL; while ((cmd=vfbyte())>=243) { if (cmd>246) - badvf("unexpected command in preamble") ; - newf = vfontdef(scaledsize, cmd-242) ; + badvf("unexpected command in preamble"); + newf = vfontdef(scaledsize, cmd-242); if (fm) - fm->next = newf ; - else curfnt->localfonts = newf ; - fm = newf ; - fm->next = NULL ; /* FIFO */ + fm->next = newf; + else curfnt->localfonts = newf; + fm = newf; + fm->next = NULL; /* FIFO */ } /* * Now we get down to the serious business of reading character definitions. */ do { if (cmd==242) { - length = vfquad() + 2 ; - if (length<2) badvf("negative length packet") ; - if (length>65535) badvf("packet too long") ; - cc = vfquad() ; - if (cc<0 || cc>=no_of_chars) badvf("character code out of range") ; - cd = curfnt->chardesc + cc ; - cd->TFMwidth = scalewidth(vfquad(), scaledsize) ; + length = vfquad() + 2; + if (length<2) badvf("negative length packet"); + if (length>65535) badvf("packet too long"); + cc = vfquad(); +#ifdef VFLIB + if (cc>=256) cc = ((cc>>8)-0x21)*94 + (cc&0xff)-0x21; + if (cc==256) { +#else + if (cc == 0x2121) { +#endif + no_of_chars = MAX_CODE; + curfnt->chardesc = (chardesctype *)realloc(curfnt->chardesc, + sizeof(chardesctype)*(MAX_CODE)); + for (i=256; ichardesc[i].TFMwidth = 0; + curfnt->chardesc[i].packptr = NULL; + curfnt->chardesc[i].pixelwidth = 0; + curfnt->chardesc[i].flags = 0; + } + } + else if (cc<0 || cc>=no_of_chars) badvf("character code out of range"); + cd = curfnt->chardesc + cc; + cd->TFMwidth = scalewidth(vfquad(), scaledsize); } else { length = cmd + 2; - cc = vfbyte() ; - cd = curfnt->chardesc + cc ; - cd->TFMwidth = scalewidth(vftrio(), scaledsize) ; + cc = vfbyte(); + cd = curfnt->chardesc + cc; + cd->TFMwidth = scalewidth(vftrio(), scaledsize); } maxcc = (maxccTFMwidth >= 0) - cd->pixelwidth = ((integer)(conv*cd->TFMwidth+0.5)) ; + cd->pixelwidth = ((integer)(conv*cd->TFMwidth+0.5)); else - cd->pixelwidth = -((integer)(conv*-cd->TFMwidth+0.5)) ; - cd->flags = EXISTS ; - cd->flags2 = EXISTS ; + cd->pixelwidth = -((integer)(conv*-cd->TFMwidth+0.5)); + cd->flags = EXISTS; + cd->flags2 = EXISTS; if (bytesleft < length) { #ifdef DEBUG if (dd(D_MEM)) @@ -263,39 +274,39 @@ #else "Allocating new raster memory (%d req, %ld left)\n", #endif - length, bytesleft) ; + length, bytesleft); #endif /* DEBUG */ if (length > MINCHUNK) { - tempr = (quarterword *)mymalloc((integer)length) ; - bytesleft = 0 ; + tempr = (quarterword *)mymalloc((integer)length); + bytesleft = 0; } else { - raster = (quarterword *)mymalloc((integer)RASTERCHUNK) ; - tempr = raster ; - bytesleft = RASTERCHUNK - length ; - raster += length ; + raster = (quarterword *)mymalloc((integer)RASTERCHUNK); + tempr = raster; + bytesleft = RASTERCHUNK - length; + raster += length; } } else { - tempr = raster ; - bytesleft -= length ; - raster += length ; + tempr = raster; + bytesleft -= length; + raster += length; } - cd->packptr = tempr ; - length -= 2 ; - *tempr++ = length / 256 ; - *tempr++ = length % 256 ; + cd->packptr = tempr; + length -= 2; + *tempr++ = length / 256; + *tempr++ = length % 256; for (; length>0; length--) - *tempr++ = vfbyte() ; - cmd = vfbyte() ; - } while (cmd < 243) ; + *tempr++ = vfbyte(); + cmd = vfbyte(); + } while (cmd < 243); if (cmd != 248) - badvf("missing postamble") ; - (void)fclose(vffile) ; - curfnt->loaded = 2 ; + badvf("missing postamble"); + (void)fclose(vffile); + curfnt->loaded = 2; if (maxcc+1chardesc = (chardesctype *) xrealloc(curfnt->chardesc, (maxcc+1) * (integer)sizeof(chardesctype)); curfnt->maxchars=maxcc+1; } - return (1) ; + return (1); } diff -Nu dvipsk2009/writet1.c dvipsk/writet1.c --- dvipsk2009/writet1.c Sat Jul 18 01:08:25 2009 +++ dvipsk/writet1.c Mon Mar 29 22:51:14 2010 @@ -1,6 +1,6 @@ /* -$Id: writet1.c 14299 2009-07-17 16:08:25Z peter $ -Copyright 1996-2005, 2009 Han The Thanh, +$Id: writet1.c 17592 2010-03-28 18:14:06Z karl $ +Copyright 1996-2005, 2009, 2010 Han The Thanh, This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,38 +15,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifdef pdfTeX /* writet1 used with pdfTeX */ -#include "ptexlib.h" -#define t1_log(s) tex_printf(s) -#define t1_open() \ - open_input(&t1_file, kpse_type1_format, FOPEN_RBIN_MODE) -#define enc_open() \ - open_input(&enc_file, kpse_enc_format, FOPEN_RBIN_MODE) -#define external_enc() (fm_cur->encoding)->glyph_names -#define full_file_name() (char*)nameoffile + 1 -#define get_length1() t1_length1 = t1_offset() - t1_save_offset -#define get_length2() t1_length2 = t1_offset() - t1_save_offset -#define get_length3() t1_length3 = t1_offset() - t1_save_offset -#define is_used_char(c) pdfcharmarked(tex_font, c) -#define t1_putchar fb_putchar -#define t1_offset fb_offset -#define out_eexec_char t1_putchar -#define save_offset() t1_save_offset = t1_offset() -#define end_last_eexec_line() \ - t1_eexec_encrypt = false -#define t1_char(c) c -#define embed_all_glyphs(tex_font) fm_cur->all_glyphs -#define extra_charset() fm_cur->charset -#define update_subset_tag() \ - strncpy(fb_array + t1_fontname_offset, fm_cur->subset_tag, 6) - -integer t1_length1, t1_length2, t1_length3; -static integer t1_save_offset; -static integer t1_fontname_offset; -extern char *fb_array; - -#else /* writet1 used with dvips */ #include "dvips.h" +/* + * The external declarations: + */ #include "protos.h" #include "ptexmac.h" #undef fm_extend @@ -85,8 +57,6 @@ #define embed_all_glyphs(tex_font) false #undef pdfmovechars #ifdef SHIFTLOWCHARS -extern char errbuf[]; -extern Boolean shiftlowchars; #define pdfmovechars shiftlowchars #define t1_char(c) T1Char(c) #else /* SHIFTLOWCHARS */ @@ -97,9 +67,7 @@ #define make_subset_tag(a, b) #define update_subset_tag() -static char *dvips_extra_charset ; -extern FILE *bitfile ; -extern FILE *search(); +static char *dvips_extra_charset; static char *cur_file_name; static char *cur_enc_name; static unsigned char *grid; @@ -108,7 +76,6 @@ static int hexline_length; static char notdef[] = ".notdef"; static size_t last_ptr_index; -#endif /* pdfTeX */ #include @@ -271,8 +238,7 @@ #define t1_end_eexec() t1_suffix("mark currentfile closefile") #define t1_cleartomark() t1_prefix("cleartomark") -#ifndef pdfTeX -static void pdftex_fail(char *fmt,...) +static void pdftex_fail(const char *fmt,...) { va_list args; va_start(args, fmt); @@ -287,7 +253,7 @@ exit(-1); } -static void pdftex_warn(char *fmt,...) +static void pdftex_warn(const char *fmt,...) { va_list args; va_start(args, fmt); @@ -313,13 +279,12 @@ static void t1_outhex(byte b) { - static char *hexdigits = "0123456789ABCDEF"; + static const char *hexdigits = "0123456789ABCDEF"; t1_putchar(hexdigits[b/16]); t1_putchar(hexdigits[b%16]); hexline_length += 2; end_hexline(); } -#endif /* pdfTeX */ static void enc_getline(void) @@ -339,7 +304,7 @@ goto restart; } -void load_enc(char *enc_name, char **glyph_names) +void load_enc(char *enc_name, const char **glyph_names) { char buf[ENC_BUF_SIZE], *p, *r; int names_count; @@ -526,7 +491,7 @@ goto exit; while (!t1_eof()) { if (t1_in_eexec == 1) - c = edecrypt(c); + c = edecrypt((byte)c); alloc_array(t1_line, 1, T1_BUF_SIZE); append_char_to_buf(c, t1_line_ptr, t1_line_array, t1_line_limit); if (t1_in_eexec == 0 && eexec_scan >= 0 && eexec_scan < eexec_len) { @@ -546,7 +511,7 @@ cs_start = t1_line_ptr - t1_line_array; /* cs_start is an index now */ alloc_array(t1_line, l, T1_BUF_SIZE); while (l-- > 0) - *t1_line_ptr++ = edecrypt(t1_getbyte()); + *t1_line_ptr++ = edecrypt((byte)t1_getbyte()); } c = t1_getbyte(); } @@ -623,7 +588,7 @@ return; c = t1_getbyte(); if (decrypt) - c = edecrypt(c); + c = edecrypt((byte)c); l = t1_block_length; if (!(l == 0 && (c == 10 || c == 13))) { pdftex_warn("%i bytes more than expected were ignored", l + 1); @@ -642,7 +607,7 @@ if (!t1_pfa) t1_check_block_len(false); for (t1_line_ptr = t1_line_array, i = 0; i < 4; i++) { - edecrypt(t1_getbyte()); + edecrypt((byte)t1_getbyte()); *t1_line_ptr++ = 0; } t1_eexec_encrypt = true; @@ -661,7 +626,7 @@ if (!t1_pfa) t1_check_block_len(true); else { - c = edecrypt(t1_getbyte()); + c = edecrypt((byte)t1_getbyte()); if (!(c == 10 || c == 13)) { if (last_hexbyte == 0) t1_puts("00"); @@ -673,170 +638,6 @@ t1_in_eexec = 2; } -#ifdef pdfTeX -static void t1_modify_fm(void) -{ - /* - * font matrix is given as six numbers a0..a5, which stands for the matrix - * - * a0 a1 0 - * M = a2 a3 0 - * a4 a5 1 - * - * ExtendFont is given as - * - * e 0 0 - * E = 0 1 0 - * 0 0 1 - * - * SlantFont is given as - * - * 1 0 0 - * S = s 1 0 - * 0 0 1 - * - * and the final transformation is - * - * e*a0 e*a1 0 - * F = E.S.M = s*e*a0+a2 s*e*a1+a3 0 - * a4 a5 1 - */ - float e, s, a[6], b[6]; - int i, c; - char *p, *q, *r; - if ((p = strchr(t1_line_array, '[')) == 0) - if ((p = strchr(t1_line_array, '{')) == 0) { - remove_eol(p, t1_line_array); - pdftex_fail("FontMatrix: an array expected: `%s'", t1_line_array); - } - c = *p++; /* save the character '[' resp. '{' */ - strncpy(t1_buf_array, t1_line_array, (unsigned)(p - t1_line_array)); - r = t1_buf_array + (p - t1_line_array); - for (i = 0; i < 6; i++) { - a[i] = t1_scan_num(p, &q); - p = q; - } - if (fm_extend(fm_cur) != 0) - e = fm_extend(fm_cur)*1E-3; - else - e = 1; - s = fm_slant(fm_cur)*1E-3; - b[0] = e*a[0]; - b[1] = e*a[1]; - b[2] = s*e*a[0] + a[2]; - b[3] = s*e*a[1] + a[3]; - b[4] = a[4]; - b[5] = a[5]; - for (i = 0; i < 6; i++) { - sprintf(r, "%g ", b[i]); - r = strend(r); - } - if (c == '[') { - while (*p != ']' && *p != 0) - p++; - } - else { - while (*p != '}' && *p != 0) - p++; - } - if (*p == 0) { - remove_eol(p, t1_line_array); - pdftex_fail("FontMatrix: cannot find the corresponding character to '%c': `%s'", c, t1_line_array); - } - strcpy(r, p); - strcpy(t1_line_array, t1_buf_array); - t1_line_ptr = eol(t1_line_array); -} - -static void t1_modify_italic(void) -{ - float a; - char *p, *r; - if (fm_slant(fm_cur) == 0) - return; - p = strchr(t1_line_array, ' '); - strncpy(t1_buf_array, t1_line_array, (unsigned)(p - t1_line_array + 1)); - a = t1_scan_num(p + 1, &r); - a -= atan(fm_slant(fm_cur)*1E-3)*(180/M_PI); - sprintf(t1_buf_array + (p - t1_line_array + 1), "%g", a); - strcpy(strend(t1_buf_array), r); - strcpy(t1_line_array, t1_buf_array); - t1_line_ptr = eol(t1_line_array); - font_keys[ITALIC_ANGLE_CODE].value = round(a); - font_keys[ITALIC_ANGLE_CODE].valid = true; -} - -static void t1_scan_keys(void) -{ - int i, k; - char *p, *q, *r; - key_entry *key; - if (fm_extend(fm_cur) != 0 || fm_slant(fm_cur) != 0) { - if (t1_prefix("/FontMatrix")) { - t1_modify_fm(); - return; - } - if (t1_prefix("/ItalicAngle")) { - t1_modify_italic(); - return; - } - } - if (t1_prefix("/FontType")) { - p = t1_line_array + strlen("FontType") + 1; - if ((i = t1_scan_num(p, 0)) != 1) - pdftex_fail("Type%d fonts unsupported by pdfTeX", i); - return; - } - for (key = font_keys; key - font_keys < MAX_KEY_CODE; key++) - if (strncmp(t1_line_array + 1, key->t1name, strlen(key->t1name)) == 0) - break; - if (key - font_keys == MAX_KEY_CODE) - return; - key->valid = true; - p = t1_line_array + strlen(key->t1name) + 1; - skip(p, ' '); - if ((k = key - font_keys) == FONTNAME_CODE) { - if (*p != '/') { - remove_eol(p, t1_line_array); - pdftex_fail("a name expected: `%s'", t1_line_array); - } - r = ++p; /* skip the slash */ - for (q = t1_buf_array; *p != ' ' && *p != 10; *q++ = *p++); - *q = 0; - if (fm_slant(fm_cur) != 0) { - sprintf(q, "-Slant_%i", (int)fm_slant(fm_cur)); - q = strend(q); - } - if (fm_extend(fm_cur) != 0) { - sprintf(q, "-Extend_%i", (int)fm_extend(fm_cur)); - } - strncpy(fontname_buf, t1_buf_array, FONTNAME_BUF_SIZE); - /* at this moment we cannot call make_subset_tag() yet, as the encoding - * is not read; thus we mark the offset of the subset tag and write it - * later */ - if (is_included(fm_cur) && is_subsetted(fm_cur)) { - t1_fontname_offset = t1_offset() + (r - t1_line_array); - strcpy(t1_buf_array, p); - sprintf(r, "ABCDEF+%s%s", fontname_buf, t1_buf_array); - t1_line_ptr = eol(r); - } - return; - } - if ((k == STEMV_CODE || k == FONTBBOX1_CODE) && - (*p == '[' || *p == '{')) - p++; - if (k == FONTBBOX1_CODE) { - for (i = 0; i < 4; i++) { - key[i].value = t1_scan_num(p, &r); - p = r; - } - return; - } - key->value = t1_scan_num(p, 0); -} - -#endif /* pdfTeX */ - static void t1_scan_param(void) { static const char *lenIV = "/lenIV"; @@ -988,7 +789,8 @@ } } -static void t1_check_end(void) +static void +t1_check_end(void) { if (t1_eof()) return; @@ -997,75 +799,16 @@ t1_putline(); } -#ifdef pdfTeX -static boolean t1_open_fontfile(const char *open_name_prefix) -{ - char *ex_ffname = NULL; - ff_entry *ff; - ff = check_ff_exist(fm_cur); - if (ff->ff_path != NULL) - t1_file = xfopen(cur_file_name = ff->ff_path, FOPEN_RBIN_MODE); - else { - set_cur_file_name(fm_cur->ff_name); - pdftex_warn("cannot open Type 1 font file for reading"); - return false; - } - t1_init_params(open_name_prefix); - fontfile_found = true; - return true; -} - -static void t1_scan_only(void) -{ - do { - t1_getline(); - t1_scan_param(); - } while (t1_in_eexec == 0); - t1_start_eexec(); - do { - t1_getline(); - t1_scan_param(); - } while (!(t1_charstrings() || t1_subrs())); -} - -static void t1_include(void) -{ - do { - t1_getline(); - t1_scan_param(); - t1_putline(); - } while (t1_in_eexec == 0); - t1_start_eexec(); - do { - t1_getline(); - t1_scan_param(); - t1_putline(); - } while (!(t1_charstrings() || t1_subrs())); - t1_cs = true; - do { - t1_getline(); - t1_putline(); - } while (!t1_end_eexec()); - t1_stop_eexec(); - do { - t1_getline(); - t1_putline(); - } while (!t1_cleartomark()); - t1_check_end(); /* write "{restore}if" if found */ - get_length3(); -} - -#else /* not pdfTeX */ -static boolean t1_open_fontfile(char *open_name_prefix) +static boolean +t1_open_fontfile(const char *open_name_prefix) { if (!t1_open()) { - (void)sprintf(errbuf, "! Couldn't find font file %s", cur_file_name); - error(errbuf); + char *msg = concat ("! Couldn't find font file ", cur_file_name); + error(msg); } t1_init_params(open_name_prefix); return true; } -#endif /* pdfTeX */ #define check_subr(subr) \ if (subr >= subr_size || subr < 0) \ @@ -1230,7 +973,7 @@ assert(ptr != NULL && ptr->valid && ptr->used); /* decrypt the cs data to t1_buf_array, append CS_RETURN */ - p = t1_buf_array; + p = (byte *) t1_buf_array; data = ptr->data + 4; cr = 4330; for (i = 0; i < ptr->cslen; i++) @@ -1241,7 +984,7 @@ new_data = xtalloc(ptr->len + 1, byte); memcpy(new_data, ptr->data, 4); p = new_data + 4; - q = t1_buf_array; + q = (byte *) t1_buf_array; cr = 4330; for (i = 0; i < ptr->cslen + 1; i++) *p++ = cencrypt(*q++, &cr); @@ -1733,16 +1476,6 @@ void writet1(void) { read_encoding_only = false; -#ifdef pdfTeX - t1_save_offset = 0; - if (strcasecmp(strend(fm_fontfile(fm_cur)) - 4, ".otf") == 0) { - if (!is_included(fm_cur) || is_subsetted(fm_cur)) - pdftex_fail("OTF fonts must be included entirely"); - writeotf(); - is_otf_font = true; - return; - } -#endif if (!is_included(fm_cur)) { /* scan parameters from font file */ if (!t1_open_fontfile("{")) return; @@ -1776,7 +1509,6 @@ xfree(t1_buf_array); } -#ifndef pdfTeX boolean t1_subset(char *fontfile, char *encfile, unsigned char *g) { int i; @@ -1784,7 +1516,7 @@ for (i = 0; i <= MAX_CHAR_CODE; i++) ext_glyph_names[i] = (char*) notdef; if (cur_enc_name != NULL) - load_enc(cur_enc_name, ext_glyph_names); + load_enc(cur_enc_name, (const char **) ext_glyph_names); grid = g; cur_file_name = fontfile; hexline_length = 0; @@ -1792,7 +1524,7 @@ for (i = 0; i <= MAX_CHAR_CODE; i++) if (ext_glyph_names[i] != notdef) free(ext_glyph_names[i]); - return 1 ; /* note: there *is* no unsuccessful return */ + return 1; /* note: there *is* no unsuccessful return */ } boolean t1_subset_2(char *fontfile, unsigned char *g, char *extraGlyphs) @@ -1803,11 +1535,10 @@ grid = g; cur_file_name = fontfile; hexline_length = 0; - dvips_extra_charset = extraGlyphs ; + dvips_extra_charset = extraGlyphs; writet1(); for (i = 0; i <= MAX_CHAR_CODE; i++) if (ext_glyph_names[i] != notdef) free(ext_glyph_names[i]); - return 1 ; /* note: there *is* no unsuccessful return */ + return 1; /* note: there *is* no unsuccessful return */ } -#endif /* not pdfTeX */ ChangeLog.jpatch100666 0 0 10112 11365332230 12700 0ustar kakutogroupdvipsk-jpatch 変更履歴 株式会社アスキー・メディアワークス p1.0 -> p1.1 ・根号を連続して使用したときに文字位置がおかしい、というバグに対し て東京大学の竹内敬亮さんがパッチ作成、そのパッチを差分内容に反映。 ・\shortstackを使って和文+英文1文字としてから改行すると文字位置が おかしくなる、というバグに対する修正。 p1.1 -> p1.1a ・和文フォント用AFMに関するドキュメントの記述の変更のみ。 p1.1a -> p1.2 ・近畿大学の角藤亮さんのご協力により、生成されるPSファイルのサイズを 縮小化。 ・-EオプションによりEPSファイルを生成するとBoundingBoxおよぴ日本語 部分がおかしくなるバグを修正。 p1.3 ・近畿大学の角藤亮さん、神戸大学の内山孝憲さんの御協力により、 dvipsk-5.66aに対応。 p1.3 -> p1.3a ・解像度、フォント、文字の並びの組合せによっては和文の並びがずれる ことがあるので和文の位置がより正確になるように修正。 ・RKSJエンコーディング和文フォント(1バイト部分)に対応。 p1.3a -> p1.3b ・Shift-JISエンコード出力に対応。 p1.4 ・近畿大学の角藤亮さんの御協力により、dvipsk-5.78に対応。 ・岡山大学の篭谷さんの御協力により、dvi2ps-j 用の epsf.sty と jdvi2kps 用の epsbox.sty が生成する \special に対応。 p1.4 -> p1.4a ・縦組み時の \special の処理がおかしい。 - EPSを読み込むと横方向のまま表示される - 拡大/縮小の縦横の方向が逆になる これらのバグを修正。 ・縦組み時のBoundingBoxの取り方がおかしいので修正。 ・和文VFの作成に関する説明を変更。 p1.4a -> p1.4b ・縦横切り替え時の欧文出力がおかしいので修正。 p1.4b -> p1.4c ・\pagestyle{empty}の縦書き文書でページが変わったときの文字方向がおかしいので 修正。 p1.4c -> p1.4d ・tpicにより作成された図が丸め誤差の蓄積によりずれてしまうことがある。 東京理科大学の松田一朗さんのご協力により修正。 ・HyperTeX の hyper.sty 使用時に、fixhyperbox のオプションを指定すると dvips が落ちる。慶応義塾大学の内山孝憲さんのご協力により修正。 ・出力ファイル名が正しくならない場合がある。近畿大学の角藤亮さん、松阪大学の 奥村晴彦さんのご協力により修正。 ・元プログラムである dvipsk がGPL(GNU General Public License)に従っているため、 本パッチも配布条件をGPLに従うように変更。 ・pstricksの\pstextpath中で日本語を使用するとPSエラーが出る。東京理科大学の 松田一朗さんによる対処方法を PSTricks.patch に記載。 ・漢字コードの範囲を94区94点から120区94点に拡張。 p1.5 ・近畿大学の角藤亮さんのご協力により、dvipsk-5.86に対応。 p1.5 -> p1.5a ・Omegaモードでのコンパイルができるように修正。 ・各種設定ファイルがインストールされるように Makefile を修正。 ・インストール方法を変更。 p1.5a -> p1.5b ・Makefile.in の記述にミスがあったので修正。 (Makefile.in の1行目の行頭に # を追加のみ) p1.5b -> p1.5c ・type1フォントを使用した場合に英字のずれが起こる場合がある。 近畿大学の角藤亮さん、慶応義塾大学の内山孝憲さん、松阪大学の奥村晴彦さんの ご協力により修正。 ・-z オプションを付けた場合にPSファイル中の改行がおかしくなる。 近畿大学の角藤亮さんのご協力により修正。 p1.5c -> p1.5d ・type1フォントの読み込みに失敗することがある。 ・\raisebox{}〜<和文>〜\raisebox{}〜と並べた場合、 後の\raiseboxが効かなくなる場合がある。 上記2つを近畿大学の角藤亮さんのご協力により修正。 p1.5d -> p1.5e ・各ページ末尾に余計なrotateが入っていたので、入らないように修正。 ・欧文フォントの出力位置のずれを、東京大学の鈴木秀幸さんのご協力により修正。 p1.5e -> p1.5f ・config.ps中の用紙サイズ b4, b5 の設定を修正。 p1.5f -> p1.5g ・縦書き時にtpicコマンドによる図が正しく描画されない不具合を修正。 ・近畿大学の角藤亮さんのご協力により、PSTricks.patch に FMapType が9の場合の 処理を追加。 p1.6 ・近畿大学の角藤亮さんのご協力により、dvipsk-5.92bに対応。 p1.6 -> p1.6a ・make install で config.ps, psfonts.map がインストールされるように Makefile を修正。 ・dvi2ps用のマクロでEPSファイルを読み込んだ場合にMac用改行コードが正しく 認識されない不具合を修正。 p1.6a -> p1.6a1 ・$TEXMF/dvips/base/config.ps が作られないように Makefile を修正。 p1.7 ・近畿大学の角藤亮さんのご協力により、dvipsk-5.95aに対応。 ・デフォルトでUnicodeへ対応。 p1.7 -> p1.7a ・近畿大学の角藤亮さんのご協力により、和文フォントのデフォルト文字幅を修正。 p1.7a -> p1.7b ・TANAKA Takujiさんのご協力により、斜体和文フォントのイタリック補正値計算を修正。 ・縦書き/横書き混在時に欧文の単語間や文字間の空きがおかしくなる症状を修正。 README.jpatch100666 0 0 21012 11365331034 12010 0ustar kakutogroupdvipsk-jpatch-p1.7b について 株式会社アスキー・メディアワークス www-ptex@ascii.co.jp dvipsk-5.95a (teTeX-3.0に含まれる) に対するアスキー日本語TeX(pTeX)対応 パッチです。 このパッチにより、dvipsk-5.95a が ・JFM(日本語用TFM)対応 ・縦書き対応 となり、アスキー日本語TeX(pTeX)に対応します。 基本的な使用方法は英語版と同じです。dvipsk 5.95a のマニュアルを参照して 下さい。 なお、このパッチファイルは以下の事項を確認の上、ご利用ください。 1. 本プログラムの日本語化部分に関しては株式会社アスキー・メディアワークス に著作権があります。 2. 本プログラムの配布、改変条件等はGPL(GNU General Public License)に 従います。 3. 本プログラムの使用または、使用不能から生ずるいかなる損害に関しても、 株式会社アスキー・メディアワークスは、一切責任を負わないものとします。 -------------------------------------------------- ● 必要なファイル -------------------------------------------------- このパッチを使用するにはこのアーカイブの他に、つぎのファイルが必要 です。別途、入手してください。 teTeXアーカイブ ・tetex-src-3.0.tar.gz ・tetex-texmf-3.0.tar.gz (CTANサイト /systems/unix/teTeX/currnet/distrib にあります) pTeXアーカイブ ・ptex-src-3.1.8.1.tar.gz ・ptex-texmf-2.3.tar.gz (ftp://ftp.ascii.co.jp/pub/TeX/ascii-ptex/tetex にあります) 日本語VFファイル ・makejvf-1.1a.tar.gz または standard.tar.gz (ftp://ftp.ascii.co.jp/pub/TeX/ascii-ptex/jvf にあります) ※ 日本国内のCTANサイトは、以下の場所があります。 ftp://ftp.ring.gr.jp/pub/text/CTAN ftp://ftp.iij.ad.jp/pub/TeX/CTAN ftp://ftp.riken.go.jp/pub/CTAN ftp://ftp.u-aizu.ac.jp/pub/tex/CTAN -------------------------------------------------- ● インストール -------------------------------------------------- パッチを当てる手順は以下の通りです。 1. tetex-src-3.0.tar.gz を展開します。 また、あらかじめ tetex-texmf-3.0.tar.gz をTeXライブラリを置く場所 (デフォルト:/usr/local/teTeX/share/texmf-dist)へ展開しておきます。 和文フォントファイル等のインストールのため、teTeX-3.0 に対応した pTeXのパッチを当てておいてください。 2. この README.jpatch ファイルと同時に展開される dvipsk-p1.7b.patch を tetex-src-3.0/texkに置きます。 3. tetex-src-3.0/texk ディレクトリで以下のコマンドを実行し、 dvipsk にパッチを当てます。 patch -p0 < dvipsk-p1.7b.patch 4. tetex-src-3.0 ディレクトリで ./configure を実行します。 ※インストール先を指定する場合は、configure のオプションとして --prefix=<インストール先> を指定する必要があります。指定しなければ実行ファイルは /usr/local/teTeX/bin/ 以下にインストールされ、 TeX関連ライブラリは /usr/local/teTeX/share/texmf* 以下が参照されます。 ./configure --prefix=/usr/local のように指定すると、実行ファイルは /usr/local/bin/、 TeX関連ライブラリは /usr/local/share/texmf* になります。 実行ファイルを /usr/local/bin の直下に置きたい場合は ./configure --prefix=/usr/local --disable-multiplatform のようにオプションを指定します。 5. tetex-src-3.0/texk/dvipsk ディレクトリに移動してから make ; make install を実行します。 6. PSTricksマクロパッケージを使用している場合は、PSTricks.patch の冒頭に 記載の方法でPSTricksヘッダファイルを修正してください。 PSTricksを使用しない場合はこの修正は不要です。 -------------------------------------------------- ● 和文フォントのインストール -------------------------------------------------- dvipsで日本語を扱う場合、書体毎にファイルが必要となります。 新たに日本語フォントを追加するときの手順を以下に示します。 1. makejvf-1.1a.tar.gz または standard.tar.gz を展開する 2. makejvf で日本語VFファイルを作る(standard.tar.gz を使用する場合は 不要) 詳細は、makejvf のドキュメントを参照してください。 3. 作成したVFファイルをフォントディレクトリに移動する $TEXMF/fonts の下の適当な場所に置きます。 注意:======================================================= | kpathseach がVFファイルを見つけることができるように、 | $TEXMF/web2c/texmf.cnf を修正する必要があるかもしれません。 | VFFONTS の設定箇所を確認してください。 |============================================================ 5. フォントマップファイルに登録する $TEXMF/fonts/map/dvips/ptex/psfonts_jp.map ファイルにフォントの 設定を記述します。たとえば、この日本語パッチでは、次のような設定を しています。 rml Ryumin-Light-H rmlv Ryumin-Light-V gbm GothicBBB-Medium-H gbmv GothicBBB-Medium-V 左側にはVFで置き換えたTFMの名前を、右側には出力するデバイスが持って いるPSフォント名を指定します。 注意:======================================================= | プリンタによっては Ryumin-Light-H、GothicBBB-Medium-H といっ | たフォント名ではうまく出力できないものがあるようです | この場合は Ryumin-Light-Ext-H、GothicBBB-Medium-Ext-H 等の | フォント名、または後述の Shift-JIS コードフォントで使用して | みてください(-V のフォント名も同様)。 |============================================================ 以上です。 dvipsk が出力した PS ファイルをプリンタやプレビューアに表示するには、 そのデバイスで Ryumin-Light-H や GothicBBB-Medium-H などのPSフォント を使用できる必要があります。cmr10 などの欧文フォントに関しては、PK形式 のグリフを展開してビットマップとしてPSファイルに埋め込むこともできます ので、この限りではありません。 -------------------------------------------------- ● Shift-JISコードフォントでの出力方法 -------------------------------------------------- 和文の漢字コードとしてJISコードまたはShift-JISコードが選択できます。 ただし、両者を混在させることはできませんのでご注意ください。 1. フォントマップファイルのフォント名を書き換える $TEXMF/fonts/map/dvips/ptex/psfonts_jp.map ファイルの和文フォント名 をShift-JISエンコーディングのものに書き換えます。 rml Ryumin-Light-RKSJ-H rmlv Ryumin-Light-RKSJ-V gbm GothicBBB-Medium-RKSJ-H gbmv GothicBBB-Medium-RKSJ-V Shift-JISコードのフォントは名前に'RKSJ'が付いてます。 2. config.ps に漢字コードの指定を追加する $TEXMF/dvips/config/config.ps ファイルに次の1行を追加します。 SJIS これで和文がShift-JISコードで出力されるようになります。 なお dvips の実行時のオプションに `-SJIS' を付加すれば強制的に Shift-JIS コードに、'-SJIS0' を付加すれば強制的に JIS コードになります。ただし PS フォントは psfonts_jp.map で指定されたものがそのまま使用されます。 -------------------------------------------------- ● dvipsk-jpatch の問題点について -------------------------------------------------- 現在、dvipsk-jpatchには次のような問題点があります。 ・-X や -Y オプションで縦横の解像度が異なった場合、線の太さや回転させた 文字の縦横比/回転角度がおかしくなる この問題は特に縦書き時に問題となります。縦書き文章中に欧文書体を使用した 場合、欧文は90度の回転文字として扱われます。このとき、欧文の縦横の比率が おかしくなってしまいます。また、横書き時でもgraphicsパッケージ等の 回転マクロや図形描画マクロを使用している場合は回転角度や文字の形、線の 太さに歪みが生じます。 このため、-X や -Y による解像度指定はできるだけ行わないようにしてください。 -------------------------------------------------- ● Unicodeへの対応について -------------------------------------------------- dvipsk-jpatch のバージョンp1.7以降では、デフォルトでUnicodeへの対応がなさ れています。従ってotfパッケージ、utfパッケージなどにおけるUnicodeやCIDを そのまま扱うことができます。また、オリジナルの dvipsk-5.95a に従って、 "odvips" の機能も含んでいますから、dvips だけでOmega, Alephの出力DVIを 処理することができます。なお、以前との互換性のため、 odvips は dvips へ のシンボリックリンクとしてインストールされるようになっています。 Unicode 対応は、稲垣淳さんによるumsパッケージを仮想フォント経由で使う 場合に使用することを想定しています。この場合、Unicodeの範囲にある広範な 文字種を扱うことが可能になります。また、齋藤修三郎さんによる、utf/otf パッケージの出力DVIをPSに変換する場合にも使用でき、255 以下のコードを 和文フォントとしてアクセスすることもできるようになっています(umsおよび utf/otfパッケージを使った場合の出力DVIに限る)。 Unicodeの出力PSは、そのまま PostScript プリンタに出力しても、おそらく 印刷することはできません。CID フォントに対応した Ghostscript で処理したり (ps2pdf でPDF変換することを含む)、Acrobat Distiller でPDF変換したりした 上で印刷することができます。 なお、Unicodeを使用する場合は`-SJIS'オプションは使用できません。 Unicode 対応関連の情報については、 奥村晴彦さんによるTeX Wiki http://oku.edu.mie-u.ac.jp/~okumura/texwiki/ 等のTeX関連サイトでお調べください。