[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1688-ga093216
[email protected] (Robin Watts)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, master has been updated
via a09321624369d215a733fb991bf48c300c90107a (commit)
via 02108ce46f9beafbfa733598164a6ad254ada7ca (commit)
from c0df83637a6234f804bef5a7ef31fe1bc5b66d78 (commit)
----------------------------------------------------------------------
commit a09321624369d215a733fb991bf48c300c90107a
Author: Robin Watts <[email protected]>
Date: Thu Sep 19 11:51:40 2019 +0100
Remove some needlessly passed parameters.
For I am a bear of tiny brain, and such things confuse me.
diff --git a/base/gdevp14.c b/base/gdevp14.c
index 993ad57..2b2a7fb 100644
--- a/base/gdevp14.c
+++ b/base/gdevp14.c
@@ -4494,9 +4494,9 @@ pdf14_create_compositor(gx_device * dev, gx_device * * pcdev,
}
static int
-pdf14_push_text_group(gx_device *dev, gs_gstate *pgs, gx_path *path,
- const gx_clip_path *pcpath, gs_blend_mode_t blend_mode, float opacity,
- bool is_clist)
+pdf14_push_text_group(gx_device *dev, gs_gstate *pgs,
+ gs_blend_mode_t blend_mode, float opacity,
+ bool is_clist)
{
int code;
gs_transparency_group_params_t params = { 0 };
@@ -4562,7 +4562,7 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
gs_currenttextrenderingmode(pgs) != 3 && /* don't bother with invisible text */
pdev->text_group == PDF14_TEXTGROUP_BT_NOT_PUSHED)
if (draw) {
- code = pdf14_push_text_group(dev, pgs, path, pcpath, blend_mode, opacity,
+ code = pdf14_push_text_group(dev, pgs, blend_mode, opacity,
false);
}
*ppenum = (gs_text_enum_t *)penum;
@@ -8611,7 +8611,7 @@ pdf14_clist_text_begin(gx_device * dev, gs_gstate * pgs,
gs_currenttextrenderingmode(pgs) != 3 && /* don't bother with invisible text */
pdev->text_group == PDF14_TEXTGROUP_BT_NOT_PUSHED) {
if (draw) {
- code = pdf14_push_text_group(dev, pgs, path, pcpath, blend_mode, opacity, true);
+ code = pdf14_push_text_group(dev, pgs, blend_mode, opacity, true);
if (code == 0)
pdev->text_group = PDF14_TEXTGROUP_BT_PUSHED; /* Needed during clist writing */
}
----------------------------------------------------------------------
commit 02108ce46f9beafbfa733598164a6ad254ada7ca
Author: Robin Watts <[email protected]>
Date: Fri Sep 20 17:49:57 2019 +0100
Fix "permit-file-xxxx" handling.
Ray spotted that gs_add_explicit_control_path was adding 17
to arg before using it. 17 happens to be the right amount
to add for "--permit-file-read=", but the wrong amount for
write/control/all.
Update the code to call it with the correct arg pointer
to start with.
Also, update a couple of routines to cope with being called
with NULL strings.
Also use enum values in switch rather than 0, 1, 2.
diff --git a/base/gslibctx.c b/base/gslibctx.c
index a72a81d..e7af870 100644
--- a/base/gslibctx.c
+++ b/base/gslibctx.c
@@ -627,10 +627,13 @@ gs_add_outputfile_control_path(gs_memory_t *mem, const char *fname)
int
gs_add_explicit_control_path(gs_memory_t *mem, const char *arg, gs_path_control_t control)
{
- char *p2, *p1 = (char *)arg + 17;
- const char *lim = arg + strlen(arg);
+ char *p2, *p1 = (char *)arg;
+ const char *lim;
int code = 0;
+ if (arg == NULL)
+ return 0;
+ lim = arg + strlen(arg);
while (code >= 0 && p1 < lim && (p2 = strchr(p1, (int)gp_file_name_list_separator)) != NULL) {
code = gs_add_control_path_len(mem, control, p1, (int)(p2 - p1));
p1 = p2 + 1;
@@ -649,18 +652,21 @@ gs_add_control_path_len(const gs_memory_t *mem, gs_path_control_t type, const ch
char *buffer;
uint rlen;
+ if (path == NULL || len == 0)
+ return 0;
+
if (mem == NULL || mem->gs_lib_ctx == NULL ||
(core = mem->gs_lib_ctx->core) == NULL)
return gs_error_unknownerror;
switch(type) {
- case 0:
+ case gs_permit_file_reading:
control = &core->permit_reading;
break;
- case 1:
+ case gs_permit_file_writing:
control = &core->permit_writing;
break;
- case 2:
+ case gs_permit_file_control:
control = &core->permit_control;
break;
default:
@@ -714,6 +720,9 @@ gs_add_control_path_len(const gs_memory_t *mem, gs_path_control_t type, const ch
int
gs_add_control_path(const gs_memory_t *mem, gs_path_control_t type, const char *path)
{
+ if (path == NULL)
+ return 0;
+
return gs_add_control_path_len(mem, type, path, strlen(path));
}
@@ -726,6 +735,9 @@ gs_remove_control_path_len(const gs_memory_t *mem, gs_path_control_t type, const
char *buffer;
uint rlen;
+ if (path == NULL || len == 0)
+ return 0;
+
if (mem == NULL || mem->gs_lib_ctx == NULL ||
(core = mem->gs_lib_ctx->core) == NULL)
return gs_error_unknownerror;
@@ -774,6 +786,9 @@ gs_remove_control_path_len(const gs_memory_t *mem, gs_path_control_t type, const
int
gs_remove_control_path(const gs_memory_t *mem, gs_path_control_t type, const char *path)
{
+ if (path == NULL)
+ return 0;
+
return gs_remove_control_path_len(mem, type, path, strlen(path));
}
diff --git a/pcl/pl/plmain.c b/pcl/pl/plmain.c
index 73f45fe..ff89da2 100644
--- a/pcl/pl/plmain.c
+++ b/pcl/pl/plmain.c
@@ -1323,6 +1323,24 @@ pl_main_set_string_param(pl_main_instance_t * pmi, const char *arg)
}
static int
+do_arg_match(const char **arg, const char *match, size_t match_len)
+{
+ const char *s = *arg;
+ if (strncmp(s, match, match_len) != 0)
+ return 0;
+ s += match_len;
+ if (*s == '=')
+ *arg = ++s;
+ else if (*s != 0)
+ return 0;
+ else
+ *arg = NULL;
+ return 1;
+}
+
+#define arg_match(A, B) do_arg_match(A, B, sizeof(B)-1)
+
+static int
pl_main_process_options(pl_main_instance_t * pmi, arg_list * pal,
pl_interp_implementation_t * pjli)
{
@@ -1422,19 +1440,19 @@ pl_main_process_options(pl_main_instance_t * pmi, arg_list * pal,
break;
}
/* Now handle the explicitly added paths to the file control lists */
- else if (strncmp(arg, "permit-file-read", 16) == 0) {
+ else if (arg_match(&arg, "permit-file-read")) {
code = gs_add_explicit_control_path(pmi->memory, arg, gs_permit_file_reading);
if (code < 0) return code;
break;
- } else if (strncmp(arg, "permit-file-write", 17) == 0) {
+ } else if (arg_match(&arg, "permit-file-write")) {
code = gs_add_explicit_control_path(pmi->memory, arg, gs_permit_file_writing);
if (code < 0) return code;
break;
- } else if (strncmp(arg, "permit-file-control", 19) == 0) {
+ } else if (arg_match(&arg, "permit-file-control")) {
code = gs_add_explicit_control_path(pmi->memory, arg, gs_permit_file_control);
if (code < 0) return code;
break;
- } else if (strncmp(arg, "permit-file-all", 15) == 0) {
+ } else if (arg_match(&arg, "permit-file-all")) {
code = gs_add_explicit_control_path(pmi->memory, arg, gs_permit_file_reading);
if (code < 0) return code;
code = gs_add_explicit_control_path(pmi->memory, arg, gs_permit_file_writing);
diff --git a/psi/imainarg.c b/psi/imainarg.c
index d22d3ca..76653f3 100644
--- a/psi/imainarg.c
+++ b/psi/imainarg.c
@@ -315,6 +315,23 @@ gs_main_run_start(gs_main_instance * minst)
return run_string(minst, "systemdict /start get exec", runFlush, minst->user_errors, NULL, NULL);
}
+static int
+do_arg_match(const char **arg, const char *match, size_t match_len)
+{
+ const char *s = *arg;
+ if (strncmp(s, match, match_len) != 0)
+ return 0;
+ s += match_len;
+ if (*s == '=')
+ *arg = ++s;
+ else if (*s != 0)
+ return 0;
+ else
+ *arg = NULL;
+ return 1;
+}
+
+#define arg_match(A, B) do_arg_match(A, B, sizeof(B)-1)
/* Process switches. Return 0 if processed, 1 for unknown switch, */
/* <0 if error. */
@@ -436,19 +453,19 @@ run_stdin:
minst->saved_pages_test_mode = true;
break;
/* Now handle the explicitly added paths to the file control lists */
- } else if (strncmp(arg, "permit-file-read", 16) == 0) {
+ } else if (arg_match(&arg, "permit-file-read")) {
code = gs_add_explicit_control_path(minst->heap, arg, gs_permit_file_reading);
if (code < 0) return code;
break;
- } else if (strncmp(arg, "permit-file-write", 17) == 0) {
+ } else if (arg_match(&arg, "permit-file-write")) {
code = gs_add_explicit_control_path(minst->heap, arg, gs_permit_file_writing);
if (code < 0) return code;
break;
- } else if (strncmp(arg, "permit-file-control", 19) == 0) {
+ } else if (arg_match(&arg, "permit-file-control")) {
code = gs_add_explicit_control_path(minst->heap, arg, gs_permit_file_control);
if (code < 0) return code;
break;
- } else if (strncmp(arg, "permit-file-all", 15) == 0) {
+ } else if (arg_match(&arg, "permit-file-all")) {
code = gs_add_explicit_control_path(minst->heap, arg, gs_permit_file_reading);
if (code < 0) return code;
code = gs_add_explicit_control_path(minst->heap, arg, gs_permit_file_writing);
Summary of changes:
base/gdevp14.c | 10 +++++-----
base/gslibctx.c | 25 ++++++++++++++++++++-----
pcl/pl/plmain.c | 26 ++++++++++++++++++++++----
psi/imainarg.c | 25 +++++++++++++++++++++----
4 files changed, 68 insertions(+), 18 deletions(-)