[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1674-g511260d

[email protected] (Shailesh Mistry)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
       via  511260d72a4b6df9bd2ba48e022f7c3921b547cb (commit)
      from  c917d64d73fae679d445b233662e0ef4480078f6 (commit)

----------------------------------------------------------------------
commit 511260d72a4b6df9bd2ba48e022f7c3921b547cb
Author: Shailesh Mistry <[email protected]>
Date:   Sun Sep 15 12:18:48 2019 +0100

    Bug 697545 : Propagate error codes from pcl_break_underline correctly.
    
    The code has been updated to correctly propagate error codes from all
    instances of pcl_break_underline.

diff --git a/pcl/pcl/pccprint.c b/pcl/pcl/pccprint.c
index 4690146..6a7e851 100644
--- a/pcl/pcl/pccprint.c
+++ b/pcl/pcl/pccprint.c
@@ -39,11 +39,12 @@ pcl_logical_operation(pcl_args_t * pargs, pcl_state_t * pcs)
     if (rop > 255)
         return e_Range;
 
-    pcl_break_underline(pcs);   /* use the 5c convention; in 5e, the
-                                 * underline is not broken by a change in
-                                 * the logical operation */
     pcs->logical_op = rop;
-    return 0;
+
+    /* use the 5c convention; in 5e, the
+     * underline is not broken by a change in
+     * the logical operation */
+    return pcl_break_underline(pcs);
 }
 
 /*
diff --git a/pcl/pcl/pcfont.h b/pcl/pcl/pcfont.h
index 85f43eb..494845a 100644
--- a/pcl/pcl/pcfont.h
+++ b/pcl/pcl/pcfont.h
@@ -35,15 +35,9 @@ void pcl_decache_font(pcl_state_t * pcs, int set, bool id_select_disable);
  */
 int pcl_recompute_font(pcl_state_t * pcs, bool internal_only);
 
-/*
- * Do any underlining just before a break in motion (vertical motion or
- * negative horizontal motion)...
- */
-#define	pcl_break_underline(pcs)   \
-    BEGIN                           \
-    if (pcs->underline_enabled)    \
-        pcl_do_underline(pcs);     \
-    END
+
+int pcl_break_underline(pcl_state_t * pcs);
+
 
 /* ...and then, after repositioning, restart underlining if necessary... */
 #define	pcl_continue_underline(pcs)        \
@@ -52,7 +46,7 @@ int pcl_recompute_font(pcl_state_t * pcs, bool internal_only);
         pcs->underline_start = pcs->cap;    \
     END
 
-void pcl_do_underline(pcl_state_t * pcs);
+int pcl_do_underline(pcl_state_t * pcs);
 
 /* Define the common structure of downloaded font headers. */
 typedef struct pcl_font_header_s
diff --git a/pcl/pcl/pcpage.c b/pcl/pcl/pcpage.c
index 143289b..59dc46c 100644
--- a/pcl/pcl/pcpage.c
+++ b/pcl/pcl/pcpage.c
@@ -603,9 +603,9 @@ pcl_cursor_moved(pcl_state_t * pcs)
 int
 pcl_end_page(pcl_state_t * pcs, pcl_print_condition_t condition)
 {
-    int code = 0;
-
-    pcl_break_underline(pcs);   /* (could mark page) */
+    int code = pcl_break_underline(pcs);   /* (could mark page) */
+    if (code < 0)
+        return code;
 
     /* If we are conditionally printing (normal case) check if the
        page is marked */
@@ -827,7 +827,9 @@ set_print_direction(pcl_args_t * pargs, pcl_state_t * pcs)
     if ((i <= 270) && (i % 90 == 0)) {
         i /= 90;
         if (i != pcs->xfm_state.print_dir) {
-            pcl_break_underline(pcs);
+            int code = pcl_break_underline(pcs);
+            if (code < 0)
+                return code;
             pcs->xfm_state.print_dir = i;
             update_xfm_state(pcs, 0);
             pcl_continue_underline(pcs);
diff --git a/pcl/pcl/pcpatrn.c b/pcl/pcl/pcpatrn.c
index 6ef7d53..b0cb019 100644
--- a/pcl/pcl/pcpatrn.c
+++ b/pcl/pcl/pcpatrn.c
@@ -1128,13 +1128,14 @@ set_pattern_id(pcl_args_t * pargs, pcl_state_t * pcs)
 static int
 set_source_transparency_mode(pcl_args_t * pargs, pcl_state_t * pcs)
 {
+    int code = 0;
     uint i = uint_arg(pargs);
 
     if (i <= 1) {
-        pcl_break_underline(pcs);
+        code = pcl_break_underline(pcs);
         pcs->source_transparent = (i == 0);
     }
-    return 0;
+    return code;
 }
 
 /*
@@ -1145,13 +1146,14 @@ set_source_transparency_mode(pcl_args_t * pargs, pcl_state_t * pcs)
 static int
 set_pattern_transparency_mode(pcl_args_t * pargs, pcl_state_t * pcs)
 {
+    int code = 0;
     uint i = uint_arg(pargs);
 
     if (i <= 1) {
-        pcl_break_underline(pcs);
+        code = pcl_break_underline(pcs);
         pcs->pcl_pattern_transparent = (i == 0);
     }
-    return 0;
+    return code;
 }
 
 /*
@@ -1162,14 +1164,15 @@ set_pattern_transparency_mode(pcl_args_t * pargs, pcl_state_t * pcs)
 static int
 select_current_pattern(pcl_args_t * pargs, pcl_state_t * pcs)
 {
+    int code = 0;
     uint i = uint_arg(pargs);
 
     if (i <= (int)pcl_pattern_user_defined) {
-        pcl_break_underline(pcs);
+        code = pcl_break_underline(pcs);
         pcs->current_pattern_id = pcs->pattern_id;
         pcs->pattern_type = (pcl_pattern_source_t) i;
     }
-    return 0;
+    return code;
 }
 
 /*
diff --git a/pcl/pcl/pcpatxfm.c b/pcl/pcl/pcpatxfm.c
index 4434c41..1cc00de 100644
--- a/pcl/pcl/pcpatxfm.c
+++ b/pcl/pcl/pcpatxfm.c
@@ -282,17 +282,18 @@ pcl_xfm_gl_set_pat_ref_pt(pcl_state_t * pcs)
 static int
 set_pat_ref_pt(pcl_args_t * pargs, pcl_state_t * pcs)
 {
+    int code = 0;
     uint rotate = uint_arg(pargs);
 
     if (rotate <= 1) {
-        pcl_break_underline(pcs);
+        code = pcl_break_underline(pcs);
         gs_point_transform((double) pcs->cap.x,
                            (double) pcs->cap.y,
                            &(pcs->xfm_state.pd2lp_mtx), &(pcs->pcl_pat_ref_pt)
             );
         pcs->rotate_patterns = (rotate == 0);
     }
-    return 0;
+    return code;
 }
 
 /*
diff --git a/pcl/pcl/pctext.c b/pcl/pcl/pctext.c
index 15dadce..64a1f44 100644
--- a/pcl/pcl/pctext.c
+++ b/pcl/pcl/pctext.c
@@ -1104,28 +1104,45 @@ pcl_plain_char(pcl_args_t * pargs, pcl_state_t * pcs)
 }
 
 /*
+ * Do any underlining just before a break in motion (vertical motion or
+ * negative horizontal motion)...
+ */
+int pcl_break_underline(pcl_state_t * pcs)
+{
+    int code = 0;
+
+    if (pcs->underline_enabled)
+        code = pcl_do_underline(pcs);
+
+    return code;
+}
+
+/*
  * draw underline up to current point, adjust status
  */
-void
+int
 pcl_do_underline(pcl_state_t * pcs)
 {
+    int code = 0;
+
     if (pcs->underline_start.x != pcs->cap.x) {
         gs_gstate *pgs = pcs->pgs;
         float y = pcs->underline_start.y + pcs->underline_position;
-        int code;
 
-        /* save the grapics state */
+        /* save the graphics state */
         code = pcl_gsave(pcs);
         if (code < 0)
-            return;
+            return code;
 
         code = pcl_set_drawing_color(pcs,
                                      pcs->pattern_type,
                                      pcs->current_pattern_id, false);
         if (code >= 0)
             code = pcl_set_graphics_state(pcs);
-        if (code < 0)
-            return;
+        if (code < 0) {
+            (void)pcl_grestore(pcs);
+            return code;
+        }
 
         /*
          * TRM says (8-34) that underline is 3 dots.  In a victory for
@@ -1136,10 +1153,13 @@ pcl_do_underline(pcl_state_t * pcs)
         if ((gs_moveto(pgs, pcs->underline_start.x, y) < 0) ||
             (gs_lineto(pgs, pcs->cap.x, y) < 0) ||
             (gs_stroke(pgs) < 0)) {
-            return;
+            (void)pcl_grestore(pcs);
+            return code;
         }
 
-        pcl_grestore(pcs);
+        code = pcl_grestore(pcs);
+        if (code < 0)
+            return code;
     }
 
     /*
@@ -1148,6 +1168,7 @@ pcl_do_underline(pcl_state_t * pcs)
      */
     pcs->underline_start = pcs->cap;
     pcs->underline_position = pcs->underline_floating ? 0.0 : dots(5);
+    return code;
 }
 
 /* ------ Commands ------ */
@@ -1209,14 +1230,16 @@ pcl_enable_underline(pcl_args_t * pargs, pcl_state_t * pcs)
 static int
 pcl_disable_underline(pcl_args_t * pargs, pcl_state_t * pcs)
 {
+    int code = 0;
+
     /* apparently disabling underlining has the side effect of
        flushing any pending underlines.  This side effect is not
        documented */
     if (pcs->underline_enabled == true) {
-        pcl_do_underline(pcs);
+        code = pcl_do_underline(pcs);
         pcs->underline_enabled = false;
     }
-    return 0;
+    return code;
 }
 
 /* (From PCL5 Comparison Guide, p. 1-56) */
diff --git a/pcl/pcl/pcursor.c b/pcl/pcl/pcursor.c
index 337a1d6..a6e8c0b 100644
--- a/pcl/pcl/pcursor.c
+++ b/pcl/pcl/pcursor.c
@@ -213,7 +213,7 @@ pcl_set_cap_x(pcl_state_t * pcs, coord x, bool relative, bool use_margins)
 
     /* leftward motion "breaks" an underline */
     if (x < old_x) {
-        pcl_break_underline(pcs);
+        code = pcl_break_underline(pcs);
         pcs->cap.x = x;
         pcl_continue_underline(pcs);
     } else
@@ -228,6 +228,7 @@ pcl_set_cap_y(pcl_state_t * pcs,
               bool relative,
               bool use_margins, bool by_row, bool by_row_command)
 {
+    int code = 0;
     coord lim_y = pcs->xfm_state.pd_size.y;
     coord max_y = pcs->margins.top + pcs->margins.length;
     bool page_eject = by_row && relative;
@@ -249,7 +250,9 @@ pcl_set_cap_y(pcl_state_t * pcs,
         y += (by_row ? HOME_Y(pcs) : pcs->margins.top);
 
     /* vertical moves always "break" underlines */
-    pcl_break_underline(pcs);
+    code = pcl_break_underline(pcs);
+    if (code < 0)
+        return code;
 
     max_y = (use_margins ? max_y : lim_y);
     if (y < 0L)
@@ -283,7 +286,7 @@ pcl_set_cap_y(pcl_state_t * pcs,
     }
 
     pcl_continue_underline(pcs);
-    return 0;
+    return code;
 }
 
 static inline float
@@ -334,9 +337,10 @@ do_vertical_move(pcl_state_t * pcs, pcl_args_t * pargs, float mul,
 int
 pcl_do_CR(pcl_state_t * pcs)
 {
-    int code = 0;
+    int code =  pcl_break_underline(pcs);
+    if (code < 0)
+        return code;
 
-    pcl_break_underline(pcs);
     code = pcl_set_cap_x(pcs, pcs->margins.left, false, false);
     if (code >= 0) {
         pcl_continue_underline(pcs);


Summary of changes:
 pcl/pcl/pccprint.c |  9 +++++----
 pcl/pcl/pcfont.h   | 14 ++++----------
 pcl/pcl/pcpage.c   | 10 ++++++----
 pcl/pcl/pcpatrn.c  | 15 +++++++++------
 pcl/pcl/pcpatxfm.c |  5 +++--
 pcl/pcl/pctext.c   | 43 +++++++++++++++++++++++++++++++++----------
 pcl/pcl/pcursor.c  | 14 +++++++++-----
 7 files changed, 69 insertions(+), 41 deletions(-)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.