diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/GsWidget.cxx | 4 | ||||
-rw-r--r-- | src/PSEditModel.H | 2 | ||||
-rw-r--r-- | src/PostscriptDSC.cxx | 18 |
3 files changed, 18 insertions, 6 deletions
diff --git a/src/GsWidget.cxx b/src/GsWidget.cxx index d92b8ba..5741be6 100644 --- a/src/GsWidget.cxx +++ b/src/GsWidget.cxx @@ -298,10 +298,10 @@ void GsWidget::exec_gs() { dup2(d_null, STDOUT_FILENO); - snprintf(gvenv, sizeof(gvenv), "%d %d", + snprintf(gvenv, sizeof(gvenv), "GHOSTVIEW=%d %d", (int) fl_xid(window()), (int) offscreen); - setenv("GHOSTVIEW", gvenv, 1); + putenv(gvenv); argv[0] = "gs"; argv[1] = "-dSAFER"; argv[2] = "-dQUIET"; diff --git a/src/PSEditModel.H b/src/PSEditModel.H index d181814..b5ebc14 100644 --- a/src/PSEditModel.H +++ b/src/PSEditModel.H @@ -83,7 +83,7 @@ public: int dump_tags(); - int PSEditModel::load(FILE *fp); + int load(FILE *fp); int save(FILE *sfp, int tmp_fd); }; diff --git a/src/PostscriptDSC.cxx b/src/PostscriptDSC.cxx index b8b998a..345a32b 100644 --- a/src/PostscriptDSC.cxx +++ b/src/PostscriptDSC.cxx @@ -22,6 +22,7 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> +#include <ctype.h> #include "PostscriptDSC.H" PostscriptDSC::PostscriptDSC() { @@ -49,7 +50,7 @@ PostscriptDSC::parse(int fd) { FILE *fp; char linebuf[1024]; int x, y, w, h; - int p1, p2, ps; + int p1 = 0, ps; int i = 0; int bb_read = 0; @@ -93,7 +94,18 @@ PostscriptDSC::parse(int fd) { page_len = (size_t*) malloc(sizeof(size_t) * pages); memset(page_len, 0, sizeof(size_t) * pages); - } else if (sscanf(linebuf, "%%%%Page: %d %d", &p1, &p2) == 2) { + } else if (strncmp(linebuf, "%%Page: ", strlen("%%Page: ")) == 0) { + char *p_str = &linebuf[strlen(linebuf)]; + + // move p_str back to beginning of last number in linebuf + while (p_str > linebuf && !isdigit(*p_str)) { + p_str--; + } + while (p_str > linebuf && isdigit(*p_str)) { + p_str--; + } + + p1 = atoi(p_str); if (!page_off || !page_len) { fprintf(stderr, "Number of pages not defined\n"); @@ -120,7 +132,7 @@ PostscriptDSC::parse(int fd) { } } - if (page_len && page_off) { + if (page_len && page_off && p1 > 0 && p1 <= pages) { page_len[p1 - 1] = ftello(fp) - page_off[p1 - 1]; for (int i=0; i<pages; i++) { |