summaryrefslogtreecommitdiff
path: root/gs/base
diff options
context:
space:
mode:
Diffstat (limited to 'gs/base')
-rw-r--r--gs/base/configure.ac6
-rw-r--r--gs/base/freetype.mak2
-rw-r--r--gs/base/gdevbit.c4
-rw-r--r--gs/base/gdevcdj.c126
-rw-r--r--gs/base/gdevifno.c2
-rw-r--r--gs/base/gdevlbp8.c7
-rw-r--r--gs/base/gdevmgr.c66
-rw-r--r--gs/base/gdevprn.c8
-rw-r--r--gs/base/gdevps.c3
-rw-r--r--gs/base/gdevtsep.c18
-rw-r--r--gs/base/gdevupd.c5
-rw-r--r--gs/base/gsdevice.c20
-rw-r--r--gs/base/gsfname.c9
-rw-r--r--gs/base/gsfname.h3
-rw-r--r--gs/base/gsht.c2
-rw-r--r--gs/base/gsht1.c6
-rw-r--r--gs/base/gshtscr.c60
-rw-r--r--gs/base/gsiodev.c32
-rw-r--r--gs/base/gslibctx.c14
-rw-r--r--gs/base/gslibctx.h24
-rw-r--r--gs/base/gsnamecl.c2
-rw-r--r--gs/base/gsutil.c17
-rw-r--r--gs/base/gsutil.h14
-rw-r--r--gs/base/gxcllzw.c35
-rw-r--r--gs/base/gxclmem.c29
-rw-r--r--gs/base/gxclmem.h7
-rw-r--r--gs/base/gxclzlib.c40
-rw-r--r--gs/base/gxdevice.h2
-rw-r--r--gs/base/gxht.h17
-rw-r--r--gs/base/gxiodev.h6
-rw-r--r--gs/base/gxstroke.c12
-rw-r--r--gs/base/lib.mak1
-rw-r--r--gs/base/sfxcommon.c2
-rw-r--r--gs/base/strmio.c4
-rw-r--r--gs/base/szlibd.c1
-rw-r--r--gs/base/ttinterp.c3
36 files changed, 331 insertions, 278 deletions
diff --git a/gs/base/configure.ac b/gs/base/configure.ac
index 6ff432616..cbfe59b5d 100644
--- a/gs/base/configure.ac
+++ b/gs/base/configure.ac
@@ -322,14 +322,14 @@ AC_SUBST(FONTCONFIG_LIBS)
AC_CHECK_LIB(dl, dlopen)
-AC_ARG_ENABLE([freetype], AC_HELP_STRING([--enable-freetype],
- [Use freetype for font rasterization]))
+AC_ARG_ENABLE([freetype], AC_HELP_STRING([--disable-freetype],
+ [Disable freetype for font rasterization]))
FT_BRIDGE=0
SHARE_FT=0
FTSRCDIR=
FT_CFLAGS=
FT_LIBS=
-if test x"$enable_freetype" == xyes; then
+if test x"$enable_freetype" != xno; then
AC_MSG_CHECKING([for local freetype library source])
dnl We prefer freetype2 over freetype, so it is easy to override
dnl the included freetype source with a checkout from upstream.
diff --git a/gs/base/freetype.mak b/gs/base/freetype.mak
index d75cccd6c..f3a9ae1b0 100644
--- a/gs/base/freetype.mak
+++ b/gs/base/freetype.mak
@@ -29,7 +29,7 @@ FTO_=$(O_)$(FTOBJ)
# Define our local compiler alias
# we must define FT2_BUILD_LIBRARY to get internal declarations
-FTCC=$(CC_) $(I_)$(FTSRCDIR)$(D)include$(_I) -DFT2_BUILD_LIBRARY
+FTCC=$(CC_) $(I_)$(FTSRCDIR)$(D)include$(_I) -DFT2_BUILD_LIBRARY -DDARWIN_NO_CARBON
# Define the name of this makefile.
FT_MAK=$(GLSRC)freetype.mak
diff --git a/gs/base/gdevbit.c b/gs/base/gdevbit.c
index 4939b5bfb..34b148d3c 100644
--- a/gs/base/gdevbit.c
+++ b/gs/base/gdevbit.c
@@ -356,7 +356,7 @@ bittag_rgb_map_rgb_color(gx_device * dev, const gx_color_value cv[])
((cv[2]) >> ((sizeof(gx_color_value) * 8) - 8)) +
((uint) ((cv[1]) >> ((sizeof(gx_color_value) * 8) - 8)) << 8) +
((ulong) ((cv[0]) >> ((sizeof(gx_color_value) * 8) - 8)) << 16) +
- ((ulong)gs_current_object_tag() << 24);
+ ((ulong)gs_current_object_tag(dev->memory) << 24);
}
static int
@@ -484,7 +484,7 @@ bit_map_cmyk_color(gx_device * dev, const gx_color_value cv[])
static int
bittag_put_params(gx_device * pdev, gs_param_list * plist)
{
- gs_enable_object_tagging();
+ gs_enable_object_tagging(pdev->memory);
return gdev_prn_put_params(pdev, plist);
}
/* Get parameters. We provide a default CRD. */
diff --git a/gs/base/gdevcdj.c b/gs/base/gdevcdj.c
index 1e2004363..b25cce478 100644
--- a/gs/base/gdevcdj.c
+++ b/gs/base/gdevcdj.c
@@ -1878,22 +1878,28 @@ bjc_compress(const byte *row, const byte *end_row, byte *compressed)
* For the ESC/P mode, resolution is fixed as 360dpi and we must transform
* image data to serialized data.
*/
-static word *ep_storage;
-static uint ep_storage_size_words;
-static byte *ep_raster_buf[4][BJC_HEAD_ROWS], *ep_print_buf;
-static int ep_num_comps, ep_plane_size, img_rows=BJC_HEAD_ROWS;
+typedef struct {
+ word *storage;
+ uint storage_size_words;
+ byte *raster_buf[4][BJC_HEAD_ROWS];
+ byte *print_buf;
+ int num_comps;
+ int plane_size;
+ int img_rows;
+ int ln_idx;
+ int vskip1;
+ int vskip2;
+} ep_globals;
#define row_bytes (img_rows / 8)
-#define row_words (row_bytes / sizeof(word))
#define min_rows (32) /* for optimization of text image printing */
static int
-ep_print_image(FILE *prn_stream, char cmd, byte *data, int size)
+ep_print_image(FILE *prn_stream, ep_globals *eg, char cmd, byte *data, int size)
{
- static int ln_idx=0, vskip1=0, vskip2=0, real_rows;
- int i;
+ int i, real_rows;
static const char color[4] = {4,1,2,0};
@@ -1902,77 +1908,77 @@ ep_print_image(FILE *prn_stream, char cmd, byte *data, int size)
case 2: /* Cyan */
case 1: /* Magenta */
case 0: /* Yellow */
- memcpy(ep_raster_buf[((int) cmd)][ln_idx+vskip2], data, size);
+ memcpy(eg->raster_buf[((int) cmd)][eg->ln_idx+eg->vskip2], data, size);
return 0;
case 'B': /* blank line skip */
- if (!ln_idx) {
- vskip1 += size;
- } else if (size >= img_rows - (ln_idx+vskip2) || ln_idx+vskip2 >= min_rows) {
+ if (!eg->ln_idx) {
+ eg->vskip1 += size;
+ } else if (size >= eg->img_rows - (eg->ln_idx+eg->vskip2) || eg->ln_idx+eg->vskip2 >= min_rows) {
/* The 'I' cmd must precede 'B' cmd! */
- vskip2 += size;
- ep_print_image(prn_stream, 'F', 0, 0); /* flush and reset status */
+ eg->vskip2 += size;
+ ep_print_image(prn_stream, eg, 'F', 0, 0); /* flush and reset status */
} else {
- vskip2 += size;
+ eg->vskip2 += size;
}
return 0;
case 'I': /* Increment index */
- ln_idx += vskip2 + 1;
- vskip2 = 0;
- if (ln_idx < img_rows) return 0;
- /* if ep_raster_buf filled up, then fall through here and flush buffer */
+ eg->ln_idx += eg->vskip2 + 1;
+ eg->vskip2 = 0;
+ if (eg->ln_idx < eg->img_rows) return 0;
+ /* if eg->raster_buf filled up, then fall through here and flush buffer */
case 'F': /* flush print buffer */
- if (!ln_idx) return 0; /* The end of the page. */
+ if (!eg->ln_idx) return 0; /* The end of the page. */
/* before print the image, perform vertical skip. */
- while (vskip1 >= (255*2)) {
+ while (eg->vskip1 >= (255*2)) {
fputs("\033J\377", prn_stream); /* n/180in. feeding */
- vskip1 -= (255*2);
+ eg->vskip1 -= (255*2);
}
- if (vskip1 > 255) {
+ if (eg->vskip1 > 255) {
fputs("\033J\200", prn_stream);
- vskip1 -= 256;
+ eg->vskip1 -= 256;
}
- if (vskip1) {
+ if (eg->vskip1) {
/* n/360in. feeding */
- fputs("\033|J", prn_stream); putc(0, prn_stream); putc(vskip1, prn_stream);
+ fputs("\033|J", prn_stream); putc(0, prn_stream); putc(eg->vskip1, prn_stream);
}
/* Optimize the number of nozzles to be used. */
- if (ln_idx > 56) { /* use 64 nozzles */
+ if (eg->ln_idx > 56) { /* use 64 nozzles */
real_rows = 64;
- } else if (ln_idx > 48) { /* use 56 nozzles */
+ } else if (eg->ln_idx > 48) { /* use 56 nozzles */
real_rows = 56;
- } else if (ln_idx > 32) { /* use 48 nozzles */
+ } else if (eg->ln_idx > 32) { /* use 48 nozzles */
real_rows = 48;
} else { /* use 32 nozzles */
real_rows = 32;
}
- for (i = 0; i < ep_num_comps; i++) {
+ for (i = 0; i < eg->num_comps; i++) {
int lnum, hskip, print_size, img_rows;
byte *p0, *p1, *p2, *p3;
byte *inp, *inbuf, *outp, *outbuf;
- img_rows = real_rows; /* Note that this img_rows is not the one that
- * defined out of this function. */
- outbuf = ep_print_buf;
+ img_rows = real_rows; /* Note that this img_rows is not the one in
+ * the globals struct. */
+ outbuf = eg->print_buf;
/* Transpose raster image for serial printer image */
for (lnum=0; lnum < img_rows; lnum+=8, outbuf++) {
- inbuf = inp = ep_raster_buf[i][lnum];
- for (outp = outbuf; inp < inbuf+ep_plane_size; inp++, outp += img_rows) {
- memflip8x8(inp, ep_plane_size, outp, row_bytes);
+ inbuf = inp = eg->raster_buf[i][lnum];
+ for (outp = outbuf; inp < inbuf+eg->plane_size; inp++, outp += img_rows) {
+ memflip8x8(inp, eg->plane_size, outp, row_bytes);
}
}
/* Set color */
- if (ep_num_comps == 1) {
+ if (eg->num_comps == 1) {
/* Don't set color (to enable user setting). */
putc('\015', prn_stream);
} else {
@@ -1982,10 +1988,10 @@ ep_print_image(FILE *prn_stream, char cmd, byte *data, int size)
}
- *(outp = ep_print_buf + ep_plane_size * img_rows) = 1; /* sentinel */
+ *(outp = eg->print_buf + eg->plane_size * img_rows) = 1; /* sentinel */
- p0 = p3 = ep_print_buf;
+ p0 = p3 = eg->print_buf;
/* print image p0 to p1 and h skip p1 to p2 if p2<outp,
@@ -2020,12 +2026,12 @@ ep_print_image(FILE *prn_stream, char cmd, byte *data, int size)
p0 = p2;
}
}
- return ep_print_image(prn_stream, 'R', 0, vskip2 + ln_idx);
+ return ep_print_image(prn_stream, eg, 'R', 0, eg->vskip2 + eg->ln_idx);
case 'R': /* Reset status */
- ln_idx = 0;
- vskip1 = size;
- vskip2 = 0;
- memset(ep_storage, 0, ep_storage_size_words * W);
+ eg->ln_idx = 0;
+ eg->vskip1 = size;
+ eg->vskip2 = 0;
+ memset(eg->storage, 0, eg->storage_size_words * W);
return 0;
default: /* This should not happen */
errprintf("ep_print_image: illegal command character `%c'.\n", cmd);
@@ -2062,6 +2068,10 @@ hp_colour_print_page(gx_device_printer * pdev, FILE * prn_stream, int ptype)
byte *out_row, *out_row_alt;
word *storage;
uint storage_size_words;
+ ep_globals eg;
+
+ memset(&eg, 0, sizeof(eg));
+ eg.img_rows=BJC_HEAD_ROWS;
/* Tricks and cheats ... */
switch (ptype) {
@@ -2098,7 +2108,7 @@ hp_colour_print_page(gx_device_printer * pdev, FILE * prn_stream, int ptype)
}
plane_size = calc_buffsize(line_size, storage_bpp);
- ep_plane_size = plane_size;
+ eg.plane_size = plane_size;
if (bits_per_pixel == 1) { /* Data printed direct from i/p */
databuff_size = 0; /* so no data buffer required, */
@@ -2123,9 +2133,9 @@ hp_colour_print_page(gx_device_printer * pdev, FILE * prn_stream, int ptype)
databuff_size + errbuff_size + outbuff_size) / W;
storage = (ulong *) gs_malloc(pdev->memory, storage_size_words, W, "hp_colour_print_page");
- ep_storage_size_words = (plane_size * (num_comps + 1)) / W * img_rows
+ eg.storage_size_words = (plane_size * (num_comps + 1)) / W * eg.img_rows
+ 16; /* Redundant space for sentinel and aligning. */
- ep_storage = (word *) gs_malloc(pdev->memory, ep_storage_size_words, W, "ep_print_buffer");
+ eg.storage = (word *) gs_malloc(pdev->memory, eg.storage_size_words, W, "ep_print_buffer");
/*
* The principal data pointers are stored as pairs of values, with
@@ -2141,12 +2151,12 @@ hp_colour_print_page(gx_device_printer * pdev, FILE * prn_stream, int ptype)
* plane_data: 4 (scan direction and alternating buffers)
*/
- if (storage == 0 || ep_storage == 0) /* can't allocate working area */
+ if (storage == 0 || eg.storage == 0) /* can't allocate working area */
return_error(gs_error_VMerror);
else {
int i, j;
byte *p = out_data = out_row = (byte *)storage;
- byte *ep_p = (byte *)ep_storage;
+ byte *ep_p = (byte *)eg.storage;
data[0] = data[1] = data[2] = p;
data[3] = p + databuff_size;
out_row_alt = out_row + plane_size * 2;
@@ -2174,14 +2184,14 @@ hp_colour_print_page(gx_device_printer * pdev, FILE * prn_stream, int ptype)
data[3] += databuff_size;
}
for (i = 0; i < num_comps; i++) {
- for (j = 0; j < img_rows; j++) {
- ep_raster_buf[i][j] = ep_p;
+ for (j = 0; j < eg.img_rows; j++) {
+ eg.raster_buf[i][j] = ep_p;
ep_p += plane_size;
}
/* Make a sentinel and align to word size. */
- ep_print_buf = (byte *)((word)(ep_p + sizeof(word)) & ~(sizeof(word)-1));
+ eg.print_buf = (byte *)((word)(ep_p + sizeof(word)) & ~(sizeof(word)-1));
}
- ep_num_comps = num_comps;
+ eg.num_comps = num_comps;
}
/* Initialize printer. */
@@ -2463,7 +2473,7 @@ hp_colour_print_page(gx_device_printer * pdev, FILE * prn_stream, int ptype)
fprintf(prn_stream,"\033_Y%c%c",
num_blank_lines & 0xff, (num_blank_lines >> 8) & 0xff);
} else if (ptype == ESC_P) {
- ep_print_image(prn_stream, 'B', 0, num_blank_lines);
+ ep_print_image(prn_stream, &eg, 'B', 0, num_blank_lines);
} else if (ptype == BJC600 || ptype == BJC800) {
bjc_v_skip(num_blank_lines, pdev, prn_stream);
} else if (num_blank_lines < this_pass) {
@@ -2733,7 +2743,7 @@ hp_colour_print_page(gx_device_printer * pdev, FILE * prn_stream, int ptype)
out_count, out_data, pdev, prn_stream);
if (i == 0) bjc_v_skip(1, pdev, prn_stream);
} else if (ptype == ESC_P)
- ep_print_image(prn_stream, (char)i, plane_data[scan][i], plane_size);
+ ep_print_image(prn_stream, &eg, (char)i, plane_data[scan][i], plane_size);
else
fprintf(prn_stream, "\033*b%d%c", out_count, "WVVV"[i]);
if (ptype < ESC_P)
@@ -2742,7 +2752,7 @@ hp_colour_print_page(gx_device_printer * pdev, FILE * prn_stream, int ptype)
} /* Transfer Raster Graphics ... */
if (ptype == ESC_P)
- ep_print_image(prn_stream, 'I', 0, 0); /* increment line index */
+ ep_print_image(prn_stream, &eg, 'I', 0, 0); /* increment line index */
scan = 1 - scan; /* toggle scan direction */
} /* Printing non-blank lines */
} /* for lnum ... */
@@ -2769,13 +2779,13 @@ hp_colour_print_page(gx_device_printer * pdev, FILE * prn_stream, int ptype)
else if (ptype == BJC600 || ptype == BJC800)
; /* Already done */
else if (ptype == ESC_P) {
- ep_print_image(prn_stream, 'F', 0, 0); /* flush print buffer */
+ ep_print_image(prn_stream, &eg, 'F', 0, 0); /* flush print buffer */
fputs("\014\033@", prn_stream); /* reset after eject page */
} else
fputs("\033&l0H", prn_stream);
/* free temporary storage */
- gs_free(pdev->memory, (char *) ep_storage, ep_storage_size_words, W, "ep_print_buffer");
+ gs_free(pdev->memory, (char *) eg.storage, eg.storage_size_words, W, "ep_print_buffer");
gs_free(pdev->memory, (char *) storage, storage_size_words, W, "hp_colour_print_page");
return 0;
diff --git a/gs/base/gdevifno.c b/gs/base/gdevifno.c
index 8079d35dc..6c4836643 100644
--- a/gs/base/gdevifno.c
+++ b/gs/base/gdevifno.c
@@ -45,7 +45,7 @@ struct Rectangle {
Point min;
Point max;
};
-static Point ZP = { 0, 0 };
+static const Point ZP = { 0, 0 };
static WImage* initwriteimage(FILE *f, Rectangle r, int ldepth, gs_memory_t *mem);
static int writeimageblock(WImage *w, uchar *data, int ndata, gs_memory_t *mem);
diff --git a/gs/base/gdevlbp8.c b/gs/base/gdevlbp8.c
index 98ce2816f..c1ed175ba 100644
--- a/gs/base/gdevlbp8.c
+++ b/gs/base/gdevlbp8.c
@@ -80,8 +80,6 @@ static const char lbp8_init[] = {
ESC, '[', '6', '3', 'k', /* Move 63 dots up (to top of printable area) */
};
-static const char *lbp8_end = NULL;
-
#ifdef NOCONTRIB
static const char lips3_init[] = {
ESC, '<', /* soft reset */
@@ -201,8 +199,9 @@ can_print_page(gx_device_printer *pdev, FILE *prn_stream,
/* Print an LBP-8 page. */
static int
lbp8_print_page(gx_device_printer *pdev, FILE *prn_stream)
-{ return can_print_page(pdev, prn_stream, lbp8_init, sizeof(lbp8_init),
- lbp8_end, sizeof(lbp8_end));
+{
+ return can_print_page(pdev, prn_stream, lbp8_init, sizeof(lbp8_init),
+ NULL, 0);
}
#ifdef NOCONTRIB
diff --git a/gs/base/gdevmgr.c b/gs/base/gdevmgr.c
index 284ce2bb9..d3ba9d1b9 100644
--- a/gs/base/gdevmgr.c
+++ b/gs/base/gdevmgr.c
@@ -22,11 +22,15 @@ struct gx_device_mgr_s {
gx_prn_device_common;
/* Add MGR specific variables */
int mgr_depth;
+ /* globals for greymapped printing */
+ unsigned char bgreytable[16];
+ unsigned char bgreybacktable[16];
+ unsigned char bgrey256table[256];
+ unsigned char bgrey256backtable[256];
+ struct nclut clut[256];
};
typedef struct gx_device_mgr_s gx_device_mgr;
-static struct nclut clut[256];
-
static unsigned int clut2mgr(int, int);
static void swap_bwords(unsigned char *, int);
@@ -163,14 +167,13 @@ mgr_print_page(gx_device_printer *pdev, FILE *pstream)
/* Print a gray-mapped page. */
-static unsigned char bgreytable[16], bgreybacktable[16];
-static unsigned char bgrey256table[256], bgrey256backtable[256];
static int
mgrN_print_page(gx_device_printer *pdev, FILE *pstream)
{ mgr_cursor cur;
int i = 0, j, k, mgr_wide;
uint mgr_line_size;
byte *bp, *data = NULL, *dp;
+ gx_device_mgr *mgr = (gx_device_mgr *)pdev;
int code = mgr_begin_page(bdev, pstream, &cur);
if ( code < 0 ) return code;
@@ -184,14 +187,14 @@ mgrN_print_page(gx_device_printer *pdev, FILE *pstream)
if ( bdev->mgr_depth == 4 )
for ( i = 0; i < 16; i++ ) {
- bgreytable[i] = mgrlut[LUT_BGREY][RGB_RED][i];
- bgreybacktable[bgreytable[i]] = i;
+ mgr->bgreytable[i] = mgrlut[LUT_BGREY][RGB_RED][i];
+ mgr->bgreybacktable[mgr->bgreytable[i]] = i;
}
if ( bdev->mgr_depth == 8 ) {
for ( i = 0; i < 16; i++ ) {
- bgrey256table[i] = mgrlut[LUT_BGREY][RGB_RED][i] << 4;
- bgrey256backtable[bgrey256table[i]] = i;
+ mgr->bgrey256table[i] = mgrlut[LUT_BGREY][RGB_RED][i] << 4;
+ mgr->bgrey256backtable[mgr->bgrey256table[i]] = i;
}
for ( i = 16,j = 0; i < 256; i++ ) {
for ( k = 0; k < 16; k++ )
@@ -199,8 +202,8 @@ mgrN_print_page(gx_device_printer *pdev, FILE *pstream)
j++;
break;
}
- bgrey256table[i] = j;
- bgrey256backtable[j++] = i;
+ mgr->bgrey256table[i] = j;
+ mgr->bgrey256backtable[j++] = i;
}
}
@@ -223,8 +226,8 @@ mgrN_print_page(gx_device_printer *pdev, FILE *pstream)
case 4:
for (i = 0,dp = data, bp = cur.data; i < mgr_line_size; i++) {
- *dp = bgreybacktable[*(bp++) >> 4] << 4;
- *(dp++) |= bgreybacktable[*(bp++) >> 4];
+ *dp = mgr->bgreybacktable[*(bp++) >> 4] << 4;
+ *(dp++) |= mgr->bgreybacktable[*(bp++) >> 4];
}
if ( fwrite(data, sizeof(byte), mgr_line_size, pstream) < mgr_line_size )
return_error(gs_error_ioerror);
@@ -232,7 +235,7 @@ mgrN_print_page(gx_device_printer *pdev, FILE *pstream)
case 8:
for (i = 0,bp = cur.data; i < mgr_line_size; i++, bp++)
- *bp = bgrey256backtable[*bp];
+ *bp = mgr->bgrey256backtable[*bp];
if ( fwrite(cur.data, sizeof(cur.data[0]), mgr_line_size, pstream)
< mgr_line_size )
return_error(gs_error_ioerror);
@@ -244,26 +247,26 @@ mgrN_print_page(gx_device_printer *pdev, FILE *pstream)
if (bdev->mgr_depth == 2) {
for (i = 0; i < 4; i++) {
- clut[i].colnum = i;
- clut[i].red = clut[i].green = clut[i].blue = clut2mgr(i, 2);
+ mgr->clut[i].colnum = i;
+ mgr->clut[i].red = mgr->clut[i].green = mgr->clut[i].blue = clut2mgr(i, 2);
}
}
if (bdev->mgr_depth == 4) {
for (i = 0; i < 16; i++) {
- clut[i].colnum = i;
- clut[i].red = clut[i].green = clut[i].blue = clut2mgr(bgreytable[i], 4);
+ mgr->clut[i].colnum = i;
+ mgr->clut[i].red = mgr->clut[i].green = mgr->clut[i].blue = clut2mgr(mgr->bgreytable[i], 4);
}
}
if (bdev->mgr_depth == 8) {
for (i = 0; i < 256; i++) {
- clut[i].colnum = i;
- clut[i].red = clut[i].green = clut[i].blue = clut2mgr(bgrey256table[i], 8);
+ mgr->clut[i].colnum = i;
+ mgr->clut[i].red = mgr->clut[i].green = mgr->clut[i].blue = clut2mgr(mgr->bgrey256table[i], 8);
}
}
#if !arch_is_big_endian
- swap_bwords( (unsigned char *) clut, sizeof( struct nclut ) * i );
+ swap_bwords( (unsigned char *) mgr->clut, sizeof( struct nclut ) * i );
#endif
- if ( fwrite(&clut, sizeof(struct nclut), i, pstream) < i )
+ if ( fwrite(&mgr->clut, sizeof(struct nclut), i, pstream) < i )
return_error(gs_error_ioerror);
return (code < 0 ? code : 0);
}
@@ -277,6 +280,7 @@ cmgrN_print_page(gx_device_printer *pdev, FILE *pstream)
byte *bp, *data, *dp;
ushort prgb[3];
unsigned char table[256], backtable[256];
+ gx_device_mgr *mgr = (gx_device_mgr *)pdev;
int code = mgr_begin_page(bdev, pstream, &cur);
if ( code < 0 ) return code;
@@ -328,26 +332,26 @@ cmgrN_print_page(gx_device_printer *pdev, FILE *pstream)
if (bdev->mgr_depth == 4) {
for (i = 0; i < 16; i++) {
pc_4bit_map_color_rgb((gx_device *)0, (gx_color_index) i, prgb);
- clut[i].colnum = i;
- clut[i].red = clut2mgr(prgb[0], 16);
- clut[i].green = clut2mgr(prgb[1], 16);
- clut[i].blue = clut2mgr(prgb[2], 16);
+ mgr->clut[i].colnum = i;
+ mgr->clut[i].red = clut2mgr(prgb[0], 16);
+ mgr->clut[i].green = clut2mgr(prgb[1], 16);
+ mgr->clut[i].blue = clut2mgr(prgb[2], 16);
}
}
if (bdev->mgr_depth == 8) {
for (i = 0; i < colors8; i++) {
mgr_8bit_map_color_rgb((gx_device *)0, (gx_color_index)
table[i], prgb);
- clut[i].colnum = MGR_RESERVEDCOLORS + i;
- clut[i].red = clut2mgr(prgb[0], 16);
- clut[i].green = clut2mgr(prgb[1], 16);
- clut[i].blue = clut2mgr(prgb[2], 16);
+ mgr->clut[i].colnum = MGR_RESERVEDCOLORS + i;
+ mgr->clut[i].red = clut2mgr(prgb[0], 16);
+ mgr->clut[i].green = clut2mgr(prgb[1], 16);
+ mgr->clut[i].blue = clut2mgr(prgb[2], 16);
}
}
#if !arch_is_big_endian
- swap_bwords( (unsigned char *) clut, sizeof( struct nclut ) * i );
+ swap_bwords( (unsigned char *) mgr->clut, sizeof( struct nclut ) * i );
#endif
- if ( fwrite(&clut, sizeof(struct nclut), i, pstream) < i )
+ if ( fwrite(&mgr->clut, sizeof(struct nclut), i, pstream) < i )
return_error(gs_error_ioerror);
return (code < 0 ? code : 0);
}
diff --git a/gs/base/gdevprn.c b/gs/base/gdevprn.c
index cea0ef157..25253e6ea 100644
--- a/gs/base/gdevprn.c
+++ b/gs/base/gdevprn.c
@@ -522,13 +522,13 @@ gdev_prn_get_params(gx_device * pdev, gs_param_list * plist)
/* Validate an OutputFile name by checking any %-formats. */
static int
-validate_output_file(const gs_param_string * ofs)
+validate_output_file(const gs_param_string * ofs, gs_memory_t *memory)
{
gs_parsed_file_name_t parsed;
const char *fmt;
return gx_parse_output_file_name(&parsed, &fmt, (const char *)ofs->data,
- ofs->size) >= 0;
+ ofs->size, memory) >= 0;
}
/* Put parameters. */
@@ -642,7 +642,7 @@ label:\
code = gs_error_invalidaccess;
}
else
- code = validate_output_file(&ofs);
+ code = validate_output_file(&ofs, pdev->memory);
if (code >= 0)
break;
/* falls through */
@@ -1263,7 +1263,7 @@ gdev_prn_close_printer(gx_device * pdev)
gs_parsed_file_name_t parsed;
const char *fmt;
int code = gx_parse_output_file_name(&parsed, &fmt, ppdev->fname,
- strlen(ppdev->fname));
+ strlen(ppdev->fname), pdev->memory);
if ((code >= 0 && fmt) /* file per page */ ||
ppdev->ReopenPerPage /* close and reopen for each page */
diff --git a/gs/base/gdevps.c b/gs/base/gdevps.c
index 143d150e0..4e1fee744 100644
--- a/gs/base/gdevps.c
+++ b/gs/base/gdevps.c
@@ -652,7 +652,8 @@ psw_is_separate_pages(gx_device_vector *const vdev)
{
const char *fmt;
gs_parsed_file_name_t parsed;
- int code = gx_parse_output_file_name(&parsed, &fmt, vdev->fname, strlen(vdev->fname));
+ int code = gx_parse_output_file_name(&parsed, &fmt, vdev->fname,
+ strlen(vdev->fname), vdev->memory);
return (code >= 0 && fmt != 0);
}
diff --git a/gs/base/gdevtsep.c b/gs/base/gdevtsep.c
index be51553c1..92d98a727 100644
--- a/gs/base/gdevtsep.c
+++ b/gs/base/gdevtsep.c
@@ -742,13 +742,13 @@ tiffsep1_prn_close(gx_device * pdev)
if (code < 0)
return code;
- code = gx_parse_output_file_name(&parsed, &fmt,
- tfdev->fname, strlen(tfdev->fname));
+ code = gx_parse_output_file_name(&parsed, &fmt, tfdev->fname,
+ strlen(tfdev->fname), pdev->memory);
if (code < 0)
return code;
/* If we are doing separate pages, delete the old default file */
- if (parsed.iodev == iodev_default) { /* filename includes "%nnd" */
+ if (parsed.iodev == iodev_default(pdev->memory)) { /* filename includes "%nnd" */
if (fmt) {
char compname[MAX_FILE_NAME_SIZE];
long count1 = pdev->PageCount;
@@ -1355,8 +1355,8 @@ tiffsep_print_page(gx_device_printer * pdev, FILE * file)
* Check if the file name has a numeric format. If so then we want to
* create individual separation files for each page of the input.
*/
- code = gx_parse_output_file_name(&parsed, &fmt,
- tfdev->fname, strlen(tfdev->fname));
+ code = gx_parse_output_file_name(&parsed, &fmt, tfdev->fname,
+ strlen(tfdev->fname), pdev->memory);
/* Write the page directory for the CMYK equivalent file. */
pdev->color_info.depth = 32; /* Create directory for 32 bit cmyk */
@@ -1520,12 +1520,12 @@ tiffsep1_print_page(gx_device_printer * pdev, FILE * file)
* Check if the file name has a numeric format. If so then we want to
* create individual separation files for each page of the input.
*/
- code = gx_parse_output_file_name(&parsed, &fmt,
- pdev->fname, strlen(pdev->fname));
+ code = gx_parse_output_file_name(&parsed, &fmt, pdev->fname,
+ strlen(pdev->fname), pdev->memory);
/* If the output file is on disk and the name contains a page #, */
/* then delete the previous file. */
- if (pdev->file != NULL && parsed.iodev == iodev_default && fmt) {
+ if (pdev->file != NULL && parsed.iodev == iodev_default(pdev->memory) && fmt) {
char compname[MAX_FILE_NAME_SIZE];
long count1 = pdev->PageCount;
@@ -1648,7 +1648,7 @@ tiffsep1_print_page(gx_device_printer * pdev, FILE * file)
#ifdef USE_32_BIT_WRITES
uint32_t *dest = dithered_line;
uint32_t val = 0;
- uint32_t *mask = &bit_order[0];
+ const uint32_t *mask = &bit_order[0];
#else /* example 8-bit code */
byte *dest = dithered_line;
byte val = 0;
diff --git a/gs/base/gdevupd.c b/gs/base/gdevupd.c
index d8b7bd094..b300924b9 100644
--- a/gs/base/gdevupd.c
+++ b/gs/base/gdevupd.c
@@ -1201,7 +1201,8 @@ upd_print_page(gx_device_printer *pdev, FILE *out)
const char *fmt;
if (NULL != udev->fname &&
- 0 <= gx_parse_output_file_name(&parsed, &fmt, udev->fname, strlen(udev->fname)) &&
+ 0 <= gx_parse_output_file_name(&parsed, &fmt, udev->fname,
+ strlen(udev->fname), udev->memory) &&
fmt
) {
if (0 < upd->strings[S_CLOSE].size)
@@ -1265,7 +1266,7 @@ upd_open(gx_device *pdev)
if((NULL != upd) &&
(NULL != upd->float_a[FA_MARGINS].data) &&
(4 == upd->float_a[FA_MARGINS].size) ) {
- static float m[4];
+ float m[4];
m[1] = upd->float_a[FA_MARGINS].data[1] / 72.0;
m[3] = upd->float_a[FA_MARGINS].data[3] / 72.0;
if(B_YFLIP & upd->flags) {
diff --git a/gs/base/gsdevice.c b/gs/base/gsdevice.c
index d6c692ff4..7c5f93734 100644
--- a/gs/base/gsdevice.c
+++ b/gs/base/gsdevice.c
@@ -839,7 +839,7 @@ gx_parse_output_format(gs_parsed_file_name_t *pfn, const char **pfmt)
*/
int
gx_parse_output_file_name(gs_parsed_file_name_t *pfn, const char **pfmt,
- const char *fname, uint fnlen)
+ const char *fname, uint fnlen, gs_memory_t *memory)
{
int code;
@@ -854,7 +854,7 @@ gx_parse_output_file_name(gs_parsed_file_name_t *pfn, const char **pfmt,
* If the file name begins with a %, it might be either an IODevice
* or a %nnd format. Check (carefully) for this case.
*/
- code = gs_parse_file_name(pfn, fname, fnlen);
+ code = gs_parse_file_name(pfn, fname, fnlen, memory);
if (code < 0) {
if (fname[0] == '%') {
/* not a recognized iodev -- may be a leading format descriptor */
@@ -867,13 +867,13 @@ gx_parse_output_file_name(gs_parsed_file_name_t *pfn, const char **pfmt,
}
if (!pfn->iodev) {
if ( (pfn->len == 1) && (pfn->fname[0] == '-') ) {
- pfn->iodev = gs_findiodevice((const byte *)"%stdout", 7);
+ pfn->iodev = gs_findiodevice(memory, (const byte *)"%stdout", 7);
pfn->fname = NULL;
} else if (pfn->fname[0] == '|') {
- pfn->iodev = gs_findiodevice((const byte *)"%pipe", 5);
+ pfn->iodev = gs_findiodevice(memory, (const byte *)"%pipe", 5);
pfn->fname++, pfn->len--;
} else
- pfn->iodev = iodev_default;
+ pfn->iodev = iodev_default(memory);
if (!pfn->iodev)
return_error(gs_error_undefinedfilename);
}
@@ -895,7 +895,8 @@ gx_device_open_output_file(const gx_device * dev, char *fname,
gs_parsed_file_name_t parsed;
const char *fmt;
char pfname[gp_file_name_sizeof];
- int code = gx_parse_output_file_name(&parsed, &fmt, fname, strlen(fname));
+ int code = gx_parse_output_file_name(&parsed, &fmt, fname, strlen(fname),
+ dev->memory);
if (code < 0)
return code;
@@ -925,7 +926,7 @@ gx_device_open_output_file(const gx_device * dev, char *fname,
parsed.fname = pfname;
parsed.len = strlen(parsed.fname);
}
- if (positionable || (parsed.iodev && parsed.iodev != iodev_default)) {
+ if (positionable || (parsed.iodev && parsed.iodev != iodev_default(dev->memory))) {
char fmode[4];
if (!parsed.fname)
@@ -953,7 +954,8 @@ gx_device_close_output_file(const gx_device * dev, const char *fname,
{
gs_parsed_file_name_t parsed;
const char *fmt;
- int code = gx_parse_output_file_name(&parsed, &fmt, fname, strlen(fname));
+ int code = gx_parse_output_file_name(&parsed, &fmt, fname, strlen(fname),
+ dev->memory);
if (code < 0)
return code;
@@ -961,7 +963,7 @@ gx_device_close_output_file(const gx_device * dev, const char *fname,
if (!strcmp(parsed.iodev->dname, "%stdout%"))
return 0;
/* NOTE: fname is unsubstituted if the name has any %nnd formats. */
- if (parsed.iodev != iodev_default)
+ if (parsed.iodev != iodev_default(dev->memory))
return parsed.iodev->procs.fclose(parsed.iodev, file);
}
gp_close_printer(file, (parsed.fname ? parsed.fname : fname));
diff --git a/gs/base/gsfname.c b/gs/base/gsfname.c
index c8c87d03d..8ec2ceb55 100644
--- a/gs/base/gsfname.c
+++ b/gs/base/gsfname.c
@@ -26,7 +26,8 @@
/* According to the Adobe documentation, %device and %device% */
/* are equivalent; both return name==NULL. */
int
-gs_parse_file_name(gs_parsed_file_name_t * pfn, const char *pname, uint len)
+gs_parse_file_name(gs_parsed_file_name_t * pfn, const char *pname, uint len,
+ const gs_memory_t *memory)
{
uint dlen;
const char *pdelim;
@@ -51,7 +52,7 @@ gs_parse_file_name(gs_parsed_file_name_t * pfn, const char *pname, uint len)
dlen = pdelim - pname;
pdelim++, len--;
}
- iodev = gs_findiodevice((const byte *)pname, dlen);
+ iodev = gs_findiodevice(memory, (const byte *)pname, dlen);
if (iodev == 0)
return_error(gs_error_undefinedfilename);
pfn->memory = 0;
@@ -66,7 +67,7 @@ int
gs_parse_real_file_name(gs_parsed_file_name_t * pfn, const char *pname,
uint len, gs_memory_t *mem, client_name_t cname)
{
- int code = gs_parse_file_name(pfn, pname, len);
+ int code = gs_parse_file_name(pfn, pname, len, mem);
if (code < 0)
return code;
@@ -84,7 +85,7 @@ gs_terminate_file_name(gs_parsed_file_name_t * pfn, gs_memory_t *mem,
char *fname;
if (pfn->iodev == NULL) /* no device */
- pfn->iodev = iodev_default;
+ pfn->iodev = iodev_default(mem);
if (pfn->memory)
return 0; /* already copied */
/* Copy the file name to a C string. */
diff --git a/gs/base/gsfname.h b/gs/base/gsfname.h
index 6809f047e..cc6bac3a0 100644
--- a/gs/base/gsfname.h
+++ b/gs/base/gsfname.h
@@ -39,7 +39,8 @@ typedef struct gs_parsed_file_name_s {
} gs_parsed_file_name_t;
/* Parse a file name into device and individual name. */
-int gs_parse_file_name(gs_parsed_file_name_t *, const char *, uint);
+int gs_parse_file_name(gs_parsed_file_name_t *, const char *, uint,
+ const gs_memory_t *);
/* Parse a real (non-device) file name and convert to a C string. */
int gs_parse_real_file_name(gs_parsed_file_name_t *, const char *, uint,
diff --git a/gs/base/gsht.c b/gs/base/gsht.c
index 8c0753257..d66900e2c 100644
--- a/gs/base/gsht.c
+++ b/gs/base/gsht.c
@@ -147,7 +147,7 @@ gs_setscreen(gs_state * pgs, gs_screen_halftone * phsp)
{
gs_screen_enum senum;
int code = gx_ht_process_screen(&senum, pgs, phsp,
- gs_currentaccuratescreens());
+ gs_currentaccuratescreens(pgs->memory));
if (code < 0)
return code;
diff --git a/gs/base/gsht1.c b/gs/base/gsht1.c
index b7870795c..5b5986dcf 100644
--- a/gs/base/gsht1.c
+++ b/gs/base/gsht1.c
@@ -172,7 +172,7 @@ gs_sethalftone_prepare(gs_state * pgs, gs_halftone * pht,
gx_ht_order_component *pocs = 0;
int code = 0;
- if (gs_currentusewts() && gs_sethalftone_try_wts(pht, pgs, pdht) == 0)
+ if (gs_currentusewts(mem) && gs_sethalftone_try_wts(pht, pgs, pdht) == 0)
return 0;
switch (pht->type) {
@@ -195,8 +195,8 @@ gs_sethalftone_prepare(gs_state * pgs, gs_halftone * pht,
int ci = cindex[i];
gx_ht_order_component *poc = &pocs[i];
- code = gx_ht_process_screen_memory(&senum, pgs,
- &phc[ci], gs_currentaccuratescreens(), mem);
+ code = gx_ht_process_screen_memory(&senum, pgs, &phc[ci],
+ gs_currentaccuratescreens(mem), mem);
if (code < 0)
break;
poc->corder = senum.order;
diff --git a/gs/base/gshtscr.c b/gs/base/gshtscr.c
index 519520a61..6c18ed37d 100644
--- a/gs/base/gshtscr.c
+++ b/gs/base/gshtscr.c
@@ -56,50 +56,51 @@ static RELOC_PTRS_WITH(screen_enum_reloc_ptrs, gs_screen_enum *eptr)
}
RELOC_PTRS_END
-/* Define the default value of AccurateScreens that affects setscreen
- and setcolorscreen. Note that this is effectively a global, and
- thus gets in the way of reentrancy. We'll want to fix that. */
-static bool screen_accurate_screens;
-
/* Default AccurateScreens control */
void
-gs_setaccuratescreens(bool accurate)
+gs_setaccuratescreens(gs_memory_t *mem, bool accurate)
{
- screen_accurate_screens = accurate;
+ gs_lib_ctx_t *ctx = gs_lib_ctx_get_interp_instance(mem);
+
+ ctx->screen_accurate_screens = accurate;
}
bool
-gs_currentaccuratescreens(void)
+gs_currentaccuratescreens(gs_memory_t *mem)
{
- return screen_accurate_screens;
-}
+ gs_lib_ctx_t *ctx = gs_lib_ctx_get_interp_instance(mem);
-/* As with AccurateScreens, this is also effectively a global. However,
- it is going away soon. */
-static bool screen_use_wts;
+ return ctx->screen_accurate_screens;
+}
void
-gs_setusewts(bool use_wts)
+gs_setusewts(gs_memory_t *mem, bool use_wts)
{
- screen_use_wts = use_wts;
+ gs_lib_ctx_t *ctx = gs_lib_ctx_get_interp_instance(mem);
+
+ ctx->screen_use_wts = use_wts;
}
+
bool
-gs_currentusewts(void)
+gs_currentusewts(gs_memory_t *mem)
{
- return screen_use_wts;
-}
+ gs_lib_ctx_t *ctx = gs_lib_ctx_get_interp_instance(mem);
-/* Define the MinScreenLevels user parameter similarly. */
-static uint screen_min_screen_levels;
+ return ctx->screen_use_wts;
+}
void
-gs_setminscreenlevels(uint levels)
+gs_setminscreenlevels(gs_memory_t *mem, uint levels)
{
- screen_min_screen_levels = levels;
+ gs_lib_ctx_t *ctx = gs_lib_ctx_get_interp_instance(mem);
+
+ ctx->screen_min_screen_levels = levels;
}
uint
-gs_currentminscreenlevels(void)
+gs_currentminscreenlevels(gs_memory_t *mem)
{
- return screen_min_screen_levels;
+ gs_lib_ctx_t *ctx = gs_lib_ctx_get_interp_instance(mem);
+
+ return ctx->screen_min_screen_levels;
}
/* Initialize the screen control statics at startup. */
@@ -107,8 +108,8 @@ init_proc(gs_gshtscr_init); /* check prototype */
int
gs_gshtscr_init(gs_memory_t *mem)
{
- gs_setaccuratescreens(false);
- gs_setminscreenlevels(1);
+ gs_setaccuratescreens(mem, false);
+ gs_setminscreenlevels(mem, 1);
return 0;
}
@@ -195,8 +196,10 @@ int
gs_screen_init(gs_screen_enum * penum, gs_state * pgs,
gs_screen_halftone * phsp)
{
+ gs_lib_ctx_t *ctx = gs_lib_ctx_get_interp_instance(pgs->memory);
+
return gs_screen_init_accurate(penum, pgs, phsp,
- screen_accurate_screens);
+ ctx->screen_accurate_screens);
}
int
gs_screen_init_memory(gs_screen_enum * penum, gs_state * pgs,
@@ -251,12 +254,13 @@ gs_screen_order_init_memory(gx_ht_order * porder, const gs_state * pgs,
gs_matrix imat;
ulong max_size = gx_ht_cache_default_bits_size();
int code;
+ gs_lib_ctx_t *ctx = gs_lib_ctx_get_interp_instance(mem);
if (phsp->frequency < 0.1)
return_error(gs_error_rangecheck);
gs_deviceinitialmatrix(gs_currentdevice(pgs), &imat);
code = pick_cell_size(phsp, &imat, max_size,
- screen_min_screen_levels, accurate,
+ ctx->screen_min_screen_levels, accurate,
&porder->params);
if (code < 0)
return code;
diff --git a/gs/base/gsiodev.c b/gs/base/gsiodev.c
index 14210bbd1..276db85b7 100644
--- a/gs/base/gsiodev.c
+++ b/gs/base/gsiodev.c
@@ -28,10 +28,6 @@
/* Import the IODevice table from gconf.c. */
extern_gx_io_device_table();
-/* Define a table of local copies of the IODevices, */
-/* allocated at startup. This just postpones the day of reckoning.... */
-static gx_io_device **io_device_table;
-
private_st_io_device();
gs_private_st_ptr(st_io_device_ptr, gx_io_device *, "gx_io_device *",
iodev_ptr_enum_ptrs, iodev_ptr_reloc_ptrs);
@@ -68,10 +64,11 @@ gs_iodev_init(gs_memory_t * mem)
gs_alloc_struct_array(mem, gx_io_device_table_count,
gx_io_device *, &st_io_device_ptr_element,
"gs_iodev_init(table)");
+ gs_lib_ctx_t *libctx = gs_lib_ctx_get_interp_instance(mem);
int i, j;
int code = 0;
- if (table == 0)
+ if ((table == NULL) || (libctx == NULL))
return_error(gs_error_VMerror);
for (i = 0; i < gx_io_device_table_count; ++i) {
gx_io_device *iodev =
@@ -83,8 +80,9 @@ gs_iodev_init(gs_memory_t * mem)
table[i] = iodev;
memcpy(table[i], gx_io_device_table[i], sizeof(gx_io_device));
}
- io_device_table = table;
- code = gs_register_struct_root(mem, NULL, (void **)&io_device_table,
+ libctx->io_device_table = table;
+ code = gs_register_struct_root(mem, NULL,
+ (void **)&libctx->io_device_table,
"io_device_table");
if (code < 0)
goto fail;
@@ -100,7 +98,7 @@ gs_iodev_init(gs_memory_t * mem)
for (; i >= 0; --i)
gs_free_object(mem, table[i - 1], "gs_iodev_init(iodev)");
gs_free_object(mem, table, "gs_iodev_init(table)");
- io_device_table = 0;
+ libctx->io_device_table = 0;
return (code < 0 ? code : gs_note_error(gs_error_VMerror));
}
@@ -263,24 +261,28 @@ os_get_params(gx_io_device * iodev, gs_param_list * plist)
/* Get the N'th IODevice from the known device table. */
gx_io_device *
-gs_getiodevice(int index)
+gs_getiodevice(const gs_memory_t *mem, int index)
{
- if (!io_device_table || index < 0 || index >= gx_io_device_table_count)
+ gs_lib_ctx_t *libctx = gs_lib_ctx_get_interp_instance(mem);
+
+ if (libctx == NULL || libctx->io_device_table == NULL ||
+ index < 0 || index >= gx_io_device_table_count)
return 0; /* index out of range */
- return io_device_table[index];
+ return libctx->io_device_table[index];
}
/* Look up an IODevice name. */
/* The name may be either %device or %device%. */
gx_io_device *
-gs_findiodevice(const byte * str, uint len)
+gs_findiodevice(const gs_memory_t *mem, const byte * str, uint len)
{
int i;
+ gs_lib_ctx_t *libctx = gs_lib_ctx_get_interp_instance(mem);
if (len > 1 && str[len - 1] == '%')
len--;
for (i = 0; i < gx_io_device_table_count; ++i) {
- gx_io_device *iodev = io_device_table[i];
+ gx_io_device *iodev = libctx->io_device_table[i];
const char *dname = iodev->dname;
if (dname && strlen(dname) == len + 1 && !memcmp(str, dname, len))
@@ -377,10 +379,10 @@ gs_enumerate_files_init(const char *pat, uint patlen, gs_memory_t * mem)
int code = 0;
/* Get the iodevice */
- code = gs_parse_file_name(&pfn, pat, patlen);
+ code = gs_parse_file_name(&pfn, pat, patlen, mem);
if (code < 0)
return NULL;
- iodev = (pfn.iodev == NULL) ? iodev_default : pfn.iodev;
+ iodev = (pfn.iodev == NULL) ? iodev_default(mem) : pfn.iodev;
/* Check for several conditions that just cause us to return success */
if (pfn.len == 0 || iodev->procs.enumerate_files == iodev_no_enumerate_files) {
diff --git a/gs/base/gslibctx.c b/gs/base/gslibctx.c
index bcfc7c843..3b32d3f84 100644
--- a/gs/base/gslibctx.c
+++ b/gs/base/gslibctx.c
@@ -19,6 +19,7 @@
/* Capture stdin/out/err before gs.h redefines them. */
#include "stdio_.h"
+#include "gp.h"
static void
gs_lib_ctx_get_real_stdio(FILE **in, FILE **out, FILE **err)
@@ -78,10 +79,23 @@ int gs_lib_ctx_init( gs_memory_t *mem )
pio->gs_next_id = 5; /* this implies that each thread has its own complete state */
pio->dict_auto_expand = false;
+ pio->screen_accurate_screens = false;
+ pio->screen_use_wts = false;
+ pio->screen_min_screen_levels = 0;
+ pio->BITTAG = GS_DEVICE_DOESNT_SUPPORT_TAGS;
+
+ gp_get_realtime(pio->real_time_0);
return 0;
}
+gs_lib_ctx_t *gs_lib_ctx_get_interp_instance(const gs_memory_t *mem)
+{
+ if (mem == NULL)
+ return NULL;
+ return mem->gs_lib_ctx;
+}
+
/* Provide a single point for all "C" stdout and stderr.
*/
diff --git a/gs/base/gslibctx.h b/gs/base/gslibctx.h
index c3ef56c71..2f014f6db 100644
--- a/gs/base/gslibctx.h
+++ b/gs/base/gslibctx.h
@@ -22,6 +22,16 @@
typedef struct name_table_s *name_table_ptr;
+/* graphical object tags */
+typedef enum {
+ GS_DEVICE_DOESNT_SUPPORT_TAGS = 0, /* default */
+ GS_UNKNOWN_TAG = 0x1,
+ GS_TEXT_TAG = 0x2,
+ GS_IMAGE_TAG = 0x4,
+ GS_PATH_TAG = 0x8,
+ GS_UNTOUCHED_TAG = 0x10
+} gs_object_tag_type_t;
+
typedef struct gs_lib_ctx_s
{
gs_memory_t *memory; /* mem->gs_lib_ctx->memory == mem */
@@ -47,6 +57,18 @@ typedef struct gs_lib_ctx_s
*/
/* Define whether dictionaries expand automatically when full. */
bool dict_auto_expand; /* ps dictionary: false level 1 true level 2 or 3 */
+ /* A table of local copies of the IODevices */
+ struct gx_io_device_s **io_device_table;
+ /* Define the default value of AccurateScreens that affects setscreen
+ and setcolorscreen. */
+ bool screen_accurate_screens;
+ bool screen_use_wts;
+ uint screen_min_screen_levels;
+ /* tag stuff */
+ gs_object_tag_type_t BITTAG;
+ /* real time clock 'bias' value. Not strictly required, but some FTS
+ * tests work better if realtime starts from 0 at boot time. */
+ long real_time_0[2];
} gs_lib_ctx_t;
/** initializes and stores itself in the given gs_memory_t pointer.
@@ -55,7 +77,7 @@ typedef struct gs_lib_ctx_s
*/
int gs_lib_ctx_init( gs_memory_t *mem );
-void *gs_lib_ctx_get_interp_instance( gs_memory_t *mem );
+gs_lib_ctx_t *gs_lib_ctx_get_interp_instance( const gs_memory_t *mem );
/* HACK to get at non garbage collection memory pointer
*
diff --git a/gs/base/gsnamecl.c b/gs/base/gsnamecl.c
index 1c6a618e3..4f6435d69 100644
--- a/gs/base/gsnamecl.c
+++ b/gs/base/gsnamecl.c
@@ -207,7 +207,7 @@ custom_color_callback_put_params(gs_state * pgs, gs_param_list * plist)
* Custom color processing can depend upon the type of object
* being imaged so we enable object type tagging.
*/
- gs_enable_object_tagging();
+ gs_enable_object_tagging(pgs->memory);
}
return 0;
diff --git a/gs/base/gsutil.c b/gs/base/gsutil.c
index 767f8695b..d8f9f5a79 100644
--- a/gs/base/gsutil.c
+++ b/gs/base/gsutil.c
@@ -282,27 +282,24 @@ int_rect_difference(gs_int_rect * outer, const gs_int_rect * inner,
return count;
}
-/* tag stuff */
-static gs_object_tag_type_t BITTAG = GS_DEVICE_DOESNT_SUPPORT_TAGS;
-
void
-gs_enable_object_tagging()
+gs_enable_object_tagging(gs_memory_t * mem)
{
- if (BITTAG == GS_DEVICE_DOESNT_SUPPORT_TAGS)
- BITTAG = GS_UNKNOWN_TAG;
+ if (mem->gs_lib_ctx->BITTAG == GS_DEVICE_DOESNT_SUPPORT_TAGS)
+ mem->gs_lib_ctx->BITTAG = GS_UNKNOWN_TAG;
}
void
gs_set_object_tag(gs_state * pgs, const gs_object_tag_type_t tag)
{
- if (BITTAG != GS_DEVICE_DOESNT_SUPPORT_TAGS) {
+ if (pgs->memory->gs_lib_ctx->BITTAG != GS_DEVICE_DOESNT_SUPPORT_TAGS) {
if ( pgs->object_tag != tag ) {
pgs->object_tag = tag;
/* mkromfs breaks this dependance
NB: needs to be fixed.
gx_unset_dev_color(pgs);
**/
- BITTAG = tag;
+ pgs->memory->gs_lib_ctx->BITTAG = tag;
/* the assumption is made that the caller will:
* gx_set_dev_color(pgs);
*/
@@ -311,8 +308,8 @@ gs_set_object_tag(gs_state * pgs, const gs_object_tag_type_t tag)
}
gs_object_tag_type_t
-gs_current_object_tag()
+gs_current_object_tag(gs_memory_t * mem)
{
- return BITTAG;
+ return mem->gs_lib_ctx->BITTAG;
}
diff --git a/gs/base/gsutil.h b/gs/base/gsutil.h
index eaa05bdcd..f022e85c1 100644
--- a/gs/base/gsutil.h
+++ b/gs/base/gsutil.h
@@ -58,22 +58,14 @@ bool string_match(const byte * str, uint len,
const byte * pstr, uint plen,
const string_match_params * psmp);
-/* graphical object tags */
-typedef enum {
- GS_DEVICE_DOESNT_SUPPORT_TAGS = 0, /* default */
- GS_UNKNOWN_TAG = 0x1,
- GS_TEXT_TAG = 0x2,
- GS_IMAGE_TAG = 0x4,
- GS_PATH_TAG = 0x8,
- GS_UNTOUCHED_TAG = 0x10
-} gs_object_tag_type_t;
+#include "gslibctx.h"
/* accessors for object tags */
-gs_object_tag_type_t gs_current_object_tag(void);
+gs_object_tag_type_t gs_current_object_tag(gs_memory_t *);
#include "gxstate.h"
void gs_set_object_tag(gs_state * pgs, const gs_object_tag_type_t tag);
-void gs_enable_object_tagging(void);
+void gs_enable_object_tagging(gs_memory_t *);
#endif /* gsutil_INCLUDED */
diff --git a/gs/base/gxcllzw.c b/gs/base/gxcllzw.c
index 313cc982e..e0e49e1f1 100644
--- a/gs/base/gxcllzw.c
+++ b/gs/base/gxcllzw.c
@@ -19,28 +19,25 @@
#include "gxclmem.h"
#include "slzwx.h"
-static stream_LZW_state cl_LZWE_state;
-static stream_LZW_state cl_LZWD_state;
-
-/* Initialize the states to be copied. */
-int
-gs_cl_lzw_init(gs_memory_t * mem)
+/* Return the prototypes for compressing/decompressing the band list. */
+const stream_template *clist_compressor_template(void)
{
- s_LZW_set_defaults((stream_state *) & cl_LZWE_state);
- cl_LZWE_state.template = &s_LZWE_template;
- s_LZW_set_defaults((stream_state *) & cl_LZWD_state);
- cl_LZWD_state.template = &s_LZWD_template;
- return 0;
+ return &cl_LZWE_template;
}
-
-/* Return the prototypes for compressing/decompressing the band list. */
-const stream_state *
-clist_compressor_state(void *client_data)
+const stream_template *
+clist_decompressor_state(void)
+{
+ return &cl_LZWD_state;
+}
+void
+clist_compressor_init(stream_state *state)
{
- return (const stream_state *)&cl_LZWE_state;
+ s_LZW_set_defaults(state);
+ state->template = &s_LZWE_template;
}
-const stream_state *
-clist_decompressor_state(void *client_data)
+void
+clist_decompressor_init(stream_state *state)
{
- return (const stream_state *)&cl_LZWD_state;
+ s_LZW_set_defaults(state);
+ state->template = &s_LZWD_template;
}
diff --git a/gs/base/gxclmem.c b/gs/base/gxclmem.c
index 2ef41cbe9..b4c6f7048 100644
--- a/gs/base/gxclmem.c
+++ b/gs/base/gxclmem.c
@@ -130,8 +130,17 @@ LIMITATIONS.
COMPRESSION_THRESHOLD amount of data. The threshold should be at
least as large as the fixed overhead of the compressor plus the
decompressor, plus the expected compressed size of a block that size.
+
+ As a testing measure we have a a define TEST_BAND_LIST_COMPRESSION
+ which, if set, will set the threshold to a low value so as to cause
+ compression to trigger.
*/
-static const long COMPRESSION_THRESHOLD = 500000000; /* 0.5 Gb for host machines */
+static const long COMPRESSION_THRESHOLD =
+#ifdef TEST_BAND_LIST_COMPRESSION
+ 1024; /* Low value to force compression */
+#else
+ 500000000; /* 0.5 Gb for host machines */
+#endif
#define NEED_TO_COMPRESS(f)\
((f)->ok_to_compress && (f)->total_space > COMPRESSION_THRESHOLD)
@@ -281,8 +290,7 @@ memfile_fopen(char fname[gp_file_name_sizeof], const char *fmode,
LOG_MEMFILE_BLK *log_block, *new_log_block;
int i;
int num_log_blocks = (f->log_length + MEMFILE_DATA_SIZE - 1) / MEMFILE_DATA_SIZE;
- const stream_state *decompress_proto = clist_decompressor_state(NULL);
- const stream_template *decompress_template = decompress_proto->template;
+ const stream_template *decompress_template = clist_decompressor_template();
new_log_block = MALLOC(f, num_log_blocks * sizeof(LOG_MEMFILE_BLK), "memfile_fopen" );
if (new_log_block == NULL) {
@@ -308,8 +316,7 @@ memfile_fopen(char fname[gp_file_name_sizeof], const char *fmode,
code = gs_note_error(gs_error_VMerror);
goto finish;
}
- memcpy(f->decompress_state, decompress_proto,
- gs_struct_type_size(decompress_template->stype));
+ clist_decompressor_init(f->decompress_state);
f->decompress_state->memory = mem;
if (decompress_template->set_defaults)
(*decompress_template->set_defaults) (f->decompress_state);
@@ -353,10 +360,8 @@ memfile_fopen(char fname[gp_file_name_sizeof], const char *fmode,
f->compress_state = 0; /* make clean for GC */
f->decompress_state = 0;
if (f->ok_to_compress) {
- const stream_state *compress_proto = clist_compressor_state(NULL);
- const stream_state *decompress_proto = clist_decompressor_state(NULL);
- const stream_template *compress_template = compress_proto->template;
- const stream_template *decompress_template = decompress_proto->template;
+ const stream_template *compress_template = clist_compressor_template();
+ const stream_template *decompress_template = clist_decompressor_template();
f->compress_state =
gs_alloc_struct(mem, stream_state, compress_template->stype,
@@ -369,11 +374,9 @@ memfile_fopen(char fname[gp_file_name_sizeof], const char *fmode,
code = gs_note_error(gs_error_VMerror);
goto finish;
}
- memcpy(f->compress_state, compress_proto,
- gs_struct_type_size(compress_template->stype));
+ clist_compressor_init(f->compress_state);
+ clist_decompressor_init(f->decompress_state);
f->compress_state->memory = mem;
- memcpy(f->decompress_state, decompress_proto,
- gs_struct_type_size(decompress_template->stype));
f->decompress_state->memory = mem;
if (compress_template->set_defaults)
(*compress_template->set_defaults) (f->compress_state);
diff --git a/gs/base/gxclmem.h b/gs/base/gxclmem.h
index 588e75f2f..d7779a1f0 100644
--- a/gs/base/gxclmem.h
+++ b/gs/base/gxclmem.h
@@ -135,8 +135,9 @@ typedef struct MEMFILE_s MEMFILE;
/* Declare the procedures for returning the prototype filter states */
/* for compressing and decompressing the band list. */
-const stream_state *clist_compressor_state(void *);
-const stream_state *clist_decompressor_state(void *);
-int gs_cl_zlib_init(gs_memory_t * mem);
+const stream_template *clist_compressor_template(void);
+const stream_template *clist_decompressor_template(void);
+void clist_compressor_init(stream_state *state);
+void clist_decompressor_init(stream_state *state);
#endif /* gxclmem_INCLUDED */
diff --git a/gs/base/gxclzlib.c b/gs/base/gxclzlib.c
index 988d75d5a..992ff9f46 100644
--- a/gs/base/gxclzlib.c
+++ b/gs/base/gxclzlib.c
@@ -20,30 +20,28 @@
#include "gxclmem.h"
#include "szlibx.h"
-static stream_zlib_state cl_zlibE_state;
-static stream_zlib_state cl_zlibD_state;
-
-/* Initialize the states to be copied. */
-int
-gs_cl_zlib_init(gs_memory_t * mem)
+/* Return the prototypes for compressing/decompressing the band list. */
+const stream_template *
+clist_compressor_template(void)
{
- s_zlib_set_defaults((stream_state *) & cl_zlibE_state);
- cl_zlibE_state.no_wrapper = true;
- cl_zlibE_state.template = &s_zlibE_template;
- s_zlib_set_defaults((stream_state *) & cl_zlibD_state);
- cl_zlibD_state.no_wrapper = true;
- cl_zlibD_state.template = &s_zlibD_template;
- return 0;
+ return &s_zlibE_template;
}
-
-/* Return the prototypes for compressing/decompressing the band list. */
-const stream_state *
-clist_compressor_state(void *client_data)
+const stream_template *
+clist_decompressor_template(void)
+{
+ return &s_zlibD_template;
+}
+void
+clist_compressor_init(stream_state *state)
{
- return (const stream_state *)&cl_zlibE_state;
+ s_zlib_set_defaults(state);
+ ((stream_zlib_state *)state)->no_wrapper = true;
+ state->template = &s_zlibE_template;
}
-const stream_state *
-clist_decompressor_state(void *client_data)
+void
+clist_decompressor_init(stream_state *state)
{
- return (const stream_state *)&cl_zlibD_state;
+ s_zlib_set_defaults(state);
+ ((stream_zlib_state *)state)->no_wrapper = true;
+ state->template = &s_zlibD_template;
}
diff --git a/gs/base/gxdevice.h b/gs/base/gxdevice.h
index 27b2b0961..afb82fd17 100644
--- a/gs/base/gxdevice.h
+++ b/gs/base/gxdevice.h
@@ -423,7 +423,7 @@ void gx_device_copy_params(gx_device *dev, const gx_device *target);
*/
int gx_parse_output_file_name(gs_parsed_file_name_t *pfn,
const char **pfmt, const char *fname,
- uint len);
+ uint len, gs_memory_t *memory);
/*
* Open the output file for a device. Note that if the file name is empty,
diff --git a/gs/base/gxht.h b/gs/base/gxht.h
index f5b026cd2..050ee80fa 100644
--- a/gs/base/gxht.h
+++ b/gs/base/gxht.h
@@ -206,16 +206,15 @@ extern_st(st_halftone);
/*
* Set/get the default AccurateScreens value (for set[color]screen).
- * Note that this value is stored in a static variable.
*/
-void gs_setaccuratescreens(bool);
-bool gs_currentaccuratescreens(void);
+void gs_setaccuratescreens(gs_memory_t *, bool);
+bool gs_currentaccuratescreens(gs_memory_t *);
/*
- * Set/get the value for UseWTS. Also a static, but it's going away.
+ * Set/get the value for UseWTS.
*/
-void gs_setusewts(bool);
-bool gs_currentusewts(void);
+void gs_setusewts(gs_memory_t *, bool);
+bool gs_currentusewts(gs_memory_t *);
/* Initiate screen sampling with optional AccurateScreens. */
int gs_screen_init_memory(gs_screen_enum *, gs_state *,
@@ -228,10 +227,8 @@ int gs_screen_init_memory(gs_screen_enum *, gs_state *,
/*
* Set/get the MinScreenLevels value.
- *
- * Note that this value is stored in a static variable.
*/
-void gs_setminscreenlevels(uint);
-uint gs_currentminscreenlevels(void);
+void gs_setminscreenlevels(gs_memory_t *, uint);
+uint gs_currentminscreenlevels(gs_memory_t *);
#endif /* gxht_INCLUDED */
diff --git a/gs/base/gxiodev.h b/gs/base/gxiodev.h
index 33618b527..586b0839b 100644
--- a/gs/base/gxiodev.h
+++ b/gs/base/gxiodev.h
@@ -160,12 +160,12 @@ iodev_proc_fopen(iodev_os_fopen);
iodev_proc_fclose(iodev_os_fclose);
/* Get the N'th IODevice. */
-gx_io_device *gs_getiodevice(int);
+gx_io_device *gs_getiodevice(const gs_memory_t *,int);
-#define iodev_default (gs_getiodevice(0))
+#define iodev_default(mem) (gs_getiodevice(mem,0))
/* Look up an IODevice name. */
-gx_io_device *gs_findiodevice(const byte *, uint);
+gx_io_device *gs_findiodevice(const gs_memory_t *,const byte *, uint);
/* Get and put IODevice parameters. */
int gs_getdevparams(gx_io_device *, gs_param_list *);
diff --git a/gs/base/gxstroke.c b/gs/base/gxstroke.c
index 339f23644..34b0c2a0b 100644
--- a/gs/base/gxstroke.c
+++ b/gs/base/gxstroke.c
@@ -1626,9 +1626,15 @@ stroke_add_fast(gx_path * ppath, gx_path * rpath, bool ensure_closed, int first,
l = (double)(plp->width.x) /* x1 */ * (nplp->width.y) /* y2 */;
r = (double)(nplp->width.x) /* x2 */ * (plp->width.y) /* y1 */;
- if ((l == r) && (join == gs_join_round))
- return add_pie_cap(ppath, &plp->e);
- else if ((l > r) ^ reflected) {
+ if ((l == r) && (join == gs_join_round)) {
+ /* Do a cap, and leave the point on the same side as it was
+ * originally. This is required for paths that come to a stop
+ * and then reverse themselves, but may produce more complexity
+ * than we'd really like at the ends of smooth beziers. */
+ code = add_pie_cap(ppath, &plp->e);
+ if (code >= 0)
+ code = gx_path_add_line(ppath, plp->e.co.x, plp->e.co.y);
+ } else if ((l > r) ^ reflected) {
/* CCW rotation. Join in the forward path. "Underjoin" in the
* reverse path. */
/* RJW: Ideally we should include the "|| flags" clause in
diff --git a/gs/base/lib.mak b/gs/base/lib.mak
index 05f8128f8..7923187e5 100644
--- a/gs/base/lib.mak
+++ b/gs/base/lib.mak
@@ -1779,7 +1779,6 @@ $(GLD)clmemory.dev : $(LIB_MAK) $(ECHOGS_XE) $(clmemory_) $(GLD)s$(BAND_LIST_COM
$(ADDMOD) $(GLD)clmemory -include $(GLD)s$(BAND_LIST_COMPRESSOR)e
$(ADDMOD) $(GLD)clmemory -include $(GLD)s$(BAND_LIST_COMPRESSOR)d
$(ADDMOD) $(GLD)clmemory -init gxclmem
- $(ADDMOD) $(GLD)clmemory -init cl_$(BAND_LIST_COMPRESSOR)
gxclmem_h=$(GLSRC)gxclmem.h $(gxclio_h) $(strimpl_h)
diff --git a/gs/base/sfxcommon.c b/gs/base/sfxcommon.c
index d5692ca94..74342f85f 100644
--- a/gs/base/sfxcommon.c
+++ b/gs/base/sfxcommon.c
@@ -65,7 +65,7 @@ file_open_stream(const char *fname, uint len, const char *file_access,
char fmode[4]; /* r/w/a, [+], [b], null */
if (!iodev)
- iodev = iodev_default;
+ iodev = iodev_default(mem);
code = file_prepare_stream(fname, len, file_access, buffer_size, ps, fmode, mem);
if (code < 0)
return code;
diff --git a/gs/base/strmio.c b/gs/base/strmio.c
index 8b1d8fb6a..1bf796e4a 100644
--- a/gs/base/strmio.c
+++ b/gs/base/strmio.c
@@ -40,7 +40,7 @@ sfopen(const char *path, const char *mode, gs_memory_t *memory)
iodev_proc_open_file((*open_file));
gs_memory_t *mem = (memory == NULL) ? gs_lib_ctx_get_non_gc_memory_t() : memory;
- int code = gs_parse_file_name(&pfn, path, strlen(path));
+ int code = gs_parse_file_name(&pfn, path, strlen(path), mem);
if (code < 0) {
# define EMSG "sfopen: gs_parse_file_name failed.\n"
errwrite(EMSG, strlen(EMSG));
@@ -54,7 +54,7 @@ sfopen(const char *path, const char *mode, gs_memory_t *memory)
return NULL;
}
if (pfn.iodev == NULL)
- pfn.iodev = iodev_default;
+ pfn.iodev = iodev_default(mem);
open_file = pfn.iodev->procs.open_file;
if (open_file == 0)
code = file_open_stream(pfn.fname, pfn.len, mode, 2048, &s,
diff --git a/gs/base/szlibd.c b/gs/base/szlibd.c
index a4b2e1e50..8a42488e4 100644
--- a/gs/base/szlibd.c
+++ b/gs/base/szlibd.c
@@ -106,6 +106,7 @@ s_zlibD_release(stream_state * st)
{
stream_zlib_state *const ss = (stream_zlib_state *)st;
+ if (ss->dynamic != NULL)
inflateEnd(&ss->dynamic->zstate);
s_zlib_free_dynamic_state(ss);
}
diff --git a/gs/base/ttinterp.c b/gs/base/ttinterp.c
index 6c17fd36d..e83d4bf57 100644
--- a/gs/base/ttinterp.c
+++ b/gs/base/ttinterp.c
@@ -4626,6 +4626,7 @@ static int nInstrCount=0;
A = CUR.stack[CUR.args + 1];
B = CUR.stack[CUR.args];
+
#if 0
if ( BOUNDS( A, CUR.zp0.n_points ) )
#else
@@ -4633,7 +4634,7 @@ static int nInstrCount=0;
if ( BOUNDS( A, CUR.zp0.n_points + 2 ) )
#endif
{
- CUR.error = TT_Err_Invalid_Reference;
+/* CUR.error = TT_Err_Invalid_Reference;*/
return;
}