summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vrhel <michael.vrhel@artifex.com>2010-04-16 05:41:18 +0000
committerMichael Vrhel <michael.vrhel@artifex.com>2010-04-16 05:41:18 +0000
commit0e4191426e2a7476606c999be6ac8e26a30041f5 (patch)
tree5531dea41400c5d71d1f34f6093c149e1ba0b8c7
parent0ab52696fc1c6d58d879615aa8a49476f34e6add (diff)
downloadghostpdl-0e4191426e2a7476606c999be6ac8e26a30041f5.tar.gz
Merge of trunk into icc branch through rev 11084
git-svn-id: http://svn.ghostscript.com/ghostscript/branches/icc_work@11085 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r--gs/Resource/Init/FAPIcidfmap (renamed from gs/lib/FAPIcidfmap)64
-rw-r--r--gs/Resource/Init/FAPIconfig14
-rw-r--r--gs/Resource/Init/FAPIfontmap (renamed from gs/lib/FAPIfontmap)66
-rw-r--r--gs/Resource/Init/gs_fapi.ps16
-rw-r--r--gs/Resource/Init/gs_fonts.ps2
-rwxr-xr-xgs/autogen.sh6
-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
-rw-r--r--gs/contrib/japanese/gdev10v.c4
-rwxr-xr-xgs/ghostscript-ufst.vcproj87
-rw-r--r--gs/jasper/src/appl/imgcmp.c1
-rw-r--r--gs/jasper/src/appl/imginfo.c1
-rw-r--r--gs/jasper/src/appl/jasper.c1
-rw-r--r--gs/jasper/src/libjasper/base/jas_image.c194
-rw-r--r--gs/jasper/src/libjasper/base/jas_init.c75
-rw-r--r--gs/jasper/src/libjasper/include/jasper/jas_image.h9
-rw-r--r--gs/jbig2dec/jbig2_symbol_dict.c5
-rw-r--r--gs/jbig2dec/jbig2dec.c2
-rw-r--r--gs/lib/FAPIconfig14
-rw-r--r--gs/lib/mkcidfm.ps2
-rw-r--r--gs/psi/fapi_ft.c195
-rw-r--r--gs/psi/fapiufst.c26
-rw-r--r--gs/psi/files.h11
-rw-r--r--gs/psi/icontext.c28
-rw-r--r--gs/psi/icstate.h2
-rw-r--r--gs/psi/ifapi.h2
-rw-r--r--gs/psi/interp.c4
-rw-r--r--gs/psi/msvc32.mak52
-rw-r--r--gs/psi/zcolor.c10
-rw-r--r--gs/psi/zcontext.c4
-rw-r--r--gs/psi/zcontrol.c2
-rw-r--r--gs/psi/zfapi.c82
-rw-r--r--gs/psi/zfcid0.c8
-rw-r--r--gs/psi/zfcid1.c2
-rw-r--r--gs/psi/zfile.c73
-rw-r--r--gs/psi/zfileio.c14
-rw-r--r--gs/psi/zfrsd.c7
-rw-r--r--gs/psi/zht.c2
-rw-r--r--gs/psi/zht2.c9
-rw-r--r--gs/psi/zicc.c4
-rw-r--r--gs/psi/ziodev.c4
-rw-r--r--gs/psi/ziodev2.c4
-rw-r--r--gs/psi/ziodevsc.c6
-rw-r--r--gs/psi/zmisc.c17
-rw-r--r--gs/psi/zshade.c2
-rw-r--r--gs/psi/ztoken.c4
-rw-r--r--gs/psi/zusparam.c12
-rw-r--r--gs/psi/zvmem.c20
-rw-r--r--gs/tiff/libtiff/tif_aux.c80
-rw-r--r--gs/tiff/libtiff/tif_dir.c34
-rw-r--r--gs/tiff/libtiff/tif_dir.h2
-rw-r--r--gs/tiff/libtiff/tif_dirinfo.c2
-rw-r--r--gs/tiff/libtiff/tif_jpeg.c2
-rw-r--r--gs/tiff/libtiff/tif_ojpeg.c6
-rw-r--r--gs/tiff/man/TIFFGetField.3tiff60
-rwxr-xr-xgs/toolbin/localcluster/build.pl67
-rwxr-xr-xgs/toolbin/localcluster/cachearchive.pl2
-rwxr-xr-xgs/toolbin/localcluster/clustermaster.pl20
-rwxr-xr-xgs/toolbin/localcluster/compare.pl6
-rwxr-xr-xgs/toolbin/localcluster/run.pl52
94 files changed, 1275 insertions, 836 deletions
diff --git a/gs/lib/FAPIcidfmap b/gs/Resource/Init/FAPIcidfmap
index a231ce6d2..697a2a176 100644
--- a/gs/lib/FAPIcidfmap
+++ b/gs/Resource/Init/FAPIcidfmap
@@ -1,32 +1,32 @@
-%!
-% $Id$
-% This is a sample map file for FAPI CID fonts.
-
-%
-% The map is a set of records like this :
-%
-% /CIDfont_name options_dict ;
-%
-% where options_dict is a dictionary with the following entries :
-%
-% Key Type Description
-% Path string Absolute path to font file, or relative path to font file from
-% the GS_EXTFONTPATH value.
-% CIDFontType interger PostScript type for this CID font. Only 0 is currently allowed.
-% Note that this is unrelated to the real type of the font file -
-% the bridge will perform format conversion.
-% FAPI name Name of the renderer to be used with the font. Only /UFST is now allowed.
-% SubfontId integer (optional) Index of the font in font collection, such as FCO or TTC.
-% It is being ignored if /Path doesn't specify a collection.
-% Default value is 0.
-% CSI array Must have strongly 2 elements.
-% The first element of the array specifies Ordering of CIDSystemInfo.
-% The second element specifies Supplement of CIDSystemInfo.
-%
-% Use regular Postscript syntax.
-%
-% Examples :
-%
-% /Ryumin-Medium << /Path (msgothic.ttc) /CIDFontType 0 /FAPI /UFST /CSI [(Japan1) 2] >> ;
-% /HeiseiKakuGo-W5 << /Path (F:/WIN2000/Fonts/BATANG.TTC) /CIDFontType 0 /FAPI /UFST /CSI [(Japan1) 2] >> ;
-
+%!
+% $Id: FAPIcidfmap 6826 2006-05-31 15:29:52Z leonardo $
+% This is a sample map file for FAPI CID fonts.
+
+%
+% The map is a set of records like this :
+%
+% /CIDfont_name options_dict ;
+%
+% where options_dict is a dictionary with the following entries :
+%
+% Key Type Description
+% Path string Absolute path to font file, or relative path to font file from
+% the GS_EXTFONTPATH value.
+% CIDFontType interger PostScript type for this CID font. Only 0 is currently allowed.
+% Note that this is unrelated to the real type of the font file -
+% the bridge will perform format conversion.
+% FAPI name Name of the renderer to be used with the font. Only /UFST is now allowed.
+% SubfontId integer (optional) Index of the font in font collection, such as FCO or TTC.
+% It is being ignored if /Path doesn't specify a collection.
+% Default value is 0.
+% CSI array Must have strongly 2 elements.
+% The first element of the array specifies Ordering of CIDSystemInfo.
+% The second element specifies Supplement of CIDSystemInfo.
+%
+% Use regular Postscript syntax.
+%
+% Examples :
+%
+% /Ryumin-Medium << /Path (msgothic.ttc) /CIDFontType 0 /FAPI /UFST /CSI [(Japan1) 2] >> ;
+% /HeiseiKakuGo-W5 << /Path (F:/WIN2000/Fonts/BATANG.TTC) /CIDFontType 0 /FAPI /UFST /CSI [(Japan1) 2] >> ;
+
diff --git a/gs/Resource/Init/FAPIconfig b/gs/Resource/Init/FAPIconfig
new file mode 100644
index 000000000..aa18975c5
--- /dev/null
+++ b/gs/Resource/Init/FAPIconfig
@@ -0,0 +1,14 @@
+%!
+% $Id: FAPIconfig 6870 2006-06-20 16:31:15Z leonardo $
+% This is configuration file for FAPI client.
+%
+% /FontPath (/Fonts) % A default directory for FAPI-handled font files path in FAPIfontmap.
+% /CIDFontPath (/CIDFonts) % A default directory for FAPI-handled CID font files path in FAPIcidfmap.
+% /HookDiskFonts [1 2 9 11 42] % FontType values for disk PS fonts to be redirected to FAPI.
+% /HookEmbeddedFonts [1 2 9 11 42] % FontType values for embedded PS fonts to be redirected to FAPI.
+%
+% Values allowed for HookDiskFonts and HookEmbeddedFonts are 1, 2, 9, 11, 42.
+% "Disk fonts" are fonts being installed to Ghostscript with 'lib/Fontmap' or with GS_FONTPATH,
+% and CID font resource files.
+% "Embedded fonts" are fonts and CID fonts being embedded into a document.
+
diff --git a/gs/lib/FAPIfontmap b/gs/Resource/Init/FAPIfontmap
index af3f24085..a3d4ca3f3 100644
--- a/gs/lib/FAPIfontmap
+++ b/gs/Resource/Init/FAPIfontmap
@@ -1,33 +1,33 @@
-%!
-% $Id$
-% This is a sample map file for FAPI fonts.
-
-%
-% The map is a set of records like this :
-%
-% /font_name options_dict ;
-%
-% where options_dict is a dictionary with the following entries :
-%
-% Key Type Description
-% Path string Absolute path to font file, or relative path to font file from
-% the GS_EXTFONTPATH value.
-% FontType interger PostScript type for this font. Only 1 and 42 are currently allowed.
-% Note that this is unrelated to the real type of the font file -
-% the bridge will perform format conversion.
-% FAPI name Name of the renderer to be used with the font. Only /AgfaUFST is now allowed.
-% SubfontId integer (optional) Index of the font in font collection, such as FCO or TTC.
-% It is being ignored if /Path doesn't specify a collection.
-% Default value is 0.
-% Decoding name (optional) The name of a Decoding resource to be used with the font.
-% If specified, "xlatmap" doesn't work for this font.
-%
-% Use regular Postscript syntax.
-%
-% Examples :
-%
-% /ArialTT << /Path (arial.ttf) /FontType 1 /FAPI /UFST >> ;
-% /CourierTT << /Path (F:/WIN2000/Fonts/cour.ttf) /FontType 1 /FAPI /UFST >> ;
-% /FCO1 << /Path (F:/AFPL/ufst/fontdata/MTFONTS/PCLPS3/MT1/PCLP3__G.FCO) /FontType 42 /FAPI /UFST /SubfontId 10 >> ;
-%
-
+%!
+% $Id: FAPIfontmap 6870 2006-06-20 16:31:15Z leonardo $
+% This is a sample map file for FAPI fonts.
+
+%
+% The map is a set of records like this :
+%
+% /font_name options_dict ;
+%
+% where options_dict is a dictionary with the following entries :
+%
+% Key Type Description
+% Path string Absolute path to font file, or relative path to font file from
+% the GS_EXTFONTPATH value.
+% FontType interger PostScript type for this font. Only 1 and 42 are currently allowed.
+% Note that this is unrelated to the real type of the font file -
+% the bridge will perform format conversion.
+% FAPI name Name of the renderer to be used with the font. Only /AgfaUFST is now allowed.
+% SubfontId integer (optional) Index of the font in font collection, such as FCO or TTC.
+% It is being ignored if /Path doesn't specify a collection.
+% Default value is 0.
+% Decoding name (optional) The name of a Decoding resource to be used with the font.
+% If specified, "xlatmap" doesn't work for this font.
+%
+% Use regular Postscript syntax.
+%
+% Examples :
+%
+% /ArialTT << /Path (arial.ttf) /FontType 1 /FAPI /UFST >> ;
+% /CourierTT << /Path (F:/WIN2000/Fonts/cour.ttf) /FontType 1 /FAPI /UFST >> ;
+% /FCO1 << /Path (F:/AFPL/ufst/fontdata/MTFONTS/PCLPS3/MT1/PCLP3__G.FCO) /FontType 42 /FAPI /UFST /SubfontId 10 >> ;
+%
+
diff --git a/gs/Resource/Init/gs_fapi.ps b/gs/Resource/Init/gs_fapi.ps
index 56da0fa40..6ab72986a 100644
--- a/gs/Resource/Init/gs_fapi.ps
+++ b/gs/Resource/Init/gs_fapi.ps
@@ -37,6 +37,13 @@ languagelevel 2 .setlanguagelevel
} {
exch pop exch pop 0 eq
} ifelse
+ %
+ % Temporary switch to allow override of FAPI and fallback to GS font rendering
+ % to be removed at some date after FT integration is completed and released.
+ %
+ /DisableFAPI where {
+ /DisableFAPI get not and
+ }if
% The code above assumes that only the requested parameter is rendered.
% The commented-out code below may be useful for general case.
% Keeping it for a while.
@@ -55,6 +62,15 @@ languagelevel 2 .setlanguagelevel
/Config
<<
+ % Setup the default FAPIConfig values to default to FreeType
+ %
+ /FontPath (/Fonts) % A default directory for FAPI-handled font files
+ % path in FAPIfontmap.
+ /CIDFontPath (/CIDFonts) % A default directory for FAPI-handled CIDfont % files path in FAPIcidfmap.
+ /HookDiskFonts [1 2 9 11 42] % FontType values for disk PS fonts to be
+ % redirected to FAPI.
+ /HookEmbeddedFonts [1 2 9 11 42] % FontType values for embedded PS fonts to be
+ % redirected to FAPI.
systemdict /FAPIconfig known {/FAPIconfig .systemvar} {(FAPIconfig)} ifelse .runlibfile
/ServerOptions 2 dict
>> def
diff --git a/gs/Resource/Init/gs_fonts.ps b/gs/Resource/Init/gs_fonts.ps
index e935a5403..446c1cda2 100644
--- a/gs/Resource/Init/gs_fonts.ps
+++ b/gs/Resource/Init/gs_fonts.ps
@@ -645,7 +645,7 @@ buildfontdict 3 /.buildfont3 cvx put
[(Univers) /Helvetica 0]
] readonly def
/.substituteproperties [
- [(It) 9] [(Oblique) 1]
+ [(It) 1] [(Oblique) 1]
[(Black) 2] [(Bd) 2] [(Bold) 2] [(bold) 2] [(Demi) 2] [(Heavy) 2] [(Sb) 2]
[(Cn) 4] [(Cond) 4] [(Narrow) 4] [(Pkg) 4] [(Compr) 4]
[(Serif) 8] [(Sans) -8]
diff --git a/gs/autogen.sh b/gs/autogen.sh
index ee50a88e2..733ec2c40 100755
--- a/gs/autogen.sh
+++ b/gs/autogen.sh
@@ -25,12 +25,6 @@ rm -f configure.ac Makefile.in
ln -s base/configure.ac .
ln -s base/Makefile.in .
-#echo " aclocal $ACLOCAL_FLAGS"
-#aclocal $ACLOCAL_FLAGS || exit 1
-#echo " autoheader"
-#autoheader || exit 1
-#echo " automake --add-missing $AUTOMAKE_FLAGS"
-#automake --add-missing $AUTOMAKE_FLAGS || exit 1
echo " running autoconf"
autoconf || exit 1
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;
}
diff --git a/gs/contrib/japanese/gdev10v.c b/gs/contrib/japanese/gdev10v.c
index 21a3ab8e9..73419949a 100644
--- a/gs/contrib/japanese/gdev10v.c
+++ b/gs/contrib/japanese/gdev10v.c
@@ -234,12 +234,12 @@ bj10v_print_page(gx_device_printer *pdev, FILE *prn_stream)
/* them so badly that this code is faster. */
{ register long *zip = (long *)in;
register int zcnt = line_size;
- static long zeroes[4] = { 0, 0, 0, 0 };
+ static const long zeroes[4] = { 0, 0, 0, 0 };
for ( ; zcnt >= 4 * sizeof(long); zip += 4, zcnt -= 4 * sizeof(long) )
{ if ( zip[0] | zip[1] | zip[2] | zip[3] )
goto notz;
}
- if ( !memcmp(in, (char *)zeroes, zcnt) )
+ if ( !memcmp(in, (const char *)zeroes, zcnt) )
{ /* Line is all zero, skip */
if (++blank_lines >= y_skip_unit) {
lnum += y_skip_unit;
diff --git a/gs/ghostscript-ufst.vcproj b/gs/ghostscript-ufst.vcproj
new file mode 100755
index 000000000..8f95fe259
--- /dev/null
+++ b/gs/ghostscript-ufst.vcproj
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="ghostscript-ufst"
+ ProjectGUID="{A93401D2-5D65-4BA5-BD0F-419310537401}"
+ RootNamespace="ghostscript-ufst"
+ Keyword="MakeFileProj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="0"
+ >
+ <Tool
+ Name="VCNMakeTool"
+ BuildCommandLine="nmake -f psi\msvc32.mak UFST_ROOT=C:\cvs\artifex\ghostpcl\ufst SBR=1 DEVSTUDIO= ufst-debug &amp;&amp; nmake -f psi\msvc32.mak UFST_ROOT=C:\ufst DEVSTUDIO= ufst-debugbsc"
+ ReBuildCommandLine="nmake -f psi\msvc32.mak UFST_ROOT=C:\ufst DEVSTUDIO= ufst-debugclean &amp;&amp; nmake -f psi\msvc32.mak UFST_ROOT=C:\ufst SBR=1 DEVSTUDIO= ufst-debug &amp;&amp; nmake -f psi\msvc32.mak UFST_ROOT=C:\ufst DEVSTUDIO= ufst-debugbsc"
+ CleanCommandLine="nmake -f psi\msvc32.mak UFST_ROOT=C:\ufst DEVSTUDIO= ufst-debugclean"
+ Output="ghostscript-ufst.exe"
+ PreprocessorDefinitions="WIN32;_DEBUG"
+ IncludeSearchPath=""
+ ForcedIncludes=""
+ AssemblySearchPath=""
+ ForcedUsingAssemblies=""
+ CompileAsManaged=""
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="0"
+ >
+ <Tool
+ Name="VCNMakeTool"
+ BuildCommandLine="nmake -f psi\msvc32.mak UFST_ROOT=C:\ufst SBR=1 DEVSTUDIO= ufst &amp;&amp; nmake -f psi\msvc32.mak UFST_ROOT=C:\ufst DEVSTUDIO= ufst-bsc"
+ ReBuildCommandLine="nmake -f psi\msvc32.mak UFST_ROOT=C:\ufst DEVSTUDIO= ufst-clean &amp;&amp; nmake -f psi\msvc32.mak UFST_ROOT=C:\ufst SBR=1 DEVSTUDIO= ufst &amp;&amp; nmake -f psi\msvc32.mak UFST_ROOT=C:\ufst DEVSTUDIO= ufst-bsc"
+ CleanCommandLine="nmake -f psi\msvc32.mak UFST_ROOT=C:\ufst DEVSTUDIO= ufst-clean"
+ Output="ghostscript-ufst.exe"
+ PreprocessorDefinitions="WIN32;NDEBUG"
+ IncludeSearchPath=""
+ ForcedIncludes=""
+ AssemblySearchPath=""
+ ForcedUsingAssemblies=""
+ CompileAsManaged=""
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <File
+ RelativePath=".\readme.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/gs/jasper/src/appl/imgcmp.c b/gs/jasper/src/appl/imgcmp.c
index 2acc4dd2f..ef8f82a18 100644
--- a/gs/jasper/src/appl/imgcmp.c
+++ b/gs/jasper/src/appl/imgcmp.c
@@ -381,7 +381,6 @@ int main(int argc, char **argv)
jas_image_destroy(origimage);
jas_image_destroy(reconimage);
- jas_image_clearfmts();
return EXIT_SUCCESS;
}
diff --git a/gs/jasper/src/appl/imginfo.c b/gs/jasper/src/appl/imginfo.c
index 25b151d7b..70b8edf33 100644
--- a/gs/jasper/src/appl/imginfo.c
+++ b/gs/jasper/src/appl/imginfo.c
@@ -199,7 +199,6 @@ int main(int argc, char **argv)
jas_eprintf("%s %d %d %d %d %ld\n", fmtname, numcmpts, width, height, depth, (long) jas_image_rawsize(image));
jas_image_destroy(image);
- jas_image_clearfmts();
return EXIT_SUCCESS;
}
diff --git a/gs/jasper/src/appl/jasper.c b/gs/jasper/src/appl/jasper.c
index 1c1038d60..c083ecde9 100644
--- a/gs/jasper/src/appl/jasper.c
+++ b/gs/jasper/src/appl/jasper.c
@@ -298,7 +298,6 @@ int main(int argc, char **argv)
cmdopts_destroy(cmdopts);
jas_image_destroy(image);
- jas_image_clearfmts();
/* Success at last! :-) */
return EXIT_SUCCESS;
diff --git a/gs/jasper/src/libjasper/base/jas_image.c b/gs/jasper/src/libjasper/base/jas_image.c
index 99b77b5cc..524d0804d 100644
--- a/gs/jasper/src/libjasper/base/jas_image.c
+++ b/gs/jasper/src/libjasper/base/jas_image.c
@@ -119,8 +119,145 @@ static void jas_image_dump(jas_image_t *image, FILE *out);
* Global data.
\******************************************************************************/
-static int jas_image_numfmts = 0;
-static jas_image_fmtinfo_t jas_image_fmtinfos[JAS_IMAGE_MAXFMTS];
+#define MIF_ID 0
+#define PNM_ID 1
+#define BMP_ID 2
+#define RAS_ID 3
+#define JP2_ID 4
+#define JPC_ID 5
+#define JPG_ID 6
+#define PGX_ID 7
+
+const jas_image_fmtinfo_t jas_image_fmtinfos[] = {
+#if !defined(EXCLUDE_MIF_SUPPORT)
+ {
+ MIF_ID,
+ "mif",
+ "mif",
+ "My Image Format (MIF)",
+ {
+ mif_decode,
+ mif_encode,
+ mif_validate,
+ },
+ },
+#endif /* EXCLUDE_MIF_SUPPORT */
+#if !defined(EXCLUDE_PNM_SUPPORT)
+ {
+ PNM_ID,
+ "pnm",
+ "pnm",
+ "Portable Graymap/Pixmap (PNM)",
+ {
+ pnm_decode,
+ pnm_encode,
+ pnm_validate,
+ },
+ },
+ {
+ PNM_ID,
+ "pnm",
+ "pgm",
+ "Portable Graymap/Pixmap (PNM)",
+ {
+ pnm_decode,
+ pnm_encode,
+ pnm_validate,
+ },
+ },
+ {
+ PNM_ID,
+ "pnm",
+ "ppm",
+ "Portable Graymap/Pixmap (PNM)",
+ {
+ pnm_decode,
+ pnm_encode,
+ pnm_validate,
+ },
+ },
+#endif /* EXCLUDE_PNM_SUPPORT */
+#if !defined(EXCLUDE_BMP_SUPPORT)
+ {
+ BMP_ID,
+ "bmp",
+ "bmp",
+ "Microsoft Bitmap (BMP)",
+ {
+ bmp_decode,
+ bmp_encode,
+ bmp_validate,
+ },
+ },
+#endif /* EXCLUDE_BMP_SUPPORT */
+#if !defined(EXCLUDE_RAS_SUPPORT)
+ {
+ RAS_ID,
+ "ras",
+ "ras",
+ "Sun Rastefile (RAS)",
+ {
+ ras_decode,
+ ras_encode,
+ ras_validate,
+ },
+ },
+#endif /* EXCLUDE_RAS_SUPPORT */
+#if !defined(EXCLUDE_JP2_SUPPORT)
+ {
+ JP2_ID,
+ "jp2",
+ "jp2",
+ "JPEG-2000 JP2 File Format Syntax (ISO/IEC 15444-1)",
+ {
+ jp2_decode,
+ jp2_encode,
+ jp2_validate,
+ },
+ },
+ {
+ JPC_ID,
+ "jpc",
+ "jpc",
+ "JPEG-2000 Code Stream Syntax (ISO/IEC 15444-1)",
+ {
+ jpc_decode,
+ jpc_encode,
+ jpc_validate,
+ },
+ },
+#endif /* EXCLUDE_JP2_SUPPORT */
+#if !defined(EXCLUDE_JPG_SUPPORT)
+ {
+ JPG_ID,
+ "jpg",
+ "jpg",
+ "JPEG (ISO/IEC 10918-1)",
+
+ {
+ jpg_decode,
+ jpg_encode,
+ jpg_validate,
+ },
+ },
+#endif /* EXCLUDE_JPG_SUPPORT */
+#if !defined(EXCLUDE_PGX_SUPPORT)
+ {
+ PGX_ID,
+ "pgx",
+ "pgx",
+ "JPEG-2000 VM Format (PGX)",
+ {
+ pgx_decode,
+ pgx_encode,
+ pgx_validate,
+ }
+ }
+#endif /* EXCLUDE_PGX_SUPPORT */
+};
+
+const int jas_image_numfmts =
+ sizeof(jas_image_fmtinfos) / sizeof(jas_image_fmtinfos[0]);
/******************************************************************************\
* Create and destroy operations.
@@ -516,59 +653,6 @@ int jas_image_writecmpt(jas_image_t *image, int cmptno, jas_image_coord_t x, jas
return 0;
}
-/******************************************************************************\
-* File format operations.
-\******************************************************************************/
-
-void jas_image_clearfmts()
-{
- int i;
- jas_image_fmtinfo_t *fmtinfo;
- for (i = 0; i < jas_image_numfmts; ++i) {
- fmtinfo = &jas_image_fmtinfos[i];
- if (fmtinfo->name) {
- jas_free(fmtinfo->name);
- fmtinfo->name = 0;
- }
- if (fmtinfo->ext) {
- jas_free(fmtinfo->ext);
- fmtinfo->ext = 0;
- }
- if (fmtinfo->desc) {
- jas_free(fmtinfo->desc);
- fmtinfo->desc = 0;
- }
- }
- jas_image_numfmts = 0;
-}
-
-int jas_image_addfmt(int id, char *name, char *ext, char *desc,
- jas_image_fmtops_t *ops)
-{
- jas_image_fmtinfo_t *fmtinfo;
- assert(id >= 0 && name && ext && ops);
- if (jas_image_numfmts >= JAS_IMAGE_MAXFMTS) {
- return -1;
- }
- fmtinfo = &jas_image_fmtinfos[jas_image_numfmts];
- fmtinfo->id = id;
- if (!(fmtinfo->name = jas_strdup(name))) {
- return -1;
- }
- if (!(fmtinfo->ext = jas_strdup(ext))) {
- jas_free(fmtinfo->name);
- return -1;
- }
- if (!(fmtinfo->desc = jas_strdup(desc))) {
- jas_free(fmtinfo->name);
- jas_free(fmtinfo->ext);
- return -1;
- }
- fmtinfo->ops = *ops;
- ++jas_image_numfmts;
- return 0;
-}
-
int jas_image_strtofmt(char *name)
{
jas_image_fmtinfo_t *fmtinfo;
diff --git a/gs/jasper/src/libjasper/base/jas_init.c b/gs/jasper/src/libjasper/base/jas_init.c
index 1d518ed9d..64bf32dbd 100644
--- a/gs/jasper/src/libjasper/base/jas_init.c
+++ b/gs/jasper/src/libjasper/base/jas_init.c
@@ -78,79 +78,6 @@
/* Initialize the image format table. */
int jas_init()
{
- jas_image_fmtops_t fmtops;
- int fmtid;
-
- fmtid = 0;
-
-#if !defined(EXCLUDE_MIF_SUPPORT)
- fmtops.decode = mif_decode;
- fmtops.encode = mif_encode;
- fmtops.validate = mif_validate;
- jas_image_addfmt(fmtid, "mif", "mif", "My Image Format (MIF)", &fmtops);
- ++fmtid;
-#endif
-
-#if !defined(EXCLUDE_PNM_SUPPORT)
- fmtops.decode = pnm_decode;
- fmtops.encode = pnm_encode;
- fmtops.validate = pnm_validate;
- jas_image_addfmt(fmtid, "pnm", "pnm", "Portable Graymap/Pixmap (PNM)",
- &fmtops);
- jas_image_addfmt(fmtid, "pnm", "pgm", "Portable Graymap/Pixmap (PNM)",
- &fmtops);
- jas_image_addfmt(fmtid, "pnm", "ppm", "Portable Graymap/Pixmap (PNM)",
- &fmtops);
- ++fmtid;
-#endif
-
-#if !defined(EXCLUDE_BMP_SUPPORT)
- fmtops.decode = bmp_decode;
- fmtops.encode = bmp_encode;
- fmtops.validate = bmp_validate;
- jas_image_addfmt(fmtid, "bmp", "bmp", "Microsoft Bitmap (BMP)", &fmtops);
- ++fmtid;
-#endif
-
-#if !defined(EXCLUDE_RAS_SUPPORT)
- fmtops.decode = ras_decode;
- fmtops.encode = ras_encode;
- fmtops.validate = ras_validate;
- jas_image_addfmt(fmtid, "ras", "ras", "Sun Rasterfile (RAS)", &fmtops);
- ++fmtid;
-#endif
-
-#if !defined(EXCLUDE_JP2_SUPPORT)
- fmtops.decode = jp2_decode;
- fmtops.encode = jp2_encode;
- fmtops.validate = jp2_validate;
- jas_image_addfmt(fmtid, "jp2", "jp2",
- "JPEG-2000 JP2 File Format Syntax (ISO/IEC 15444-1)", &fmtops);
- ++fmtid;
- fmtops.decode = jpc_decode;
- fmtops.encode = jpc_encode;
- fmtops.validate = jpc_validate;
- jas_image_addfmt(fmtid, "jpc", "jpc",
- "JPEG-2000 Code Stream Syntax (ISO/IEC 15444-1)", &fmtops);
- ++fmtid;
-#endif
-
-#if !defined(EXCLUDE_JPG_SUPPORT)
- fmtops.decode = jpg_decode;
- fmtops.encode = jpg_encode;
- fmtops.validate = jpg_validate;
- jas_image_addfmt(fmtid, "jpg", "jpg", "JPEG (ISO/IEC 10918-1)", &fmtops);
- ++fmtid;
-#endif
-
-#if !defined(EXCLUDE_PGX_SUPPORT)
- fmtops.decode = pgx_decode;
- fmtops.encode = pgx_encode;
- fmtops.validate = pgx_validate;
- jas_image_addfmt(fmtid, "pgx", "pgx", "JPEG-2000 VM Format (PGX)", &fmtops);
- ++fmtid;
-#endif
-
/* We must not register the JasPer library exit handler until after
at least one memory allocation is performed. This is desirable
as it ensures that the JasPer exit handler is called before the
@@ -162,5 +89,5 @@ int jas_init()
void jas_cleanup()
{
- jas_image_clearfmts();
+ /* stub */
}
diff --git a/gs/jasper/src/libjasper/include/jasper/jas_image.h b/gs/jasper/src/libjasper/include/jasper/jas_image.h
index df5c3e88b..aef354c1d 100644
--- a/gs/jasper/src/libjasper/include/jasper/jas_image.h
+++ b/gs/jasper/src/libjasper/include/jasper/jas_image.h
@@ -255,9 +255,6 @@ typedef struct {
* File format related classes.
\******************************************************************************/
-#define JAS_IMAGE_MAXFMTS 32
-/* The maximum number of image data formats supported. */
-
/* Image format-dependent operations. */
typedef struct {
@@ -280,13 +277,13 @@ typedef struct {
int id;
/* The ID for this format. */
- char *name;
+ char name[4];
/* The name by which this format is identified. */
- char *ext;
+ char ext[4];
/* The file name extension associated with this format. */
- char *desc;
+ char desc[60];
/* A brief description of the format. */
jas_image_fmtops_t ops;
diff --git a/gs/jbig2dec/jbig2_symbol_dict.c b/gs/jbig2dec/jbig2_symbol_dict.c
index 25a635c85..b5ee8b114 100644
--- a/gs/jbig2dec/jbig2_symbol_dict.c
+++ b/gs/jbig2dec/jbig2_symbol_dict.c
@@ -696,7 +696,7 @@ jbig2_decode_symbol_dict(Jbig2Ctx *ctx,
exrunlength = params->SDNUMEXSYMS;
else
code = jbig2_arith_int_decode(IAEX, as, &exrunlength);
- if (exrunlength > params->SDNUMEXSYMS - j) {
+ if (exflag && exrunlength > params->SDNUMEXSYMS - j) {
jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
"runlength too large in export symbol table (%d > %d - %d)\n",
exrunlength, params->SDNUMEXSYMS, j);
@@ -705,11 +705,12 @@ jbig2_decode_symbol_dict(Jbig2Ctx *ctx,
SDEXSYMS = NULL;
break;
}
- for(k = 0; k < exrunlength; k++)
+ for(k = 0; k < exrunlength; k++) {
if (exflag) {
SDEXSYMS->glyphs[j++] = (i < m) ?
jbig2_image_clone(ctx, params->SDINSYMS->glyphs[i]) :
jbig2_image_clone(ctx, SDNEWSYMS->glyphs[i-m]);
+ }
i++;
}
exflag = !exflag;
diff --git a/gs/jbig2dec/jbig2dec.c b/gs/jbig2dec/jbig2dec.c
index 22f7a99ec..84e0c5b88 100644
--- a/gs/jbig2dec/jbig2dec.c
+++ b/gs/jbig2dec/jbig2dec.c
@@ -141,7 +141,7 @@ parse_options(int argc, char *argv[], jbig2dec_params_t *params)
while (1) {
option = getopt_long(argc, argv,
- "Vh?qvdo:t:", long_options, &option_idx);
+ "Vh?qv:do:t:", long_options, &option_idx);
if (option == -1) break;
switch (option) {
diff --git a/gs/lib/FAPIconfig b/gs/lib/FAPIconfig
deleted file mode 100644
index 5c86a102f..000000000
--- a/gs/lib/FAPIconfig
+++ /dev/null
@@ -1,14 +0,0 @@
-%!
-% $Id$
-% This is configuration file for FAPI client.
-
-/FontPath (/Fonts) % A default directory for FAPI-handled font files path in FAPIfontmap.
-/CIDFontPath (/CIDFonts) % A default directory for FAPI-handled CID font files path in FAPIcidfmap.
-/HookDiskFonts [1 2 9 11 42] % FontType values for disk PS fonts to be redirected to FAPI.
-/HookEmbeddedFonts [1 2 9 11 42] % FontType values for embedded PS fonts to be redirected to FAPI.
-
-% Values allowed for HookDiskFonts and HookEmbeddedFonts are 1, 2, 9, 11, 42.
-% "Disk fonts" are fonts being installed to Ghostscript with 'lib/Fontmap' or with GS_FONTPATH,
-% and CID font resource files.
-% "Embedded fonts" are fonts and CID fonts being embedded into a document.
-
diff --git a/gs/lib/mkcidfm.ps b/gs/lib/mkcidfm.ps
index 20d8ad84c..d6215a910 100644
--- a/gs/lib/mkcidfm.ps
+++ b/gs/lib/mkcidfm.ps
@@ -747,6 +747,7 @@ FONTDIR writecidfmap
% msmincho.ttc 10057108 5.01 19321 (3,1)(3,10) MS-Mincho/MS-PMincho 932
% mssong.ttf 2569040 1.00 26304 (1,0)(3,1) MS Song
% mssong.ttf 2569116 1.00 26304 (1,0)(3,1) MS Song
+% msyh.ttf 12263452 6.01 22562 (0,3)(3,1)(3,10) MSYH
% msyh.ttf 15067744 0.71 29207 (0,3)(3,1)(3,10) MicrosoftYaHei
% msyh.ttf 15043584 0.75 29126 (0,3)(3,1)(3,10) MicrosoftYaHei
% msyh.ttf 15044440 5.00 29126 (0,3)(3,1)(3,10) MicrosoftYaHei
@@ -754,6 +755,7 @@ FONTDIR writecidfmap
% msyhbd.ttf 14707012 0.71 29240 (0,3)(3,1)(3,10) MicrosoftYaHei
% msyhbd.ttf 14685876 5.00 29126 (0,3)(3,1)(3,10) MicrosoftYaHei
% nbatang.ttf 32472240 3.00 49636 (3,1) New Batang
+% ngulim.ttf 8862844 2.00 23181 (3,1) New Gulim
% ngulim.ttf 25719724 3.10 49284 (3,1) New Gulim
% ogulim.ttf 830340 1.00 2921 (3,1) Gulim Old Hangul Jamo
% palmm.ttf 13816928 001.003 27560 (3,1) PMmy
diff --git a/gs/psi/fapi_ft.c b/gs/psi/fapi_ft.c
index c7c65e071..e845f6459 100644
--- a/gs/psi/fapi_ft.c
+++ b/gs/psi/fapi_ft.c
@@ -26,6 +26,8 @@ Started by Graham Asher, 6th June 2002.
#include "write_t2.h"
#include "math_.h"
#include "gserror.h"
+#include "gsmemory.h"
+#include "gsmalloc.h"
#include "gxfixed.h"
/* FreeType headers */
@@ -33,6 +35,10 @@ Started by Graham Asher, 6th June 2002.
#include FT_FREETYPE_H
#include FT_INCREMENTAL_H
#include FT_GLYPH_H
+#include FT_SYSTEM_H
+#include FT_MODULE_H
+#include FT_TRIGONOMETRY_H
+#include FT_OUTLINE_H
/* Note: structure definitions here start with FF_, which stands for 'FAPI FreeType". */
@@ -42,6 +48,8 @@ typedef struct FF_server_s
FT_Library freetype_library;
FT_OutlineGlyph outline_glyph;
FT_BitmapGlyph bitmap_glyph;
+ gs_memory_t *mem;
+ FT_Memory ftmemory;
} FF_server;
typedef struct FF_face_s
@@ -79,10 +87,51 @@ typedef struct FT_IncrementalRec_
FAPI_metrics_type metrics_type; /* determines whether metrics are replaced, added, etc. */
} FT_IncrementalRec;
+
+FT_CALLBACK_DEF( void* )
+FF_alloc( FT_Memory memory, long size)
+{
+ gs_memory_t *mem = (gs_memory_t *)memory->user;
+
+ return(gs_malloc (mem, size, 1, "FF_alloc"));
+}
+
+FT_CALLBACK_DEF( void* )
+FF_realloc(FT_Memory memory, long cur_size, long new_size, void* block)
+{
+ gs_memory_t *mem = (gs_memory_t *)memory->user;
+ void *tmp;
+
+ if (cur_size == new_size) {
+ return (block);
+ }
+
+ tmp = gs_malloc (mem, new_size, 1, "FF_realloc");
+
+
+ if (tmp && block) {
+ memcpy (tmp, block, min(cur_size, new_size));
+
+ gs_free (mem, block, 0, 0, "FF_realloc");
+ }
+
+ return(tmp);
+}
+
+FT_CALLBACK_DEF( void )
+FF_free(FT_Memory memory, void* block)
+{
+ gs_memory_t *mem = (gs_memory_t *)memory->user;
+ gs_free (mem, block, 0, 0, "FF_free");
+}
+
+
static FF_face *
-new_face(FT_Face a_ft_face, FT_Incremental_InterfaceRec *a_ft_inc_int, unsigned char *a_font_data)
+new_face(FAPI_server *a_server, FT_Face a_ft_face, FT_Incremental_InterfaceRec *a_ft_inc_int, unsigned char *a_font_data)
{
- FF_face* face = (FF_face *)malloc(sizeof(FF_face));
+ FF_server *s = (FF_server*)a_server;
+
+ FF_face *face = (FF_face *)FF_alloc(s->ftmemory, sizeof(FF_face));
if (face)
{
face->ft_face = a_ft_face;
@@ -93,21 +142,25 @@ new_face(FT_Face a_ft_face, FT_Incremental_InterfaceRec *a_ft_inc_int, unsigned
}
static void
-delete_face(FF_face *a_face)
+delete_face(FAPI_server *a_server, FF_face *a_face)
{
if (a_face)
{
+ FF_server *s = (FF_server*)a_server;
+
FT_Done_Face(a_face->ft_face);
- free(a_face->ft_inc_int);
- free(a_face->font_data);
- free(a_face);
+ FF_free(s->ftmemory, a_face->ft_inc_int);
+ FF_free(s->ftmemory, a_face->font_data);
+ FF_free(s->ftmemory, a_face);
}
}
static FT_IncrementalRec *
-new_inc_int_info(FAPI_font *a_fapi_font)
+new_inc_int_info(FAPI_server *a_server, FAPI_font *a_fapi_font)
{
- FT_IncrementalRec* info = (FT_IncrementalRec*)malloc(sizeof(FT_IncrementalRec));
+ FF_server *s = (FF_server*)a_server;
+
+ FT_IncrementalRec *info = (FT_IncrementalRec*)FF_alloc(s->ftmemory, sizeof(FT_IncrementalRec));
if (info)
{
info->fapi_font = a_fapi_font;
@@ -121,12 +174,13 @@ new_inc_int_info(FAPI_font *a_fapi_font)
}
static void
-delete_inc_int_info(FT_IncrementalRec *a_inc_int_info)
+delete_inc_int_info(FAPI_server *a_server, FT_IncrementalRec *a_inc_int_info)
{
+ FF_server *s = (FF_server*)a_server;
if (a_inc_int_info)
{
- free(a_inc_int_info->glyph_data);
- free(a_inc_int_info);
+ FF_free(s->ftmemory, a_inc_int_info->glyph_data);
+ FF_free(s->ftmemory, a_inc_int_info);
}
}
@@ -148,11 +202,11 @@ get_fapi_glyph_data(FT_Incremental a_info, FT_UInt a_index, FT_Data *a_data)
length = ff->get_glyph(ff,a_index,NULL,0);
if (length == 65535)
return FT_Err_Invalid_Glyph_Index;
- buffer = malloc(length);
+ buffer = gs_malloc ((gs_memory_t *)a_info->fapi_font->memory, length, 1, "get_fapi_glyph_data");
if (!buffer)
return FT_Err_Out_Of_Memory;
if (ff->get_glyph(ff, a_index, buffer, length) == 65535) {
- free (buffer);
+ gs_free ((gs_memory_t *)a_info->fapi_font->memory, buffer, 0, 0, "get_fapi_glyph_data");
return FT_Err_Invalid_Glyph_Index;
}
a_data->pointer = buffer;
@@ -169,11 +223,14 @@ get_fapi_glyph_data(FT_Incremental a_info, FT_UInt a_index, FT_Data *a_data)
length = ff->get_glyph(ff, a_index, a_info->glyph_data, (ushort)a_info->glyph_data_length);
/* If the buffer was too small enlarge it and try again. */
- if (length > a_info->glyph_data_length)
- {
- a_info->glyph_data = realloc(a_info->glyph_data, length);
- if (!a_info->glyph_data)
- {
+ if (length > a_info->glyph_data_length) {
+ if (a_info->glyph_data) {
+ gs_free ((gs_memory_t *)a_info->fapi_font->memory, a_info->glyph_data, 0, 0, "get_fapi_glyph_data");
+ }
+
+ a_info->glyph_data = gs_malloc ((gs_memory_t *)a_info->fapi_font->memory, length, 1, "get_fapi_glyph_data");
+
+ if (!a_info->glyph_data) {
a_info->glyph_data_length = 0;
return FT_Err_Out_Of_Memory;
}
@@ -198,7 +255,7 @@ free_fapi_glyph_data(FT_Incremental a_info, FT_Data *a_data)
if (a_data->pointer == (const FT_Byte*)a_info->glyph_data)
a_info->glyph_data_in_use = false;
else
- free((FT_Byte*)a_data->pointer);
+ gs_free((gs_memory_t *)a_info->fapi_font->memory, (FT_Byte*)a_data->pointer, 0, 0, "free_fapi_glyph_data");
}
static FT_Error
@@ -244,30 +301,33 @@ FT_Incremental_FuncsRec TheFAPIIncrementalInterfaceFuncs =
};
static FT_Incremental_InterfaceRec *
-new_inc_int(FAPI_font *a_fapi_font)
+new_inc_int(FAPI_server *a_server, FAPI_font *a_fapi_font)
{
+ FF_server *s = (FF_server*)a_server;
+
FT_Incremental_InterfaceRec *i =
- (FT_Incremental_InterfaceRec*) malloc(sizeof(FT_Incremental_InterfaceRec)); /* malloc!? /Tor */
+ (FT_Incremental_InterfaceRec*) FF_alloc(s->ftmemory, sizeof(FT_Incremental_InterfaceRec));
if (i)
{
- i->object = (FT_Incremental)new_inc_int_info(a_fapi_font);
+ i->object = (FT_Incremental)new_inc_int_info(a_server, a_fapi_font);
i->funcs = &TheFAPIIncrementalInterfaceFuncs;
}
if (!i->object)
{
- free(i);
+ FF_free(s->ftmemory, i);
i = NULL;
}
return i;
}
static void
-delete_inc_int(FT_Incremental_InterfaceRec *a_inc_int)
+delete_inc_int(FAPI_server *a_server, FT_Incremental_InterfaceRec *a_inc_int)
{
+ FF_server *s = (FF_server*)a_server;
if (a_inc_int)
{
- delete_inc_int_info(a_inc_int->object);
- free(a_inc_int);
+ delete_inc_int_info(a_server, a_inc_int->object);
+ FF_free(s->ftmemory, a_inc_int);
}
}
@@ -344,6 +404,7 @@ load_glyph(FAPI_font *a_fapi_font, const FAPI_char_ref *a_char_ref,
face->ft_inc_int->object->metrics_type = a_char_ref->metrics_type;
}
else
+ if (face->ft_inc_int)
/* Make sure we don't leave this set to the last value, as we may then use inappropriate metrics values */
face->ft_inc_int->object->glyph_metrics_index = 0xFFFFFFFF;
@@ -387,6 +448,15 @@ load_glyph(FAPI_font *a_fapi_font, const FAPI_char_ref *a_char_ref,
h = (((double)ft_face->glyph->metrics.height * ft_face->units_per_EM / face->height) / face->vert_res) * 72;
hadv = (((double)ft_face->glyph->metrics.horiAdvance * ft_face->units_per_EM / face->width) / face->horz_res) * 72;
+
+ /* Ugly. FreeType creates verticla metrics for TT fonts, normally we override them in the
+ * metrics callbacks, but those only work for incremental interface fonts, and TrueType fonts
+ * loaded as CIDFont replacements are not incrementally handled. So here, if its a CIDFont, and
+ * its not type 1 outlines, and its not a vertical mode fotn, ignore the advance.
+ */
+ if(!a_fapi_font->is_type1 && a_fapi_font->is_cid && !a_fapi_font->is_vertical)
+ vadv = 0;
+ else
vadv = (((double)ft_face->glyph->metrics.vertAdvance * ft_face->units_per_EM / face->height) / face->vert_res) * 72;
a_metrics->bbox_x0 = hx;
@@ -432,13 +502,36 @@ ensure_open(FAPI_server *a_server, const byte *server_param, int server_param_si
FF_server* s = (FF_server*)a_server;
if (!s->freetype_library)
{
- FT_Error ft_error = FT_Init_FreeType(&s->freetype_library);
+ FT_Error ft_error;
+
+ /* As we want FT to use our memory management, we cannot use the convenience of
+ * FT_Init_FreeType(), we have to do each stage "manually"
+ */
+ s->ftmemory = gs_malloc (s->mem, sizeof(*s->ftmemory), 1, "ensure_open");
+ if (!s->ftmemory) {
+ return(-1);
+ }
+
+ s->ftmemory->user = s->mem;
+ s->ftmemory->alloc = FF_alloc;
+ s->ftmemory->free = FF_free;
+ s->ftmemory->realloc = FF_realloc;
+
+ ft_error = FT_New_Library(s->ftmemory, &s->freetype_library);
+ if (ft_error) {
+ gs_free (s->mem, s->ftmemory, 0, 0, "ensure_open");
+ }
+ else {
+ FT_Add_Default_Modules(s->freetype_library);
+ }
+
if (ft_error)
return ft_to_gs_error(ft_error);
}
return 0;
}
+#if 0 /* Not currently used */
static void
transform_concat(FT_Matrix *a_A, const FT_Matrix *a_B)
{
@@ -466,6 +559,7 @@ make_rotation(FT_Matrix *a_transform, const FT_Vector *a_vector)
a_transform->xy = -sin;
a_transform->yx = sin;
}
+#endif /* Not currently used */
/* Divide a transformation into a scaling part and a rotation-and-shear part.
* The scaling part is used for setting the pixel size for hinting.
@@ -588,7 +682,7 @@ get_scaled_font(FAPI_server *a_server, FAPI_font *a_font,
length = FF_serialize_type1_font(a_font,NULL,0);
else
length = FF_serialize_type2_font(a_font,NULL,0);
- open_args.memory_base = own_font_data = malloc(length);
+ open_args.memory_base = own_font_data = FF_alloc(s->ftmemory, length);
if (!open_args.memory_base)
return e_VMerror;
if (type == 1)
@@ -597,10 +691,10 @@ get_scaled_font(FAPI_server *a_server, FAPI_font *a_font,
open_args.memory_size = FF_serialize_type2_font(a_font,own_font_data,length);
if (open_args.memory_size != length)
return_error(e_unregistered); /* Must not happen. */
- ft_inc_int = new_inc_int(a_font);
+ ft_inc_int = new_inc_int(a_server, a_font);
if (!ft_inc_int)
{
- free(own_font_data);
+ FF_free (s->ftmemory, own_font_data);
return e_VMerror;
}
}
@@ -614,17 +708,17 @@ get_scaled_font(FAPI_server *a_server, FAPI_font *a_font,
return e_invalidfont;
/* Load the TrueType data into a single buffer. */
- open_args.memory_base = own_font_data = malloc(open_args.memory_size);
+ open_args.memory_base = own_font_data = FF_alloc(s->ftmemory, open_args.memory_size);
if (!own_font_data)
return e_VMerror;
if (a_font->serialize_tt_font(a_font,own_font_data,open_args.memory_size))
return e_invalidfont;
/* We always load incrementally. */
- ft_inc_int = new_inc_int(a_font);
+ ft_inc_int = new_inc_int(a_server, a_font);
if (!ft_inc_int)
{
- free(own_font_data);
+ FF_free(s->ftmemory, own_font_data);
return e_VMerror;
}
}
@@ -642,12 +736,12 @@ get_scaled_font(FAPI_server *a_server, FAPI_font *a_font,
if (ft_face)
{
- face = new_face(ft_face,ft_inc_int,own_font_data);
+ face = new_face(a_server, ft_face, ft_inc_int, own_font_data);
if (!face)
{
- free(own_font_data);
+ FF_free(s->ftmemory, own_font_data);
FT_Done_Face(ft_face);
- delete_inc_int(ft_inc_int);
+ delete_inc_int(a_server, ft_inc_int);
return e_VMerror;
}
a_font->server_font_data = face;
@@ -684,7 +778,7 @@ get_scaled_font(FAPI_server *a_server, FAPI_font *a_font,
if (ft_error)
{
- delete_face(face);
+ delete_face(a_server, face);
a_font->server_font_data = NULL;
return ft_to_gs_error(ft_error);
}
@@ -784,6 +878,17 @@ get_char_width(FAPI_server *a_server, FAPI_font *a_font, FAPI_char_ref *a_char_r
return load_glyph(a_font,a_char_ref,a_metrics,NULL,false);
}
+static FAPI_retcode get_fontmatrix(FAPI_server *server, gs_matrix *m)
+{
+ m->xx = 1.0;
+ m->xy = 0.0;
+ m->yx = 0.0;
+ m->yy = 1.0;
+ m->tx = 0.0;
+ m->ty = 0.0;
+ return 0;
+}
+
/*
* Rasterize the character a_char and return its metrics. Do not return the
* bitmap but store this. It can be retrieved by a subsequent call to
@@ -944,6 +1049,7 @@ get_char_outline(FAPI_server *a_server, FAPI_path *a_path)
p.x = 0;
p.y = 0;
ft_error = FT_Outline_Decompose(&s->outline_glyph->outline, &TheFtOutlineFuncs, &p);
+ if (a_path->gs_error == 0)
a_path->closepath(a_path);
return ft_to_gs_error(ft_error);
}
@@ -962,14 +1068,13 @@ static FAPI_retcode
release_typeface(FAPI_server *a_server, void *a_server_font_data)
{
FF_face* face = (FF_face*)a_server_font_data;
- delete_face(face);
+ delete_face(a_server, face);
return 0;
}
static FAPI_retcode
check_cmap_for_GID(FAPI_server *server, uint *index)
{
- FF_server* s = (FF_server*)server;
FF_face* face = (FF_face*)(server->ff.server_font_data);
FT_Face ft_face = face->ft_face;
@@ -1000,6 +1105,7 @@ static const FAPI_server TheFreeTypeServer =
get_font_proportional_feature,
can_retrieve_char_by_name,
can_replace_metrics,
+ get_fontmatrix,
get_char_width,
get_char_raster_metrics,
get_char_raster,
@@ -1018,6 +1124,7 @@ int gs_fapi_ft_instantiate( i_plugin_client_memory *a_memory, i_plugin_instance
if (!server)
return e_VMerror;
memset(server,0,sizeof(*server));
+ server->mem = a_memory->client_data;
server->fapi_server = TheFreeTypeServer;
*a_plugin_instance = &server->fapi_server.ig;
return 0;
@@ -1026,8 +1133,16 @@ int gs_fapi_ft_instantiate( i_plugin_client_memory *a_memory, i_plugin_instance
static void gs_freetype_destroy(i_plugin_instance *a_plugin_instance,i_plugin_client_memory *a_memory)
{
FF_server *server = (FF_server *)a_plugin_instance;
+
FT_Done_Glyph(&server->outline_glyph->root);
FT_Done_Glyph(&server->bitmap_glyph->root);
- FT_Done_FreeType(server->freetype_library);
+
+ /* As with initialization: since we're supplying memory management to
+ * FT, we cannot just to use FT_Done_FreeType (), we have to use
+ * FT_Done_Library () and then discard the memory ourselves
+ */
+ FT_Done_Library(server->freetype_library);
+ gs_free (server->mem, server->ftmemory, 0, 0, "gs_freetype_destroy");
+
a_memory->free(a_memory,server,"FF_server");
}
diff --git a/gs/psi/fapiufst.c b/gs/psi/fapiufst.c
index b10b69fda..a855a7872 100644
--- a/gs/psi/fapiufst.c
+++ b/gs/psi/fapiufst.c
@@ -919,6 +919,18 @@ static void release_glyphs(fapi_ufst_server *r, ufst_common_font_data *d)
}
}
+static FAPI_retcode get_fontmatrix(FAPI_server *I, gs_matrix *m)
+{
+ gs_matrix *base_font_matrix = &I->initial_FontMatrix;
+ m->xx = I->initial_FontMatrix.xx;
+ m->xy = I->initial_FontMatrix.xy;
+ m->yx = I->initial_FontMatrix.yx;
+ m->yy = I->initial_FontMatrix.yy;
+ m->tx = I->initial_FontMatrix.tx;
+ m->ty = I->initial_FontMatrix.ty;
+ return 0;
+}
+
static FAPI_retcode get_char_width(FAPI_server *server, FAPI_font *ff, FAPI_char_ref *c, FAPI_metrics *metrics)
{ fapi_ufst_server *r = If_to_I(server);
UW16 buffer[2];
@@ -961,24 +973,23 @@ static int export_outline(fapi_ufst_server *r, PIFOUTLINE pol, FAPI_path *p)
segment = (LPSB8)((LPSB8)(outchar->loop) + outchar->loop[i].segmt_offset);
points = (PINTRVECTOR)((LPSB8)(outchar->loop) + outchar->loop[i].coord_offset);
for(j=0; j<num_segmts; j++) {
- int code;
if(*segment == 0x00) {
- if ((code = p->moveto(p, points->x, points->y)) != 0)
- return code;
+ if ((p->gs_error = p->moveto(p, points->x, points->y)) != 0)
+ return p->gs_error;
points++;
} else if (*segment == 0x01) {
- if ((code = p->lineto(p, points->x, points->y)) != 0)
- return code;
+ if ((p->gs_error = p->lineto(p, points->x, points->y)) != 0)
+ return p->gs_error;
points++;
} else if (*segment == 0x02) {
points+=2;
return e_invalidfont; /* This must not happen */
} else if (*segment == 0x03) {
- if ((code = p->curveto(p, points[0].x, points[0].y,
+ if ((p->gs_error = p->curveto(p, points[0].x, points[0].y,
points[1].x, points[1].y,
points[2].x, points[2].y)) < 0)
- return code;
+ return p->gs_error;
points+=3;
} else
return e_invalidfont; /* This must not happen */
@@ -1295,6 +1306,7 @@ static const FAPI_server If0 = {
get_font_proportional_feature,
can_retrieve_char_by_name,
can_replace_metrics,
+ get_fontmatrix,
get_char_width,
get_char_raster_metrics,
get_char_raster,
diff --git a/gs/psi/files.h b/gs/psi/files.h
index 4e29115be..3d664630f 100644
--- a/gs/psi/files.h
+++ b/gs/psi/files.h
@@ -43,9 +43,8 @@ bool zis_stdin(const stream *);
#define ref_stderr ref_stdio[2]
/* An invalid (closed) file. */
#define avm_invalid_file_entry avm_foreign
-extern stream *const invalid_file_entry;
/* Make an invalid file object. */
-void make_invalid_file(ref *);
+void make_invalid_file(i_ctx_t *,ref *);
/*
* If a file is open for both reading and writing, its read_id, write_id,
@@ -54,13 +53,13 @@ void make_invalid_file(ref *);
*/
int file_switch_to_read(const ref *);
-#define check_read_file(svar,op)\
+#define check_read_file(ctx, svar,op)\
BEGIN\
check_read_type(*(op), t_file);\
- check_read_known_file(svar, op, return);\
+ check_read_known_file(ctx, svar, op, return);\
END
-#define check_read_known_file(svar,op,error_return)\
- check_read_known_file_else(svar, op, error_return, svar = invalid_file_entry)
+#define check_read_known_file(ctx,svar,op,error_return)\
+ check_read_known_file_else(svar, op, error_return, svar = (ctx->invalid_file_stream))
#define check_read_known_file_else(svar,op,error_return,invalid_action)\
BEGIN\
svar = fptr(op);\
diff --git a/gs/psi/icontext.c b/gs/psi/icontext.c
index 6c24e264e..e089aed1e 100644
--- a/gs/psi/icontext.c
+++ b/gs/psi/icontext.c
@@ -152,18 +152,37 @@ context_state_alloc(gs_context_state_t ** ppcst,
pcst->LockFilePermissions = false;
pcst->starting_arg_file = false;
pcst->RenderTTNotdef = true;
+ /* Create and initialize an invalid (closed) stream. */
+ /* Initialize the stream for the sake of the GC, */
+ /* and so it can act as an empty input stream. */
+ {
+ stream *s;
+
+ s = (stream*)gs_alloc_bytes_immovable(mem->non_gc_memory->stable_memory,
+ sizeof(*s),
+ "context_state_alloc");
+ if (s == NULL)
+ goto x3;
+ pcst->invalid_file_stream = s;
+
+ s_init(s, NULL);
+ sread_string(s, NULL, 0);
+ s->next = s->prev = 0;
+ s_init_no_id(s);
+ }
/* The initial stdio values are bogus.... */
make_file(&pcst->stdio[0], a_readonly | avm_invalid_file_entry, 1,
- invalid_file_entry);
+ pcst->invalid_file_stream);
make_file(&pcst->stdio[1], a_all | avm_invalid_file_entry, 1,
- invalid_file_entry);
+ pcst->invalid_file_stream);
make_file(&pcst->stdio[2], a_all | avm_invalid_file_entry, 1,
- invalid_file_entry);
+ pcst->invalid_file_stream);
for (i = countof(pcst->memory.spaces_indexed); --i >= 0;)
if (dmem->spaces_indexed[i] != 0)
++(dmem->spaces_indexed[i]->num_contexts);
*ppcst = pcst;
return 0;
+ x3:/* No need to delete dictionary here, as gc will do it for us. */
x2:gs_state_free(pcst->pgs);
x1:gs_interp_free_stacks(mem, pcst);
x0:if (*ppcst == 0)
@@ -259,6 +278,9 @@ context_state_free(gs_context_state_t * pcst)
int freed = 0;
int i;
+ /* Invalid file stream is always in static space, so needs to be done
+ * separately. */
+ gs_free_object(mem->non_gc_memory->stable_memory, pcst->invalid_file_stream, "context_state_alloc");
/*
* If this context is the last one referencing a particular VM
* (local / global / system), free the entire VM space;
diff --git a/gs/psi/icstate.h b/gs/psi/icstate.h
index 4e5369e2b..3daf214fb 100644
--- a/gs/psi/icstate.h
+++ b/gs/psi/icstate.h
@@ -22,6 +22,7 @@
#include "idsdata.h"
#include "iesdata.h"
#include "iosdata.h"
+#include "stream.h"
/*
* Define the externally visible state of an interpreter context.
@@ -59,6 +60,7 @@ struct gs_context_state_s {
bool RenderTTNotdef; /* accessed from userparams */
gs_file_path_ptr lib_path; /* library search list (GS_LIB) */
ref stdio[3]; /* t_file */
+ stream *invalid_file_stream;/* An invalid file object (stable memory) */
/* Put the stacks at the end to minimize other offsets. */
dict_stack_t dict_stack;
exec_stack_t exec_stack;
diff --git a/gs/psi/ifapi.h b/gs/psi/ifapi.h
index 3f5c78cfc..b18e40e73 100644
--- a/gs/psi/ifapi.h
+++ b/gs/psi/ifapi.h
@@ -143,6 +143,7 @@ typedef struct FAPI_path_s FAPI_path;
struct FAPI_path_s {
void *olh; /* Client's data. */
int shift;
+ int gs_error;
int (*moveto )(FAPI_path *, FracInt, FracInt);
int (*lineto )(FAPI_path *, FracInt, FracInt);
int (*curveto )(FAPI_path *, FracInt, FracInt, FracInt, FracInt, FracInt, FracInt);
@@ -199,6 +200,7 @@ struct FAPI_server_s {
FAPI_retcode (*get_font_proportional_feature)(FAPI_server *server, FAPI_font *ff, bool *bProportional);
FAPI_retcode (*can_retrieve_char_by_name)(FAPI_server *server, FAPI_font *ff, FAPI_char_ref *c, int *result);
FAPI_retcode (*can_replace_metrics)(FAPI_server *server, FAPI_font *ff, FAPI_char_ref *c, int *result);
+ FAPI_retcode (*get_fontmatrix)(FAPI_server *server, gs_matrix *m);
FAPI_retcode (*get_char_width)(FAPI_server *server, FAPI_font *ff, FAPI_char_ref *c, FAPI_metrics *metrics);
FAPI_retcode (*get_char_raster_metrics)(FAPI_server *server, FAPI_font *ff, FAPI_char_ref *c, FAPI_metrics *metrics);
FAPI_retcode (*get_char_raster)(FAPI_server *server, FAPI_raster *r);
diff --git a/gs/psi/interp.c b/gs/psi/interp.c
index 82792fa45..643323a4e 100644
--- a/gs/psi/interp.c
+++ b/gs/psi/interp.c
@@ -116,7 +116,7 @@ call_operator(op_proc_t op_proc, i_ctx_t *i_ctx_p)
# endif
# endif
code = op_proc(i_ctx_p);
-# if defined(DEBUG_TRACE_PS_OPERATORS) && !defined(SHOW_STACK_DEPTHS)
+# if defined(DEBUG_TRACE_PS_OPERATORS) && defined(SHOW_STACK_DEPTHS)
if_debug2('!', "[!][es=%d os=%d]\n",
esp-i_ctx_p->exec_stack.stack.bot,
osp-i_ctx_p->op_stack.stack.bot);
@@ -1321,7 +1321,7 @@ remap: if (iesp + 2 >= estop) {
stream *s;
scanner_state sstate;
- check_read_known_file(s, IREF, return_with_error_iref);
+ check_read_known_file(i_ctx_p, s, IREF, return_with_error_iref);
rt:
if (iosp >= ostop) /* check early */
return_with_stackoverflow_iref();
diff --git a/gs/psi/msvc32.mak b/gs/psi/msvc32.mak
index 88e2fb1eb..089ac8b13 100644
--- a/gs/psi/msvc32.mak
+++ b/gs/psi/msvc32.mak
@@ -181,6 +181,16 @@ MAKEDLL=1
# Define the directory where the FreeType2 library sources are stored.
# See freetype.mak for more information.
+!ifdef UFST_BRIDGE
+!if "$(UFST_BRIDGE)"=="1"
+FT_BRIDGE=0
+!endif
+!endif
+
+!ifndef FT_BRIDGE
+FT_BRIDGE=1
+!endif
+
!ifndef FTSRCDIR
FTSRCDIR=freetype
!ifndef FT_CFLAGS
@@ -863,13 +873,49 @@ $(UNINSTALL_XE): $(PSOBJ)dwuninst.obj $(PSOBJ)dwuninst.res $(PSSRC)dwuninst.def
DEBUGDEFS=BINDIR=.\debugbin GLGENDIR=.\debugobj GLOBJDIR=.\debugobj PSLIBDIR=.\lib PSGENDIR=.\debugobj PSOBJDIR=.\debugobj DEBUG=1 TDEBUG=1 SBRDIR=.\debugobj
debug:
- nmake -f $(MAKEFILE) DEVSTUDIO="$(DEVSTUDIO)" $(DEBUGDEFS)
+ nmake -f $(MAKEFILE) DEVSTUDIO="$(DEVSTUDIO)" FT_BRIDGE=$(FT_BRIDGE) $(DEBUGDEFS)
debugclean:
- nmake -f $(MAKEFILE) DEVSTUDIO="$(DEVSTUDIO)" $(DEBUGDEFS) clean
+ nmake -f $(MAKEFILE) DEVSTUDIO="$(DEVSTUDIO)" FT_BRIDGE=$(FT_BRIDGE) $(DEBUGDEFS) clean
debugbsc:
- nmake -f $(MAKEFILE) DEVSTUDIO="$(DEVSTUDIO)" $(DEBUGDEFS) bsc
+ nmake -f $(MAKEFILE) DEVSTUDIO="$(DEVSTUDIO)" FT_BRIDGE=$(FT_BRIDGE) $(DEBUGDEFS) bsc
+
+
+
+# ---------------------- UFST targets ---------------------- #
+# Simply set some definitions and call ourselves back #
+
+!ifndef UFST_ROOT
+UFST_ROOT=C:\ufst
+!endif
+
+UFSTBASEDEFS=UFST_BRIDGE=1 FT_BRIDGE=1 UFST_ROOT="$(UFST_ROOT)"
+UFSTDEBUGDEFS=BINDIR=.\ufstdebugbin GLGENDIR=.\ufstdebugobj GLOBJDIR=.\ufstdebugobj PSLIBDIR=.\lib PSGENDIR=.\ufstdebugobj PSOBJDIR=.\ufstdebugobj DEBUG=1 TDEBUG=1 SBRDIR=.\ufstdebugobj
+UFSTDEFS=BINDIR=.\ufstbin GLGENDIR=.\ufstobj GLOBJDIR=.\ufstobj PSLIBDIR=.\lib PSGENDIR=.\ufstobj PSOBJDIR=.\ufstobj SBRDIR=.\ufstobj
+
+ufst-lib:
+# Could make this call a makefile in the ufst code?
+# cd $(UFST_ROOT)\rts\lib
+# nmake -f makefile.artifex fco_lib.a if_lib.a psi_lib.a tt_lib.a
+
+ufst-debug: ufst-lib
+ nmake -f $(MAKEFILE) DEVSTUDIO="$(DEVSTUDIO)" $(UFSTBASEDEFS) $(UFSTDEBUGDEFS)
+
+ufst-debugclean: ufst-lib
+ nmake -f $(MAKEFILE) DEVSTUDIO="$(DEVSTUDIO)" $(UFSTBASEDEFS) $(UFSTDEBUGDEFS) clean
+
+ufst-debugbsc: ufst-lib
+ nmake -f $(MAKEFILE) DEVSTUDIO="$(DEVSTUDIO)" $(UFSTBASEDEFS) $(UFSTDEBUGDEFS) bsc
+
+ufst: ufst-lib
+ nmake -f $(MAKEFILE) DEVSTUDIO="$(DEVSTUDIO)" $(UFSTBASEDEFS) $(UFSTDEFS)
+
+ufst-clean: ufst-lib
+ nmake -f $(MAKEFILE) DEVSTUDIO="$(DEVSTUDIO)" $(UFSTBASEDEFS) $(UFSTDEFS) clean
+
+ufst-bsc: ufst-lib
+ nmake -f $(MAKEFILE) DEVSTUDIO="$(DEVSTUDIO)" $(UFSTBASEDEFS) $(UFSTDEFS) bsc
diff --git a/gs/psi/zcolor.c b/gs/psi/zcolor.c
index cc3dcf602..71a10da83 100644
--- a/gs/psi/zcolor.c
+++ b/gs/psi/zcolor.c
@@ -3228,11 +3228,11 @@ static int ciedefgcompareproc(i_ctx_t *i_ctx_p, ref *space, ref *testspace)
return 1;
}
-static char *CIESpaces[] = {
- (char *)"CIEBasedA",
- (char *)"CIEBasedABC",
- (char *)"CIEBasedDEF",
- (char *)"CIEBasedDEFG"
+static char const * const CIESpaces[] = {
+ "CIEBasedA",
+ "CIEBasedABC",
+ "CIEBasedDEF",
+ "CIEBasedDEFG"
};
/* This routine returns the Device space equivalents for a CIEBased space.
* Used by currentgray, currentrgb and currentcmyk, the PLRM says that CIE
diff --git a/gs/psi/zcontext.c b/gs/psi/zcontext.c
index 151f833b4..283e0ea2a 100644
--- a/gs/psi/zcontext.c
+++ b/gs/psi/zcontext.c
@@ -585,14 +585,14 @@ do_fork(i_ctx_t *i_ctx_p, os_ptr op, const ref * pstdin, const ref * pstdout,
return code;
pstdout = &ref_stdio[1];
} else
- check_read_file(s, pstdout);
+ check_read_file(i_ctx_p, s, pstdout);
if (r_has_type(pstdin, t_null)) {
code = zget_stdin(i_ctx_p, &s);
if (code < 0)
return code;
pstdin = &ref_stdio[0];
} else
- check_read_file(s, pstdin);
+ check_read_file(i_ctx_p, s, pstdin);
dmem = gs_imemory;
if (local) {
/* Share global VM, private local VM. */
diff --git a/gs/psi/zcontrol.c b/gs/psi/zcontrol.c
index 1ba6041de..ecff36312 100644
--- a/gs/psi/zcontrol.c
+++ b/gs/psi/zcontrol.c
@@ -890,7 +890,7 @@ zcurrentfile(i_ctx_t *i_ctx_p)
} else if ((fp = zget_current_file(i_ctx_p)) == 0) { /* Return an invalid file object. */
/* This doesn't make a lot of sense to me, */
/* but it's what the PostScript manual specifies. */
- make_invalid_file(op);
+ make_invalid_file(i_ctx_p, op);
} else {
ref_assign(op, fp);
esfile_set_cache(fp);
diff --git a/gs/psi/zfapi.c b/gs/psi/zfapi.c
index b79f709aa..e07fc9d97 100644
--- a/gs/psi/zfapi.c
+++ b/gs/psi/zfapi.c
@@ -80,37 +80,40 @@ static int add_closepath(FAPI_path *I)
{ FAPI_outline_handler *olh = (FAPI_outline_handler *)I->olh;
olh->need_close = false;
- return gx_path_close_subpath_notes(olh->path, 0);
+ I->gs_error = gx_path_close_subpath_notes(olh->path, 0);
+ return I->gs_error;
}
static int add_move(FAPI_path *I, FracInt x, FracInt y)
{ FAPI_outline_handler *olh = (FAPI_outline_handler *)I->olh;
- int code;
if (olh->need_close && olh->close_path)
- if ((code = add_closepath(I)) < 0)
- return code;
+ if ((I->gs_error = add_closepath(I)) < 0)
+ return I->gs_error;
olh->need_close = false;
- return gx_path_add_point(olh->path, import_shift(x, I->shift) + olh->x0, -import_shift(y, I->shift) + olh->y0);
+ I->gs_error = gx_path_add_point(olh->path, import_shift(x, I->shift) + olh->x0, -import_shift(y, I->shift) + olh->y0);
+ return I->gs_error;
}
static int add_line(FAPI_path *I, FracInt x, FracInt y)
{ FAPI_outline_handler *olh = (FAPI_outline_handler *)I->olh;
olh->need_close = true;
- return gx_path_add_line_notes(olh->path, import_shift(x, I->shift) + olh->x0, -import_shift(y, I->shift) + olh->y0, 0);
+ I->gs_error = gx_path_add_line_notes(olh->path, import_shift(x, I->shift) + olh->x0, -import_shift(y, I->shift) + olh->y0, 0);
+ return I->gs_error;
}
static int add_curve(FAPI_path *I, FracInt x0, FracInt y0, FracInt x1, FracInt y1, FracInt x2, FracInt y2)
{ FAPI_outline_handler *olh = (FAPI_outline_handler *)I->olh;
olh->need_close = true;
- return gx_path_add_curve_notes(olh->path, import_shift(x0, I->shift) + olh->x0, -import_shift(y0, I->shift) + olh->y0,
+ I->gs_error = gx_path_add_curve_notes(olh->path, import_shift(x0, I->shift) + olh->x0, -import_shift(y0, I->shift) + olh->y0,
import_shift(x1, I->shift) + olh->x0, -import_shift(y1, I->shift) + olh->y0,
import_shift(x2, I->shift) + olh->x0, -import_shift(y2, I->shift) + olh->y0, 0);
+ return I->gs_error;
}
-static FAPI_path path_interface_stub = { NULL, 0, add_move, add_line, add_curve, add_closepath };
+static FAPI_path path_interface_stub = { NULL, 0, 0, add_move, add_line, add_curve, add_closepath };
static inline bool IsCIDFont(const gs_font_base *pbfont)
{ return (pbfont->FontType == ft_CID_encrypted ||
@@ -575,34 +578,35 @@ static ulong FAPI_FF_get_long(FAPI_font *ff, fapi_font_feature var_id, int index
static float FAPI_FF_get_float(FAPI_font *ff, fapi_font_feature var_id, int index)
{ gs_font_base *pbfont = (gs_font_base *)ff->client_font_data;
ref *pdr = (ref *)ff->client_font_data2;
+ FAPI_server *I = pbfont->FAPI;
switch((int)var_id) {
case FAPI_FONT_FEATURE_FontMatrix:
-#if 0
- { double FontMatrix_div = (ff->is_cid && !IsCIDFont(pbfont) ? 1000 : 1);
-
- switch(index) {
- case 0 : return pbfont->base->FontMatrix.xx / FontMatrix_div;
- case 1 : return pbfont->base->FontMatrix.xy / FontMatrix_div;
- case 2 : return pbfont->base->FontMatrix.yx / FontMatrix_div;
- case 3 : return pbfont->base->FontMatrix.yy / FontMatrix_div;
- case 4 : return pbfont->base->FontMatrix.tx / FontMatrix_div;
- case 5 : return pbfont->base->FontMatrix.ty / FontMatrix_div;
+ {
+ double FontMatrix_div;
+ gs_matrix m, *mptr;
+
+ if (I && I->get_fontmatrix) {
+ FontMatrix_div = 1;
+ mptr = &m;
+ I->get_fontmatrix (I, mptr);
}
+ else {
+ FontMatrix_div = (ff->is_cid && !IsCIDFont(pbfont) ? 1000 : 1);
+
+ mptr = &(pbfont->base->FontMatrix);
}
-#else
- /* Temporary: replace with a FAPI call to check *if* the library needs a replacement matrix */
- {
+
switch(index) {
- case 0 : return 1.0;
- case 1 : return 0.0;
- case 2 : return 0.0;
- case 3 : return 1.0;
- case 4 : return 0.0;
- case 5 : return 0.0;
+ case 0 : return mptr->xx / FontMatrix_div;
+ case 1 : return mptr->xy / FontMatrix_div;
+ case 2 : return mptr->yx / FontMatrix_div;
+ case 3 : return mptr->yy / FontMatrix_div;
+ case 4 : return mptr->tx / FontMatrix_div;
+ case 5 : return mptr->ty / FontMatrix_div;
}
}
-#endif
+
case FAPI_FONT_FEATURE_WeightVector:
{ ref *Array, value;
@@ -1376,8 +1380,12 @@ static int outline_char(i_ctx_t *i_ctx_p, FAPI_server *I, int import_shift_v, gs
olh.need_close = false;
path_interface.olh = &olh;
path_interface.shift = import_shift_v;
- if ((code = renderer_retcode(i_ctx_p, I, I->get_char_outline(I, &path_interface))) < 0)
+ if ((code = renderer_retcode(i_ctx_p, I, I->get_char_outline(I, &path_interface))) < 0 || path_interface.gs_error != 0) {
+ if (path_interface.gs_error != 0)
+ return path_interface.gs_error;
+ else
return code;
+ }
if (olh.need_close && olh.close_path)
if ((code = add_closepath(&path_interface)) < 0)
return code;
@@ -1390,11 +1398,16 @@ static void compute_em_scale(const gs_font_base *pbfont, FAPI_metrics *metrics,
gs_matrix *m = &pbfont->base->orig_FontMatrix;
int rounding_x, rounding_y; /* Striking out the 'float' representation error in FontMatrix. */
double sx, sy;
+ FAPI_server *I = pbfont->FAPI;
- /* Temporary: replace with a FAPI call to check *if* the library needs a replacement matrix */
m = &mat;
+#if 1
+ I->get_fontmatrix(I, m);
+#else
+ /* Temporary: replace with a FAPI call to check *if* the library needs a replacement matrix */
memset(m, 0x00, sizeof(gs_matrix));
m->xx = m->yy = 1.0;
+#endif
if (m->xx == 0 && m->xy == 0 && m->yx == 0 && m->yy == 0)
m = &pbfont->base->FontMatrix;
@@ -1674,6 +1687,10 @@ retry_oversampling:
code = gs_matrix_multiply(ctm, &scale_ctm, &scale_mat); /* scale_mat == CTM - resolution scaling */
+ code = I->get_fontmatrix(I, &scale_ctm);
+ code = gs_matrix_invert((const gs_matrix *)&scale_ctm, &scale_ctm);
+ code = gs_matrix_multiply(&scale_mat, &scale_ctm, &scale_mat); /* scale_mat == CTM - resolution scaling - FontMatrix scaling */
+
font_scale.matrix[0] = (FracInt)(scale_mat.xx * FontMatrix_div * scale + 0.5);
font_scale.matrix[1] = -(FracInt)(scale_mat.xy * FontMatrix_div * scale + 0.5);
font_scale.matrix[2] = (FracInt)(scale_mat.yx * FontMatrix_div * scale + 0.5);
@@ -1810,8 +1827,10 @@ retry_oversampling:
* matching character code. Otherwise it returns
* zero after setting c to zero (.notdef glyph id)
* or a negative value on error. */
+#if 0
if (code > 0)
is_glyph_index = false;
+#endif
}
cr.char_codes[0] = c;
cr.is_glyph_index = is_glyph_index;
@@ -2311,12 +2330,13 @@ static int do_FAPIpassfont(i_ctx_t *i_ctx_p, char *font_file_path, bool *success
font_scale.HWResolution[0] = font_scale.HWResolution[1] = 72 << I->frac_shift;
font_scale.matrix[0] = font_scale.matrix[3] = 1 << I->frac_shift;
+ pbfont->FAPI = I; /* we need the FAPI server during this stage */
code = FAPI_prepare_font(i_ctx_p, I, pdr, pbfont, font_file_path, &font_scale, xlatmap, BBox, &decodingID);
if (code < 0) {
+ pbfont->FAPI = NULL;
/* Failed, skip this renderer : */
continue;
}
- pbfont->FAPI = I; /* We found a good renderer, so go with it */
if ((code = name_ref(imemory, (const byte *)I->ig.d->subtype, strlen(I->ig.d->subtype), &FAPI_ID, false)) < 0)
return code;
if ((code = dict_put_string(pdr, "FAPI", &FAPI_ID, NULL)) < 0)
diff --git a/gs/psi/zfcid0.c b/gs/psi/zfcid0.c
index f4df51ade..285fa0925 100644
--- a/gs/psi/zfcid0.c
+++ b/gs/psi/zfcid0.c
@@ -35,6 +35,9 @@
#include "ifont2.h"
#include "ifont42.h"
#include "store.h"
+#include "imain.h"
+#include "iapi.h"
+#include "iminst.h"
/* Type 1 font procedures (defined in zchar1.c) */
font_proc_glyph_outline(zcharstring_glyph_outline);
@@ -140,8 +143,9 @@ cid0_read_bytes(gs_font_cid0 *pfont, ulong base, uint count, byte *buf,
/* Get the bytes from DataSource (a stream). */
stream *s;
uint nread;
+ i_ctx_t *i_ctx_p = get_minst_from_memory(pfont->memory)->i_ctx_p;
- check_read_known_file(s, &pfdata->u.cid0.DataSource, return_error);
+ check_read_known_file(i_ctx_p, s, &pfdata->u.cid0.DataSource, return_error);
if (sseek(s, base) < 0)
return_error(e_ioerror);
if (data == 0) { /* no buffer provided */
@@ -434,7 +438,7 @@ zbuildfont9(i_ctx_t *i_ctx_p)
if ((code = dict_find_string(op, "DataSource", &pds)) < 0)
return code;
- check_read_file(ignore_s, pds);
+ check_read_file(i_ctx_p, ignore_s, pds);
DataSource = *pds;
} else {
if (!r_has_type(&GlyphData, t_string) && !r_is_array(&GlyphData))
diff --git a/gs/psi/zfcid1.c b/gs/psi/zfcid1.c
index c51e0422e..32260b8a4 100644
--- a/gs/psi/zfcid1.c
+++ b/gs/psi/zfcid1.c
@@ -487,7 +487,7 @@ zbuildfont11(i_ctx_t *i_ctx_p)
*/
stream *s;
- check_read_file(s, &file);
+ check_read_file(i_ctx_p, s, &file);
pfont->data.loca = loca_glyph_pos[0][0];
pfont->data.glyf = loca_glyph_pos[1][0];
pfont->data.get_outline = gs_get_glyph_data_cached;
diff --git a/gs/psi/zfile.c b/gs/psi/zfile.c
index fcbb61c67..b5acebe2a 100644
--- a/gs/psi/zfile.c
+++ b/gs/psi/zfile.c
@@ -51,7 +51,8 @@ extern_gx_io_device_table();
extern const char iodev_dtype_stdio[];
/* Forward references: file name parsing. */
-static int parse_file_name(const ref * op, gs_parsed_file_name_t * pfn, bool safemode);
+static int parse_file_name(const ref * op, gs_parsed_file_name_t * pfn,
+ bool safemode, gs_memory_t *memory);
static int parse_real_file_name(const ref * op,
gs_parsed_file_name_t * pfn,
gs_memory_t *mem, client_name_t cname);
@@ -107,32 +108,11 @@ stream_proc_report_error(filter_report_error);
#define DEFAULT_BUFFER_SIZE 2048
extern const uint file_default_buffer_size;
-/* An invalid file object */
-static stream invalid_file_stream;
-stream *const invalid_file_entry = &invalid_file_stream;
-
-/* Initialize the file table */
-static int
-zfile_init(i_ctx_t *i_ctx_p)
-{
- /* Create and initialize an invalid (closed) stream. */
- /* Initialize the stream for the sake of the GC, */
- /* and so it can act as an empty input stream. */
-
- stream *const s = &invalid_file_stream;
-
- s_init(s, NULL);
- sread_string(s, NULL, 0);
- s->next = s->prev = 0;
- s_init_no_id(s);
- return 0;
-}
-
/* Make an invalid file object. */
void
-make_invalid_file(ref * fp)
+make_invalid_file(i_ctx_t *i_ctx_p, ref * fp)
{
- make_file(fp, avm_invalid_file_entry, ~0, invalid_file_entry);
+ make_file(fp, avm_invalid_file_entry, ~0, i_ctx_p->invalid_file_stream);
}
/* Check a file name for permission by stringmatch on one of the */
@@ -227,7 +207,7 @@ zfile(i_ctx_t *i_ctx_p)
if (code < 0)
return code;
- code = parse_file_name(op - 1, &pname, i_ctx_p->LockFilePermissions);
+ code = parse_file_name(op-1, &pname, i_ctx_p->LockFilePermissions, imemory);
if (code < 0)
return code;
/*
@@ -242,7 +222,8 @@ zfile(i_ctx_t *i_ctx_p)
return_error(e_invalidfileaccess);
if (statement || lineedit) {
/* These need special code to support callouts */
- gx_io_device *indev = gs_findiodevice((const byte *)"%stdin", 6);
+ gx_io_device *indev = gs_findiodevice(imemory,
+ (const byte *)"%stdin", 6);
stream *ins;
if (strcmp(file_access, "r"))
return_error(e_invalidfileaccess);
@@ -265,7 +246,7 @@ zfile(i_ctx_t *i_ctx_p)
pname.iodev->state = NULL;
} else {
if (pname.iodev == NULL)
- pname.iodev = iodev_default;
+ pname.iodev = iodev_default(imemory);
code = zopen_file(i_ctx_p, &pname, file_access, &s, imemory);
}
if (code < 0)
@@ -313,7 +294,7 @@ zdeletefile(i_ctx_t *i_ctx_p)
if (code < 0)
return code;
- if (pname.iodev == iodev_default) {
+ if (pname.iodev == iodev_default(imemory)) {
if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
"PermitFileControl")) < 0 &&
!file_is_tempfile(i_ctx_p, op->value.bytes, r_size(op))) {
@@ -347,10 +328,10 @@ zfilenameforall(i_ctx_t *i_ctx_p)
/* and the procedure, and invoke the continuation. */
check_estack(7);
/* Get the iodevice */
- code = parse_file_name(op - 2, &pname, i_ctx_p->LockFilePermissions);
+ code = parse_file_name(op-2, &pname, i_ctx_p->LockFilePermissions, imemory);
if (code < 0)
return code;
- iodev = (pname.iodev == NULL) ? iodev_default : pname.iodev;
+ iodev = (pname.iodev == NULL) ? iodev_default(imemory) : pname.iodev;
/* Check for several conditions that just cause us to return success */
if (pname.len == 0 || iodev->procs.enumerate_files == iodev_no_enumerate_files) {
@@ -430,14 +411,15 @@ zrenamefile(i_ctx_t *i_ctx_p)
pname1.fname = 0;
code = parse_real_file_name(op - 1, &pname1, imemory, "renamefile(from)");
if (code >= 0) {
+ gx_io_device *iodev_dflt = iodev_default(imemory);
if (pname1.iodev != pname2.iodev ) {
- if (pname1.iodev == iodev_default)
+ if (pname1.iodev == iodev_dflt)
pname1.iodev = pname2.iodev;
- if (pname2.iodev == iodev_default)
+ if (pname2.iodev == iodev_dflt)
pname2.iodev = pname1.iodev;
}
if (pname1.iodev != pname2.iodev ||
- (pname1.iodev == iodev_default &&
+ (pname1.iodev == iodev_dflt &&
/*
* We require FileControl permissions on the source path
* unless it is a temporary file. Also, we require FileControl
@@ -484,7 +466,8 @@ zstatus(i_ctx_t *i_ctx_p)
{
gs_parsed_file_name_t pname;
struct stat fstat;
- int code = parse_file_name(op, &pname, i_ctx_p->LockFilePermissions);
+ int code = parse_file_name(op, &pname,
+ i_ctx_p->LockFilePermissions, imemory);
if (code < 0)
return code;
@@ -601,14 +584,16 @@ zlibfile(i_ctx_t *i_ctx_p)
uint clen;
gs_parsed_file_name_t pname;
stream *s;
+ gx_io_device *iodev_dflt;
check_ostack(2);
- code = parse_file_name(op, &pname, i_ctx_p->LockFilePermissions);
+ code = parse_file_name(op, &pname, i_ctx_p->LockFilePermissions, imemory);
if (code < 0)
return code;
+ iodev_dflt = iodev_default(imemory);
if (pname.iodev == NULL)
- pname.iodev = iodev_default;
- if (pname.iodev != iodev_default) { /* Non-OS devices don't have search paths (yet). */
+ pname.iodev = iodev_dflt;
+ if (pname.iodev != iodev_dflt) { /* Non-OS devices don't have search paths (yet). */
code = zopen_file(i_ctx_p, &pname, "r", &s, imemory);
if (code >= 0) {
code = ssetfilename(s, op->value.const_bytes, r_size(op));
@@ -729,8 +714,9 @@ ztempfile(i_ctx_t *i_ctx_p)
file_init_stream(s, sfile, fmode, buf, file_default_buffer_size);
code = ssetfilename(s, (const unsigned char*) fname, fnlen);
if (code < 0) {
+ gx_io_device *iodev_dflt = iodev_default(imemory);
sclose(s);
- iodev_default->procs.delete_file(iodev_default, fname);
+ iodev_dflt->procs.delete_file(iodev_dflt, fname);
ifree_string(sbody, fnlen, ".tempfile(fname)");
return_error(e_VMerror);
}
@@ -756,7 +742,7 @@ const op_def zfile_op_defs[] =
/* Internal operators */
{"0%file_continue", file_continue},
{"0%execfile_finish", execfile_finish},
- op_def_end(zfile_init)
+ op_def_end(0)
};
/* ------ File name parsing ------ */
@@ -764,13 +750,14 @@ const op_def zfile_op_defs[] =
/* Parse a file name into device and individual name. */
/* See gsfname.c for details. */
static int
-parse_file_name(const ref * op, gs_parsed_file_name_t * pfn, bool safemode)
+parse_file_name(const ref * op, gs_parsed_file_name_t * pfn, bool safemode,
+ gs_memory_t *memory)
{
int code;
check_read_type(*op, t_string);
code = gs_parse_file_name(pfn, (const char *)op->value.const_bytes,
- r_size(op));
+ r_size(op), memory);
if (code < 0)
return code;
/*
@@ -918,7 +905,7 @@ lib_file_open(gs_file_path_ptr lib_path, const gs_memory_t *mem, i_ctx_t *i_ctx
bool search_with_combine = false;
char fmode[4] = { 'r', 0, 0, 0 }; /* room for binary suffix */
stream *s;
- gx_io_device *iodev = iodev_default;
+ gx_io_device *iodev = iodev_default(mem);
/* when starting arg files (@ files) iodev_default is not yet set */
if (iodev == 0)
@@ -968,7 +955,7 @@ lib_file_open(gs_file_path_ptr lib_path, const gs_memory_t *mem, i_ctx_t *i_ctx
/* We concatenate directly since gp_file_name_combine_*
* rules are not correct for other devices such as %rom% */
- code = gs_parse_file_name(&pname, pstr, plen);
+ code = gs_parse_file_name(&pname, pstr, plen, mem);
if (code < 0)
continue;
memcpy(buffer, pname.fname, pname.len);
diff --git a/gs/psi/zfileio.c b/gs/psi/zfileio.c
index 72224459a..fa5e39f26 100644
--- a/gs/psi/zfileio.c
+++ b/gs/psi/zfileio.c
@@ -70,7 +70,7 @@ zread(i_ctx_t *i_ctx_p)
stream *s;
int ch;
- check_read_file(s, op);
+ check_read_file(i_ctx_p, s, op);
/* We 'push' first in case of ostack block overflow and the */
/* usual case is we will need to push anyway. If we get EOF */
/* we will need to 'pop' and decrement the 'op' pointer. */
@@ -130,7 +130,7 @@ zreadhexstring_at(i_ctx_t *i_ctx_p, os_ptr op, uint start, int odd)
stream_cursor_write cw;
int status;
- check_read_file(s, op - 1);
+ check_read_file(i_ctx_p, s, op - 1);
/*check_write_type(*op, t_string); *//* done by caller */
str = op->value.bytes;
len = r_size(op);
@@ -282,7 +282,7 @@ zreadstring_at(i_ctx_t *i_ctx_p, os_ptr op, uint start)
int status;
check_write_type(*op, t_string);
- check_read_file(s, op - 1);
+ check_read_file(i_ctx_p, s, op - 1);
len = r_size(op);
status = sgets(s, op->value.bytes + start, len - start, &rlen);
rlen += start;
@@ -372,7 +372,7 @@ zreadline_at(i_ctx_t *i_ctx_p, os_ptr op, uint count, bool in_eol)
gs_string str;
check_write_type(*op, t_string);
- check_read_file(s, op - 1);
+ check_read_file(i_ctx_p, s, op - 1);
str.data = op->value.bytes;
str.size = r_size(op);
status = zreadline_from(s, &str, NULL, &count, &in_eol);
@@ -453,7 +453,7 @@ zbytesavailable(i_ctx_t *i_ctx_p)
stream *s;
long avail;
- check_read_file(s, op);
+ check_read_file(i_ctx_p, s, op);
switch (savailable(s, &avail)) {
default:
return_error(e_ioerror);
@@ -680,7 +680,7 @@ zpeekstring(i_ctx_t *i_ctx_p)
stream *s;
uint len, rlen;
- check_read_file(s, op - 1);
+ check_read_file(i_ctx_p, s, op - 1);
check_write_type(*op, t_string);
len = r_size(op);
while ((rlen = sbufavailable(s)) < len) {
@@ -723,7 +723,7 @@ zunread(i_ctx_t *i_ctx_p)
stream *s;
ulong ch;
- check_read_file(s, op - 1);
+ check_read_file(i_ctx_p, s, op - 1);
check_type(*op, t_integer);
ch = op->value.intval;
if (ch > 0xff)
diff --git a/gs/psi/zfrsd.c b/gs/psi/zfrsd.c
index 1be7b4ba4..56924c555 100644
--- a/gs/psi/zfrsd.c
+++ b/gs/psi/zfrsd.c
@@ -182,7 +182,7 @@ zreusablestream(i_ctx_t *i_ctx_p)
stream *source;
stream *s;
- check_read_file(source, source_op);
+ check_read_file(i_ctx_p, source, source_op);
s = source;
rs:
if (s->cbuf_string.data != 0) { /* string stream */
@@ -263,13 +263,14 @@ make_rfs(i_ctx_t *i_ctx_p, os_ptr op, stream *fs, long offset, long length)
if (sfilename(fs, &fname) < 0)
return_error(e_ioerror);
- code = gs_parse_file_name(&pname, (const char *)fname.data, fname.size);
+ code = gs_parse_file_name(&pname, (const char *)fname.data, fname.size,
+ imemory);
if (code < 0)
return code;
if (pname.len == 0) /* %stdin% etc. won't have a filename */
return_error(e_invalidfileaccess); /* can't reopen */
if (pname.iodev == NULL)
- pname.iodev = iodev_default;
+ pname.iodev = iodev_default(imemory);
/* Open the file again, to be independent of the source. */
ialloc_set_space(idmemory, stream_space);
code = zopen_file(i_ctx_p, &pname, "r", &s, imemory);
diff --git a/gs/psi/zht.c b/gs/psi/zht.c
index 468216b25..66aa45257 100644
--- a/gs/psi/zht.c
+++ b/gs/psi/zht.c
@@ -138,7 +138,7 @@ zsetscreen(i_ctx_t *i_ctx_p)
* This keeps the space relationships consistent.
*/
code = gs_screen_order_init_memory(&order, igs, &screen,
- gs_currentaccuratescreens(), mem);
+ gs_currentaccuratescreens(mem), mem);
if (code < 0)
return code;
return zscreen_enum_init(i_ctx_p, &order, &screen, op, 3,
diff --git a/gs/psi/zht2.c b/gs/psi/zht2.c
index 0cd0aafc4..8d54ec4ed 100644
--- a/gs/psi/zht2.c
+++ b/gs/psi/zht2.c
@@ -30,7 +30,8 @@
#include "zht2.h"
/* Forward references */
-static int dict_spot_params(const ref *, gs_spot_halftone *, ref *, ref *);
+static int dict_spot_params(const ref *, gs_spot_halftone *, ref *, ref *,
+ gs_memory_t *);
static int dict_spot_results(i_ctx_t *, ref *, const gs_spot_halftone *);
static int dict_threshold_params(const ref *, gs_threshold_halftone *,
ref *);
@@ -205,7 +206,7 @@ zsethalftone5(i_ctx_t *i_ctx_p)
break;
case 1:
code = dict_spot_params(&rvalue[1], &pc->params.spot,
- sprocs + j, tprocs + j);
+ sprocs + j, tprocs + j, mem);
pc->params.spot.screen.spot_function = spot1_dummy;
pc->type = ht_type_spot;
break;
@@ -394,7 +395,7 @@ const op_def zht2_l2_op_defs[] =
/* from a dictionary. */
static int
dict_spot_params(const ref * pdict, gs_spot_halftone * psp,
- ref * psproc, ref * ptproc)
+ ref * psproc, ref * ptproc, gs_memory_t *mem)
{
int code;
@@ -405,7 +406,7 @@ dict_spot_params(const ref * pdict, gs_spot_halftone * psp,
&psp->screen.angle)) != 0 ||
(code = dict_proc_param(pdict, "SpotFunction", psproc, false)) != 0 ||
(code = dict_bool_param(pdict, "AccurateScreens",
- gs_currentaccuratescreens(),
+ gs_currentaccuratescreens(mem),
&psp->accurate_screens)) < 0 ||
(code = dict_proc_param(pdict, "TransferFunction", ptproc, false)) < 0
)
diff --git a/gs/psi/zicc.c b/gs/psi/zicc.c
index b418d0521..ca390219c 100644
--- a/gs/psi/zicc.c
+++ b/gs/psi/zicc.c
@@ -61,7 +61,7 @@ int seticc(i_ctx_t * i_ctx_p, int ncomps, ref *ICCdict, float *range_buff)
/* verify the DataSource entry */
if (dict_find_string(ICCdict, "DataSource", &pstrmval) <= 0)
return_error(e_undefined);
- check_read_file(s, pstrmval);
+ check_read_file(i_ctx_p, s, pstrmval);
/* build the color space object */
code = gs_cspace_build_ICC(&pcs, NULL, gs_state_memory(igs));
@@ -218,7 +218,7 @@ zseticcspace(i_ctx_t * i_ctx_p)
/* verify the DataSource entry */
if (dict_find_string(op, "DataSource", &pstrmval) <= 0)
return_error(e_undefined);
- check_read_file(s, pstrmval);
+ check_read_file(i_ctx_p, s, pstrmval);
/*
* Verify that the current color space can be a alternative color space.
* The check for ICCBased color space is a hack to avoid introducing yet
diff --git a/gs/psi/ziodev.c b/gs/psi/ziodev.c
index 74a5a3cd9..f47dc2849 100644
--- a/gs/psi/ziodev.c
+++ b/gs/psi/ziodev.c
@@ -74,7 +74,7 @@ zgetiodevice(i_ctx_t *i_ctx_p)
const byte *dname;
check_type(*op, t_integer);
- iodev = gs_getiodevice((int)(op->value.intval));
+ iodev = gs_getiodevice(imemory, (int)(op->value.intval));
if (iodev == 0) /* index out of range */
return_error(e_rangecheck);
dname = (const byte *)iodev->dname;
@@ -129,7 +129,7 @@ zfilelineedit(i_ctx_t *i_ctx_p)
count = (op-1)->value.intval;
check_type(*(op-2), t_boolean); /* statementedit/lineedit */
statement = (op-2)->value.boolval;
- check_read_file(ins, op - 3); /* %stdin */
+ check_read_file(i_ctx_p, ins, op - 3); /* %stdin */
/* extend string */
initial_buf_size = statement ? STATEMENTEDIT_BUF_SIZE : LINEEDIT_BUF_SIZE;
diff --git a/gs/psi/ziodev2.c b/gs/psi/ziodev2.c
index 368428517..f366cecd2 100644
--- a/gs/psi/ziodev2.c
+++ b/gs/psi/ziodev2.c
@@ -66,7 +66,7 @@ zgetdevparams(i_ctx_t *i_ctx_p)
ref *pmark;
check_read_type(*op, t_string);
- iodev = gs_findiodevice(op->value.bytes, r_size(op));
+ iodev = gs_findiodevice(imemory, op->value.bytes, r_size(op));
if (iodev == 0)
return_error(e_undefined);
stack_param_list_write(&list, &o_stack, NULL, iimemory);
@@ -91,7 +91,7 @@ zputdevparams(i_ctx_t *i_ctx_p)
password system_params_password;
check_read_type(*op, t_string);
- iodev = gs_findiodevice(op->value.bytes, r_size(op));
+ iodev = gs_findiodevice(imemory, op->value.bytes, r_size(op));
if (iodev == 0)
return_error(e_undefined);
code = stack_param_list_read(&list, &o_stack, 1, NULL, false, iimemory);
diff --git a/gs/psi/ziodevsc.c b/gs/psi/ziodevsc.c
index 4515e1c5e..1830eff86 100644
--- a/gs/psi/ziodevsc.c
+++ b/gs/psi/ziodevsc.c
@@ -162,7 +162,7 @@ zget_stdin(i_ctx_t *i_ctx_p, stream ** ps)
*ps = s;
return 0;
}
- iodev = gs_findiodevice((const byte *)"%stdin", 6);
+ iodev = gs_findiodevice(imemory, (const byte *)"%stdin", 6);
iodev->state = i_ctx_p;
code = (*iodev->procs.open_device)(iodev, "r", ps, imemory_system);
iodev->state = NULL;
@@ -240,7 +240,7 @@ zget_stdout(i_ctx_t *i_ctx_p, stream ** ps)
*ps = s;
return 0;
}
- iodev = gs_findiodevice((const byte *)"%stdout", 7);
+ iodev = gs_findiodevice(imemory, (const byte *)"%stdout", 7);
iodev->state = i_ctx_p;
code = (*iodev->procs.open_device)(iodev, "w", ps, imemory_system);
iodev->state = NULL;
@@ -311,7 +311,7 @@ zget_stderr(i_ctx_t *i_ctx_p, stream ** ps)
*ps = s;
return 0;
}
- iodev = gs_findiodevice((const byte *)"%stderr", 7);
+ iodev = gs_findiodevice(imemory, (const byte *)"%stderr", 7);
iodev->state = i_ctx_p;
code = (*iodev->procs.open_device)(iodev, "w", ps, imemory_system);
iodev->state = NULL;
diff --git a/gs/psi/zmisc.c b/gs/psi/zmisc.c
index a832a0ae0..aae51e6ad 100644
--- a/gs/psi/zmisc.c
+++ b/gs/psi/zmisc.c
@@ -170,26 +170,17 @@ zserialnumber(i_ctx_t *i_ctx_p)
return 0;
}
-/* some FTS tests work better if realtime starts from 0 at boot time */
-static long real_time_0[2];
-
-static int
-zmisc_init_realtime(i_ctx_t * i_ctx_p)
-{
- gp_get_realtime(real_time_0);
- return 0;
-}
-
/* - realtime <int> */
static int
zrealtime(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
long secs_ns[2];
+ gs_lib_ctx_t *libctx = gs_lib_ctx_get_interp_instance(imemory);
gp_get_realtime(secs_ns);
- secs_ns[1] -= real_time_0[1];
- secs_ns[0] -= real_time_0[0];
+ secs_ns[1] -= libctx->real_time_0[1];
+ secs_ns[0] -= libctx->real_time_0[0];
push(1);
make_int(op, secs_ns[0] * 1000 + secs_ns[1] / 1000000);
return 0;
@@ -521,5 +512,5 @@ const op_def zmisc_op_defs[] =
{"2.pcacheinsert", zpcacheinsert},
{"1.pcachequery", zpcachequery},
#endif
- op_def_end(zmisc_init_realtime)
+ op_def_end(0)
};
diff --git a/gs/psi/zshade.c b/gs/psi/zshade.c
index dfc07d36b..733a44574 100644
--- a/gs/psi/zshade.c
+++ b/gs/psi/zshade.c
@@ -494,7 +494,7 @@ build_mesh_shading(i_ctx_t *i_ctx_p, const ref * op,
case t_file: {
stream *s;
- check_read_file(s, pDataSource);
+ check_read_file(i_ctx_p, s, pDataSource);
data_source_init_stream(&params->DataSource, s);
break;
}
diff --git a/gs/psi/ztoken.c b/gs/psi/ztoken.c
index 3e96a743a..2e8feb20d 100644
--- a/gs/psi/ztoken.c
+++ b/gs/psi/ztoken.c
@@ -48,7 +48,7 @@ ztoken(i_ctx_t *i_ctx_p)
stream *s;
scanner_state state;
- check_read_file(s, op);
+ check_read_file(i_ctx_p, s, op);
check_ostack(1);
scanner_init(&state, op);
return token_continue(i_ctx_p, &state, true);
@@ -158,7 +158,7 @@ ztokenexec(i_ctx_t *i_ctx_p)
stream *s;
scanner_state state;
- check_read_file(s, op);
+ check_read_file(i_ctx_p, s, op);
check_estack(1);
scanner_init(&state, op);
return tokenexec_continue(i_ctx_p, &state, true);
diff --git a/gs/psi/zusparam.c b/gs/psi/zusparam.c
index 9abd82fc6..723d64c93 100644
--- a/gs/psi/zusparam.c
+++ b/gs/psi/zusparam.c
@@ -414,12 +414,12 @@ set_WaitTimeout(i_ctx_t *i_ctx_p, long val)
static long
current_MinScreenLevels(i_ctx_t *i_ctx_p)
{
- return gs_currentminscreenlevels();
+ return gs_currentminscreenlevels(imemory);
}
static int
set_MinScreenLevels(i_ctx_t *i_ctx_p, long val)
{
- gs_setminscreenlevels((uint) val);
+ gs_setminscreenlevels(imemory, (uint) val);
return 0;
}
static long
@@ -819,24 +819,24 @@ static const string_param_def_t user_string_params[] =
static bool
current_AccurateScreens(i_ctx_t *i_ctx_p)
{
- return gs_currentaccuratescreens();
+ return gs_currentaccuratescreens(imemory);
}
static int
set_AccurateScreens(i_ctx_t *i_ctx_p, bool val)
{
- gs_setaccuratescreens(val);
+ gs_setaccuratescreens(imemory, val);
return 0;
}
/* Boolean values */
static bool
current_UseWTS(i_ctx_t *i_ctx_p)
{
- return gs_currentusewts();
+ return gs_currentusewts(imemory);
}
static int
set_UseWTS(i_ctx_t *i_ctx_p, bool val)
{
- gs_setusewts(val);
+ gs_setusewts(imemory, val);
return 0;
}
static bool
diff --git a/gs/psi/zvmem.c b/gs/psi/zvmem.c
index da4dd771a..ac71af50d 100644
--- a/gs/psi/zvmem.c
+++ b/gs/psi/zvmem.c
@@ -101,7 +101,7 @@ zsave(i_ctx_t *i_ctx_p)
/* <save> restore - */
static int restore_check_operand(os_ptr, alloc_save_t **, gs_dual_memory_t *);
static int restore_check_stack(const i_ctx_t *i_ctx_p, const ref_stack_t *, const alloc_save_t *, bool);
-static void restore_fix_stack(ref_stack_t *, const alloc_save_t *, bool);
+static void restore_fix_stack(i_ctx_t *i_ctx_p, ref_stack_t *, const alloc_save_t *, bool);
int
zrestore(i_ctx_t *i_ctx_p)
{
@@ -133,9 +133,9 @@ zrestore(i_ctx_t *i_ctx_p)
}
/* Reset l_new in all stack entries if the new save level is zero. */
/* Also do some special fixing on the e-stack. */
- restore_fix_stack(&o_stack, asave, false);
- restore_fix_stack(&e_stack, asave, true);
- restore_fix_stack(&d_stack, asave, false);
+ restore_fix_stack(i_ctx_p, &o_stack, asave, false);
+ restore_fix_stack(i_ctx_p, &e_stack, asave, true);
+ restore_fix_stack(i_ctx_p, &d_stack, asave, false);
/* Iteratively restore the state of memory, */
/* also doing a grestoreall at each step. */
do {
@@ -306,8 +306,8 @@ restore_check_stack(const i_ctx_t *i_ctx_p, const ref_stack_t * pstack,
* Note that this procedure is only called if restore_check_stack succeeded.
*/
static void
-restore_fix_stack(ref_stack_t * pstack, const alloc_save_t * asave,
- bool is_estack)
+restore_fix_stack(i_ctx_t *i_ctx_p, ref_stack_t * pstack,
+ const alloc_save_t * asave, bool is_estack)
{
ref_stack_enum_t rsenum;
@@ -337,7 +337,7 @@ restore_fix_stack(ref_stack_t * pstack, const alloc_save_t * asave,
if (alloc_is_since_save(stkp->value.pfile,
asave)
) {
- make_invalid_file(stkp);
+ make_invalid_file(i_ctx_p, stkp);
break;
}
continue;
@@ -389,9 +389,9 @@ zforgetsave(i_ctx_t *i_ctx_p)
return 0;
vmsave = alloc_save_client_data(asave);
/* Reset l_new in all stack entries if the new save level is zero. */
- restore_fix_stack(&o_stack, asave, false);
- restore_fix_stack(&e_stack, asave, false);
- restore_fix_stack(&d_stack, asave, false);
+ restore_fix_stack(i_ctx_p, &o_stack, asave, false);
+ restore_fix_stack(i_ctx_p, &e_stack, asave, false);
+ restore_fix_stack(i_ctx_p, &d_stack, asave, false);
/*
* Forget the gsaves, by deleting the bottom gstate on
* the current stack and the top one on the saved stack and then
diff --git a/gs/tiff/libtiff/tif_aux.c b/gs/tiff/libtiff/tif_aux.c
index 43d591b38..f9daa3b7c 100644
--- a/gs/tiff/libtiff/tif_aux.c
+++ b/gs/tiff/libtiff/tif_aux.c
@@ -100,6 +100,35 @@ bad:
return 0;
}
+static int
+TIFFDefaultRefBlackWhite(TIFFDirectory* td)
+{
+ int i;
+
+ if (!(td->td_refblackwhite = (float *)_TIFFmalloc(6*sizeof (float))))
+ return 0;
+ if (td->td_photometric == PHOTOMETRIC_YCBCR) {
+/*
+ * YCbCr (Class Y) images must have the ReferenceBlackWhite
+ * tag set. Fix the broken images, which lacks that tag.
+ */
+ td->td_refblackwhite[0] = 0.0F;
+ td->td_refblackwhite[1] = td->td_refblackwhite[3] =
+ td->td_refblackwhite[5] = 255.0F;
+ td->td_refblackwhite[2] = td->td_refblackwhite[4] = 128.0F;
+ } else {
+ /*
+ * Assume RGB (Class R)
+ */
+ for (i = 0; i < 3; i++) {
+ td->td_refblackwhite[2*i+0] = 0;
+ td->td_refblackwhite[2*i+1] =
+ (float)((1L<<td->td_bitspersample)-1L);
+ }
+ }
+ return 1;
+}
+
/*
* Like TIFFGetField, but return any default
* value if the tag is not present in the directory.
@@ -167,7 +196,7 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)
return (1);
case TIFFTAG_EXTRASAMPLES:
*va_arg(ap, uint16 *) = td->td_extrasamples;
- *va_arg(ap, uint16 **) = td->td_sampleinfo;
+ *va_arg(ap, const uint16 **) = td->td_sampleinfo;
return (1);
case TIFFTAG_MATTEING:
*va_arg(ap, uint16 *) =
@@ -189,8 +218,8 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)
case TIFFTAG_YCBCRCOEFFICIENTS:
{
/* defaults are from CCIR Recommendation 601-1 */
- static float ycbcrcoeffs[] = { 0.299f, 0.587f, 0.114f };
- *va_arg(ap, float **) = ycbcrcoeffs;
+ static const float ycbcrcoeffs[] = { 0.299f, 0.587f, 0.114f };
+ *va_arg(ap, const float **) = ycbcrcoeffs;
return 1;
}
case TIFFTAG_YCBCRSUBSAMPLING:
@@ -202,14 +231,12 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)
return (1);
case TIFFTAG_WHITEPOINT:
{
- static float whitepoint[2];
-
/* TIFF 6.0 specification tells that it is no default
value for the WhitePoint, but AdobePhotoshop TIFF
Technical Note tells that it should be CIE D50. */
- whitepoint[0] = D50_X0 / (D50_X0 + D50_Y0 + D50_Z0);
- whitepoint[1] = D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0);
- *va_arg(ap, float **) = whitepoint;
+ static const float whitepoint[] = { D50_X0 / (D50_X0 + D50_Y0 + D50_Z0),
+ D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0) };
+ *va_arg(ap, const float **) = whitepoint;
return 1;
}
case TIFFTAG_TRANSFERFUNCTION:
@@ -218,41 +245,18 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "No space for \"TransferFunction\" tag");
return (0);
}
- *va_arg(ap, uint16 **) = td->td_transferfunction[0];
+ *va_arg(ap, const uint16 **) = td->td_transferfunction[0];
if (td->td_samplesperpixel - td->td_extrasamples > 1) {
- *va_arg(ap, uint16 **) = td->td_transferfunction[1];
- *va_arg(ap, uint16 **) = td->td_transferfunction[2];
+ *va_arg(ap, const uint16 **) = td->td_transferfunction[1];
+ *va_arg(ap, const uint16 **) = td->td_transferfunction[2];
}
return (1);
case TIFFTAG_REFERENCEBLACKWHITE:
- {
- int i;
- static float ycbcr_refblackwhite[] =
- { 0.0F, 255.0F, 128.0F, 255.0F, 128.0F, 255.0F };
- static float rgb_refblackwhite[6];
-
- for (i = 0; i < 3; i++) {
- rgb_refblackwhite[2 * i + 0] = 0.0F;
- rgb_refblackwhite[2 * i + 1] =
- (float)((1L<<td->td_bitspersample)-1L);
- }
-
- if (td->td_photometric == PHOTOMETRIC_YCBCR) {
- /*
- * YCbCr (Class Y) images must have the
- * ReferenceBlackWhite tag set. Fix the
- * broken images, which lacks that tag.
- */
- *va_arg(ap, float **) = ycbcr_refblackwhite;
- } else {
- /*
- * Assume RGB (Class R)
- */
- *va_arg(ap, float **) = rgb_refblackwhite;
+ if (!td->td_refblackwhite && !TIFFDefaultRefBlackWhite(td))
+ return (0);
+ *va_arg(ap, const float **) = td->td_refblackwhite;
+ return (1);
}
- return 1;
- }
- }
return 0;
}
diff --git a/gs/tiff/libtiff/tif_dir.c b/gs/tiff/libtiff/tif_dir.c
index 102c9a85c..ed68ee5de 100644
--- a/gs/tiff/libtiff/tif_dir.c
+++ b/gs/tiff/libtiff/tif_dir.c
@@ -377,6 +377,10 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
_TIFFsetShortArray(&td->td_transferfunction[i],
va_arg(ap, uint16*), 1L<<td->td_bitspersample);
break;
+ case TIFFTAG_REFERENCEBLACKWHITE:
+ /* XXX should check for null range */
+ _TIFFsetFloatArray(&td->td_refblackwhite, va_arg(ap, float*), 6);
+ break;
case TIFFTAG_INKNAMES:
v = va_arg(ap, uint32);
s = va_arg(ap, char*);
@@ -745,17 +749,17 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
*va_arg(ap, uint16*) = td->td_halftonehints[1];
break;
case TIFFTAG_COLORMAP:
- *va_arg(ap, uint16**) = td->td_colormap[0];
- *va_arg(ap, uint16**) = td->td_colormap[1];
- *va_arg(ap, uint16**) = td->td_colormap[2];
+ *va_arg(ap, const uint16**) = td->td_colormap[0];
+ *va_arg(ap, const uint16**) = td->td_colormap[1];
+ *va_arg(ap, const uint16**) = td->td_colormap[2];
break;
case TIFFTAG_STRIPOFFSETS:
case TIFFTAG_TILEOFFSETS:
- *va_arg(ap, uint32**) = td->td_stripoffset;
+ *va_arg(ap, const uint32**) = td->td_stripoffset;
break;
case TIFFTAG_STRIPBYTECOUNTS:
case TIFFTAG_TILEBYTECOUNTS:
- *va_arg(ap, uint32**) = td->td_stripbytecount;
+ *va_arg(ap, const uint32**) = td->td_stripbytecount;
break;
case TIFFTAG_MATTEING:
*va_arg(ap, uint16*) =
@@ -764,7 +768,7 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
break;
case TIFFTAG_EXTRASAMPLES:
*va_arg(ap, uint16*) = td->td_extrasamples;
- *va_arg(ap, uint16**) = td->td_sampleinfo;
+ *va_arg(ap, const uint16**) = td->td_sampleinfo;
break;
case TIFFTAG_TILEWIDTH:
*va_arg(ap, uint32*) = td->td_tilewidth;
@@ -799,7 +803,7 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
break;
case TIFFTAG_SUBIFD:
*va_arg(ap, uint16*) = td->td_nsubifd;
- *va_arg(ap, uint32**) = td->td_subifd;
+ *va_arg(ap, const uint32**) = td->td_subifd;
break;
case TIFFTAG_YCBCRPOSITIONING:
*va_arg(ap, uint16*) = td->td_ycbcrpositioning;
@@ -809,14 +813,17 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
*va_arg(ap, uint16*) = td->td_ycbcrsubsampling[1];
break;
case TIFFTAG_TRANSFERFUNCTION:
- *va_arg(ap, uint16**) = td->td_transferfunction[0];
+ *va_arg(ap, const uint16**) = td->td_transferfunction[0];
if (td->td_samplesperpixel - td->td_extrasamples > 1) {
- *va_arg(ap, uint16**) = td->td_transferfunction[1];
- *va_arg(ap, uint16**) = td->td_transferfunction[2];
+ *va_arg(ap, const uint16**) = td->td_transferfunction[1];
+ *va_arg(ap, const uint16**) = td->td_transferfunction[2];
}
break;
+ case TIFFTAG_REFERENCEBLACKWHITE:
+ *va_arg(ap, const float**) = td->td_refblackwhite;
+ break;
case TIFFTAG_INKNAMES:
- *va_arg(ap, char**) = td->td_inknames;
+ *va_arg(ap, const char**) = td->td_inknames;
break;
default:
{
@@ -857,7 +864,7 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
*va_arg(ap, uint32*) = (uint32)tv->count;
else /* Assume TIFF_VARIABLE */
*va_arg(ap, uint16*) = (uint16)tv->count;
- *va_arg(ap, void **) = tv->value;
+ *va_arg(ap, const void **) = tv->value;
ret_val = 1;
} else {
if ((fip->field_type == TIFF_ASCII
@@ -869,7 +876,7 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
&& fip->field_tag != TIFFTAG_HALFTONEHINTS
&& fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING
&& fip->field_tag != TIFFTAG_DOTRANGE) {
- *va_arg(ap, void **) = tv->value;
+ *va_arg(ap, const void **) = tv->value;
ret_val = 1;
} else {
int j;
@@ -989,6 +996,7 @@ TIFFFreeDirectory(TIFF* tif)
CleanupField(td_sampleinfo);
CleanupField(td_subifd);
CleanupField(td_inknames);
+ CleanupField(td_refblackwhite);
CleanupField(td_transferfunction[0]);
CleanupField(td_transferfunction[1]);
CleanupField(td_transferfunction[2]);
diff --git a/gs/tiff/libtiff/tif_dir.h b/gs/tiff/libtiff/tif_dir.h
index e2aeea291..0a96ec0de 100644
--- a/gs/tiff/libtiff/tif_dir.h
+++ b/gs/tiff/libtiff/tif_dir.h
@@ -75,6 +75,7 @@ typedef struct {
uint16 td_ycbcrsubsampling[2];
uint16 td_ycbcrpositioning;
/* Colorimetry parameters */
+ float* td_refblackwhite;
uint16* td_transferfunction[3];
/* CMYK parameters */
int td_inknameslen;
@@ -133,6 +134,7 @@ typedef struct {
#define FIELD_HALFTONEHINTS 37
#define FIELD_YCBCRSUBSAMPLING 39
#define FIELD_YCBCRPOSITIONING 40
+#define FIELD_REFBLACKWHITE 41
#define FIELD_TRANSFERFUNCTION 44
#define FIELD_INKNAMES 46
#define FIELD_SUBIFD 49
diff --git a/gs/tiff/libtiff/tif_dirinfo.c b/gs/tiff/libtiff/tif_dirinfo.c
index 99a871cc3..0bd7632ee 100644
--- a/gs/tiff/libtiff/tif_dirinfo.c
+++ b/gs/tiff/libtiff/tif_dirinfo.c
@@ -217,7 +217,7 @@ tiffFieldInfo[] = {
0, 0, "YCbCrSubsampling" },
{ TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, FIELD_YCBCRPOSITIONING,
0, 0, "YCbCrPositioning" },
- { TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_RATIONAL, FIELD_CUSTOM,
+ { TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_RATIONAL, FIELD_REFBLACKWHITE,
1, 0, "ReferenceBlackWhite" },
/* XXX temporarily accept LONG for backwards compatibility */
{ TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_LONG, FIELD_CUSTOM,
diff --git a/gs/tiff/libtiff/tif_jpeg.c b/gs/tiff/libtiff/tif_jpeg.c
index 74b0d3f86..37b3d0ebb 100644
--- a/gs/tiff/libtiff/tif_jpeg.c
+++ b/gs/tiff/libtiff/tif_jpeg.c
@@ -1761,7 +1761,7 @@ JPEGVGetField(TIFF* tif, ttag_t tag, va_list ap)
switch (tag) {
case TIFFTAG_JPEGTABLES:
*va_arg(ap, uint32*) = sp->jpegtables_length;
- *va_arg(ap, void**) = sp->jpegtables;
+ *va_arg(ap, const void**) = sp->jpegtables;
break;
case TIFFTAG_JPEGQUALITY:
*va_arg(ap, int*) = sp->jpegquality;
diff --git a/gs/tiff/libtiff/tif_ojpeg.c b/gs/tiff/libtiff/tif_ojpeg.c
index 9d1e8043e..f5a712943 100644
--- a/gs/tiff/libtiff/tif_ojpeg.c
+++ b/gs/tiff/libtiff/tif_ojpeg.c
@@ -469,15 +469,15 @@ OJPEGVGetField(TIFF* tif, ttag_t tag, va_list ap)
break;
case TIFFTAG_JPEGQTABLES:
*va_arg(ap,uint32*)=(uint32)sp->qtable_offset_count;
- *va_arg(ap,void**)=(void*)sp->qtable_offset;
+ *va_arg(ap,const void**)=(const void*)sp->qtable_offset;
break;
case TIFFTAG_JPEGDCTABLES:
*va_arg(ap,uint32*)=(uint32)sp->dctable_offset_count;
- *va_arg(ap,void**)=(void*)sp->dctable_offset;
+ *va_arg(ap,const void**)=(const void*)sp->dctable_offset;
break;
case TIFFTAG_JPEGACTABLES:
*va_arg(ap,uint32*)=(uint32)sp->actable_offset_count;
- *va_arg(ap,void**)=(void*)sp->actable_offset;
+ *va_arg(ap,const void**)=(const void*)sp->actable_offset;
break;
case TIFFTAG_JPEGPROC:
*va_arg(ap,uint16*)=(uint16)sp->jpeg_proc;
diff --git a/gs/tiff/man/TIFFGetField.3tiff b/gs/tiff/man/TIFFGetField.3tiff
index 907cc4b49..27cce4779 100644
--- a/gs/tiff/man/TIFFGetField.3tiff
+++ b/gs/tiff/man/TIFFGetField.3tiff
@@ -103,77 +103,77 @@ meaning of each tag and their possible values.
.ta \w'TIFFTAG_CONSECUTIVEBADFAXLINES'u+2n +\w'Count'u+2n +\w'TIFFFaxFillFunc*'u+2n
\fITag Name\fP \fICount\fP \fITypes\fP \fINotes\fP
.sp 5p
-TIFFTAG_ARTIST 1 char**
+TIFFTAG_ARTIST 1 const char**
TIFFTAG_BADFAXLINES 1 uint32*
TIFFTAG_BITSPERSAMPLE 1 uint16*
TIFFTAG_CLEANFAXDATA 1 uint16*
-TIFFTAG_COLORMAP 3 uint16** 1<<BitsPerSample arrays
+TIFFTAG_COLORMAP 3 const uint16** 1<<BitsPerSample arrays
TIFFTAG_COMPRESSION 1 uint16*
TIFFTAG_CONSECUTIVEBADFAXLINES 1 uint32*
-TIFFTAG_COPYRIGHT 1 char**
+TIFFTAG_COPYRIGHT 1 const char**
TIFFTAG_DATATYPE 1 uint16*
-TIFFTAG_DATETIME 1 char**
-TIFFTAG_DOCUMENTNAME 1 char**
+TIFFTAG_DATETIME 1 const char**
+TIFFTAG_DOCUMENTNAME 1 const char**
TIFFTAG_DOTRANGE 2 uint16*
-TIFFTAG_EXTRASAMPLES 2 uint16*,uint16** count & types array
+TIFFTAG_EXTRASAMPLES 2 uint16*,const uint16** count & types array
TIFFTAG_FAXFILLFUNC 1 TIFFFaxFillFunc* G3/G4 compression pseudo-tag
TIFFTAG_FAXMODE 1 int* G3/G4 compression pseudo-tag
TIFFTAG_FILLORDER 1 uint16*
TIFFTAG_GROUP3OPTIONS 1 uint32*
TIFFTAG_GROUP4OPTIONS 1 uint32*
TIFFTAG_HALFTONEHINTS 2 uint16*
-TIFFTAG_HOSTCOMPUTER 1 char**
-TIFFTAG_ICCPROFILE 2 uint32*,void** count, profile data
+TIFFTAG_HOSTCOMPUTER 1 const char**
+TIFFTAG_ICCPROFILE 2 uint32*,const void** count, profile data
TIFFTAG_IMAGEDEPTH 1 uint32*
-TIFFTAG_IMAGEDESCRIPTION 1 char**
+TIFFTAG_IMAGEDESCRIPTION 1 const char**
TIFFTAG_IMAGELENGTH 1 uint32*
TIFFTAG_IMAGEWIDTH 1 uint32*
-TIFFTAG_INKNAMES 1 char**
+TIFFTAG_INKNAMES 1 const char**
TIFFTAG_INKSET 1 uint16*
TIFFTAG_JPEGCOLORMODE 1 int* JPEG pseudo-tag
TIFFTAG_JPEGQUALITY 1 int* JPEG pseudo-tag
-TIFFTAG_JPEGTABLES 2 uint32*,void** count & tables
+TIFFTAG_JPEGTABLES 2 uint32*,const void** count & tables
TIFFTAG_JPEGTABLESMODE 1 int* JPEG pseudo-tag
-TIFFTAG_MAKE 1 char**
+TIFFTAG_MAKE 1 const char**
TIFFTAG_MATTEING 1 uint16*
TIFFTAG_MAXSAMPLEVALUE 1 uint16*
TIFFTAG_MINSAMPLEVALUE 1 uint16*
-TIFFTAG_MODEL 1 char**
+TIFFTAG_MODEL 1 const char**
TIFFTAG_ORIENTATION 1 uint16*
-TIFFTAG_PAGENAME 1 char**
+TIFFTAG_PAGENAME 1 const char**
TIFFTAG_PAGENUMBER 2 uint16*
TIFFTAG_PHOTOMETRIC 1 uint16*
-TIFFTAG_PHOTOSHOP 2 uint32*,void** count, data
+TIFFTAG_PHOTOSHOP 2 uint32*,const void** count, data
TIFFTAG_PLANARCONFIG 1 uint16*
TIFFTAG_PREDICTOR 1 uint16*
-TIFFTAG_PRIMARYCHROMATICITIES 1 float** 6-entry array
-TIFFTAG_REFERENCEBLACKWHITE 1 float** 2*SamplesPerPixel array
+TIFFTAG_PRIMARYCHROMATICITIES 1 const float** 6-entry array
+TIFFTAG_REFERENCEBLACKWHITE 1 const float** 2*SamplesPerPixel array
TIFFTAG_RESOLUTIONUNIT 1 uint16*
-TIFFTAG_RICHTIFFIPTC 2 uint32*,void** count, data
+TIFFTAG_RICHTIFFIPTC 2 uint32*,const void** count, data
TIFFTAG_ROWSPERSTRIP 1 uint32*
TIFFTAG_SAMPLEFORMAT 1 uint16*
TIFFTAG_SAMPLESPERPIXEL 1 uint16*
TIFFTAG_SMAXSAMPLEVALUE 1 double*
TIFFTAG_SMINSAMPLEVALUE 1 double*
-TIFFTAG_SOFTWARE 1 char**
-TIFFTAG_STONITS 1 double**
-TIFFTAG_STRIPBYTECOUNTS 1 uint32**
-TIFFTAG_STRIPOFFSETS 1 uint32**
+TIFFTAG_SOFTWARE 1 const char**
+TIFFTAG_STONITS 1 const double**
+TIFFTAG_STRIPBYTECOUNTS 1 const uint32**
+TIFFTAG_STRIPOFFSETS 1 const uint32**
TIFFTAG_SUBFILETYPE 1 uint32*
-TIFFTAG_SUBIFD 2 uint16*,uint32** count & offsets array
-TIFFTAG_TARGETPRINTER 1 char**
+TIFFTAG_SUBIFD 2 uint16*,const uint32** count & offsets array
+TIFFTAG_TARGETPRINTER 1 const char**
TIFFTAG_THRESHHOLDING 1 uint16*
-TIFFTAG_TILEBYTECOUNTS 1 uint32**
+TIFFTAG_TILEBYTECOUNTS 1 const uint32**
TIFFTAG_TILEDEPTH 1 uint32*
TIFFTAG_TILELENGTH 1 uint32*
-TIFFTAG_TILEOFFSETS 1 uint32**
+TIFFTAG_TILEOFFSETS 1 const uint32**
TIFFTAG_TILEWIDTH 1 uint32*
-TIFFTAG_TRANSFERFUNCTION 1 or 3\(dg uint16**1<<BitsPerSample entry arrays
-TIFFTAG_WHITEPOINT 1 float** 2-entry array
-TIFFTAG_XMLPACKET 2 uint32*,void** count, data
+TIFFTAG_TRANSFERFUNCTION 1 or 3\(dg const uint16**1<<BitsPerSample entry arrays
+TIFFTAG_WHITEPOINT 1 const float** 2-entry array
+TIFFTAG_XMLPACKET 2 uint32*,const void** count, data
TIFFTAG_XPOSITION 1 float*
TIFFTAG_XRESOLUTION 1 float*
-TIFFTAG_YCBCRCOEFFICIENTS 1 float** 3-entry array
+TIFFTAG_YCBCRCOEFFICIENTS 1 const float** 3-entry array
TIFFTAG_YCBCRPOSITIONING 1 uint16*
TIFFTAG_YCBCRSUBSAMPLING 2 uint16*
TIFFTAG_YPOSITION 1 float*
diff --git a/gs/toolbin/localcluster/build.pl b/gs/toolbin/localcluster/build.pl
index 214e6b606..55ed40b9c 100755
--- a/gs/toolbin/localcluster/build.pl
+++ b/gs/toolbin/localcluster/build.pl
@@ -24,6 +24,7 @@ my $bmpcmp=0;
my $local=0;
my $filename="";
my $bmpcmpOptions;
+my $bmpcmp_icc_work=0;
my $t;
@@ -35,6 +36,8 @@ while ($t=shift) {
$lowres=1;
} elsif ($t eq "highres") {
$highres=1;
+ } elsif ($t eq "bmpcmp_icc_work") {
+ $bmpcmp_icc_work=1;
} elsif ($t eq "bmpcmp") {
$bmpcmp=1;
$filename=shift;
@@ -98,8 +101,7 @@ $svnURLPrivate='svn+ssh://svn.ghostscript.com/var/lib/svn-private/ghostpcl/trunk
$svnURLPublic='http://svn.ghostscript.com/ghostscript/';
}
-my $timeCommand="";
-my $niceCommand="";
+my $preCommand="";
my $temp="./temp";
#$temp="/tmp/space/temp";
@@ -118,6 +120,7 @@ my $pclBin=$baseDirectory."gs/bin/pcl6";
my $xpsBin=$baseDirectory."gs/bin/gxps";
my $svgBin=$baseDirectory."gs/bin/gsvg";
my $mupdfBin=$baseDirectory."gs/bin/pdfdraw";
+my $timeBin=$baseDirectory."gs/bin/time";
# mupdf uses the same test files as gs but only ones ending in pdf (or PDF)
@@ -324,9 +327,9 @@ sub build($$$$$) {
my $bmpcmp=shift;
if ($md5sumOnly) {
- $niceCommand = 'nice';
+ $preCommand = "nice $timeBin -f \"%U %S %E %P\"";
} else {
- $timeCommand = '/usr/bin/time -f "%U %S %E %P"';
+ $preCommand = "$timeBin -f \"%U %S %E %P\"";
}
my $cmd="";
@@ -367,13 +370,13 @@ sub build($$$$$) {
$outputFilename="$temp/$tempname.$options.pdf";
if ($product eq 'gs') {
- $cmd1a.="$niceCommand $gsBin";
+ $cmd1a.="$gsBin";
} elsif ($product eq 'pcl') {
- $cmd1a.="$niceCommand $pclBin";
+ $cmd1a.="$pclBin";
} elsif ($product eq 'xps') {
- $cmd1a.="$niceCommand $xpsBin";
+ $cmd1a.="$xpsBin";
} elsif ($product eq 'svg') {
- $cmd1a.="$niceCommand $svgBin";
+ $cmd1a.="$svgBin";
} else {
die "unexpected product: $product";
}
@@ -395,13 +398,17 @@ sub build($$$$$) {
# $cmd.=" 2>&1";
if ($bmpcmp) {
- $cmd.=" ; $timeCommand $cmd1a $cmd1b $cmd1c >>$logFilename 2>&1";
+ $cmd.=" ; $preCommand $cmd1a $cmd1b $cmd1c >>$logFilename 2>&1";
+ if ($bmpcmp_icc_work) {
+ $cmd1a =~ s|/gs/|/icc_work/|;
+ } else {
$cmd1a =~ s|/gs/|/head/|;
+ }
$cmd1b =~ s|$temp|$baselineRaster|;
- $cmd.=" ; $timeCommand $cmd1a $cmd1b $cmd1c >>$logFilename 2>&1";
+ $cmd.=" ; $preCommand $cmd1a $cmd1b $cmd1c >>$logFilename 2>&1";
} else {
$cmd.=" ; echo \"$cmd1a $cmd1b $cmd1c\" >>$logFilename ";
- $cmd.=" ; $timeCommand $cmd1a $cmd1b $cmd1c >>$logFilename 2>&1";
+ $cmd.=" ; $preCommand $cmd1a $cmd1b $cmd1c >>$logFilename 2>&1";
}
$cmd.=" ; echo '---' >>$logFilename";
@@ -413,7 +420,7 @@ sub build($$$$$) {
$rasterFilename="$raster/$tempname.$options";
$bmpcmpFilename="$bmpcmpDir/$tempname.$options";
- $cmd2a.=" $niceCommand $gsBin";
+ $cmd2a.=" $gsBin";
if ($updateBaseline) {
$cmd2b.=" -sOutputFile='|gzip -1 -n >$baselineFilename.gz'";
} elsif ($md5sumOnly) {
@@ -440,16 +447,20 @@ sub build($$$$$) {
$cmd2c.=" $inputFilename";
if ($bmpcmp) {
- $cmd.=" ; $timeCommand $cmd2a -sOutputFile='|gzip -1 -n >$outputFilename.gz' $cmd2c >>$logFilename 2>&1";
+ $cmd.=" ; $preCommand $cmd2a -sOutputFile='|gzip -1 -n >$outputFilename.gz' $cmd2c >>$logFilename 2>&1";
+ if ($bmpcmp_icc_work) {
+ $cmd2a =~ s|/gs/|/icc_work/|;
+ } else {
$cmd2a =~ s|/gs/|/head/|;
+ }
$cmd2c =~ s|$temp|$baselineRaster|;
- $cmd.=" ; $timeCommand $cmd2a -sOutputFile='|gzip -1 -n >$baselineFilename.gz' $cmd2c >>$logFilename 2>&1";
- $cmd.=" ; bash -c \"./bmpcmp $bmpcmpOptions <(gunzip -c $outputFilename.gz) <(gunzip -c $baselineFilename.gz) $bmpcmpFilename 0 100\""; # ; gzip $bmpcmpFilename.* ";
+ $cmd.=" ; $preCommand $cmd2a -sOutputFile='|gzip -1 -n >$baselineFilename.gz' $cmd2c >>$logFilename 2>&1";
+ $cmd.=" ; bash -c \"nice ./bmpcmp $bmpcmpOptions <(gunzip -c $outputFilename.gz) <(gunzip -c $baselineFilename.gz) $bmpcmpFilename 0 100\""; # ; gzip $bmpcmpFilename.* ";
$cmd.=" ; bash -c \"for (( c=1; c<=5; c++ )); do scp -q -o ConnectTimeout=30 -i ~/.ssh/cluster_key $bmpcmpFilename.* regression\@casper3.ghostscript.com:/home/regression/cluster/bmpcmp/. ; t=\\\$?; if [ \\\$t == 0 ]; then break; fi; echo 'scp retry \\\$c' ; done \"";
# $cmd.=" ; scp -q -o ConnectTimeout=30 -i ~/.ssh/cluster_key $logFilename regression\@casper3.ghostscript.com:/home/regression/cluster/bmpcmp/.";
} else {
$cmd.=" ; echo \"$cmd2a $cmd2b $cmd2c\" >>$logFilename ";
- $cmd.=" ; $timeCommand $cmd2a $cmd2b $cmd2c >>$logFilename 2>&1";
+ $cmd.=" ; $preCommand $cmd2a $cmd2b $cmd2c >>$logFilename 2>&1";
if ($local) {
$cmd.=" ; zcat $outputFilename.gz | md5sum >$md5Filename";
# $cmd.=" ; md5sum $outputFilename.gz >$md5Filename";
@@ -472,15 +483,15 @@ sub build($$$$$) {
$bmpcmpFilename="$bmpcmpDir/$tempname.$options";
if ($product eq 'gs') {
- $cmd2a.=" $niceCommand $gsBin";
+ $cmd2a.=" $gsBin";
} elsif ($product eq 'pcl') {
- $cmd2a.=" $niceCommand $pclBin";
+ $cmd2a.=" $pclBin";
} elsif ($product eq 'xps') {
- $cmd2a.=" $niceCommand $xpsBin";
+ $cmd2a.=" $xpsBin";
} elsif ($product eq 'svg') {
- $cmd2a.=" $niceCommand $svgBin";
+ $cmd2a.=" $svgBin";
} elsif ($product eq 'mupdf') {
- $cmd2a.=" $niceCommand $mupdfBin";
+ $cmd2a.=" $mupdfBin";
} else {
die "unexpected product: $product";
}
@@ -491,7 +502,7 @@ sub build($$$$$) {
$cmd2b.=" -o $outputFilename.%04d";
$cmd2b.=" $inputFilename ";
$cmd.=" ; echo \"$cmd2a $cmd2b $cmd2c\" >>$logFilename ";
- $cmd.=" ; $timeCommand $cmd2a $cmd2b $cmd2c >>$logFilename 2>&1";
+ $cmd.=" ; $preCommand $cmd2a $cmd2b $cmd2c >>$logFilename 2>&1";
$cmd.=" ; cat $outputFilename.???? >$outputFilename ";
$cmd.=" ; md5sum $outputFilename >>$md5Filename";
} else {
@@ -524,15 +535,19 @@ sub build($$$$$) {
$cmd2c.=" $inputFilename ";
if ($bmpcmp) {
- $cmd.=" ; $timeCommand $cmd2a -sOutputFile='|gzip -1 -n >$outputFilename.gz' $cmd2c >>$logFilename 2>&1";
+ $cmd.=" ; $preCommand $cmd2a -sOutputFile='|gzip -1 -n >$outputFilename.gz' $cmd2c >>$logFilename 2>&1";
+ if ($bmpcmp_icc_work) {
+ $cmd2a =~ s|/gs/|/icc_work/|;
+ } else {
$cmd2a =~ s|/gs/|/head/|;
- $cmd.=" ; $timeCommand $cmd2a -sOutputFile='|gzip -1 -n >$baselineFilename.gz' $cmd2c >>$logFilename 2>&1";
- $cmd.=" ; bash -c \"./bmpcmp $bmpcmpOptions <(gunzip -c $outputFilename.gz) <(gunzip -c $baselineFilename.gz) $bmpcmpFilename 0 100\""; # ; gzip $bmpcmpFilename.* ";
+ }
+ $cmd.=" ; $preCommand $cmd2a -sOutputFile='|gzip -1 -n >$baselineFilename.gz' $cmd2c >>$logFilename 2>&1";
+ $cmd.=" ; bash -c \"nice ./bmpcmp $bmpcmpOptions <(gunzip -c $outputFilename.gz) <(gunzip -c $baselineFilename.gz) $bmpcmpFilename 0 100\""; # ; gzip $bmpcmpFilename.* ";
$cmd.=" ; bash -c \"for (( c=1; c<=5; c++ )); do scp -q -o ConnectTimeout=30 -i ~/.ssh/cluster_key $bmpcmpFilename.* regression\@casper3.ghostscript.com:/home/regression/cluster/bmpcmp/. ; t=\\\$?; if [ \\\$t == 0 ]; then break; fi; echo 'scp retry \\\$c' ; done \"";
# $cmd.=" ; scp -q -o ConnectTimeout=30 -i ~/.ssh/cluster_key $logFilename regression\@casper3.ghostscript.com:/home/regression/cluster/bmpcmp/.";
} else {
$cmd.=" ; echo \"$cmd2a $cmd2b $cmd2c\" >>$logFilename ";
- $cmd.=" ; $timeCommand $cmd2a $cmd2b $cmd2c >>$logFilename 2>&1";
+ $cmd.=" ; $preCommand $cmd2a $cmd2b $cmd2c >>$logFilename 2>&1";
if ($local) {
$cmd.=" ; zcat $outputFilename.gz | md5sum >$md5Filename";
# $cmd.=" ; md5sum $outputFilename.gz >$md5Filename";
diff --git a/gs/toolbin/localcluster/cachearchive.pl b/gs/toolbin/localcluster/cachearchive.pl
index 2061a8ffb..5cb379999 100755
--- a/gs/toolbin/localcluster/cachearchive.pl
+++ b/gs/toolbin/localcluster/cachearchive.pl
@@ -16,7 +16,7 @@ print STDERR "reading archive directory\n" if ($verbose);
my %archives;
if (opendir(DIR, 'archive')) { # || die "can't opendir archive: $!";
foreach (readdir(DIR)) {
- $archives{$_}=1 if (!(-d $_) && (m/.tab$/));
+ $archives{$_}=1 if (!(-d $_) && (m/.tab$/) && !(m/mupdf/));
}
closedir DIR;
}
diff --git a/gs/toolbin/localcluster/clustermaster.pl b/gs/toolbin/localcluster/clustermaster.pl
index 53b98238f..c5a604292 100755
--- a/gs/toolbin/localcluster/clustermaster.pl
+++ b/gs/toolbin/localcluster/clustermaster.pl
@@ -663,8 +663,13 @@ if ($normalRegression==1 || $userRegression ne "" || $mupdfRegression==1 || $upd
if ($product=~m/^bmpcmp/) {
$bmpcmp=1;
my @a=split ' ',$product,2;
+ if ($userName eq "mvrhel") {
+ $product="bmpcmp_icc_work bmpcmp $userName";
+ } else {
$product="bmpcmp $userName";
+ }
$options=$a[1];
+ $options="" if (!$options);
# print "userName=$userName product=$product options=$options\n"; exit;
}
mylog "userName=$userName product=$product options=$options\n" if ($verbose);
@@ -769,9 +774,14 @@ mylog "done checking jobs, product=$product\n";
}
if ($userRegression ne "") {
- my $cmd="diff -w -c -r ./ghostpdl ./users/$userName/ghostpdl | grep -v \"Only in\" > $userName.diff";
+ if ($userName eq "mvrhel") {
+ my $cmd="diff -I '\$Id:' -w -c -r ./icc_work ./users/$userName/ghostpdl/gs | grep -v \"Only in\" > $userName.diff";
+ `$cmd`;
+ } else {
+ my $cmd="diff -I '\$Id:' -w -c -r ./ghostpdl ./users/$userName/ghostpdl | grep -v \"Only in\" > $userName.diff";
`$cmd`;
}
+ }
use IO::Socket;
use Net::hostent;
@@ -1139,8 +1149,16 @@ mylog "now running ./compare.pl mupdf_current.tab mupdf_previous.tab $elapsedTim
checkPID();
+ if ($userName eq "mvrhel") {
+ open(F,">>$userName.txt");
+ print F "\nComparison made to current icc_work branch md5sums\n\n";
+ close(F);
+ mylog "now running ./compare.pl temp.tab icc_work_current.tab $elapsedTime $machineCount true \"$product\"\n";
+ `./compare.pl temp.tab icc_work_current.tab $elapsedTime $machineCount true \"$product\" >>$userName.txt`;
+ } else {
mylog "now running ./compare.pl temp.tab current.tab $elapsedTime $machineCount true \"$product\"\n";
`./compare.pl temp.tab current.tab $elapsedTime $machineCount true \"$product\" >>$userName.txt`;
+ }
open(F,">>$userName.txt");
print F "\n\nDifferences from previous clusterpush:\n\n";
diff --git a/gs/toolbin/localcluster/compare.pl b/gs/toolbin/localcluster/compare.pl
index c2e275043..d9101240b 100755
--- a/gs/toolbin/localcluster/compare.pl
+++ b/gs/toolbin/localcluster/compare.pl
@@ -6,7 +6,7 @@ use warnings;
use Data::Dumper;
my $verbose=1;
-
+my $reportAllErrors=0; # possibly changed below
my $previousValues=50;
my @errorDescription=(
@@ -32,7 +32,6 @@ my $products=shift;
$products="gs pcl xps svg" if (!$products);
my %skip;
-
if (open(F,"<skip.lst")) {
while(<F>) {
chomp;
@@ -42,6 +41,7 @@ if (open(F,"<skip.lst")) {
close(F);
}
+$reportAllErrors=1 if ($current=~m/icc_work/);
my %current;
@@ -324,7 +324,7 @@ if (!$skipMissing || $skipMissing eq "false" || $skipMissing eq "0") {
print "\n";
}
-if (0) {
+if ($reportAllErrors) {
if (@allErrors) {
print "The following ".scalar(@allErrors)." regression file(s) are producing errors:\n";
while(my $t=shift @allErrors) {
diff --git a/gs/toolbin/localcluster/run.pl b/gs/toolbin/localcluster/run.pl
index 5e1f6ae94..66f221e26 100755
--- a/gs/toolbin/localcluster/run.pl
+++ b/gs/toolbin/localcluster/run.pl
@@ -53,6 +53,10 @@ if ($local) {
}
}
+# the commands below only need to be done once
+mkdir("icc_work");
+mkdir("icc_work/bin");
+
my $user;
my $revs;
@@ -113,14 +117,21 @@ close(F);
mylog "starting run.pl: pid=$$\n";
-if (0) {
- mylog "about to kill any jobs still running from previous regression\n";
- my $a=`ps -ef | grep nice | grep temp | grep true | grep -v grep`;
+if (1) {
+ mylog "about to kill any jobs that appear to be running from previous regression\n";
+ my $a=`ps -ef | grep md5sum | grep temp | grep -v grep`;
my @a=split '\n',$a;
foreach (@a) {
- if (m/\S+ +(\d+)/) {
- mylog "killing $1\n";
- kill 9, $1;
+ chomp;
+ my @b=split ' ',$_,8;
+ my $minutes=-1;
+ $minutes=$1 if ($b[6]=~ m/\d+:(\d+):\d+/); # ps -ef results from linux (I know, this isn't right)
+ $minutes=$1 if ($b[6]=~ m/^(\d+):\d+\.\d+/); # ps -ef results from max os x
+ $minutes+=0; # convert from 01 to 1
+# print "$b[1] $b[6] $minutes\n";
+ if ($minutes>=10) {
+ mylog "killing $b[1] (running $minutes minutes): $b[7]\n";
+ kill 9, $b[1];
}
}
}
@@ -447,13 +458,14 @@ if (!$abort) {
}
+ mylog "$cmd";
print "$cmd\n" if ($verbose);
`$cmd`;
}
}
#`cc -o bmpcmp ghostpdl/gs/toolbin/bmpcmp.c`;
-`svn update $baseDirectory/ghostpdl/gs`;
+`svn update $baseDirectory/ghostpdl/gs/toolbin/bmpcmp.c`;
`cc -I$baseDirectory/ghostpdl/gs/libpng -o bmpcmp -DHAVE_LIBPNG $baseDirectory/ghostpdl/gs/toolbin/bmpcmp.c $baseDirectory/ghostpdl/gs/libpng/png.c $baseDirectory/ghostpdl/gs/libpng/pngerror.c $baseDirectory/ghostpdl/gs/libpng/pnggccrd.c $baseDirectory/ghostpdl/gs/libpng/pngget.c $baseDirectory/ghostpdl/gs/libpng/pngmem.c $baseDirectory/ghostpdl/gs/libpng/pngpread.c $baseDirectory/ghostpdl/gs/libpng/pngread.c $baseDirectory/ghostpdl/gs/libpng/pngrio.c $baseDirectory/ghostpdl/gs/libpng/pngrtran.c $baseDirectory/ghostpdl/gs/libpng/pngrutil.c $baseDirectory/ghostpdl/gs/libpng/pngset.c $baseDirectory/ghostpdl/gs/libpng/pngtrans.c $baseDirectory/ghostpdl/gs/libpng/pngvcrd.c $baseDirectory/ghostpdl/gs/libpng/pngwio.c $baseDirectory/ghostpdl/gs/libpng/pngwrite.c $baseDirectory/ghostpdl/gs/libpng/pngwtran.c $baseDirectory/ghostpdl/gs/libpng/pngwutil.c -lm -lz`;
mkdir("$gsBin");
@@ -538,6 +550,9 @@ if (!$dontBuild) {
`$cmd`;
if (-e "$gsBin/bin/gs") {
+ if ($icc_work) {
+ `cp -p $gsBin/bin/gs ./icc_work/bin/.`;
+ }
if ($revs) {
`cp -p $gsBin/bin/gs ./head/bin/.`;
}
@@ -559,6 +574,9 @@ if ($products{'pcl'} && !$abort) {
$cmd="cp -p $gpdlSource/main/obj/pcl6 $gsBin/bin/.";
print "$cmd\n" if ($verbose);
`$cmd`;
+ if ($icc_work) {
+ `cp -p $gsBin/bin/pcl6 ./icc_work/bin/.`;
+ }
if ($revs) {
`cp -p $gsBin/bin/pcl6 ./head/bin/.`;
}
@@ -579,6 +597,9 @@ if ($products{'xps'} && !$abort) {
$cmd="cp -p $gpdlSource/xps/obj/gxps $gsBin/bin/.";
print "$cmd\n" if ($verbose);
`$cmd`;
+ if ($icc_work) {
+ `cp -p $gsBin/bin/gxps ./icc_work/bin/.`;
+ }
if ($revs) {
`cp -p $gsBin/bin/gxps ./head/bin/.`;
}
@@ -599,6 +620,9 @@ if ($products{'svg'} && !$abort) {
$cmd="cp -p $gpdlSource/svg/obj/gsvg $gsBin/bin/.";
print "$cmd\n" if ($verbose);
`$cmd`;
+ if ($icc_work) {
+ `cp -p $gsBin/bin/gsvg ./icc_work/bin/.`;
+ }
if ($revs) {
`cp -p $gsBin/bin/gsvg ./head/bin/.`;
}
@@ -616,6 +640,12 @@ $cmd="touch urwfonts ; rm -fr urwfonts ; cp -pr $gpdlSource/urwfonts .";
print "$cmd\n" if ($verbose);
`$cmd`;
+if (-e '../bin/time') {
+ `cp ../bin/time $gsBin/bin/.`; # which is different on Mac OS X, so get the one I built
+} else {
+ `cp /usr/bin/time $gsBin/bin/.`; # get the generic time command
+}
+
if ($md5sumFail ne "") {
updateStatus('md5sum fail');
mylog("setting $machine.fail on casper3\n");
@@ -726,7 +756,7 @@ while (($poll==1 || scalar(@commands)) && !$abort && $compileFail eq "") {
@commands = split '\n',$s;
$totalJobs=scalar(@commands);
mylog("received ".scalar(@commands)." commands\n");
- mylog("commands[0] eq 'done'\n") if ($commands[0] eq "done");
+ mylog("commands[0] eq 'done'\n") if ((scalar @commands==0) || $commands[0] eq "done");
if ((scalar @commands==0) || $commands[0] eq "done") {
$poll=0;
@commands=();
@@ -741,7 +771,7 @@ while (($poll==1 || scalar(@commands)) && !$abort && $compileFail eq "") {
my %name;
foreach (@a) {
chomp;
- if (m/\S+ +(\d+) +(\d+) .+ \d\d:\d\d:\d\d (.+)$/ && !m/<defunct>/ && !m/\(sh\)/) {
+ if (m/\S+ +(\d+) +(\d+) .+ \d+:\d\d.\d\d (.+)$/ && !m/<defunct>/ && !m/\(sh\)/) {
$children{$2}=$1;
$name{$1}=$3;
}
@@ -819,7 +849,9 @@ spawn(300,"ssh -i ~/.ssh/cluster_key regression\@casper3.ghostscript.com \"touch
if ($elapsedTime>=30) {
my $t=sprintf "%d tests completed",$jobs;
updateStatus($t);
+ mylog("updateStatus() done");
$abort=checkAbort;
+ mylog("checkAbort() done");
$startTime=time;
my @files = <$raster/*>;
@@ -892,7 +924,7 @@ if (!$abort || $compileFail ne "" || $timeoutFail ne "") {
my %children;
my %name;
foreach (@a) {
- if (m/\S+ +(\d+) +(\d+) .+ \d\d:\d\d:\d\d (.+)$/ && !m/<defunct>/ && !m/\(sh\)/) {
+ if (m/\S+ +(\d+) +(\d+) .+ \d+:\d\d.\d\d (.+)$/ && !m/<defunct>/ && !m/\(sh\)/) {
$children{$2}=$1;
$name{$1}=$3;
}