[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-2018-g35828fc
[email protected] (Ken Sharp) Mon, 9 Dec 2019 11:01:47 +0000 (UTC)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, master has been updated
via 35828fce7ad795c546831520b7a57ef233453b43 (commit)
from b46142c94bde32f620bda18e3bc5912fbf999446 (commit)
----------------------------------------------------------------------
commit 35828fce7ad795c546831520b7a57ef233453b43
Author: Ken Sharp <[email protected]>
Date: Mon Dec 9 03:00:42 2019 +0000
txtwrite - don't close the device on media size changes
Bug #701971 "txtwrite incomplete for certain files and differs when stdout versus file is output"
The problem is nothing to do with stdout vs file. The difference is due
to the fact that the input PDF file has multiple pages with different
media sizes. When the media size is changed the default put_params()
method closes and reopens the device. When the txtwrite device is
closed it closes its output file. Re-opening the device opens a new
file, if the filename doesn not have a %d then the sam file is opened
which will of course truncate it.
Writing to stdout obviously doesn't have this behaviour when the output
file is closed.
We don't need to close the txtwrite device when the media size changes
so here we patch the 'is_open' flag to prevent the default method
from closing the device.
diff --git a/devices/vector/gdevtxtw.c b/devices/vector/gdevtxtw.c
index c2deb8d..87f9355 100644
--- a/devices/vector/gdevtxtw.c
+++ b/devices/vector/gdevtxtw.c
@@ -1046,10 +1046,10 @@ txtwrite_put_params(gx_device * dev, gs_param_list * plist)
{
gx_device_txtwrite_t *tdev = (gx_device_txtwrite_t *) dev;
int ecode = 0;
- int code;
+ int code, old_TextFormat = tdev->TextFormat;
const char *param_name;
gs_param_string ofs;
- bool dummy;
+ bool dummy, open = dev->is_open;
switch (code = param_read_string(plist, (param_name = "OutputFile"), &ofs)) {
case 0:
@@ -1092,12 +1092,6 @@ txtwrite_put_params(gx_device * dev, gs_param_list * plist)
if (code < 0)
return code;
- code = gx_default_put_params(dev, plist);
- if (code < 0)
- return code;
-
- dev->interpolate_control = 0;
-
if (ofs.data != 0) { /* Close the file if it's open. */
if (tdev->file != 0) {
gp_fclose(tdev->file);
@@ -1106,6 +1100,23 @@ txtwrite_put_params(gx_device * dev, gs_param_list * plist)
memcpy(tdev->fname, ofs.data, ofs.size);
tdev->fname[ofs.size] = 0;
}
+
+ /* If we change media size then gs_default_put_params will close
+ * the device if it is open. We don't want it to do that, so set
+ * the device's 'is_open' flag to false, and reset it after we've
+ * processed the params.
+ */
+ if (old_TextFormat == tdev->TextFormat && open)
+ dev->is_open = false;
+
+ code = gx_default_put_params(dev, plist);
+ if (code < 0)
+ return code;
+
+ dev->is_open = open;
+
+ dev->interpolate_control = 0;
+
return 0;
}
Summary of changes:
devices/vector/gdevtxtw.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)