From 245df5d278cb080dd661f6f92c8146cb6ed630c7 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 4 Apr 2009 17:53:53 +0000 Subject: import further type1 subr fixes from thanh/pdftex git-svn-id: svn://tug.org/texlive/trunk@12622 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/dvipsk/ChangeLog | 9 ++++++ Build/source/texk/dvipsk/writet1.c | 56 ++++++++++++++++++++++++++++++++------ 2 files changed, 57 insertions(+), 8 deletions(-) diff --git a/Build/source/texk/dvipsk/ChangeLog b/Build/source/texk/dvipsk/ChangeLog index 4e2cbdc126e..7ec0655a12c 100644 --- a/Build/source/texk/dvipsk/ChangeLog +++ b/Build/source/texk/dvipsk/ChangeLog @@ -1,3 +1,12 @@ +2009-04-04 Karl Berry + + * writet1.c (append_cs_return): new fn. + (cs_mark): check for missing return in subr. + (t1_flush_cs): repair missing return. + (t1_scan_param): check for negative lenIV. + These changes from Thanh, following more investigation by Melissa, + ChoF, and Thanh. + 2009-03-24 Karl Berry * writet1.c (t1_flush_cs): t1_lenIV >= 0, not diff --git a/Build/source/texk/dvipsk/writet1.c b/Build/source/texk/dvipsk/writet1.c index a91efa0a4be..7f276b88d6f 100644 --- a/Build/source/texk/dvipsk/writet1.c +++ b/Build/source/texk/dvipsk/writet1.c @@ -844,6 +844,8 @@ static void t1_scan_param(void) return; if (t1_prefix(lenIV)) { t1_lenIV = t1_scan_num(t1_line_array + strlen(lenIV), 0); + if (t1_lenIV < 0) + pdftex_fail("negative value of lenIV is not supported"); return; } t1_scan_keys(); @@ -1218,10 +1220,44 @@ static void cs_warn(const char *cs_name, int subr, const char *fmt,...) pdftex_warn("CharString (/%s): %s", cs_name, buf); } +/* fix a return-less subr by appending CS_RETURN */ +static void append_cs_return(cs_entry *ptr) +{ + unsigned short cr; + int i, k; + byte *p, *q, *data, *new_data; + assert(ptr != NULL && ptr->valid && ptr->used); + + /* decrypt the cs data to t1_buf_array, append CS_RETURN */ + p = t1_buf_array; + data = ptr->data + 4; + cr = 4330; + for (i = 0; i < ptr->cslen; i++) + *p++ = cs_getchar(); + *p = CS_RETURN; + + /* encrypt the new cs data to new_data */ + new_data = xtalloc(ptr->len + 1, byte); + memcpy(new_data, ptr->data, 4); + p = new_data + 4; + q = t1_buf_array; + cr = 4330; + for (i = 0; i < ptr->cslen + 1; i++) + *p++ = cencrypt(*q++, &cr); + memcpy(p, ptr->data + 4 + ptr->cslen, ptr->len - ptr->cslen - 4); + + /* update *ptr */ + xfree(ptr->data); + ptr->data = new_data; + ptr->len++; + ptr->cslen++; +} + static void cs_mark(const char *cs_name, int subr) { byte *data; int i, b, cs_len; + int last_cmd = 0; integer a, a1, a2; unsigned short cr; static integer lastargOtherSubr3 = 3; /* the argument of last call to @@ -1309,6 +1345,7 @@ static void cs_mark(const char *cs_name, int subr) "more arguments on stack (%i) than required (%i)", (int)(stack_ptr - cc_stack), (int)cc->nargs); } + last_cmd = b; switch (cc - cc_tab) { case CS_CALLSUBR: a1 = cc_get(-1); @@ -1350,6 +1387,12 @@ static void cs_mark(const char *cs_name, int subr) } } } + if (cs_name == NULL && last_cmd != CS_RETURN) { + pdftex_warn("last command in subr `%i' is not a RETURN; " + "I will add it now but please consider fixing the font", + (int) subr); + append_cs_return(ptr); + } return; cs_error: /* an error occured during parsing */ cc_clear(); @@ -1537,15 +1580,12 @@ static void t1_flush_cs(boolean is_subr) if (is_subr) { cr = 4330; cs_len = 0; + /* at this point we have t1_lenIV >= 0; + * a negative value would be caught in t1_scan_param() */ return_cs = xtalloc(t1_lenIV + 1, byte); - if (t1_lenIV >= 0) { - for (cs_len = 0, r = return_cs; cs_len < t1_lenIV; cs_len++, r++) - *r = cencrypt(0x00, &cr); - *r = cencrypt(CS_RETURN, &cr); - } - else { - *return_cs = CS_RETURN; - } + for (cs_len = 0, r = return_cs; cs_len < t1_lenIV; cs_len++, r++) + *r = cencrypt(0x00, &cr); + *r = cencrypt(CS_RETURN, &cr); cs_len++; } -- cgit v1.2.3