[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1843-gaad7bca

[email protected] (Robin Watts) Mon, 11 Nov 2019 16:05:17 +0000 (UTC)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
  discards  428c92b1bce1db3c882663ef3f6b60b5c7ee9f7e (commit)
  discards  3a0d46f753a04b7297403cfb1197d004e386d21c (commit)
       via  aad7bcab6a3aedc4e2bfecd7b1e6bf893c299d0e (commit)
       via  2de09275898086e903a19812fd78e73381f7e71e (commit)
       via  c198ac5dcb26fadc53074525cabb413e5395cdba (commit)
       via  7174b69e6c0027277fe1a9ece341c3380fe7979d (commit)
       via  ba5b47dc979ca1590f280f482d432705e9b535bf (commit)
       via  4a3401e5e4f5828c67d7c65f77a3bb0106753649 (commit)
       via  f44249d69a36fa7233504bdb137af9ff5008ec37 (commit)
       via  2029235dc8997314c1925e5786212a6c7331f0cf (commit)
       via  5605c6c6a9677013560a6a3c947f4b100eae4e09 (commit)
       via  95151ae3c3c63100bc7ae958f59b8096e7a0f211 (commit)
       via  0f7653fd4f1d1c5bf36719efcd8464eafcd46faf (commit)
       via  6882df85d37819d849476cf2b4822a90e64d9b24 (commit)
       via  b7fac758d046c82d65fa69dd2c4bc0f1cf9712bc (commit)
       via  328d27b3cccc89c4ff60529106489a9a635f0f72 (commit)
       via  68aeff88e95ccfd1af430fe180597d624ad9f47e (commit)
       via  713645137a2fc483e5509bfd0f92d7311faeb614 (commit)
       via  6c3af6e12e4448b519d2b48c2047c0c83b3cf082 (commit)
       via  66878fb30f37b06a532fdce39991f31642cdb09b (commit)
       via  76db3df8090127482960b742f15831e59816a05e (commit)
       via  9caccf9f09e06324f07822cc55e1737d881c6eb3 (commit)
       via  018003614ad80910ca2c009eb1d523e8015756bc (commit)
       via  7da3de0c7662491fa2a0b6f5a638848bcf13a5fa (commit)
       via  494eeedf73d13fac5710e56f3a8fb2e7e2379d73 (commit)
       via  4f6bc662909ab79e8fbe9822afb36e8a0eafc2b7 (commit)
       via  ce681338646435ca064ab2d1b8bde1614e5ed3f1 (commit)
       via  4e713293de84b689c4ab358f3e110ea54aa81925 (commit)
       via  f70ab2044429fe4b991801476ea3f4b4a5c0cdf4 (commit)
       via  ce2afc4f02617dee51f3322ae8386c4b46047c18 (commit)

This update added new revisions after undoing existing revisions.  That is
to say, the old revision is not a strict subset of the new revision.  This
situation occurs when you --force push a change and generate a repository
containing something like this:

 * -- * -- B -- O -- O -- O (428c92b1bce1db3c882663ef3f6b60b5c7ee9f7e)
            \
             N -- N -- N (aad7bcab6a3aedc4e2bfecd7b1e6bf893c299d0e)

When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.

----------------------------------------------------------------------
commit aad7bcab6a3aedc4e2bfecd7b1e6bf893c299d0e
Author: Chris Liddell <[email protected]>
Date:   Mon Nov 11 10:21:13 2019 +0000

    Better solution for commit 68aeff88e95c
    
    This is a simplified (and fixed) solution for the problem addressed in commit
    68aeff88e95c: instead of assiging to the 'fixed' type, then converting to
    ufixed (wrongly, in the original commit), just go straight to ufixed.
    
    This solves coverity issues: 350493 and 350492

diff --git a/base/gxhintn.c b/base/gxhintn.c
index 0458157..dc28c00 100644
--- a/base/gxhintn.c
+++ b/base/gxhintn.c
@@ -467,14 +467,9 @@ static void t1_hinter__compute_rat_transform_coef(t1_hinter * self)
 }
 
 static inline void t1_hinter__adjust_matrix_precision(t1_hinter * self, fixed xx, fixed yy)
-{   fixed x = any_abs(xx), y = any_abs(yy);
-    fixed tc = (x > y ? x : y);
-    ufixed c;
-
-    /* Protect against signed overflow -
-     * note max_import_coord below is unsigned
-     */
-    c = (ufixed)(tc < 0 ? -tc : c);
+{
+    ufixed x = any_abs(xx), y = any_abs(yy);
+    ufixed c = (x > y ? x : y);
 
     while (c >= self->max_import_coord) {
         /* Reduce the precision of ctmf to allow products to fit into 32 bits : */

----------------------------------------------------------------------
commit 2de09275898086e903a19812fd78e73381f7e71e
Author: Chris Liddell <[email protected]>
Date:   Mon Nov 11 10:42:11 2019 +0000

    Bug 695873: reverse search to auto-set GenericResourceDir
    
    A -I path like:
    
    /path/to/Resources/share/ghostscript/9.15/Resource/Init
    
    Would cause us to wrongly set GenericResourceDir and the ICCProfilesDir because
    in both cases we'd search the path for the string 'Resource', and end up using:
    
    /path/to/Resource
    
    To work better, this uses the new and non-standard rsearch operator to search
    the path backwards.
    
    I opted not to include the trailing directory separator at this stage because
    that complicates matters with platforms that uses different directory
    separators (Unix vs Windows vs OpenVMS, for example)

diff --git a/Resource/Init/gs_lev2.ps b/Resource/Init/gs_lev2.ps
index 0fd4164..8c41aba 100644
--- a/Resource/Init/gs_lev2.ps
+++ b/Resource/Init/gs_lev2.ps
@@ -660,7 +660,7 @@ currentuserparams /WaitTimeout known
     % Search for valid (iccprofiles) directory as a sibling to (Resource)
     % and set it as a default if found.
     LIBPATH {
-      (Resource) search {
+      (Resource) rsearch {
         exch pop exch pop (iccprofiles) concatstrings
         .file_name_separator concatstrings
         dup (default_gray.icc) concatstrings status {
diff --git a/Resource/Init/gs_res.ps b/Resource/Init/gs_res.ps
index 068514b..5559e6a 100644
--- a/Resource/Init/gs_res.ps
+++ b/Resource/Init/gs_res.ps
@@ -284,7 +284,7 @@ systemdict begin
     dup .file_name_current eq {
       pop
     } {
-      (Resource) search {
+      (Resource) rsearch {
         exch concatstrings
         exch pop
         .file_name_separator concatstrings exit

----------------------------------------------------------------------
commit c198ac5dcb26fadc53074525cabb413e5395cdba
Author: Ray Johnston <[email protected]>
Date:   Sat Nov 9 12:51:05 2019 -0800

    Clear out gs_gstate at the start of clist playback.
    
    There are some elements of the (stack based) gs_gstate that were not being
    set by either GS_STATE_INIT_VALUES_CLIST, or gs_gstate_initialize, so set
    the entire structure to 0 before setting the values we care about. This
    was prompted by a customer that has made modifications to the clist playback
    that relied on gs_gstate.color[0/1].color_space being NULL or valid, but
    since it is so quick and only happens once per band, go ahead and do it.

diff --git a/base/gxclrast.c b/base/gxclrast.c
index 30c7e36..b75054f 100644
--- a/base/gxclrast.c
+++ b/base/gxclrast.c
@@ -608,6 +608,7 @@ in:                             /* Initialize for a new page. */
     }
     if (target != 0)
         (*dev_proc(target, get_clipping_box))(target, &target_box);
+    memset(&gs_gstate, 0, sizeof(gs_gstate));
     GS_STATE_INIT_VALUES_CLIST((&gs_gstate));
     code = gs_gstate_initialize(&gs_gstate, mem);
     /* Remove the ICC link cache and replace with the device link cache

----------------------------------------------------------------------
commit 7174b69e6c0027277fe1a9ece341c3380fe7979d
Author: Ken Sharp <[email protected]>
Date:   Sat Nov 9 10:27:22 2019 +0000

    Fix PDF 2.0 /Square annotation appearance generation
    
    All the routines to generate annotation appearances are supposed to
    return a boolean value indicating whether an annotation has a valid
    Appearance (returns true, caller must run the appearance stream) or
    the appearance has been generated (false, caller must not attempt to
    run the appearance stream).
    
    The /Square annotation was failing to return false if there was no
    appearance and one had been generated.

diff --git a/Resource/Init/pdf_draw.ps b/Resource/Init/pdf_draw.ps
index d4a3701..f7fb843 100644
--- a/Resource/Init/pdf_draw.ps
+++ b/Resource/Init/pdf_draw.ps
@@ -3631,6 +3631,7 @@ currentdict /set_bc_color undef
       } ifelse
       //endannottransparency exec
       grestore
+      //false
     }ifelse
   } bind executeonly def
 

----------------------------------------------------------------------
commit ba5b47dc979ca1590f280f482d432705e9b535bf
Author: Julian Smith <[email protected]>
Date:   Fri Nov 8 17:40:37 2019 +0000

    Coverity p11408:350177: avoid use of uninitialised state.start.x.
    
    Probably not a problem in practise because we can't get gs_pe_closepat without
    earlier gs_pe_moveto or similar.

diff --git a/base/gdevvec.c b/base/gdevvec.c
index 351228b..7136d76 100644
--- a/base/gdevvec.c
+++ b/base/gdevvec.c
@@ -630,6 +630,11 @@ gdev_vector_dopath_init(gdev_vector_dopath_state_t *state,
         gs_make_scaling(vdev->scale.x, vdev->scale.y, &state->scale_mat);
     }
     state->first = true;
+
+    /* This is purely to prevent Coverity from thinking gdev_vector_dopath()
+    could use uninitialised state->start.x. */
+    state->start.x = 0;
+    state->start.y = 0;
 }
 
 /*

----------------------------------------------------------------------
commit 4a3401e5e4f5828c67d7c65f77a3bb0106753649
Author: Julian Smith <[email protected]>
Date:   Fri Nov 8 17:21:38 2019 +0000

    Coverity p11408:350167:  fixed use of uninitialised gp_file*.

diff --git a/base/gpmisc.c b/base/gpmisc.c
index 96052fc..22b1484 100644
--- a/base/gpmisc.c
+++ b/base/gpmisc.c
@@ -770,7 +770,7 @@ gp_open_scratch_file(const gs_memory_t *mem,
                      char              *fname,
                      const char        *mode)
 {
-    gp_file *file;
+    gp_file *file = NULL;
     gs_lib_ctx_t *ctx = mem->gs_lib_ctx;
     gs_fs_list_t *fs = ctx->core->fs;
 

----------------------------------------------------------------------
commit f44249d69a36fa7233504bdb137af9ff5008ec37
Author: Julian Smith <[email protected]>
Date:   Fri Nov 8 16:40:00 2019 +0000

    Coverity Coverity p11408:350165: try to stop coverity warning about array of floats.
    
    Coverity complains about passing &float to something that assumes it is
    float[9]. Trying explicit cast of base object to float*.

diff --git a/base/gsicc_create.c b/base/gsicc_create.c
index d073257..5f8df5a 100644
--- a/base/gsicc_create.c
+++ b/base/gsicc_create.c
@@ -1537,7 +1537,7 @@ create_lutAtoBprofile(unsigned char **pp_buffer_in, icHeader *header,
     /* Multiply the matrix in the AtoB object by the cam so that the data
        is in D50 */
     if (lutatobparts->matrix == NULL) {
-        gsicc_create_copy_matrix3(cam, &(temp_matrix.cu.u));
+        gsicc_create_copy_matrix3(cam, (float*) &temp_matrix);
         lutatobparts->matrix = &temp_matrix;
     } else {
         if (yonly) {

----------------------------------------------------------------------
commit 2029235dc8997314c1925e5786212a6c7331f0cf
Author: Julian Smith <[email protected]>
Date:   Fri Nov 8 16:25:01 2019 +0000

    Coverity p11408:350164: only call memcpy() if buffers are different.
    
    We could use memmove() instead, but this makes things a little clearer.

diff --git a/pcl/pcl/pcindxed.c b/pcl/pcl/pcindxed.c
index a174c7e..f5ebc75 100644
--- a/pcl/pcl/pcindxed.c
+++ b/pcl/pcl/pcindxed.c
@@ -209,7 +209,12 @@ unshare_indexed_cspace(pcl_cs_indexed_t ** ppindexed)
     memcpy(pnew->pen_widths, pindexed->pen_widths,
            num_entries * sizeof(float));
     memcpy(pnew->norm, pindexed->norm, 3 * sizeof(pindexed->norm[0]));
-    memcpy(pnew->Decode, pindexed->Decode, 6 * sizeof(float));
+
+    /* Coverity thinks next memcpy() might need to be memmove(), so we
+    explicitly check for the buffers being equal. */
+    if (pnew->Decode != pindexed->Decode) {
+        memcpy(pnew->Decode, pindexed->Decode, 6 * sizeof(float));
+    }
 
     return 0;
 }

----------------------------------------------------------------------
commit 5605c6c6a9677013560a6a3c947f4b100eae4e09
Author: Julian Smith <[email protected]>
Date:   Fri Nov 8 12:31:08 2019 +0000

    Coverity p11408:350160: attempt to avoid coverity issues when calling pl_dict_put().
    
    Coverity doesn't like hard-coded 32 for the size of 'short
    unicode_fontname[16]', so use sizeof().

diff --git a/pcl/pl/pllfont.c b/pcl/pl/pllfont.c
index f0b9f19..d2fe927 100644
--- a/pcl/pl/pllfont.c
+++ b/pcl/pl/pllfont.c
@@ -308,7 +308,7 @@ pl_load_ufst_lineprinter(gs_memory_t * mem, pl_dict_t * pfontdict,
             if (use_unicode_names_for_keys)
                 code = pl_dict_put(pfontdict,
                             (const byte *)resident_table[i].unicode_fontname,
-                            32, pplfont);
+                            sizeof(resident_table[i].unicode_fontname), pplfont);
             else {
                 byte key[3];
 
@@ -540,8 +540,9 @@ pl_load_built_in_mtype_fonts(const char *pathname, gs_memory_t * mem,
                     }
                     if (use_unicode_names_for_keys)
                         code = pl_dict_put(pfontdict,
-                                    (const byte *)resident_table[j].
-                                    unicode_fontname, 32, plfont);
+                                    (const byte *)resident_table[j].unicode_fontname,
+                                    sizeof(resident_table[j].unicode_fontname),
+                                    plfont);
                     else {
                         key[2] = (byte) j;
                         key[0] = key[1] = 0;
@@ -702,7 +703,8 @@ pl_load_built_in_fonts(const char *pathname, gs_memory_t * mem,
                    residentp->character_complement, 8);
             if (use_unicode_names_for_keys)
                 code = pl_dict_put(pfontdict,
-                                   (const byte *)residentp->unicode_fontname, 32,
+                                   (const byte *)residentp->unicode_fontname,
+                                   sizeof(residentp->unicode_fontname),
                                    plfont);
             else {
                 key[2] = (byte) (residentp - resident_table);

----------------------------------------------------------------------
commit 95151ae3c3c63100bc7ae958f59b8096e7a0f211
Author: Ken Sharp <[email protected]>
Date:   Fri Nov 8 15:13:50 2019 +0000

    Improve handling of microscopic fonts with text rendering mode 3
    
    Bug #701875 "empty TIFF-file is generated when using -r300, correct output with -r72"
    
    In the past we've seen PDF producers set the text rendering mode to 3
    and then (goodness knows why) set a CTM where one of the scale factors
    is 0. In this case the scale factor isn't 0 but its absolutely minute,
    5.3x10-6.
    
    This evades our existing code, so here we improve it; we check to see
    if the CTM scales in either direction by a really small amount instead
    of 0 (0.000001).
    
    In addition, we previously tried to patch up the CTM and use it anyway
    but really this is only going to make sense is one scale factor is
    tiny (or 0) and the other is sensible. If that's not the case then
    any displacement due to drawing the text will also be tiny. So lets
    simply ignore it.

diff --git a/Resource/Init/pdf_ops.ps b/Resource/Init/pdf_ops.ps
index cc25751..28f2b35 100644
--- a/Resource/Init/pdf_ops.ps
+++ b/Resource/Init/pdf_ops.ps
@@ -1678,25 +1678,35 @@ end readonly def
                         % operations when the CTM is singular.
                         % Work around this here.
                   {
-                    matrix currentmatrix dup dup
-                    dup 0 get 0 eq 1 index 1 get 0 eq and {
-                      dup dup 2 get 0 eq { 0 }{ 1 } ifelse 1 put
-                    } if
-                    dup 2 get 0 eq 1 index 3 get 0 eq and {
-                      dup dup 1 get 0 eq { 3 }{ 2 } ifelse 1 put
-                    } if
-                    setmatrix
-                    currentpoint
-                    % don't worry about transparency for invisible text
-                    4 index settextfillstate show % Tr was set to graphic state.
-                    moveto
-                    setmatrix
-                    % now set the currentpoint using the original matrix
-                    gsave
-                    setmatrix
-                    //false charpath currentpoint newpath
-                    grestore
-                    moveto
+                    matrix currentmatrix
+                    % Previously we tested specifically for a scale factor of 0,
+                    % but bug #701875 has a CTM which is minute, but not zero. If
+                    % we try to use that at anything except low resolution FreeType
+                    % ends up trying to deal with glyph metrics where one dimension is 0
+                    % and it throws an error. So instead of looking for zero, we'll look
+                    % for a really tiny CTM.
+                    % We also used to patch up the CTM, and still use it, but frankly
+                    % this is too much trouble. If the CTM is tiny then the displacement
+                    % due to drawing the text will also be tiny. Negligible in fact.
+                    % So if its that small then lets just ignore it.
+                    dup 0 get abs 0.00001 lt 1 index 1 get 0.00001 abs lt and not {
+                      dup 2 get abs 0.00001 lt 1 index 3 get abs 0.00001 lt and not {
+                        pop
+                        currentpoint
+                        % don't worry about transparency for invisible text
+                        2 index settextfillstate show % Tr was set to graphic state.
+                        moveto
+                        % now set the currentpoint using the original matrix
+                        gsave
+                        //false charpath currentpoint newpath
+                        grestore
+                        moveto
+                      } {
+                        pop pop
+                      }ifelse
+                    } {
+                      pop pop
+                    }ifelse
                   }
                 } {
                   { //false charpath textrenderingprocs .currenttextrenderingmode  get exec }

----------------------------------------------------------------------
commit 0f7653fd4f1d1c5bf36719efcd8464eafcd46faf
Author: Chris Liddell <[email protected]>
Date:   Fri Nov 8 12:47:59 2019 +0000

    Bug 701870: Use object number from Font rather than FontDescriptor
    
    In case where two CIDFont /Font objects share a /FontDescriptor, because the
    /Font objects can contain different details like /CIDSystemInfo contents and
    /CIDToGIDMap, if we use the object number from the /FontDescriptor to validate
    the instance of the font we should use, we can end up reusing a (Postscript)
    font when we shouldn't. This can result in garbled or missing glyphs.

diff --git a/Resource/Init/pdf_font.ps b/Resource/Init/pdf_font.ps
index 81b7af1..8638904 100644
--- a/Resource/Init/pdf_font.ps
+++ b/Resource/Init/pdf_font.ps
@@ -2473,23 +2473,22 @@ currentdict /bndef undef
       % if the font was defined in-line, we won't have a object number
       dup /.gs.pdfobj# .knownget not { //null } if
     } {
-        dup /FontDescriptor knownoget {
           % if the font was defined in-line, we won't have a object number
-          dup /.gs.pdfobj# .knownget not { //null }if
-          dup //null eq {
-            exch pop
-          }{
-            exch dup /FontFile knownoget not {
-             dup /FontFile2 knownoget not {
-                dup /FontFile3 knownoget not {
-                  pop pop //null
-                } {pop pop}ifelse
+      dup /.gs.pdfobj# .knownget not { //null }if
+      dup //null eq not {
+         1 index /FontDescriptor knownoget {
+           dup /FontFile knownoget not {
+           dup /FontFile2 knownoget not {
+              dup /FontFile3 knownoget not {
+                pop pop //null
               } {pop pop}ifelse
-            }{pop pop}ifelse
-          }ifelse
-        }{
-          //null
-        } ifelse
+            } {pop pop}ifelse
+           }{pop pop}ifelse
+         }
+         {
+           pop //null
+         } ifelse
+      }if
     } ifelse
     3 1 roll
 

----------------------------------------------------------------------
commit 6882df85d37819d849476cf2b4822a90e64d9b24
Author: Robin Watts <[email protected]>
Date:   Fri Nov 8 12:08:52 2019 +0000

    Add a couple of FIXMEs to the xps interpreter.

diff --git a/xps/xpsimage.c b/xps/xpsimage.c
index 94a8f5f..e08a068 100644
--- a/xps/xpsimage.c
+++ b/xps/xpsimage.c
@@ -264,6 +264,7 @@ xps_paint_image_brush_imp(xps_context_t *ctx, xps_image_t *image, int alpha)
 
     gsimage.Interpolate = 1;
 
+    /* FIXME: leak enum in case of error */
     penum = gs_image_enum_alloc(ctx->memory, "xps_parse_image_brush (gs_image_enum_alloc)");
     if (!penum)
         return gs_throw(gs_error_VMerror, "gs_enum_allocate failed");
diff --git a/xps/xpstop.c b/xps/xpstop.c
index 49d31c7..a53cc7a 100644
--- a/xps/xpstop.c
+++ b/xps/xpstop.c
@@ -127,6 +127,7 @@ xps_impl_allocate_interp_instance(pl_interp_implementation_t *impl,
         return gs_error_VMerror;
     }
 
+    /* FIXME: check return value */
     gsicc_init_iccmanager(pgs);
     memset(ctx, 0, sizeof(xps_context_t));
 

----------------------------------------------------------------------
commit b7fac758d046c82d65fa69dd2c4bc0f1cf9712bc
Author: Robin Watts <[email protected]>
Date:   Fri Nov 8 12:08:24 2019 +0000

    Remove unused gpdlpsi.mak file.

diff --git a/gpdl/psi/gpdlpsi.mak b/gpdl/psi/gpdlpsi.mak
deleted file mode 100644
index 84bddb1..0000000
--- a/gpdl/psi/gpdlpsi.mak
+++ /dev/null
@@ -1,64 +0,0 @@
-# Copyright (C) 2001-2019 Artifex Software, Inc.
-# All Rights Reserved.
-#
-# This software is provided AS-IS with no warranty, either express or
-# implied.
-#
-# This software is distributed under license and may not be copied,
-# modified or distributed except as expressly authorized under the terms
-# of the license contained in the file LICENSE in this distribution.
-#
-# Refer to licensing information at http://www.artifex.com or contact
-# Artifex Software, Inc.,  1305 Grant Avenue - Suite 200, Novato,
-# CA 94945, U.S.A., +1(415)492-9861, for further information.
-#
-
-# makefile for PS Interface (PSI) to Ghostscript PostScript.
-# Users of this makefile must define the following:
-#	PSSRCDIR - the PS interpreter source directory
-#	GLSRCDIR - the GS library source directory
-#	GLGENDIR - the GS library generated file directory
-#	PLSRCDIR - the PCL* support library source directory
-#	PLOBJDIR - the PCL* support library object / executable directory
-#	PSISRCDIR - the source directory
-#	PSIGENDIR - the directory for source files generated during building
-#	PSIOBJDIR - the object / executable directory
-#	PSI_TOP_OBJ - object file to top-level interpreter API
-
-PLOBJ=$(PLOBJDIR)$(D)
-
-PSISRC=$(PSISRCDIR)$(D)
-PSIGEN=$(PSIGENDIR)$(D)
-PSIOBJ=$(PSIOBJDIR)$(D)
-PSIO_=$(O_)$(PSIOBJ)
-
-PSICCC=$(CC_) $(I_)$(PSISRCDIR)$(_I) $(I_)$(PSIGENDIR)$(_I) $(I_)$(PLSRCDIR)$(_I) $(I_)$(PSSRCDIR)$(_I) $(I_)$(GLSRCDIR)$(_I) $(I_)$(GLGENDIR)$(_I) $(C_)
-
-# Define the name of this makefile.
-PSI_MAK=$(PSISRC)psi.mak
-
-psi.clean: psi.config-clean psi.clean-not-config-clean
-
-psi.clean-not-config-clean: clean_gs
-	$(RM_) $(PSIOBJ)*.$(OBJ)
-	$(RM_) $(PSIOBJ)devs.tr6
-
-# devices are still created in the current directory.  Until that 
-# is fixed we will have to remove them from both directories.
-psi.config-clean:
-	$(RM_) $(PSIOBJ)*.dev
-	$(RM_) *.dev
-
-################ PS Language Interface ################
-
-# Top-level API
-$(PSI_TOP_OBJ): $(PSISRC)psitop.c $(AK) $(stdio__h)\
- $(string__h) $(gdebug_h) $(gp_h) $(gsdevice_h) $(gserrors_h) $(gsmemory_h)\
- $(gsstate_h) $(gsstruct_h) $(gspaint_h) $(gstypes_h) $(gxalloc_h) $(gxstate_h)\
- $(gsnogc_h) $(pltop_h) $(psitop_h) $(plparse_h) $(gsicc_manage_h)\
- $(PSIGEN)pconf.h $(plfont_h) $(uconfig_h) $(pconfig_h)
-	$(PSICCC) $(PSISRC)psitop.c $(O_)$(PSI_TOP_OBJ)
-
-$(PSIOBJ)psi.dev: $(PSI_MAK) $(ECHOGS_XE) $(PLOBJ)pjl.dev 
-	$(SETMOD) $(PSIOBJ)psi $(PSI_TOP_OBJ)
-	$(ADDMOD) $(PSIOBJ)psi -include $(PLOBJ)pl $(PLOBJ)pjl

----------------------------------------------------------------------
commit 328d27b3cccc89c4ff60529106489a9a635f0f72
Author: Julian Smith <[email protected]>
Date:   Fri Nov 8 11:32:41 2019 +0000

    Bug 701854: bj10v_print_page(): increase buffer by one byte to give space for sentinel.
    
    Fixes:
        ./sanbin/gs -r928 -sOutputFile=tmp -sDEVICE=bj10v ../bug-701854.ps

diff --git a/contrib/japanese/gdev10v.c b/contrib/japanese/gdev10v.c
index aa641de..f4c349d 100644
--- a/contrib/japanese/gdev10v.c
+++ b/contrib/japanese/gdev10v.c
@@ -219,7 +219,8 @@ bj10v_print_page(gx_device_printer *pdev, gp_file *prn_stream)
         int x_skip_unit = bytes_per_column * (xres / 180);
         int y_skip_unit = (yres / 180);
         byte *in = (byte *)gs_malloc(pdev->memory->non_gc_memory, 8, line_size, "bj10v_print_page(in)");
-        byte *out = (byte *)gs_malloc(pdev->memory->non_gc_memory, bits_per_column, line_size, "bj10v_print_page(out)");
+        /* We need one extra byte in <out> for our sentinel. */
+        byte *out = (byte *)gs_malloc(pdev->memory->non_gc_memory, bits_per_column * line_size + 1, 1, "bj10v_print_page(out)");
         int lnum = 0;
         int y_skip = 0;
         int code = 0;

----------------------------------------------------------------------
commit 68aeff88e95ccfd1af430fe180597d624ad9f47e
Author: Chris Liddell <[email protected]>
Date:   Thu Nov 7 10:08:35 2019 +0000

    Old Type 1 hinter: protect against signed overflow
    
    To avoid overflow during hinting, we tweak the balance of the size of the
    coordinates and the scaling in the hinter (this is only dealing with coords
    so large that hinting is largely pointless anyway).
    
    But the code that does that didn't protect against signed overflow in the
    starting coordinates.
    
    This is a naive protection to prevent an infinite (or near so) loop, but
    a) it's old code that shouldn't be in use anymore, and b) in practice it will
    make no difference to rendering with coordinates that large.

diff --git a/base/gxhintn.c b/base/gxhintn.c
index 1e3e429..0458157 100644
--- a/base/gxhintn.c
+++ b/base/gxhintn.c
@@ -468,7 +468,13 @@ static void t1_hinter__compute_rat_transform_coef(t1_hinter * self)
 
 static inline void t1_hinter__adjust_matrix_precision(t1_hinter * self, fixed xx, fixed yy)
 {   fixed x = any_abs(xx), y = any_abs(yy);
-    fixed c = (x > y ? x : y);
+    fixed tc = (x > y ? x : y);
+    ufixed c;
+
+    /* Protect against signed overflow -
+     * note max_import_coord below is unsigned
+     */
+    c = (ufixed)(tc < 0 ? -tc : c);
 
     while (c >= self->max_import_coord) {
         /* Reduce the precision of ctmf to allow products to fit into 32 bits : */

----------------------------------------------------------------------
commit 713645137a2fc483e5509bfd0f92d7311faeb614
Author: Chris Liddell <[email protected]>
Date:   Wed Nov 6 14:17:33 2019 +0000

    Some more transparency ops doc tweaks

diff --git a/doc/Language.htm b/doc/Language.htm
index 5f112a1..d8f9deb 100644
--- a/doc/Language.htm
+++ b/doc/Language.htm
@@ -463,6 +463,10 @@ Ghostscript's model generalizes that of PDF 1.4 in that Ghostscript
 maintains separate alpha and mask values for opacity and shape, rather than
 a single value with a Boolean that says whether it represents opacity or
 shape.</p>
+<p>
+What follows is a subset of all the custom operators related to transparency, but
+covers the most useful, most common requirements.
+</p>
 
 <h5><a name="Transparency_graphics_state_operators"></a>Graphics state
 operators</h5>
@@ -495,23 +499,43 @@ the blending mode is <code>/Compatible</code>.</dd>
 </dl>
 
 <dl>
+<dt><code>- .currentblendmode &lt;modename&gt;</code></dt>
+<dd>Returns the graphics state blend mode on the stack.
+</dl>
+
+<dl>
 <dt><code>&lt;0..1&gt; .setopacityalpha -</code></dt>
 <dd>Sets the opacity alpha value in the graphics state.
 The initial opacity alpha value is 1.</dd>
 </dl>
 
 <dl>
+<dt><code>- .currentopacityalpha &lt;0..1&gt;</code></dt>
+<dd>Returns the graphics state opacity alpha on the stack.</dd>
+</dl>
+
+<dl>
 <dt><code>&lt;0..1&gt; .setshapealpha -</code></dt>
 <dd>Sets the shape alpha value in the graphics state.
 The initial shape alpha value is 1.</dd>
 </dl>
 
 <dl>
+<dt><code>- .currentshapealpha &lt;0..1&gt;</code></dt>
+<dd>Returns the graphics state shape alpha on the stack.</dd>
+</dl>
+
+<dl>
 <dt><code>&lt;bool&gt; .settextknockout -</code></dt>
 <dd>Sets the text knockout flag in the graphics state.
 The initial value of the text knockout flag is <code>true</code>.</dd>
 </dl>
 
+<dl>
+<dt><code>- .currenttextknockout &lt;bool&gt;</code></dt>
+<dd>Returns the graphics state text knockout on the stack..</dd>
+</dl>
+
 <h5><a name="Transparency_rendering_stack_operators"></a>Rendering stack
 operators</h5>
 

----------------------------------------------------------------------
commit 6c3af6e12e4448b519d2b48c2047c0c83b3cf082
Author: Julian Smith <[email protected]>
Date:   Thu Nov 7 16:55:15 2019 +0000

    Coverity issue 102147:323319: transform_pixel_region_render_skew(): don't return pointer to local data.

diff --git a/base/gdevdflt.c b/base/gdevdflt.c
index 964f0aa..d493068 100644
--- a/base/gdevdflt.c
+++ b/base/gdevdflt.c
@@ -2123,7 +2123,8 @@ transform_pixel_region_render_skew(gx_device *dev, gx_default_transform_pixel_re
     return (code < 0 ? code : 1);
     /* Save position if error, in case we resume. */
 err:
-    buffer[0] = prev;
+    /* Only set buffer[0] if we've managed to set prev to something valid. */
+    if (prev != &initial_run[0]) buffer[0] = prev;
     return code;
 }
 

----------------------------------------------------------------------
commit 66878fb30f37b06a532fdce39991f31642cdb09b
Author: Julian Smith <[email protected]>
Date:   Thu Nov 7 16:18:32 2019 +0000

    Bug 701856: fix bad bracketting in original fix.

diff --git a/devices/gdevepsn.c b/devices/gdevepsn.c
index c8e10f4..34f0e3a 100644
--- a/devices/gdevepsn.c
+++ b/devices/gdevepsn.c
@@ -178,14 +178,14 @@ eps_print_page(gx_device_printer *pdev, gp_file *prn_stream, int y_9pin_high,
         if (y_24pin) {
             if (x_dpi / 60 >= sizeof(graphics_modes_24) / sizeof(graphics_modes_24[0])) {
                 return_error(gs_error_rangecheck);
-                start_graphics = graphics_modes_24[x_dpi / 60];
             }
+            start_graphics = graphics_modes_24[x_dpi / 60];
         }
         else {
             if (x_dpi / 60 >= sizeof(graphics_modes_9) / sizeof(graphics_modes_9[0])) {
                 return_error(gs_error_rangecheck);
-                start_graphics = graphics_modes_9[x_dpi / 60];
             }
+            start_graphics = graphics_modes_9[x_dpi / 60];
         }
         first_pass = (start_graphics & DD ? 1 : 0);
         last_pass = first_pass * (y_9pin_high == 2 ? 1 : 2);

----------------------------------------------------------------------
commit 76db3df8090127482960b742f15831e59816a05e
Author: Julian Smith <[email protected]>
Date:   Thu Nov 7 16:13:06 2019 +0000

    Coverity issue 102147: initialise gx_device_color::type.
    
    Might fix Coverity issue in base/gxiscale.c.

diff --git a/base/gxiscale.c b/base/gxiscale.c
index 72e3257..3eec2f7 100644
--- a/base/gxiscale.c
+++ b/base/gxiscale.c
@@ -1204,6 +1204,7 @@ image_render_interpolate(gx_image_enum * penum, const byte * buffer,
             int scaled_x_prev = 0;
             gx_dda_fixed save_x_dda = pss->params.scale_dda.x;
 
+            devc.type = gx_dc_type_none; /* Needed for coverity, in call to color_is_pure() if color_handler is NULL. */
             stream_w.limit = out + pss->params.WidthOut *
                 max(spp_decode * sizeofPixelOut, ARCH_SIZEOF_COLOR_INDEX) - 1;
             stream_w.ptr = stream_w.limit - width * spp_decode * sizeofPixelOut;

----------------------------------------------------------------------
commit 9caccf9f09e06324f07822cc55e1737d881c6eb3
Author: Julian Smith <[email protected]>
Date:   Thu Nov 7 12:34:24 2019 +0000

    Bug 701856: fixed buffer overflow in devices/gdevepsn.c.
    
    Need to protect aginst overflow with high x_dpi when using local
    graphics_modes_24[] or graphics_modes_9[] arrays.
    
    Fixes:
        ./sanbin/gs -dBATCH -dNOPAUSE -r914 -sOutputFile=tmp -sDEVICE=eps9high ../bug-701856.pdf

diff --git a/devices/gdevepsn.c b/devices/gdevepsn.c
index 3e53883..c8e10f4 100644
--- a/devices/gdevepsn.c
+++ b/devices/gdevepsn.c
@@ -165,16 +165,31 @@ eps_print_page(gx_device_printer *pdev, gp_file *prn_stream, int y_9pin_high,
         byte *out;
         int out_y_mult = (y_24pin ? 3 : 1);
         int x_dpi = (int)pdev->x_pixels_per_inch;
-        char start_graphics =
-                (y_24pin ? graphics_modes_24 : graphics_modes_9)[x_dpi / 60];
-        int first_pass = (start_graphics & DD ? 1 : 0);
-        int last_pass = first_pass * (y_9pin_high == 2 ? 1 : 2);
         int y_passes = (y_9pin_high ? 3 : 1);
         int dots_per_space = x_dpi / 10;	/* pica space = 1/10" */
         int bytes_per_space = dots_per_space * out_y_mult;
         int tab_min_pixels = x_dpi * MIN_TAB_10THS / 10;
         int skip = 0, lnum = 0, pass, ypass;
         
+        char start_graphics;
+        int first_pass;
+        int last_pass;
+
+        if (y_24pin) {
+            if (x_dpi / 60 >= sizeof(graphics_modes_24) / sizeof(graphics_modes_24[0])) {
+                return_error(gs_error_rangecheck);
+                start_graphics = graphics_modes_24[x_dpi / 60];
+            }
+        }
+        else {
+            if (x_dpi / 60 >= sizeof(graphics_modes_9) / sizeof(graphics_modes_9[0])) {
+                return_error(gs_error_rangecheck);
+                start_graphics = graphics_modes_9[x_dpi / 60];
+            }
+        }
+        first_pass = (start_graphics & DD ? 1 : 0);
+        last_pass = first_pass * (y_9pin_high == 2 ? 1 : 2);
+
         if (bytes_per_space == 0) {
             /* This avoids divide by zero later on, bug 701843. */
             return_error(gs_error_rangecheck);

----------------------------------------------------------------------
commit 018003614ad80910ca2c009eb1d523e8015756bc
Author: Julian Smith <[email protected]>
Date:   Thu Nov 7 11:57:35 2019 +0000

    Bug 701849: Fix buffer overflow in devices/gdevhl7x.c.
    
    High values of pdev->x_pixels_per_inch result in Summary::pageWidth being
    greater than Summary::previousData's fixed size of 1500 bytes, which causes
    buffer overflow in resetPreviousData() (and possibly other places too).
    
    So have changed to initSummary() to allocate Summary::previousData using
    gs_malloc(), and added freeSummary() to clean up.
    
    Fixes:
        ./sanbin/gs -r968 -dFitPage -dUseCropBox -sPAPERSIZE=legal -sOutputFile=tmp -sDEVICE=hl7x0 ../bug-701849.pdf

diff --git a/devices/gdevhl7x.c b/devices/gdevhl7x.c
index 786449d..d2ed8f2 100644
--- a/devices/gdevhl7x.c
+++ b/devices/gdevhl7x.c
@@ -108,7 +108,7 @@ typedef struct {
 
 typedef struct {
   short  previousSize;
-  Byte   previousData[1500]; /* Size bigger than any possible line */
+  Byte*  previousData;
   short  nbBlankLines;
   short  nbLinesSent;
   short  pageWidth;
@@ -139,7 +139,9 @@ static int dumpPage(gx_device_printer * pSource,
                       ByteList          * pCommandList,
                       Summary           * pSummary
                       );
-static void initSummary(Summary * s,short pw, short ph, short resolution);
+static int initSummary(gx_device_printer* pdev, Summary * s,short pw, short ph, short resolution);
+
+static void freeSummary(gx_device_printer* pdev, Summary * s);
 
 static void resetPreviousData(Summary * s);
 
@@ -319,6 +321,7 @@ static int
 hl7x0_print_page(gx_device_printer *pdev, gp_file *printStream, int ptype,
   int dots_per_inch, ByteList *initCommand)
 {
+  int code;
         /* UTILE*/
   /* Command for a formFeed (we can't use strings because of the zeroes...)*/
   Byte FormFeed[] = {'@','G',0x00,0x00,0x01,0xFF,'@','F'};
@@ -338,12 +341,17 @@ hl7x0_print_page(gx_device_printer *pdev, gp_file *printStream, int ptype,
         /* bool dupset = pdev->Duplex_set >= 0; */
         Summary pageSummary;
         ByteList commandsBuffer;
-        initSummary(&pageSummary,
+        if ( storage == 0 )	/* can't allocate working area */
+                return_error(gs_error_VMerror);
+        code = initSummary(pdev,
+                    &pageSummary,
                     line_size,
                     num_rows,
                     x_dpi);
-        if ( storage == 0 )	/* can't allocate working area */
-                return_error(gs_error_VMerror);
+        if (code < 0) {
+            gs_free(pdev->memory, (char *)storage, storage_size_words, 1, "hl7X0_print_page");
+            return code;
+        }
         initByteList(&commandsBuffer, storage, sizeOfBuffer,0 );
         /* PLUS A MOI */
         if ( pdev->PageCount == 0 )
@@ -370,6 +378,7 @@ hl7x0_print_page(gx_device_printer *pdev, gp_file *printStream, int ptype,
         dumpToPrinter(&formFeedCommand, printStream);
 
         /* free temporary storage */
+        freeSummary(pdev, &pageSummary);
         gs_free(pdev->memory, (char *)storage, storage_size_words, 1, "hl7X0_print_page");
 
         return 0; /* If we reach this line, it means there was no error */
@@ -413,14 +422,23 @@ return (((LETTER_WIDTH * resolution/600 - pixWidth) + pixOffset * 2) + 7) / 8;
 /*
  * First values in a Summary
  */
-static void initSummary(Summary * s,short pw, short ph, short resolution){
+static int initSummary(gx_device_printer* pdev, Summary * s,short pw, short ph, short resolution){
   s->previousSize = -1 ;
+  s->previousData = gs_malloc(pdev->memory, pw, 1, "initSummary");
   s->nbBlankLines = 1;
   s->nbLinesSent = 0;
   s->pageWidth = pw; /* In Bytes */
   s->pageHeight = ph;
   s->horizontalOffset = horizontalOffset( pw * 8,LEFT_MARGIN, resolution) ;
   s->resolution = resolution;
+  if (!s->previousData) {
+    return_error(gs_error_VMerror);
+  }
+  return 0;
+}
+
+static void freeSummary(gx_device_printer* pdev, Summary * s) {
+  gs_free(pdev->memory, s->previousData, s->pageWidth, 1, "freeSummary");
 }
 
 /*


Summary of changes:
 Resource/Init/gs_lev2.ps   |   2 +-
 Resource/Init/gs_res.ps    |   2 +-
 Resource/Init/pdf_draw.ps  |  13 ++-
 Resource/Init/pdf_font.ps  |  29 +++---
 Resource/Init/pdf_ops.ps   |  48 ++++++----
 base/gdevdbit.c            | 230 +++------------------------------------------
 base/gdevdflt.c            |   3 +-
 base/gdevvec.c             |   5 +
 base/gpmisc.c              |   2 +-
 base/gsicc_create.c        |   2 +-
 base/gxclrast.c            |   1 +
 base/gxhintn.c             |   5 +-
 base/gxiscale.c            |   1 +
 contrib/japanese/gdev10v.c |   3 +-
 devices/gdevclj.c          |   4 +-
 devices/gdevepsc.c         |  18 ++--
 devices/gdevepsn.c         |  42 +++++++--
 devices/gdevhl7x.c         |  30 ++++--
 devices/gdevlp8k.c         |   5 +-
 devices/gdevlxm.c          |  27 ++++--
 devices/gdevpjet.c         |  60 +++++++-----
 doc/Language.htm           |  24 +++++
 gpdl/psi/gpdlpsi.mak       |  64 -------------
 gpdl/psi/psitop.c          |   1 -
 pcl/pcl/pcindxed.c         |   7 +-
 pcl/pcl/pcjob.c            |   3 -
 pcl/pcl/pcstate.h          |   1 -
 pcl/pcl/pctop.c            |   2 -
 pcl/pl/pjparsei.c          |   1 -
 pcl/pl/pllfont.c           |  10 +-
 pcl/pl/plmain.c            |  65 ++-----------
 pcl/pl/plmain.h            |   3 +-
 pcl/pl/pltop.h             |   1 -
 pcl/pxl/pxtop.c            |   1 -
 xps/xpsimage.c             |   1 +
 xps/xpstop.c               |   2 +-
 36 files changed, 262 insertions(+), 456 deletions(-)
 delete mode 100644 gpdl/psi/gpdlpsi.mak