From 94c57a7e9defcae42c46e4f4f3c5c0be8ed809e0 Mon Sep 17 00:00:00 2001 From: Werner LEMBERG Date: Sun, 21 Oct 2007 08:13:17 +0000 Subject: [PATCH] * src/roff/troff/input.cpp (do_ps_file): Handle `%X' in header comments correctly. Reported by Frank Jahnke . --- ChangeLog | 6 ++++++ src/roff/troff/input.cpp | 15 +++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 76b1a6dc..df8ac684 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-10-21 Werner LEMBERG + + * src/roff/troff/input.cpp (do_ps_file): Handle `%X' in header + comments correctly. Reported by Frank Jahnke + . + 2007-10-02 Ruslan Ermilov * tmac/doc-common, tmac/groff_doc.man: Add FreeBSD 6.2, document diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp index 6e8b269e..6722b193 100644 --- a/src/roff/troff/input.cpp +++ b/src/roff/troff/input.cpp @@ -5965,10 +5965,17 @@ void do_ps_file(FILE *fp, const char* filename) return; } while (ps_get_line(buf, fp, filename) != 0) { - if (buf[0] != '%' || buf[1] != '%' - || strncmp(buf + 2, "EndComments", 11) == 0) + // in header comments, `%X' (`X' any printable character except + // whitespace) is possible too + if (buf[0] == '%') { + if (strncmp(buf + 1, "%EndComments", 12) == 0) + break; + if (white_space(buf[1])) + break; + } + else break; - if (strncmp(buf + 2, "BoundingBox:", 12) == 0) { + if (strncmp(buf + 1, "%BoundingBox:", 13) == 0) { int res = parse_bounding_box(buf + 14, &bb); if (res == 1) { assign_registers(bb.llx, bb.lly, bb.urx, bb.ury); @@ -5988,7 +5995,7 @@ void do_ps_file(FILE *fp, const char* filename) if (bb_at_end) { long offset; int last_try = 0; - /* in the trailer, the last BoundingBox comment is significant */ + // in the trailer, the last BoundingBox comment is significant for (offset = 512; !last_try; offset *= 2) { int had_trailer = 0; int got_bb = 0; -- 2.11.4.GIT