diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2010-11-12 14:22:51 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2010-11-12 14:22:51 +0000 |
commit | 63dddf15f1e38b4ee506e20300b24981a7cecc60 (patch) | |
tree | f261d90070199d8112aae3be1d4b6c50bdca29c1 /Build/source/texk/web2c | |
parent | 3f71d1014254549a8f1411044d64a8990862a673 (diff) |
more formatting and other trivial changes to further
reduce diffs betweendvipsk's and pdftex's writet1.c
git-svn-id: svn://tug.org/texlive/trunk@20416 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c')
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/ChangeLog | 7 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/writet1.c | 95 |
2 files changed, 47 insertions, 55 deletions
diff --git a/Build/source/texk/web2c/pdftexdir/ChangeLog b/Build/source/texk/web2c/pdftexdir/ChangeLog index 55984eef933..be1768fc5a7 100644 --- a/Build/source/texk/web2c/pdftexdir/ChangeLog +++ b/Build/source/texk/web2c/pdftexdir/ChangeLog @@ -1,3 +1,10 @@ +2010-11-12 Peter Breitenlohner <peb@mppmu.mpg.de> + + * writet1.c (load_enc_file): Bug fix (using glyph_names[256]). + + * writet1.c: Formatting and other trivial changes, to reduce + diffs against dvipsk's writet1.c. + 2010-11-11 Thanh Han The <thanh@river-valley.org> * writet1.c (t1_check_unusual_charstring): new fn. diff --git a/Build/source/texk/web2c/pdftexdir/writet1.c b/Build/source/texk/web2c/pdftexdir/writet1.c index 0f62e217f2c..51f9b0a68c5 100644 --- a/Build/source/texk/web2c/pdftexdir/writet1.c +++ b/Build/source/texk/web2c/pdftexdir/writet1.c @@ -1,22 +1,20 @@ /* -Copyright (c) 1996-2007 Han The Thanh, <thanh@pdftex.org> +Copyright 1996-2007, 2009-2010 Han The Thanh <thanh@pdftex.org> This file is part of pdfTeX. -pdfTeX is free software; you can redistribute it and/or modify +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -pdfTeX is distributed in the hope that it will be useful, +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License along -with pdfTeX; if not, write to the Free Software Foundation, Inc., 51 -Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ptexlib.h" #include <stdarg.h> @@ -51,7 +49,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #define enc_eof() feof(enc_file) #define valid_code(c) (c >= 0 && c < 256) -#define fixedcontent false +#define fixedcontent false /* false for pdfTeX, true for dvips */ static const char *standard_glyph_names[256] = { /* 0x00 */ @@ -225,8 +223,7 @@ static void enc_getline(void) do { c = enc_getchar(); append_char_to_buf(c, p, enc_line, ENC_BUF_SIZE); - } - while (c != 10); + } while (c != 10); append_eol(p, enc_line, ENC_BUF_SIZE); if (p - enc_line < 2 || *enc_line == '%') goto restart; @@ -253,8 +250,7 @@ char **load_enc_file(char *enc_name) enc_getline(); if (*enc_line != '/' || (r = strchr(enc_line, '[')) == NULL) { remove_eol(r, enc_line); - pdftex_fail - ("invalid encoding vector (a name or `[' missing): `%s'", enc_line); + pdftex_fail("invalid encoding vector (a name or `[' missing): `%s'", enc_line); } names_count = 0; r++; /* skip '[' */ @@ -265,7 +261,7 @@ char **load_enc_file(char *enc_name) *r != ' ' && *r != 10 && *r != ']' && *r != '/'; *p++ = *r++); *p = 0; skip(r, ' '); - if (names_count > 256) + if (names_count > 255) pdftex_fail("encoding vector contains more than 256 names"); if (strcmp(buf, notdef) != 0) glyph_names[names_count] = xstrdup(buf); @@ -276,9 +272,7 @@ char **load_enc_file(char *enc_name) goto done; else { remove_eol(r, enc_line); - pdftex_fail - ("invalid encoding vector: a name or `] def' expected: `%s'", - enc_line); + pdftex_fail("invalid encoding vector: a name or `] def' expected: `%s'", enc_line); } } enc_getline(); @@ -437,7 +431,7 @@ static void t1_getline(void) goto exit; while (!t1_eof()) { if (t1_in_eexec == 1) - c = edecrypt(c); + c = edecrypt((byte)c); alloc_array(t1_line, 1, T1_BUF_SIZE); append_char_to_buf(c, t1_line_ptr, t1_line_array, t1_line_limit); if (t1_in_eexec == 0 && eexec_scan >= 0 && eexec_scan < eexec_len) { @@ -457,7 +451,7 @@ static void t1_getline(void) cs_start = t1_line_ptr - t1_line_array; /* cs_start is an index now */ alloc_array(t1_line, l, T1_BUF_SIZE); while (l-- > 0) - *t1_line_ptr++ = edecrypt(t1_getbyte()); + *t1_line_ptr++ = edecrypt((byte)t1_getbyte()); } c = t1_getbyte(); } @@ -534,7 +528,7 @@ static void t1_check_block_len(boolean decrypt) return; c = t1_getbyte(); if (decrypt) - c = edecrypt(c); + c = edecrypt((byte)c); l = t1_block_length; if (!(l == 0 && (c == 10 || c == 13))) { pdftex_fail("%i bytes more than expected", l + 1); @@ -550,7 +544,7 @@ static void t1_start_eexec(void) if (!t1_pfa) t1_check_block_len(false); for (t1_line_ptr = t1_line_array, i = 0; i < 4; i++) { - edecrypt(t1_getbyte()); + edecrypt((byte)t1_getbyte()); *t1_line_ptr++ = 0; } t1_eexec_encrypt = true; @@ -567,7 +561,7 @@ static void t1_stop_eexec(void) if (!t1_pfa) t1_check_block_len(true); else { - c = edecrypt(t1_getbyte()); + c = edecrypt((byte)t1_getbyte()); if (!(c == 10 || c == 13)) { if (last_hexbyte == 0) t1_puts("00"); @@ -837,14 +831,12 @@ static char **t1_builtin_enc(void) counter++; } if (*r != 10 && *r != '%') { - if (str_prefix(r, "] def") - || str_prefix(r, "] readonly def")) + if (str_prefix(r, "] def") || str_prefix(r, "] readonly def")) break; else { remove_eol(r, t1_line_array); - pdftex_fail - ("a name or `] def' or `] readonly def' expected: `%s'", - t1_line_array); + pdftex_fail("a name or `] def' or `] readonly def' expected: `%s'", + t1_line_array); } } t1_getline(); @@ -879,10 +871,9 @@ static char **t1_builtin_enc(void) /* check for `dup dup <from> <size> getinterval <to> exch putinterval' */ - else if (sscanf - (p, "dup dup %i %i getinterval %i exch putinterval", - &a, &c, &b) == 3 && valid_code(a) && valid_code(b) - && valid_code(c)) { + else if (sscanf(p, "dup dup %i %i getinterval %i exch putinterval", + &a, &c, &b) == 3 + && valid_code(a) && valid_code(b) && valid_code(c)) { for (i = 0; i < c; i++) copy_glyph_names(glyph_names, a + i, b + i); p = strstr(p, " putinterval") + strlen(" putinterval"); @@ -938,28 +929,24 @@ static void t1_include(void) t1_getline(); t1_scan_param(); t1_putline(); - } - while (t1_in_eexec == 0); + } while (t1_in_eexec == 0); t1_start_eexec(); do { t1_getline(); t1_scan_param(); t1_putline(); - } - while (!(t1_charstrings() || t1_subrs())); + } while (!(t1_charstrings() || t1_subrs())); t1_cs = true; do { t1_getline(); t1_putline(); - } - while (!t1_end_eexec()); + } while (!t1_end_eexec()); t1_stop_eexec(); if (fixedcontent) { /* copy 512 zeros (not needed for PDF) */ do { t1_getline(); t1_putline(); - } - while (!t1_cleartomark()); + } while (!t1_cleartomark()); t1_check_end(); /* write "{restore}if" if found */ } get_length3(); @@ -1004,8 +991,9 @@ static void cs_store(boolean is_subr) memcpy(t1_buf_array, t1_line_array + cs_start - 4, (unsigned) (t1_cslen + 4)); /* copy the end of cs data to t1_buf_array */ - for (p = t1_line_array + cs_start + t1_cslen, t1_buf_ptr = - t1_buf_array + t1_cslen + 4; *p != 10; *t1_buf_ptr++ = *p++); + for (p = t1_line_array + cs_start + t1_cslen, + t1_buf_ptr = t1_buf_array + t1_cslen + 4; + *p != 10; *t1_buf_ptr++ = *p++); *t1_buf_ptr++ = 10; if (is_subr && cs_token_pair == NULL) cs_token_pair = check_cs_token_pair(); @@ -1079,7 +1067,7 @@ static void cc_init(void) set_cc(CS_CALLSUBR, false, 1, false); set_cc(CS_RETURN, false, 0, false); /* - set_cc(CS_ESCAPE, false, 0, false); + set_cc(CS_ESCAPE, false, 0, false); */ set_cc(CS_HSBW, true, 2, true); set_cc(CS_ENDCHAR, false, 0, true); @@ -1282,8 +1270,8 @@ 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", + 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); } @@ -1367,8 +1355,7 @@ static void t1_subset_ascii_part(void) if (t1_encoding == ENC_STANDARD) t1_puts("/Encoding StandardEncoding def\n"); else { - t1_puts - ("/Encoding 256 array\n0 1 255 {1 index exch /.notdef put} for\n"); + t1_puts("/Encoding 256 array\n0 1 255 {1 index exch /.notdef put} for\n"); gl_tree = create_t1_glyph_tree(glyph_names); avl_t_init(&t, fd_cur->gl_tree); j = 0; @@ -1392,8 +1379,7 @@ static void t1_subset_ascii_part(void) t1_scan_param(); if (!t1_prefix("/UniqueID")) /* ignore UniqueID for subsetted fonts */ t1_putline(); - } - while (t1_in_eexec == 0); + } while (t1_in_eexec == 0); } static void cs_init(void) @@ -1407,7 +1393,7 @@ static void cs_init(void) subr_max = subr_size = subr_size_pos = 0; } -static void init_cs_entry(cs_entry * cs) +static void init_cs_entry(cs_entry *cs) { cs->data = NULL; cs->name = NULL; @@ -1527,11 +1513,11 @@ static void t1_flush_cs(boolean is_subr) t1_line_ptr = eol(t1_line_array); t1_putline(); - /* create return_cs to replace unsused subr's */ + /* create return_cs to replace unused subr's */ if (is_subr) { cr = 4330; cs_len = 0; - /* at this point we have t1_lenIV >= 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); for (cs_len = 0, r = return_cs; cs_len < t1_lenIV; cs_len++, r++) @@ -1543,8 +1529,7 @@ static void t1_flush_cs(boolean is_subr) for (ptr = tab; ptr < end_tab; ptr++) { if (ptr->used) { if (is_subr) - sprintf(t1_line_array, "dup %i %u", (int) (ptr - tab), - ptr->cslen); + sprintf(t1_line_array, "dup %lu %u", (unsigned long) (ptr - tab), ptr->cslen); else sprintf(t1_line_array, "/%s %u", ptr->name, ptr->cslen); p = strend(t1_line_array); @@ -1554,8 +1539,8 @@ static void t1_flush_cs(boolean is_subr) } else { /* replace unsused subr's by return_cs */ if (is_subr) { - sprintf(t1_line_array, "dup %i %u%s ", (int) (ptr - tab), - cs_len, cs_token_pair[0]); + sprintf(t1_line_array, "dup %lu %u%s ", (unsigned long) (ptr - tab), cs_len, + cs_token_pair[0]); p = strend(t1_line_array); memcpy(p, return_cs, cs_len); t1_line_ptr = p + cs_len; @@ -1614,7 +1599,7 @@ static void t1_check_unusual_charstring(void) char *p = strstr(t1_line_array, charstringname) + strlen(charstringname); int i; /* if no number follows "/CharStrings", let's read the next line */ - if (sscanf(p, "%i", &i) != 1) { + if (sscanf(p, "%i", &i) != 1) { strcpy(t1_buf_array, t1_line_array); t1_getline(); strcat(t1_buf_array, t1_line_array); |