summaryrefslogtreecommitdiff
path: root/bk_ps.c
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2006-12-02 14:02:35 +0000
committerBen Harris <bjh21@bjh21.me.uk>2006-12-02 14:02:35 +0000
commit09c27ac2038603fde811012ba5247fef28108f61 (patch)
tree7e700c67922c6c5a2178a52d89421cdb4fb5c149 /bk_ps.c
parentcd6cbcc89171ff64ecbcd5a5edbbc617f36473d5 (diff)
downloadhalibut-09c27ac2038603fde811012ba5247fef28108f61.zip
halibut-09c27ac2038603fde811012ba5247fef28108f61.tar.gz
halibut-09c27ac2038603fde811012ba5247fef28108f61.tar.bz2
halibut-09c27ac2038603fde811012ba5247fef28108f61.tar.xz
Adjust ps_string so that it escapes characters above 126. This makes
Halibut's output 7-bit clean, which seems the best approach in PostScript. [originally from svn r6950]
Diffstat (limited to 'bk_ps.c')
-rw-r--r--bk_ps.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/bk_ps.c b/bk_ps.c
index f66420a..86b8465 100644
--- a/bk_ps.c
+++ b/bk_ps.c
@@ -46,7 +46,7 @@ void ps_backend(paragraph *sourceform, keywordlist *keywords,
fprintf(fp, "%%!PS-Adobe-3.0\n");
fprintf(fp, "%%%%Creator: Halibut, %s\n", version);
- fprintf(fp, "%%%%DocumentData: Clean8Bit\n");
+ fprintf(fp, "%%%%DocumentData: Clean7Bit\n");
fprintf(fp, "%%%%LanguageLevel: 1\n");
for (pageno = 0, page = doc->pages; page; page = page->next)
pageno++;
@@ -315,9 +315,13 @@ static void ps_string(FILE *fp, char const *str) {
fprintf(fp, "(");
for (c = str; *c; c++) {
- if (*c == '(' || *c == ')' || *c == '\\')
- fputc('\\', fp);
- fputc(*c, fp);
+ if (*c < ' ' || *c > '~') {
+ fprintf(fp, "\\%03o", 0xFF & (int)*c);
+ } else {
+ if (*c == '(' || *c == ')' || *c == '\\')
+ fputc('\\', fp);
+ fputc(*c, fp);
+ }
}
fprintf(fp, ")");
}