commit 925b2beb95713956c05529dbfeefd612b013d560
parent 0270e714d909d62250cab1c8bf29da7457d3f01c
Author: Kyle Milz <krwmilz@gmail.com>
Date: Fri, 20 Aug 2021 22:38:41 +0000
Remove PS support
Diffstat:
M | dvi-draw.c | | | 31 | +------------------------------ |
M | events.c | | | 60 | ------------------------------------------------------------ |
M | font-open.c | | | 15 | +++++++-------- |
M | popups.c | | | 5 | ----- |
D | psheader.txt | | | 297 | ------------------------------------------------------------------------------- |
M | special.c | | | 647 | +------------------------------------------------------------------------------ |
M | util.c | | | 82 | ++----------------------------------------------------------------------------- |
M | xdvi.c | | | 21 | --------------------- |
M | xdvi.h | | | 53 | ++++------------------------------------------------- |
9 files changed, 15 insertions(+), 1196 deletions(-)
diff --git a/dvi-draw.c b/dvi-draw.c
@@ -842,20 +842,9 @@ prescan()
}
if (read_events(EV_NOWAIT) & EV_GE_NEWPAGE) break;
-#if PS
- /* NOTE: longjmp(canit_env) should not be done within
- read_events(). */
- if (!setjmp(canit_env))
- spcl_scan(scan_special);
- else { /* if interrupted */
- psp.interrupt();
- break;
- }
- if (ev_flags & EV_GE_NEWPAGE) break;
-#else
+
/* No calls to read_events() occur in this case. */
spcl_scan(scan_special);
-#endif
++scanned_page;
#if COLOR
@@ -864,10 +853,6 @@ prescan()
scanned_page_color = scanned_page;
}
#endif
-#if PS
- if (scanned_page_ps < scanned_page)
- scanned_page_ps = scanned_page;
-#endif
if (scanned_page >= current_page) break;
}
@@ -877,10 +862,6 @@ prescan()
else if (pr.timer_active)
cancel_timer(&pst);
-#if PS
- if (!(ev_flags & EV_GE_NEWPAGE))
- psp.endheader();
-#endif
}
/*
@@ -1525,9 +1506,6 @@ draw_page()
expose(currwin.win == mane.win ? &mane : &alt,
min_x - currwin.base_x, min_y - currwin.base_y,
max_x - min_x, max_y - min_y);
-#if PS
- psp.interrupt();
-#endif
ev_flags &= ~EV_MAG_GONE;
}
@@ -1535,9 +1513,6 @@ draw_page()
dvi_pointer_frame = NULL;
if (currwin.win == mane.win && source_fwd_box_page >= 0)
source_fwd_draw_box(); /* draw box showing found source line */
-#if PS
- psp.endpage();
-#endif
currwin.win = (Window) 0;
}
@@ -2010,10 +1985,6 @@ geom_scan(g_info)
struct drawinf currinf_save;
ubyte maxchar_save;
-#if PS
- if (scanned_page < current_page) return; /* should not happen */
-#endif
-
if (dvi_pointer_frame != NULL)
pos_save = fseek(dvi_file, 0L, SEEK_CUR)
- (dvi_pointer_frame->end - dvi_pointer_frame->pos);
diff --git a/events.c b/events.c
@@ -142,9 +142,6 @@ static ACTION_DECL(Act_set_greyscaling);
#if COLOR
static ACTION_DECL(Act_set_color);
#endif
-#if PS
-static ACTION_DECL(Act_set_ps);
-#endif
#if BUTTONS
static ACTION_DECL(Act_set_expert_mode);
#endif
@@ -193,9 +190,6 @@ XtActionsRec Actions[] = {
#if COLOR
{"set-color", Act_set_color},
#endif
-#if PS
- {"set-ps", Act_set_ps},
-#endif
#if BUTTONS
{"set-expert-mode", Act_set_expert_mode},
#endif
@@ -374,7 +368,6 @@ struct button_info {
static struct button_info *b_head;
const char default_button_config[] =
-#if PS
"Quit:quit()\n\
Open:open-dvi-file()\n\n\
Full size:set-shrink-factor(1)\n\
@@ -387,23 +380,7 @@ Prev:back-page(1)\n\n\
Next:forward-page(1)\n\
Page+5:forward-page(5)\n\
Page+10:forward-page(10)\n\n\
-View PS:set-ps(toggle)\n\
Print:print()";
-#else
- "Quit:quit()\n\
-Open:open-dvi-file()\n\n\
-Full size:set-shrink-factor(1)\n\
-$%%:shrink-to-dpi(150)\n\
-$%%:shrink-to-dpi(100)\n\
-$%%:shrink-to-dpi(75)\n\n\
-Page-10:back-page(10)\n\
-Page-5:back-page(5)\n\
-Prev:back-page(1)\n\n\
-Next:forward-page(1)\n\
-Page+5:forward-page(5)\n\
-Page+10:forward-page(10)\n\n\
-Print:print()";
-#endif
void
create_buttons()
@@ -2115,10 +2092,6 @@ ACTION(Act_set_color)
use_color = False;
full_reset_colors();
scanned_page_color = total_pages;
-#if PS
- if (ignore_papersize_specials || scanned_page_ps <= total_pages)
- scanned_page = scanned_page_ps;
-#endif
}
else {
use_color = True;
@@ -2129,36 +2102,6 @@ ACTION(Act_set_color)
#endif /* COLOR */
-#if PS
-
-static
-ACTION(Act_set_ps)
-{
- TOGGLE(resource._postscript)
-
- if (resource._postscript) {
- resource._postscript = False;
- scanned_page_ps_bak = scanned_page_ps;
- scanned_page_ps = total_pages;
-#if COLOR
- if (ignore_papersize_specials || scanned_page_color <= total_pages)
- scanned_page = scanned_page_color;
-#endif
- }
- else {
- resource._postscript = True;
- scanned_page_ps = scanned_page_ps_bak;
- if (scanned_page > scanned_page_ps)
- scanned_page = scanned_page_ps;
- }
-
- psp.toggle();
- ev_flags |= EV_PS_TOGGLE;
- XFlush(DISP);
-}
-
-#endif /* PS */
-
#if BUTTONS
static
@@ -2210,9 +2153,6 @@ ACTION(Act_set_expert_mode)
static
ACTION(Act_reread_dvi_file)
{
-#if PS
- ps_clear_cache();
-#endif
if (dvi_file != NULL) {
Fclose(dvi_file);
dvi_file = NULL;
diff --git a/font-open.c b/font-open.c
@@ -165,7 +165,7 @@ static double magsteps[10] = {1.0, 1.2, 1.44, 1.728, 2.0736,
2.48832, 2.985984, 3.5831808,
4.29981696, 5.159780352};
-#if FREETYPE || PS
+#if FREETYPE
/*
* Information on how to search for dvips configuration files.
@@ -307,7 +307,7 @@ static struct findrec search_type1 = {
}
};
-#endif /* FREETYPE || PS */
+#endif /* FREETYPE */
static int
@@ -359,7 +359,7 @@ get_sizes(size_list, spp)
}
-#if FREETYPE || PS
+#if FREETYPE
/*
* The following code handles lookup of Type 1 fonts for use as FreeType
@@ -1530,7 +1530,7 @@ read_encoding(encp)
++n_files_left;
}
-#endif /* FREETYPE || PS */
+#endif /* FREETYPE */
void
@@ -1540,7 +1540,7 @@ init_font_open()
int *sp, *sp1;
unsigned int n;
char *p;
-#if FREETYPE || PS
+#if FREETYPE
FILE *f;
const char *dvipsrc;
#endif
@@ -1659,7 +1659,7 @@ init_font_open()
n = *sp1++ = *sp;
sizend = sp1;
-#if FREETYPE || PS
+#if FREETYPE
/*
* Initialize reading of Type 1 fonts and map files
* (PS uses T1 fonts for MetaPost figures).
@@ -1745,7 +1745,7 @@ init_font_open()
Fprintf(stderr, "Cannot open map file %s\n", p_head->value);
p_head = p_head->next;
}
-#endif /* FREETYPE || PS */
+#endif /* FREETYPE */
}
/*
@@ -2285,7 +2285,6 @@ PRE_FONT_OPEN(fontp, fontname, fdpi, magstepval, name_ret, dpi_ret)
if (resource.freetype) {
struct avl_t1 *t1p = lookup_t1_font(fontp);
- const char *path;
if (t1p != NULL) { /* if font found */
if (debug & DBG_OPEN)
diff --git a/popups.c b/popups.c
@@ -2807,11 +2807,6 @@ print_do_it()
if (q != NULL) {
struct dvips_env *dep;
-#if PS
- /* grab copies of environment variables before we change them */
- ps_init_paths();
-#endif
-
if (dvips_envs[0].envname == NULL) {
for (dep = dvips_envs; dep < dvips_envs + XtNumber(dvips_envs);
++dep) {
diff --git a/psheader.txt b/psheader.txt
@@ -1,297 +0,0 @@
-%% These are from tex.lpro
-/TeXDict 250 dict def % define a working dictionary ( IBM: color - 200->250 )
-TeXDict begin % start using it.
-/N {def} def
-/B {bind def} N
-/S {exch} N
-/X { S N } B
-/TR {translate} N
-/vsize 11 72 mul N
-end % TeXDict
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% header for the \special command
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% The structure of the PostScript produced by dvips for \special is:
-% @beginspecial
-% - any number of @hsize, @hoffset, @hscale, etc., commands
-% @setspecial
-% - the user's file of PostScript commands
-% @endspecial
-
-TeXDict begin
-/SDict 200 dict N
-SDict begin
-
-/@SpecialDefaults
- { /hs 612 N
- /vs 792 N
- /ho 0 N
- /vo 0 N
- /hsc 1 N
- /vsc 1 N
- /ang 0 N
- /CLIP 0 N
- /rwiSeen false N
- /rhiSeen false N
- /letter {} N /note {} N /a4 {} N /legal {} N
- } B
-
-%
-% The following definition sets up the units that hscale/vscale are in.
-% For certain sites this might require change, but it is
-% recommended instead that any macro packages that require
-% hscale/vscale set the units appropriately via
-%
-% \special{! /@scaleunit 1 def }
-%
-% if global, or
-%
-% \special{" /@scaleunit 1 def }
-%
-% before each instance if multiple macro packages with
-% different requirements are being used.
-%
-/@scaleunit 100 N
-% s @hscale - set scale factor
-/@hscale {@scaleunit div /hsc X} B
-/@vscale {@scaleunit div /vsc X} B
-
-% d @hsize - specify a horizontal clipping dimension
-/@hsize {/hs X /CLIP 1 N} B
-/@vsize {/vs X /CLIP 1 N} B
-
-/@clip {/CLIP 2 N} B
-
-% d @hoffset - specify a shift for the figure
-/@hoffset {/ho X} B
-/@voffset {/vo X} B
-
-% a @angle - set rotation angle
-/@angle {/ang X} B
-
-%
-% Here we handle bounding box calculations, if necessary.
-%
-/@rwi { 10 div /rwi X /rwiSeen true N } B % rwi will be real width after scaling
-/@rhi { 10 div /rhi X /rhiSeen true N } B % rhi will be real height after scaling
-/@llx { /llx X } B
-/@lly { /lly X } B
-/@urx { /urx X } B
-/@ury { /ury X } B
-
-/magscale true def
-
-end % of SDict
-
-/@MacSetUp
- { userdict /md known % if md is defined
- { userdict /md get type /dicttype eq % and if it is a dictionary
- {
- userdict begin % expand it if necessary
- md length 10 add md maxlength ge
- {/md md dup length 20 add dict copy def}if
- end
- md begin % then redefine some stuff
- /letter {} N
- /note {} N
- /legal {} N
- /od{txpose
- 1 0 mtx defaultmatrix dtransform S atan/pa X
- newpath clippath mark
- {transform{itransform moveto}}
- {transform{itransform lineto}}
- { 6 -2 roll transform
- 6 -2 roll transform
- 6 -2 roll transform
- { itransform 6 2 roll
- itransform 6 2 roll
- itransform 6 2 roll
- curveto
- }
- }
- {{closepath}}
- pathforall newpath counttomark array astore /gc xdf
- pop ct 39 0 put
- 10 fz 0 fs 2 F/|______Courier fnt invertflag{PaintBlack}if
- }N
- /txpose{
- pxs pys scale ppr aload pop
- por {
- noflips {
- pop S neg S TR pop 1 -1 scale
- }if
- xflip yflip and {
- pop S neg S TR 180 rotate 1 -1 scale
- ppr 3 get ppr 1 get neg sub neg ppr 2 get
- ppr 0 get neg sub neg TR
- }if
- xflip yflip not and {
- pop S neg S TR pop 180 rotate
- ppr 3 get ppr 1 get neg sub neg 0 TR
- }if
- yflip xflip not and {
- ppr 1 get neg ppr 0 get neg TR
- }if
- }
- {
- noflips {
- TR pop pop 270 rotate 1 -1 scale
- }if
- xflip yflip and {
- TR pop pop 90 rotate 1 -1 scale
- ppr 3 get ppr 1 get neg sub neg ppr 2 get
- ppr 0 get neg sub neg TR
- }if
- xflip yflip not and {
- TR pop pop 90 rotate ppr 3 get
- ppr 1 get neg sub neg 0 TR
- }if
- yflip xflip not and {
- TR pop pop 270 rotate ppr 2 get
- ppr 0 get neg sub neg 0 S TR
- }if
- }ifelse
- scaleby96 {
- ppr aload pop 4 -1 roll add 2 div 3 1 roll add 2 div 2 copy
- TR .96 dup scale neg S neg S TR
- }if
- }N
- /cp {pop pop showpage pm restore}N
- end
- }if
- } if
- } N
-
-%
-% The following procedure brings us back to PostScript size. It takes
-% into account the current global dvi magnification, so graphics
-% scale with the document.
-%
-/normalscale {
- Resolution 72 div VResolution 72 div neg scale
- magscale { DVImag dup scale } if
- 0 setgray
-} N
-%
-% We need the psfig macros.
-%
-% All software, documentation, and related files in this distribution of
-% psfig/tex are Copyright (c) 1987 Trevor J. Darrell
-%
-% Permission is granted for use and non-profit distribution of psfig/tex
-% providing that this notice be clearly maintained, but the right to
-% distribute any portion of psfig/tex for profit or as part of any commercial
-% product is specifically reserved for the author.
-%
-%
-% psfigTeX PostScript Prolog
-% $Header: /cvsroot/xdvi/xdvi/psheader.txt,v 1.80 2008/04/02 18:56:15 vojta Exp $
-%
-/psfts { S 65781.76 div N } N
-
-% x y bb-llx bb-lly bb-urx bb-ury startTexFig -
-/startTexFig {
- /psf$SavedState save N
- userdict maxlength dict begin
-
- /magscale true def
- normalscale
- currentpoint TR %set the current point as the user's origin
-
- /psf$ury psfts
- /psf$urx psfts
- /psf$lly psfts
- /psf$llx psfts
- /psf$y psfts
- /psf$x psfts
-
- /psf$sx psf$x psf$urx psf$llx sub div N % scaling for x
- /psf$sy psf$y psf$ury psf$lly sub div N % scaling for y
-
- psf$sx psf$sy scale % scale by (sx,sy)
-
- psf$llx neg psf$ury neg TR
-
- /showpage {
- } N
- /erasepage {
- } N
- /copypage {
- } N
- /p 3 def % necessary to get around a bug in Adobe Illustrator
- @MacSetUp
-} N
-
-% llx lly urx ury doclip - (args in figure coordinates)
-/doclip {
- psf$llx psf$lly psf$urx psf$ury
- currentpoint 6 2 roll
- newpath 4 copy
- 4 2 roll moveto
- 6 -1 roll S lineto
- S lineto
- S lineto
- closepath clip
- newpath
- moveto
-} N
-% - endTexFig -
-/endTexFig { end psf$SavedState restore } N
-
-% this will be invoked as the result of a \special command (for the
-% inclusion of PostScript graphics). The basic idea is to change all
-% scaling and graphics back to defaults, but to shift the origin
-% to the current position on the page.
-
-/@beginspecial % - @beginspecial - -- enter special mode
- { SDict begin
- /SpecialSave save N
- gsave
- normalscale
- currentpoint TR %set the current point as the user's origin
- @SpecialDefaults % setup default offsets, scales, sizes, and angle
- count /ocount X /dcount countdictstack N
- } N
-
-/@setspecial % to setup user specified offsets, scales, sizes (for clipping)
- {
- CLIP 1 eq
- { newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs neg 0 rlineto
- closepath clip }
- if
- ho vo TR
- hsc vsc scale
- ang rotate
- rwiSeen {
- rwi urx llx sub div
- rhiSeen { rhi ury lly sub div } { dup } ifelse
- scale llx neg lly neg TR
- } {
- rhiSeen { rhi ury lly sub div dup scale llx neg lly neg TR } if
- } ifelse
- CLIP 2 eq
- { newpath llx lly moveto urx lly lineto urx ury lineto llx ury lineto
- closepath clip }
- if
- /showpage {} N
- /erasepage {} N
- /copypage {} N
- newpath
- } N
-
-/@endspecial % - @endspecial - -- leave special mode
- { count ocount sub {pop} repeat
- countdictstack dcount sub {end} repeat
- grestore SpecialSave restore
- end
- } N
-/@defspecial
- {
- SDict begin
- } N
-/@fedspecial
- {
- end
- } B
-end % revert to previous dictionary
diff --git a/special.c b/special.c
@@ -60,10 +60,6 @@ NOTE:
#define rint(x) floor((x) + 0.5)
-#if PS
-# include <errno.h>
-# include <sys/wait.h>
-#endif /* PS */
#define MAXPOINTS 300 /* Max points in a path */
#define MAX_PEN_SIZE 7 /* Max pixels of pen width */
@@ -488,107 +484,6 @@ blacken_last()
* Code for PostScript<tm> specials begins here.
*/
-#if PS
-
-/*
- * Information on how to search for PS header and figure files.
- */
-
-#include "filf-app.h" /* application-related defs, etc. */
-#include "filefind.h"
-
-static const char no_f_str_ps[] = "/%f";
-
-static struct findrec search_header = {
- /* path1 */ NULL,
-#if CFGFILE
- /* envptr */ NULL,
-#endif
- /* path2 */ DEFAULT_HEADER_PATH,
- /* type */ "PS header",
- /* fF_etc */ "fF",
- /* x_var_char */ 'f',
- /* n_var_opts */ 2,
- /* no_f_str */ no_f_str_ps,
- /* no_f_str_end */ no_f_str_ps + sizeof(no_f_str_ps) - 1,
- /* abs_str */ "%f",
-#if USE_GF
- /* no_f_str_flags */ F_FILE_USED,
- /* abs_str_flags */ F_FILE_USED,
- /* pk_opt_char */ 'f',
- /* pk_gf_addr */ NULL,
-#endif
- /* pct_s_str */ "%qdvips//",
- {
- /* v.stephead */ NULL,
- /* v.pct_s_head */ NULL,
- /* v.pct_s_count */ 0,
- /* v.pct_s_atom */ NULL,
- /* v.rootp */ NULL,
- }
-};
-
-static struct findrec search_fig = {
- /* path1 */ NULL,
-#if CFGFILE
- /* envptr */ NULL,
-#endif
- /* path2 */ DEFAULT_FIG_PATH,
- /* type */ "PS",
- /* fF_etc */ "fF",
- /* x_var_char */ 'f',
- /* n_var_opts */ 2,
- /* no_f_str */ no_f_str_ps,
- /* no_f_str_end */ no_f_str_ps + sizeof(no_f_str_ps) - 1,
- /* abs_str */ "%f",
-#if USE_GF
- /* no_f_str_flags */ F_FILE_USED,
- /* abs_str_flags */ F_FILE_USED,
- /* pk_opt_char */ 'f',
- /* pk_gf_addr */ NULL,
-#endif
- /* pct_s_str */ "%qdvips//:%qtex//",
- {
- /* v.stephead */ NULL,
- /* v.pct_s_head */ NULL,
- /* v.pct_s_count */ 0,
- /* v.pct_s_atom */ NULL,
- /* v.rootp */ NULL,
- }
-};
-
-static void ps_startup(int, int, const char *);
-static void ps_startup2(void);
-void NullProc(void) {}
-static void NullProc2(const char *);
-
-struct psprocs psp = { /* used for lazy startup of the ps machinery */
- /* toggle */ NullProc,
- /* destroy */ NullProc,
- /* interrupt */ NullProc,
- /* endpage */ NullProc,
- /* drawbegin */ ps_startup,
- /* drawraw */ NullProc2,
- /* drawfile */ NULL,
- /* drawend */ NullProc2,
- /* beginheader */ ps_startup2,
- /* endheader */ NullProc,
- /* newdoc */ NullProc};
-
-struct psprocs no_ps_procs = { /* used if postscript is unavailable */
- /* toggle */ NullProc,
- /* destroy */ NullProc,
- /* interrupt */ NullProc,
- /* endpage */ NullProc,
- /* drawbegin */ drawbegin_none,
- /* drawraw */ NullProc2,
- /* drawfile */ NULL,
- /* drawend */ NullProc2,
- /* beginheader */ NullProc,
- /* endheader */ NullProc,
- /* newdoc */ NullProc};
-
-#endif /* PS */
static Boolean bbox_valid;
static unsigned int bbox_width;
@@ -652,441 +547,18 @@ draw_bbox()
}
}
-#if PS
-
-static XIOErrorHandler oldhandler;
-
-static int XDviIOErrorHandler P1C(Display *, disp)
-{
- ps_destroy();
- return oldhandler(disp);
-}
-
-/*
- * Initialize paths for file searching
- */
-
-void
-ps_init_paths()
-{
- static Boolean done_already = False;
-
- if (done_already)
- return;
- done_already = True;
-
-#if CFGFILE
-
- if ((search_header.path1 = getenv("XDVIHEADERS")) == NULL
- && (search_header.path1 = getenv("TEXPSHEADERS")) == NULL)
- search_header.path1 = getenv("PSHEADERS");
- search_header.envptr = ffgetenv("PSHEADERS");
- /* clear it if it's a getenv() placeholder */
- if (search_header.envptr != NULL && search_header.envptr->value == NULL)
- search_header.envptr = NULL;
-
- if ((search_fig.path1 = getenv("XDVIPICTS")) == NULL
- && (search_fig.path1 = getenv("TEXPICTS")) == NULL)
- search_fig.path1 = getenv("TEXINPUTS");
- search_fig.envptr = ffgetenv("TEXPICTS");
- /* clear it if it's a getenv() placeholder */
- if (search_fig.envptr != NULL && search_fig.envptr->value == NULL)
- search_fig.envptr = NULL;
-
-#else /* not CFGFILE */
-
- if ((search_header.path1 = getenv("XDVIHEADERS")) == NULL
- && (search_header.path1 = getenv("TEXPSHEADERS")) == NULL
- && (search_header.path1 = getenv("PSHEADERS")) == NULL
- ) {
- search_header.path1 = search_header.path2;
- search_header.path2 = NULL;
- }
-
- if ((search_fig.path1 = getenv("XDVIPICTS")) == NULL
- && (search_fig.path1 = getenv("TEXPICTS")) == NULL
- && (search_fig.path1 = getenv("TEXINPUTS")) == NULL
- ) {
- search_fig.path1 = search_fig.path2;
- search_fig.path2 = NULL;
- }
-
-#endif /* not CFGFILE */
-
-}
-
-
-static void
-actual_startup()
-{
- ps_init_paths();
-
- /* This allows us to clean up after server shutdowns, etc. */
- oldhandler = XSetIOErrorHandler(XDviIOErrorHandler);
-
- psp = no_ps_procs;
-}
-
-static void
-ps_startup(xul, yul, cp)
- int xul, yul;
- const char *cp;
-{
- if (!resource._postscript) {
- draw_bbox();
- return;
- }
- actual_startup();
- psp.drawbegin(xul, yul, cp);
-}
-
-static void
-ps_startup2()
-{
- actual_startup();
- psp.beginheader();
-}
-
-/* ARGSUSED */
-static void
-NullProc2(cp)
- const char *cp;
-{}
-
-static void
-ps_parseraw(PostScript_cmd)
- const char *PostScript_cmd;
-{
- const char *p;
-
- /* dumb parsing of PostScript - search for rotation H. Zeller 1/97 */
- bbox_angle = 0;
- p = strstr(PostScript_cmd, "rotate");
- if (p != NULL) {
- while (*p != '\0' && !isdigit(*p)) --p;
- while (*p != '\0' && isdigit(*p)) --p;
- if (*p != '+' && *p != '-') ++p;
- sscanf(p, "%d neg rotate", &bbox_angle);
- }
-}
-
-/* ARGSUSED */
-void
-drawbegin_none(int xul, int yul, const char *cp)
-{
- draw_bbox();
-}
-
-
-/*
- * Mechanism to cache results of ``tick'' specials.
- */
-
-struct tickrec {
- struct tickrec *next;
- int pageno;
- char *command;
- char *tempname;
-};
-
-static struct tickrec *tickhead = NULL; /* head of linked list of */
- /* cached information */
-static int nticks = 0; /* number of records total */
-
-#ifndef TICKCACHESIZE
-#define TICKCACHESIZE 3
-#endif
-
-#ifndef TICKTMP
-#define TICKTMP "/tmp"
-#endif
-
-/*
- * cachetick() - returns:
- * NULL error;
- * fp == NULL string was not in cache, fd = file
- * fp != NULL string was in cache, fp = cached file
- */
-
-static struct tickrec *
-cachetick(filename, pathinfo, fp, fdp)
- const char *filename;
- struct findrec *pathinfo;
- FILE **fp;
- int *fdp;
-{
- struct tickrec **linkp;
- struct tickrec *tikp;
- struct tickrec **freerecp;
-
- linkp = &tickhead;
- freerecp = NULL;
- for (;;) { /* see if we have it already */
- tikp = *linkp;
- if (tikp == NULL) { /* if end of list */
- int fd;
-
- if (nticks >= TICKCACHESIZE && freerecp != NULL) {
- tikp = *freerecp;
- *freerecp = tikp->next;
- free(tikp->command);
- unlink(tikp->tempname);
- /* reuse tikp and tikp->tempname */
- }
- else {
- tikp = xmalloc(sizeof(struct tickrec));
- tikp->tempname = NULL;
- ++nticks;
- }
- fd = xdvi_temp_fd(&tikp->tempname);
- if (fd == -1) {
- perror("Cannot create temporary file");
- free(tikp->tempname);
- free(tikp);
- return NULL;
- }
- tikp->command = xstrdup(filename);
- *fp = NULL;
- *fdp = fd;
- break;
- }
- if (strcmp(filename, tikp->command) == 0) { /* found it */
- *linkp = tikp->next; /* unlink it */
- *fp = xfopen(tikp->tempname, "r");
- if (*fp == NULL) {
- perror(tikp->tempname);
- free(tikp->tempname);
- free(tikp->command);
- free(tikp);
- return NULL;
- }
- break;
- }
- if (tikp->pageno != current_page) freerecp = linkp;
- linkp = &tikp->next;
- }
- tikp->next = tickhead; /* link it in */
- tickhead = tikp;
- tikp->pageno = pathinfo != &search_header ? current_page : -1;
- return tikp;
-}
-
-void
-ps_clear_cache()
-{
- struct tickrec *tikp;
-
- while (tickhead != NULL) {
- tikp = tickhead;
- tickhead = tickhead->next;
- free(tikp->command);
- unlink(tikp->tempname);
- free((char *) tikp->tempname);
- free(tikp);
- }
- nticks = 0;
-}
-
-#ifndef UNCOMPRESS
-#define UNCOMPRESS "uncompress"
-#endif
-
-#ifndef GUNZIP
-#define GUNZIP "gunzip"
-#endif
-
-#ifndef BUNZIP2
-#define BUNZIP2 "bunzip2"
-#endif
-
-static void
-send_ps_file(filename, pathinfo)
- const char *filename;
- struct findrec *pathinfo;
-{
- FILE *f;
- int fd;
- static const char *argv[] = {NULL, "-c", NULL, NULL};
- const char *bufp;
- struct tickrec *tikp;
- char *p;
- unsigned len;
- char magic1, magic2, magic3;
-
- if (psp.drawfile == NULL || !resource._postscript) return;
-
- if (filename[0] == '`') {
- if (!resource.allow_shell) {
- if (warn_spec_now)
- WARN1(XmDIALOG_ERROR,
- "Shell escape disallowed for special\n\"%s\"", filename);
- return;
- }
-
- tikp = cachetick(filename, pathinfo, &f, &fd);
- if (tikp == NULL) /* if error */
- return;
- if (f == NULL) { /* if not cached, need to create */
- close(fd);
- ++n_files_left;
- len = strlen(filename) + strlen(tikp->tempname) + (4 - 1);
- if (len > ffline_len)
- expandline(len);
- Sprintf(ffline, "%s > %s", filename + 1, tikp->tempname);
- (void) system(ffline);
- f = xfopen(tikp->tempname, "r");
- if (f == NULL) {
- perror(tikp->tempname);
- return;
- }
- }
- bufp = tikp->tempname;
- }
- else {
- f = NULL;
- /* first try the same path as the dvi file */
- if (filename[0] != '/') {
- p = rindex(dvi_name, '/');
- if (p == NULL) bufp = filename;
- else {
- unsigned len1, len2;
-
- len1 = ++p - dvi_name;
- len2 = strlen(filename) + 1;
- if (len1 + len2 > ffline_len)
- expandline(len1 + len2);
- bcopy(dvi_name, ffline, len1);
- bcopy(filename, ffline + len1, len2);
- bufp = ffline;
- }
- if (debug & DBG_OPEN) Printf("Trying PS file %s\n", bufp);
- f = xfopen(bufp, "r");
- }
- if (f == NULL) {
- f = filefind(filename, pathinfo, (const char **) NULL);
- bufp = ffline;
- }
-
- /* if still no luck, complain */
- if (f == NULL) {
- WARN1(XmDIALOG_ERROR,
- "Cannot find PostScript file for inclusion in document:\n%s",
- filename);
- draw_bbox();
- return;
- }
-
- /* check for compressed files */
- len = strlen(filename);
- magic1 = '\037';
- magic3 = '\0';
- if ((len > 2 && strcmp(filename + len - 2, ".Z") == 0
- && (argv[0] = UNCOMPRESS, magic2 = '\235', True))
- || (len > 3 && strcmp(filename + len - 3, ".gz") == 0
- && (argv[0] = GUNZIP, magic2 = '\213', True))
- || (len > 4 && strcmp(filename + len - 4, ".bz2") == 0
- && (argv[0] = BUNZIP2, magic1 = 'B', magic2 = 'Z',
- magic3 = 'h', True))) {
- if (getc(f) != magic1 || (char) getc(f) != magic2
- || (magic3 != '\0' && getc(f) != magic3))
- rewind(f);
- else {
- Fclose(f);
- ++n_files_left;
- tikp = cachetick(filename, pathinfo, &f, &fd);
- if (tikp == NULL) /* if error */
- return;
- if (f == NULL) { /* if not cached, need to create */
- pid_t pid;
- int status;
-
- argv[2] = bufp;
- Fflush(stderr); /* avoid double flushing */
- pid = vfork();
- if (pid == 0) { /* if child */
- (void) dup2(fd, 1);
- (void) execvp(argv[0], (char **) argv);
- Fprintf(stderr, "Execvp of %s failed.\n", argv[0]);
- Fflush(stderr);
- _exit(1);
- }
- (void) close(fd);
- ++n_files_left;
- for (;;) {
-#if HAVE_WAITPID
- if (waitpid(pid, &status, 0) != -1) break;
-#else
-# if HAVE_WAIT4
- if (wait4(pid, &status, 0, (struct rusage *) NULL)
- != -1)
- break;
-# else
- int retval;
-
- retval = wait(&status);
- if (retval == pid) break;
- if (retval != -1) continue;
-# endif
-#endif
- if (errno == EINTR) continue;
- perror("[xdvi] waitpid");
- return;
- }
- f = xfopen(tikp->tempname, "r");
- if (f == NULL) {
- perror(tikp->tempname);
- return;
- }
- }
- bufp = tikp->tempname;
- }
- }
- }
-
- /* Success! */
- psp.drawfile(bufp, f); /* this is supposed to close the file */
-}
-
-
-void
-ps_destroy()
-{
- struct tickrec *tikp;
-
- /* Note: old NeXT systems (at least) lack atexit/on_exit. */
- psp.destroy();
- for (tikp = tickhead; tikp != NULL; tikp = tikp->next)
- if (unlink(tikp->tempname) < 0)
- perror(tikp->tempname);
-}
-
-#endif /* PS */
void
init_prescan()
{
-#if PS
- struct tickrec *tikp;
-#endif
scanned_page =
-#if PS
- scanned_page_ps = scanned_page_ps_bak =
-#endif
#if COLOR
scanned_page_color =
#endif
scanned_page_reset = resource.prescan ? -1 : total_pages + 1;
-#if PS
- if (!resource._postscript)
- scanned_page_ps = total_pages + 1;
-
- for (tikp = tickhead; tikp != NULL; tikp = tikp->next)
- tikp->pageno = -1;
- psp.newdoc();
-#endif
#if COLOR
if (!use_color)
@@ -1095,12 +567,7 @@ init_prescan()
if (ignore_papersize_specials)
scanned_page =
-#if PS && COLOR
- scanned_page_ps < scanned_page_color
- ? scanned_page_ps : scanned_page_color;
-#elif PS
- scanned_page_ps;
-#elif COLOR
+#if COLOR
scanned_page_color;
#else
total_pages + 1;
@@ -1126,48 +593,22 @@ psfig_special(cp)
bbox_voffset = 0;
}
if (currwin.win == mane.win)
-#if PS
- psp.drawbegin(PXL_H - currwin.base_x, PXL_V - currwin.base_y,
- cp);
-#else
draw_bbox();
-#endif
psfig_begun = True;
} else if (strncmp(cp, " plotfile ", 10) == 0) {
cp += 10;
while (isspace(*cp)) cp++;
for (filename = cp; !isspace(*cp); ++cp);
*cp = '\0';
-#if PS
- if (currwin.win == mane.win) send_ps_file(filename, &search_fig);
-#endif
} else if (strncmp(cp, ":[end]", 6) == 0) {
cp += 6;
-#if PS
- if (currwin.win == mane.win) psp.drawend(cp);
-#endif
bbox_valid = False;
psfig_begun = False;
} else if (*cp == ':') {
/* I am going to send some raw postscript stuff */
++cp; /* skip the colon */
-#if PS
- ps_parseraw(cp);
- if (currwin.win == mane.win) psp.drawraw(cp);
-#endif
} else {
/* also raw PostScript, but no extra colon to skip */
-#if PS
- if (currwin.win == mane.win) {
- ps_parseraw(cp);
- if (psfig_begun) psp.drawraw(cp);
- else {
- psp.drawbegin(PXL_H - currwin.base_x,
- PXL_V - currwin.base_y, cp);
- psp.drawend("");
- }
- }
-#endif
}
}
@@ -1281,15 +722,7 @@ epsf_special(cp)
}
if (currwin.win == mane.win) {
-#if PS
- psp.drawbegin(PXL_H - currwin.base_x, PXL_V - currwin.base_y,
- buffer);
- /* talk directly with the DPSHandler here */
- send_ps_file(filename, &search_fig);
- psp.drawend(" @endspecial");
-#else
draw_bbox();
-#endif
}
bbox_valid = False;
}
@@ -1301,48 +734,10 @@ quote_special(cp)
{
bbox_valid = False;
-#if PS
- if (currwin.win == mane.win) {
- psp.drawbegin(PXL_H - currwin.base_x, PXL_V - currwin.base_y,
- "@beginspecial @setspecial ");
- /* talk directly with the DPSHandler here */
- psp.drawraw(cp + 1);
- psp.drawend(" @endspecial");
- }
-#endif
/* nothing else to do--there's no bbox here */
}
-#if PS
-
-static void
-scan_header(cp)
- char *cp;
-{
- char *filename;
-
- filename = cp;
- if (*cp == '\'' || *cp == '"') {
- do ++cp;
- while (*cp != '\0' && *cp != *filename);
- *cp = '\0';
- ++filename;
- }
-
- psp.beginheader();
- send_ps_file(filename, &search_header);
-}
-
-static void
-scan_bang(cp)
- char *cp;
-{
- psp.beginheader();
- psp.drawraw(cp + 1);
-}
-
-#endif /* PS */
#if COLOR
@@ -1804,9 +1199,6 @@ color_special(cp)
if (scanned_page_reset >= 0) {
/* turn on scanning and redraw the page */
scanned_page =
-#if PS
- scanned_page_ps =
-#endif
scanned_page_color = scanned_page_reset = -1;
ev_flags |= EV_NEWPAGE; /* force a redraw */
longjmp(canit_env, 1);
@@ -1984,18 +1376,6 @@ applicationDoSpecial(cp)
if (*cp == '!'
|| (memicmp(cp, "header", 6) == 0 && endofcommand(cp + 6) != NULL)) {
-#if PS
- if (resource._postscript && scanned_page_reset >= 0) {
- /* turn on scanning and redraw the page */
- scanned_page =
-# if COLOR
- scanned_page_color =
-# endif
- scanned_page_ps = scanned_page_reset = -1;
- ev_flags |= EV_NEWPAGE; /* force a redraw */
- longjmp(canit_env, 1);
- }
-#endif /* PS */
return;
}
@@ -2004,9 +1384,6 @@ applicationDoSpecial(cp)
if (use_color && scanned_page_reset >= 0) {
/* turn on scanning and redraw the page */
scanned_page =
-# if PS
- scanned_page_ps =
-# endif
scanned_page_color = scanned_page_reset = -1;
ev_flags |= EV_NEWPAGE; /* force a redraw */
longjmp(canit_env, 1);
@@ -2019,9 +1396,6 @@ applicationDoSpecial(cp)
if (scanned_page_reset >= 0) {
/* turn on scanning and redraw the page */
scanned_page =
-#if PS
- scanned_page_ps =
-#endif
#if COLOR
scanned_page_color =
#endif
@@ -2078,27 +1452,8 @@ scan_special(cp)
while (isspace(*cp)) ++cp;
}
-#if PS
-# if COLOR
- if (scanned_page_ps <= scanned_page)
-# endif
- {
- if (*cp == '!') {
- scan_bang(cp);
- return;
- }
- else if (memicmp(cp, "header", 6) == 0
- && (p = endofcommand(cp + 6)) != NULL) {
- scan_header(p);
- return;
- }
- }
-#endif /* PS */
#if COLOR
-# if PS
- if (scanned_page_color <= scanned_page)
-# endif
{
if (memicmp(cp, "background ", 11) == 0) {
scan_bg_color(cp);
diff --git a/util.c b/util.c
@@ -36,10 +36,6 @@ NOTE:
#include <X11/Xmd.h> /* get WORD64 and LONG64 */
-#if PS
-# include <sys/stat.h>
-#endif
-
#include <stdarg.h>
@@ -111,9 +107,6 @@ xdvi_exit(status)
/* Clean up the "xdvi windows" property in the root window. */
if (top_level)
exit_clean_windows();
-#if PS
- ps_destroy();
-#endif
exit(status);
}
@@ -492,7 +485,7 @@ snum(fp, size)
}
-#if FREETYPE || PS
+#if FREETYPE
/*
* General AVL tree mechanism. Search for a node, and return it if found.
@@ -629,7 +622,7 @@ avladd(key, key_len, headp, size)
return ap;
}
-#endif /* FREETYPE || PS */
+#endif /* FREETYPE */
/*
@@ -707,77 +700,6 @@ property_get_data(w, a, ret_buf, x_get_property)
}
-#if PS
-
-/*
- * Create a temporary file and return its fd. Also put its filename
- * in str. Create str if it's NULL.
- */
-
-#ifndef P_tmpdir
-#define P_tmpdir "/tmp"
-#endif
-
-static const char tmp_suffix[] = "/xdvi-XXXXXX";
-
-int
-xdvi_temp_fd(str)
- char **str;
-{
- int fd;
- char *p;
- size_t len;
- static const char *template = NULL;
-
- if (*str != NULL) {
- p = *str;
- if (n_files_left == 0) close_a_file();
- /* O_EXCL is there for security (if root runs xdvi) */
- fd = open(p, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
- if (fd == -1 && (errno == EMFILE || errno == ENFILE)) {
- n_files_left = 0;
- close_a_file();
- fd = open(p, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
- }
- if (!(fd == -1 && errno == EEXIST))
- return fd;
- memcpy(p + strlen(p) - 6, "XXXXXX", 6);
- }
- else {
- if (template == NULL) {
- const char *ourdir;
-
- ourdir = getenv("TMPDIR");
- if (ourdir == NULL || access(ourdir, W_OK) < 0) {
- ourdir = P_tmpdir;
- if (access(ourdir, W_OK) < 0)
- ourdir = ".";
- }
- len = strlen(ourdir);
- if (len > 0 && ourdir[len - 1] == '/') --len;
- template = p = xmalloc(len + sizeof tmp_suffix);
- memcpy(p, ourdir, len);
- memcpy(p + len, tmp_suffix, sizeof tmp_suffix);
- }
- *str = p = xstrdup(template);
- }
-
- if (n_files_left == 0) close_a_file();
-
- fd = mkstemp(p);
- if (fd == -1 && (errno == EMFILE || errno == ENFILE)) {
- n_files_left = 0;
- close_a_file();
- memcpy(p + strlen(p) - 6, "XXXXXX", 6);
- fd = mkstemp(p);
- }
-
- return fd;
-}
-
-#endif /* PS */
-
-
/*
* Prepare the file descriptor to generate SIGPOLL/SIGIO events.
* If called with a True argument, set it up for non-blocking I/O.
diff --git a/xdvi.c b/xdvi.c
@@ -297,12 +297,6 @@ static XrmOptionDescRec options[] = {
{"-thorough", ".thorough", XrmoptionNoArg, (XPointer) "on"},
{"+thorough", ".thorough", XrmoptionNoArg, (XPointer) "off"},
{"-wheelunit", ".wheelUnit", XrmoptionSepArg, (XPointer) NULL},
-#if PS
-{"-nopostscript",".postscript", XrmoptionNoArg, (XPointer) "off"},
-{"+nopostscript",".postscript", XrmoptionNoArg, (XPointer) "on"},
-{"-allowshell", ".allowShell", XrmoptionNoArg, (XPointer) "on"},
-{"+allowshell", ".allowShell", XrmoptionNoArg, (XPointer) "off"},
-#endif /* PS */
{"-noscan", ".prescan", XrmoptionNoArg, (XPointer) "off"},
{"+noscan", ".prescan", XrmoptionNoArg, (XPointer) "on"},
{"-dvipspath", ".dvipsPath", XrmoptionSepArg, (XPointer) NULL},
@@ -373,9 +367,6 @@ static const char base_translations[] = ""
#if COLOR
"\"C\":set-color()\n"
#endif
-#if PS
-"\"v\":set-ps()\n"
-#endif
#if BUTTONS
"\"x\":set-expert-mode()\n"
#endif
@@ -482,12 +473,6 @@ static XtResource application_resources[] = {
offset(icon_geometry), XtRString, (XtPointer) NULL},
{"keepPosition", "KeepPosition", XtRBoolean, sizeof(Boolean),
offset(keep_flag), XtRString, "false"},
-#if PS
-{"postscript", "Postscript", XtRBoolean, sizeof(Boolean),
- offset(_postscript), XtRString, "true"},
-{"allowShell", "AllowShell", XtRBoolean, sizeof(Boolean),
- offset(allow_shell), XtRString, "false"},
-#endif /* PS */
{"prescan", "Prescan", XtRBoolean, sizeof(Boolean),
offset(prescan), XtRString, "true"},
{"copy", "Copy", XtRBoolean, sizeof(Boolean),
@@ -1913,12 +1898,6 @@ argument is to override any papersize specials in the dvi file.\n\n", stderr);
if (mg_size[i].h <= 0) mg_size[i].w = 0;
}
}
-#if PS
- if (resource.safer) {
- resource.allow_shell = False;
- }
-#endif /* PS */
-
#if CFGFILE && !EXTRA_APP_DEFAULTS
readconfig(); /* read config file(s). */
#endif
diff --git a/xdvi.h b/xdvi.h
@@ -214,15 +214,8 @@ double tpic_conv;
int n_files_left = 32767; /* for LRU closing of fonts */
unsigned int page_w, page_h;
-#define PS 0
-
int scanned_page; /* last page prescanned */
-#if PS
-int scanned_page_ps; /* last page scanned for PS specials */
-int scanned_page_ps_bak; /* save the above if PS is turned off */
-#endif
-
#if COLOR
int scanned_page_color; /* last page scanned for color spcls */
#endif
@@ -432,12 +425,6 @@ extern struct _resource {
Boolean keep_flag;
Boolean copy;
Boolean thorough;
-#if PS
- /* default is to use DPS, then NEWS, then GhostScript;
- * we will figure out later on which one we will use */
- Boolean _postscript;
- Boolean allow_shell;
-#endif /* PS */
Boolean prescan;
const char *debug_arg;
Boolean version_flag;
@@ -774,7 +761,7 @@ char *ffline = NULL; /* an array used by filefind to store */
size_t ffline_len = 0; /* current length of ffline[] */
-#if FREETYPE || PS
+#if FREETYPE
/*
* AVL tree structures.
@@ -825,7 +812,7 @@ struct avl_enc {
const char *vec[256];
};
-#endif /* FREETYPE || PS */
+#endif /* FREETYPE */
/*
@@ -862,24 +849,6 @@ Atom atoms[5];
const char *argv0; /* argv[0] */
#endif
-#if PS
-
-extern struct psprocs {
- void (*toggle) (void);
- void (*destroy) (void);
- void (*interrupt) (void);
- void (*endpage) (void);
- void (*drawbegin) (int, int, const char *);
- void (*drawraw) (const char *);
- void (*drawfile) (const char *, FILE *);
- void (*drawend) (const char *);
- void (*beginheader) (void);
- void (*endheader) (void);
- void (*newdoc) (void);
-} psp, no_ps_procs;
-
-#endif /* PS */
-
/********************************
* Procedures *
*******************************/
@@ -970,16 +939,12 @@ extern void source_forward_search(const char *);
#if CFGFILE
extern void readconfig(void);
#endif
-#if FREETYPE || PS
+#if FREETYPE
extern FILE *open_t1_font(struct avl_t1 *, const char **);
extern void read_encoding(struct avl_enc *);
#endif
extern void init_font_open(void);
extern Boolean font_open(struct font *, char **, int *);
-#if PS
-extern void ps_clear_cache(void);
-extern void ps_destroy(void);
-#endif
extern void init_prescan(void);
#if COLOR
extern void scan_color_eop(void);
@@ -1009,16 +974,13 @@ extern DIR *xopendir(const char *);
extern const struct passwd *ff_getpw(const char **, const char *);
extern unsigned long num(FILE *, int);
extern long snum(FILE *, int);
-#if FREETYPE || PS
+#if FREETYPE
extern struct avl *avladd(const char *, size_t, struct avl **, size_t);
#endif
extern size_t property_get_data(Window, Atom, unsigned char **,
int (*x_get_property) (Display *, Window, Atom, long,
long, Bool, Atom, Atom *, int *, unsigned long *,
unsigned long *, unsigned char **));
-#if PS
-extern int xdvi_temp_fd(char **);
-#endif
extern void prep_fd(int, wide_bool);
extern void read_PK_index(struct font *, wide_bool);
extern void read_GF_index(struct font *, wide_bool);
@@ -1027,13 +989,6 @@ extern void read_VF_index(struct font *, wide_bool);
extern Boolean load_ft_font(struct font *);
#endif
-#if PS
-extern void ps_init_paths(void);
-extern void drawbegin_none(int, int, const char *);
-extern void draw_bbox(void);
-extern void NullProc(void);
-#endif /* PS */
-
_XFUNCPROTOEND
#define one(fp) ((unsigned char) getc(fp))