[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1666-ge023810
[email protected] (Shailesh Mistry)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, master has been updated
via e0238104296a361d2dfcc678075e32f4c2070c52 (commit)
from 29f3e8d45595f443170bf13290404be4d34b5a2e (commit)
----------------------------------------------------------------------
commit e0238104296a361d2dfcc678075e32f4c2070c52
Author: Shailesh Mistry <[email protected]>
Date: Fri Sep 13 10:28:37 2019 +0100
Bug 697545 : Propagate error codes from pcl_set_cap_x and pcl_set_cap_y correctly.
The code has been updated to correctly propagate error codes from all instances
of pcl_set_cap_x and pcl_set_cap_y.
diff --git a/pcl/pcl/pcfontpg.c b/pcl/pcl/pcfontpg.c
index bef6cb3..1c835c8 100644
--- a/pcl/pcl/pcfontpg.c
+++ b/pcl/pcl/pcfontpg.c
@@ -74,7 +74,9 @@ process_font(pcl_state_t * pcs, pl_font_t * fp)
return gs_rethrow(code, "failed to display font");
/* go to approx center of the page */
- pcl_set_cap_x(pcs, pcs->margins.right / 2, false, false);
+ code = pcl_set_cap_x(pcs, pcs->margins.right / 2, false, false);
+ if (code < 0)
+ return gs_rethrow(code, "failed to set cap x\n");
pcl_decache_font(pcs, -1, true);
@@ -93,8 +95,10 @@ process_font(pcl_state_t * pcs, pl_font_t * fp)
if (code < 0)
return gs_rethrow(code, "failed to display font");
- pcl_set_cap_x(pcs, (coord) (pcs->margins.right / (16.0 / 15.0)),
+ code = pcl_set_cap_x(pcs, (coord) (pcs->margins.right / (16.0 / 15.0)),
false, false);
+ if (code < 0)
+ return gs_rethrow(code, "failed to set cap x\n");
gs_sprintf(buff, "%d", fp->params.pjl_font_number);
code = pcl_text((byte *) buff, strlen(buff), pcs, false);
@@ -132,7 +136,9 @@ pcl_print_font_page(pcl_args_t * pargs, pcl_state_t * pcs)
/* assume the pcl font list string is 1 inch 7200 units */
uint pos = pcs->margins.right / 2 - 7200 / 2;
- pcl_set_cap_x(pcs, pos, false, false);
+ code = pcl_set_cap_x(pcs, pos, false, false);
+ if (code < 0)
+ return gs_rethrow(code, "failed to set cap x\n");
code = pcl_text((byte *) header_str, hlen, pcs, false);
if (code < 0)
return gs_rethrow(code, "printing PCL Font List failed\n");
@@ -142,7 +148,9 @@ pcl_print_font_page(pcl_args_t * pargs, pcl_state_t * pcs)
code = pcl_text((byte *) sample_str, strlen(sample_str), pcs, false);
if (code < 0)
return gs_rethrow(code, "printing Sample failed\n");
- pcl_set_cap_x(pcs, pcs->margins.right / 2, false, false);
+ code = pcl_set_cap_x(pcs, pcs->margins.right / 2, false, false);
+ if (code < 0)
+ return gs_rethrow(code, "failed to set cap x\n");
code = pcl_text((byte *) select_str, strlen(select_str), pcs, false);
if (code < 0)
return gs_rethrow(code, "printing Font Selection Command failed\n");
diff --git a/pcl/pcl/pcjob.c b/pcl/pcl/pcjob.c
index 8b70e86..7aa3f8f 100644
--- a/pcl/pcl/pcjob.c
+++ b/pcl/pcl/pcjob.c
@@ -104,7 +104,9 @@ pcl_simplex_duplex_print(pcl_args_t * pargs, pcl_state_t * pcs)
code = pcl_end_page_if_marked(pcs);
if (code < 0)
return code;
- pcl_home_cursor(pcs);
+ code = pcl_home_cursor(pcs);
+ if (code < 0)
+ return code;
switch (int_arg(pargs)) {
case 0:
pcs->duplex = false;
@@ -175,7 +177,11 @@ pcl_duplex_page_side_select(pcl_args_t * pargs, pcl_state_t * pcs)
return 0;
/* home the cursor even if the command has no effect */
- pcl_home_cursor(pcs);
+ if (code >= 0) {
+ int errcode = pcl_home_cursor(pcs);
+ if (errcode < 0)
+ return errcode;
+ }
/* if there is an error (code < 0) or the page is unmarked (code
== 0) then nothing to update */
diff --git a/pcl/pcl/pcpage.c b/pcl/pcl/pcpage.c
index 7a437fe..143289b 100644
--- a/pcl/pcl/pcpage.c
+++ b/pcl/pcl/pcpage.c
@@ -401,7 +401,8 @@ new_page_size(pcl_state_t * pcs,
* an underline to be put out.
*/
pcs->underline_enabled = false;
- pcl_home_cursor(pcs);
+ code = pcl_home_cursor(pcs);
+ if (code < 0) return code;
/*
* this is were we initialized the cursor position
*/
@@ -694,7 +695,9 @@ set_page_size(pcl_args_t * pargs, pcl_state_t * pcs)
code = pcl_end_page_if_marked(pcs);
if (code < 0)
return code;
- pcl_home_cursor(pcs);
+ code = pcl_home_cursor(pcs);
+ if (code < 0)
+ return code;
for (i = 0; i < pcl_paper_type_count; i++) {
if (tag == PAPER_SIZES[i].tag) {
@@ -724,7 +727,9 @@ set_paper_source(pcl_args_t * pargs, pcl_state_t * pcs)
if (code < 0)
return code;
- pcl_home_cursor(pcs);
+ code = pcl_home_cursor(pcs);
+ if (code < 0)
+ return code;
/* Do not change the page side if the wanted paper source is the same as the actual one */
if (pcs->paper_source != i) {
pcs->back_side = false;
@@ -856,9 +861,9 @@ set_left_margin(pcl_args_t * pargs, pcl_state_t * pcs)
if (lmarg < pcs->margins.right) {
pcs->margins.left = lmarg;
if (pcs->cap.x < lmarg)
- pcl_set_cap_x(pcs, lmarg, false, false);
+ code = pcl_set_cap_x(pcs, lmarg, false, false);
}
- return 0;
+ return code;
}
/*
@@ -881,10 +886,10 @@ set_right_margin(pcl_args_t * pargs, pcl_state_t * pcs)
if (rmarg > pcs->margins.left) {
pcs->margins.right = rmarg;
if (pcs->cap.x > rmarg)
- pcl_set_cap_x(pcs, rmarg, false, false);
+ code = pcl_set_cap_x(pcs, rmarg, false, false);
}
- return 0;
+ return code;
}
/*
@@ -980,7 +985,7 @@ pcl_media_type(pcl_args_t * pargs, pcl_state_t * pcs)
int code = pcl_end_page_if_marked(pcs);
if (code >= 0)
- pcl_home_cursor(pcs);
+ code = pcl_home_cursor(pcs);
return (code < 0 ? code : e_Unimplemented);
} else
return e_Range;
@@ -1147,7 +1152,7 @@ pcl_print_quality(pcl_args_t * pargs, pcl_state_t * pcs)
int code = pcl_end_page_if_marked(pcs);
if (code >= 0)
- pcl_home_cursor(pcs);
+ code = pcl_home_cursor(pcs);
return (code < 0 ? code : 0);
} else
return e_Range;
diff --git a/pcl/pcl/pcsfont.c b/pcl/pcl/pcsfont.c
index 101b723..8820abf 100644
--- a/pcl/pcl/pcsfont.c
+++ b/pcl/pcl/pcsfont.c
@@ -1030,7 +1030,7 @@ pcl_alphanumeric_id_data(pcl_args_t * pargs, pcl_state_t * pcs)
int code = pcl_end_page_if_marked(pcs);
if (code < 0)
return code;
- pcl_home_cursor(pcs);
+ return pcl_home_cursor(pcs);
}
break;
default:
diff --git a/pcl/pcl/pcstatus.c b/pcl/pcl/pcstatus.c
index cba061e..5e6d0b4 100644
--- a/pcl/pcl/pcstatus.c
+++ b/pcl/pcl/pcstatus.c
@@ -676,7 +676,7 @@ pcl_flush_all_pages(pcl_args_t * pargs, pcl_state_t * pcs)
int code = pcl_end_page_if_marked(pcs);
if (code >= 0)
- pcl_home_cursor(pcs);
+ code = pcl_home_cursor(pcs);
return code;
}
default:
diff --git a/pcl/pcl/pcursor.c b/pcl/pcl/pcursor.c
index 508f5c4..337a1d6 100644
--- a/pcl/pcl/pcursor.c
+++ b/pcl/pcl/pcursor.c
@@ -187,9 +187,10 @@ pcl_cursor_at_home_pos(pcl_state_t * pcs)
return ((pcs->cap.y == HOME_Y(pcs)) && (pcs->cap.x == HOME_X(pcs)));
}
-void
+int
pcl_set_cap_x(pcl_state_t * pcs, coord x, bool relative, bool use_margins)
{
+ int code = 0;
coord old_x = pcs->cap.x;
if (relative)
@@ -217,6 +218,8 @@ pcl_set_cap_x(pcl_state_t * pcs, coord x, bool relative, bool use_margins)
pcl_continue_underline(pcs);
} else
pcs->cap.x = x;
+
+ return code;
}
int
@@ -295,14 +298,13 @@ motion_args(pcl_args_t * pargs, bool truncate)
/* some convenient short-hand for the cursor movement commands */
-static inline void
+static inline int
do_horiz_motion(pcl_args_t * pargs,
pcl_state_t * pcs, coord mul, bool truncate_arg)
{
- pcl_set_cap_x(pcs, (coord) (motion_args(pargs, truncate_arg) * mul),
+ pcs->cursor_moved = true;
+ return pcl_set_cap_x(pcs, (coord) (motion_args(pargs, truncate_arg) * mul),
arg_is_signed(pargs), false);
- pcs->cursor_moved = true;
- return;
}
static inline int
@@ -335,9 +337,11 @@ pcl_do_CR(pcl_state_t * pcs)
int code = 0;
pcl_break_underline(pcs);
- pcl_set_cap_x(pcs, pcs->margins.left, false, false);
- pcl_continue_underline(pcs);
- pcs->cursor_moved = true;
+ code = pcl_set_cap_x(pcs, pcs->margins.left, false, false);
+ if (code >= 0) {
+ pcl_continue_underline(pcs);
+ pcs->cursor_moved = true;
+ }
return code;
}
@@ -370,11 +374,13 @@ pcl_do_FF(pcl_state_t * pcs)
/*
* Return the cursor to its "home" position
*/
-void
+int
pcl_home_cursor(pcl_state_t * pcs)
{
- pcl_set_cap_x(pcs, pcs->margins.left, false, false);
- pcl_set_cap_y(pcs, 0L, false, false, true, false);
+ int code = pcl_set_cap_x(pcs, pcs->margins.left, false, false);
+ if (code < 0)
+ return code;
+ return pcl_set_cap_y(pcs, 0L, false, false, true, false);
}
int pcl_update_hmi_cp(pcl_state_t * pcs)
@@ -452,6 +458,7 @@ set_horiz_motion_index(pcl_args_t * pargs, pcl_state_t * pcs)
static int
set_vert_motion_index(pcl_args_t * pargs, pcl_state_t * pcs)
{
+ int code = 0;
/* LMI :== 48.0 / lpi; ie 0.16 = 48/300;
* convert to pcl_coord_scale (7200), roundup the float prior to truncation.
*/
@@ -471,8 +478,8 @@ set_vert_motion_index(pcl_args_t * pargs, pcl_state_t * pcs)
coordinate (horizontal position) cause the command to not take
effect. */
if (cursor_at_home)
- pcl_home_cursor(pcs);
- return 0;
+ code = pcl_home_cursor(pcs);
+ return code;
}
#undef HP_VERT_MOTION_NEW
@@ -486,6 +493,7 @@ set_vert_motion_index(pcl_args_t * pargs, pcl_state_t * pcs)
static int
set_line_spacing(pcl_args_t * pargs, pcl_state_t * pcs)
{
+ int code = 0;
uint lpi = uint_arg(pargs);
bool cursor_at_home = pcl_cursor_at_home_pos(pcs);
@@ -494,8 +502,8 @@ set_line_spacing(pcl_args_t * pargs, pcl_state_t * pcs)
if ((48 % lpi) == 0) /* lpi must divide 48 */
pcs->vmi_cp = inch2coord(1.0 / lpi);
if (cursor_at_home)
- pcl_home_cursor(pcs);
- return 0;
+ code = pcl_home_cursor(pcs);
+ return code;
}
/*
@@ -521,9 +529,7 @@ horiz_cursor_pos_columns(pcl_args_t * pargs, pcl_state_t * pcs)
if (code < 0)
return code;
- do_horiz_motion(pargs, pcs, pcs->hmi_cp, false);
-
- return 0;
+ return do_horiz_motion(pargs, pcs, pcs->hmi_cp, false);
}
/*
@@ -532,8 +538,7 @@ horiz_cursor_pos_columns(pcl_args_t * pargs, pcl_state_t * pcs)
static int
horiz_cursor_pos_decipoints(pcl_args_t * pargs, pcl_state_t * pcs)
{
- do_horiz_motion(pargs, pcs, (coord) 10.0, false);
- return 0;
+ return do_horiz_motion(pargs, pcs, (coord) 10.0, false);
}
/*
@@ -542,8 +547,7 @@ horiz_cursor_pos_decipoints(pcl_args_t * pargs, pcl_state_t * pcs)
static int
horiz_cursor_pos_units(pcl_args_t * pargs, pcl_state_t * pcs)
{
- do_horiz_motion(pargs, pcs, pcs->uom_cp, true);
- return 0;
+ return do_horiz_motion(pargs, pcs, pcs->uom_cp, true);
}
/*
@@ -566,10 +570,9 @@ static int
cmd_BS(pcl_args_t * pargs, /* ignored */
pcl_state_t * pcs)
{
- pcl_set_cap_x(pcs, (coord) - pcs->last_width, true, true);
pcs->last_was_BS = true;
pcs->cursor_moved = true;
- return 0;
+ return pcl_set_cap_x(pcs, (coord) - pcs->last_width, true, true);
}
/*
@@ -597,9 +600,9 @@ cmd_HT(pcl_args_t * pargs, /* ignored */
else
x = 0L;
}
- pcl_set_cap_x(pcs, x, true, true);
+
pcs->cursor_moved = true;
- return 0;
+ return pcl_set_cap_x(pcs, x, true, true);
}
/*
@@ -684,6 +687,7 @@ cmd_FF(pcl_args_t * pargs, /* ignored */
static int
push_pop_cursor(pcl_args_t * pargs, pcl_state_t * pcs)
{
+ int code = 0;
int type = uint_arg(pargs);
if ((type == 0) && (pcs->cursor_stk_size < countof(pcs->cursor_stk))) {
@@ -699,13 +703,15 @@ push_pop_cursor(pcl_args_t * pargs, pcl_state_t * pcs)
pcl_invert_mtx(&(pcs->xfm_state.pd2lp_mtx), &lp2pd);
gs_point_transform(ppt->x, ppt->y, &lp2pd, ppt);
- pcl_set_cap_x(pcs, (coord) ppt->x, false, false);
- pcl_set_cap_y(pcs,
+ code = pcl_set_cap_x(pcs, (coord) ppt->x, false, false);
+ if (code < 0)
+ return code;
+ code = pcl_set_cap_y(pcs,
(coord) ppt->y - pcs->margins.top,
false, false, false, false);
}
- return 0;
+ return code;
}
static int
@@ -844,8 +850,8 @@ pcursor_do_reset(pcl_state_t * pcs, pcl_reset_type_t type)
pcs->cap.x = pcs->cap.y = 0;
}
}
- pcl_home_cursor(pcs);
- return 0;
+
+ return pcl_home_cursor(pcs);
}
const pcl_init_t pcursor_init =
diff --git a/pcl/pcl/pcursor.h b/pcl/pcl/pcursor.h
index 660cd25..137d7c6 100644
--- a/pcl/pcl/pcursor.h
+++ b/pcl/pcl/pcursor.h
@@ -41,7 +41,7 @@ coord pcl_vmi_default(pcl_state_t * pcs);
* which the pcs->cap is maintained. If passing coordinates in the
* latter space, BE SURE TO SUBTRACT THE CURRENT TOP MARGIN.
*/
-void pcl_set_cap_x(pcl_state_t * pcs, coord x, /* position or distance */
+int pcl_set_cap_x(pcl_state_t * pcs, coord x, /* position or distance */
bool relative, /* x is distance (else position) */
bool use_margins /* apply text margins */
);
@@ -59,7 +59,7 @@ int pcl_do_FF(pcl_state_t * pcs);
int pcl_do_LF(pcl_state_t * pcs);
-void pcl_home_cursor(pcl_state_t * pcs);
+int pcl_home_cursor(pcl_state_t * pcs);
/* Get the HMI. This may require recomputing it from the font. */
int pcl_updated_hmi(pcl_state_t * pcs);
diff --git a/pcl/pcl/rtgmode.c b/pcl/pcl/rtgmode.c
index c8467a1..a54c88e 100644
--- a/pcl/pcl/rtgmode.c
+++ b/pcl/pcl/rtgmode.c
@@ -388,8 +388,9 @@ pcl_end_graphics_mode(pcl_state_t * pcs)
/* transform the new point back to "pseudo print direction" space */
pcl_invert_mtx(&(pcs->xfm_state.pd2dev_mtx), &dev2pd);
gs_point_transform(cur_pt.x, cur_pt.y, &dev2pd, &cur_pt);
- pcl_set_cap_x(pcs, (coord) (cur_pt.x + 0.5) - adjust_pres_mode(pcs),
+ code = pcl_set_cap_x(pcs, (coord) (cur_pt.x + 0.5) - adjust_pres_mode(pcs),
false, false);
+ if (code < 0) return code;
return pcl_set_cap_y(pcs, (coord) (cur_pt.y + 0.5) - pcs->margins.top,
false, false, false, false);
}
Summary of changes:
pcl/pcl/pcfontpg.c | 16 +++++++++----
pcl/pcl/pcjob.c | 10 ++++++--
pcl/pcl/pcpage.c | 23 ++++++++++--------
pcl/pcl/pcsfont.c | 2 +-
pcl/pcl/pcstatus.c | 2 +-
pcl/pcl/pcursor.c | 68 +++++++++++++++++++++++++++++-------------------------
pcl/pcl/pcursor.h | 4 ++--
pcl/pcl/rtgmode.c | 3 ++-
8 files changed, 77 insertions(+), 51 deletions(-)