From 96ab2635885c40a81d6146d1f3363a019d8af93a Mon Sep 17 00:00:00 2001 From: Henry Stiles Date: Wed, 12 Sep 2018 15:34:50 -0600 Subject: Fix bug #699564 - pageside different from HP. The pageside should be updated only if the page is marked. Also refactor and simplify the Page Side Select routine. Thanks to Norbert Janssen for identifying and analyzing this problem. --- pcl/pcl/pcjob.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/pcl/pcl/pcjob.c b/pcl/pcl/pcjob.c index 792b43b1d..8d2792671 100644 --- a/pcl/pcl/pcjob.c +++ b/pcl/pcl/pcjob.c @@ -167,37 +167,37 @@ pcl_duplex_page_side_select(pcl_args_t * pargs, pcl_state_t * pcs) { uint i = uint_arg(pargs); int code = 0; - /* save : because pcl_end_page() messes with it, - or not if it was an unmarked page, so do it yourself */ - bool back_side = pcs->back_side; /* oddly the command goes to the next page irrespective of arguments */ code = pcl_end_page_if_marked(pcs); - if (code < 0) - return code; - pcl_home_cursor(pcs); - if (i > 2) return 0; - /* restore */ - pcs->back_side = back_side; - if (pcs->duplex) - { + /* home the cursor even if the command has no effect */ + pcl_home_cursor(pcs); + + /* if there is an error (code < 0) or the page is unmarked (code + == 0) then nothing to update */ + if (code <= 0) + return code; + + + if (pcs->duplex) { switch (i) { - case 0: - pcs->back_side = !pcs->back_side; - break; - case 1: - pcs->back_side = false; - break; - case 2: - pcs->back_side = true; - break; - default: - pcs->back_side = false; /* default front */ - break; + case 0: + /* do nothing, back_side was updated by + pcl_end_page_if_marked() above */ + break; + case 1: + pcs->back_side = false; + break; + case 2: + pcs->back_side = true; + break; + default: + /* can't happen */ + break; } code = put_param1_bool(pcs, "FirstSide", !pcs->back_side); } -- cgit v1.2.1