From 63dddf15f1e38b4ee506e20300b24981a7cecc60 Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Fri, 12 Nov 2010 14:22:51 +0000 Subject: 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 --- Build/source/texk/dvipsk/ChangeLog | 7 + Build/source/texk/dvipsk/download.c | 2 +- Build/source/texk/dvipsk/writet1.c | 309 ++++++++++++++-------------- Build/source/texk/web2c/pdftexdir/ChangeLog | 7 + Build/source/texk/web2c/pdftexdir/writet1.c | 95 ++++----- 5 files changed, 206 insertions(+), 214 deletions(-) (limited to 'Build/source/texk') diff --git a/Build/source/texk/dvipsk/ChangeLog b/Build/source/texk/dvipsk/ChangeLog index 3438f8f2832..fc994bb101f 100644 --- a/Build/source/texk/dvipsk/ChangeLog +++ b/Build/source/texk/dvipsk/ChangeLog @@ -1,3 +1,10 @@ +2010-11-12 Peter Breitenlohner + + * download.c [MAX_CHAR_CODE]: Define as 255 (not 256). + + * writet1.c: More formatting and other trivial changes, to + further reduce diffs against pdftex's writet1.c. + 2010-11-12 Karl Berry * writet1.c: formatting changes only, to reduce diffs against diff --git a/Build/source/texk/dvipsk/download.c b/Build/source/texk/dvipsk/download.c index ae4c4ef6fe1..f0d84fc3d9a 100644 --- a/Build/source/texk/dvipsk/download.c +++ b/Build/source/texk/dvipsk/download.c @@ -338,7 +338,7 @@ static struct seenEncodings { const char *name; const char **glyphs; } *seenEncodings; -#define MAX_CHAR_CODE 256 +#define MAX_CHAR_CODE 255 /* * Load a new encoding and return the array of glyphs as a vector. * Linear search. diff --git a/Build/source/texk/dvipsk/writet1.c b/Build/source/texk/dvipsk/writet1.c index 3b81462f6ae..14b4e8c848d 100644 --- a/Build/source/texk/dvipsk/writet1.c +++ b/Build/source/texk/dvipsk/writet1.c @@ -32,26 +32,14 @@ along with this program. If not, see . */ #define is_included(f) true #undef set_cur_file_name #define set_cur_file_name(s) cur_file_name = s -#define t1_open() \ - ((t1_file = search(type1path, cur_file_name, FOPEN_RBIN_MODE)) != NULL) -#define enc_open() \ - ((enc_file = search(encpath, cur_file_name, FOPEN_RBIN_MODE)) != NULL) #define external_enc() ext_glyph_names #define full_file_name() cur_file_name -#define get_length1() -#define get_length2() -#define get_length3() #define is_used_char(c) (grid[c] == 1) -#define out_eexec_char t1_outhex -#define save_offset() #define end_last_eexec_line() \ hexline_length = HEXLINE_WIDTH; \ end_hexline(); \ t1_eexec_encrypt = false -#define t1_log(s) #define t1_scan_only() -#define t1_include() -#define t1_putchar(c) fputc(c, bitfile) #define t1_scan_keys() #define embed_all_glyphs(tex_font) false #undef pdfmovechars @@ -70,7 +58,7 @@ static char *dvips_extra_charset; static char *cur_file_name; static char *cur_enc_name; static unsigned char *grid; -static char *ext_glyph_names[MAX_CHAR_CODE + 1]; +static char *ext_glyph_names[256]; static char print_buf[PRINTF_BUF_SIZE]; static int hexline_length; static char notdef[] = ".notdef"; @@ -78,63 +66,108 @@ static size_t last_ptr_index; #include -#define t1_getchar() getc(t1_file) -#define t1_ungetchar(c) ungetc(c, t1_file) -#define t1_eof() feof(t1_file) -#define t1_close() xfclose(t1_file, cur_file_name) - -#define enc_getchar() getc(enc_file) -#define enc_eof() feof(enc_file) -#define enc_close() xfclose(enc_file, cur_file_name) - -#define valid_code(c) (c >= 0 && c <= MAX_CHAR_CODE) - -static const char *standard_glyph_names[MAX_CHAR_CODE + 1] = { -notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, -notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, -notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, -notdef, notdef, notdef, notdef, notdef, "space", "exclam", "quotedbl", -"numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", -"parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", -"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", -"nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", -"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", -"P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", -"backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", -"b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", -"q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", -"braceright", "asciitilde", notdef, notdef, notdef, notdef, notdef, notdef, -notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, -notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, -notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, -notdef, "exclamdown", "cent", "sterling", "fraction", "yen", "florin", -"section", "currency", "quotesingle", "quotedblleft", "guillemotleft", -"guilsinglleft", "guilsinglright", "fi", "fl", notdef, "endash", "dagger", -"daggerdbl", "periodcentered", notdef, "paragraph", "bullet", -"quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", -"ellipsis", "perthousand", notdef, "questiondown", notdef, "grave", "acute", -"circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", notdef, -"ring", "cedilla", notdef, "hungarumlaut", "ogonek", "caron", "emdash", -notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, -notdef, notdef, notdef, notdef, notdef, notdef, notdef, "AE", notdef, -"ordfeminine", notdef, notdef, notdef, notdef, "Lslash", "Oslash", "OE", -"ordmasculine", notdef, notdef, notdef, notdef, notdef, "ae", notdef, notdef, -notdef, "dotlessi", notdef, notdef, "lslash", "oslash", "oe", "germandbls", -notdef, notdef, notdef, notdef -}; +#define t1_log(str) +#define get_length1() +#define get_length2() +#define get_length3() +#define save_offset() -static char charstringname[] = "/CharStrings"; +#define t1_open() \ + ((t1_file = search(type1path, cur_file_name, FOPEN_RBIN_MODE)) != NULL) +#define t1_close() xfclose(t1_file, cur_file_name) +#define t1_getchar() getc(t1_file) +#define t1_putchar(c) fputc(c, bitfile) +#define t1_ungetchar(c) ungetc(c, t1_file) +#define t1_eof() feof(t1_file) + +#define str_prefix(s1, s2) (strncmp(s1, s2, strlen(s2)) == 0) +#define t1_prefix(s) str_prefix(t1_line_array, s) +#define t1_buf_prefix(s) str_prefix(t1_buf_array, s) +#define t1_suffix(s) str_suffix(t1_line_array, t1_line_ptr, s) +#define t1_buf_suffix(s) str_suffix(t1_buf_array, t1_buf_ptr, s) +#define t1_charstrings() strstr(t1_line_array, charstringname) +#define t1_subrs() t1_prefix("/Subrs") +#define t1_end_eexec() t1_suffix("mark currentfile closefile") +#define t1_cleartomark() t1_prefix("cleartomark") + +#define enc_open() \ + ((enc_file = search(encpath, cur_file_name, FOPEN_RBIN_MODE)) != NULL) +#define enc_close() xfclose(enc_file, cur_file_name) +#define enc_getchar() getc(enc_file) +#define enc_eof() feof(enc_file) + +#define valid_code(c) (c >= 0 && c < 256) +#define fixedcontent true /* false for pdfTeX, true for dvips */ + +static const char *standard_glyph_names[256] = { + /* 0x00 */ + notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, + notdef, notdef, notdef, notdef, notdef, notdef, notdef, + /* 0x10 */ + notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, + notdef, notdef, notdef, notdef, notdef, notdef, notdef, + /* 0x20 */ + "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", + "ampersand", "quoteright", "parenleft", "parenright", "asterisk", + "plus", "comma", "hyphen", "period", "slash", + /* 0x30 */ + "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", + "nine", "colon", "semicolon", "less", "equal", "greater", "question", + /* 0x40 */ + "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", + "O", + /* 0x50 */ + "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", + "backslash", "bracketright", "asciicircum", "underscore", + /* 0x60 */ + "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", + "m", "n", "o", + /* 0x70 */ + "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", + "braceright", "asciitilde", notdef, + /* 0x80 */ + notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, + notdef, notdef, notdef, notdef, notdef, notdef, notdef, + /* 0x90 */ + notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, + notdef, notdef, notdef, notdef, notdef, notdef, notdef, + /* 0xa0 */ + notdef, "exclamdown", "cent", "sterling", "fraction", "yen", "florin", + "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", + "guilsinglleft", "guilsinglright", "fi", "fl", + /* 0xb0 */ + notdef, "endash", "dagger", "daggerdbl", "periodcentered", notdef, + "paragraph", "bullet", "quotesinglbase", "quotedblbase", + "quotedblright", "guillemotright", "ellipsis", "perthousand", notdef, + "questiondown", + /* 0xc0 */ + notdef, "grave", "acute", "circumflex", "tilde", "macron", "breve", + "dotaccent", "dieresis", notdef, + "ring", "cedilla", notdef, "hungarumlaut", "ogonek", "caron", + /* 0xd0 */ + "emdash", notdef, notdef, notdef, notdef, notdef, notdef, notdef, notdef, + notdef, notdef, notdef, notdef, notdef, notdef, notdef, + /* 0xe0 */ + notdef, "AE", notdef, "ordfeminine", notdef, notdef, notdef, notdef, + "Lslash", "Oslash", "OE", "ordmasculine", notdef, notdef, notdef, + notdef, + /* 0xf0 */ + notdef, "ae", notdef, notdef, notdef, "dotlessi", notdef, notdef, "lslash", + "oslash", "oe", "germandbls", notdef, notdef, notdef, notdef +}; char **t1_glyph_names; -char *t1_builtin_glyph_names[MAX_CHAR_CODE + 1]; +char *t1_builtin_glyph_names[256]; static boolean read_encoding_only; static int t1_encoding; +static char charstringname[] = "/CharStrings"; + #define ENC_STANDARD 0 #define ENC_BUILTIN 1 -#define T1_BUF_SIZE 0x10 -#define ENC_BUF_SIZE 0x1000 +#define T1_BUF_SIZE 0x10 +#define ENC_BUF_SIZE 0x1000 #define CS_HSTEM 1 #define CS_VSTEM 3 @@ -228,17 +261,7 @@ static int last_hexbyte; static FILE *t1_file; static FILE *enc_file; -#define str_prefix(s1, s2) (strncmp(s1, s2, strlen(s2)) == 0) -#define t1_prefix(s) str_prefix(t1_line_array, s) -#define t1_buf_prefix(s) str_prefix(t1_buf_array, s) -#define t1_suffix(s) str_suffix(t1_line_array, t1_line_ptr, s) -#define t1_buf_suffix(s) str_suffix(t1_buf_array, t1_buf_ptr, s) -#define t1_charstrings() strstr(t1_line_array, charstringname) -#define t1_subrs() t1_prefix("/Subrs") -#define t1_end_eexec() t1_suffix("mark currentfile closefile") -#define t1_cleartomark() t1_prefix("cleartomark") - -static void pdftex_fail(const char *fmt,...) +static void pdftex_fail(const char *fmt, ...) { va_list args; va_start(args, fmt); @@ -253,7 +276,7 @@ static void pdftex_fail(const char *fmt,...) exit(-1); } -static void pdftex_warn(const char *fmt,...) +static void pdftex_warn(const char *fmt, ...) { va_list args; va_start(args, fmt); @@ -322,22 +345,22 @@ void load_enc(char *enc_name, const char **glyph_names) pdftex_fail("invalid encoding vector (a name or `[' missing): `%s'", enc_line); } names_count = 0; - r++; /* skip '[' */ + r++; /* skip '[' */ skip(r, ' '); for (;;) { while (*r == '/') { - for (p = buf, r++; *r != ' ' && *r != 10 && *r != ']' && *r != '/'; *p++ = *r++); + for (p = buf, r++; + *r != ' ' && *r != 10 && *r != ']' && *r != '/'; *p++ = *r++); *p = 0; skip(r, ' '); - if (names_count > MAX_CHAR_CODE) - pdftex_fail("encoding vector contains more than %i names", - (int)(MAX_CHAR_CODE + 1)); + if (names_count > 255) + pdftex_fail("encoding vector contains more than 256 names"); if (strcmp(buf, notdef) != 0) glyph_names[names_count] = xstrdup(buf); names_count++; } if (*r != 10 && *r != '%') { - if (strncmp(r, "] def", strlen("] def")) == 0) + if (str_prefix(r, "] def")) goto done; else { remove_eol(r, enc_line); @@ -347,7 +370,7 @@ void load_enc(char *enc_name, const char **glyph_names) enc_getline(); r = enc_line; } -done: + done: enc_close(); t1_log("}"); cur_file_name = NULL; @@ -530,7 +553,7 @@ static void t1_putline(void) return; if (t1_eexec_encrypt) { while (p < t1_line_ptr) - out_eexec_char(eencrypt(*p++)); + t1_outhex(eencrypt(*p++)); } else while (p < t1_line_ptr) t1_putchar(*p++); @@ -670,7 +693,7 @@ static void t1_builtin_enc(void) if (t1_suffix("def")) { /* predefined encoding */ sscanf(t1_line_array + strlen("/Encoding"), "%256s", t1_buf_array); if (strcmp(t1_buf_array, "StandardEncoding") == 0) { - for (i = 0; i <= MAX_CHAR_CODE; i++) + for (i = 0; i < 256; i++) if (standard_glyph_names[i] == notdef) t1_builtin_glyph_names[i] = (char*) notdef; else @@ -699,21 +722,20 @@ static void t1_builtin_enc(void) * ... * readonly def */ - for (i = 0; i <= MAX_CHAR_CODE; i++) + for (i = 0; i < 256; i++) t1_builtin_glyph_names[i] = (char*) notdef; if (t1_prefix("/Encoding [") || t1_prefix("/Encoding[")) { /* the first case */ r = strchr(t1_line_array, '[') + 1; skip(r, ' '); - for(;;) { + for (;;) { while (*r == '/') { for (p = t1_buf_array, r++; *r != 32 && *r != 10 && *r != ']' && *r != '/'; *p++ = *r++); *p = 0; skip(r, ' '); - if (counter > MAX_CHAR_CODE) - pdftex_fail("encoding vector contains more than %i names", - (int)(MAX_CHAR_CODE + 1)); + if (counter > 255) + pdftex_fail("encoding vector contains more than 256 names"); if (strcmp(t1_buf_array, notdef) != 0) t1_builtin_glyph_names[counter] = xstrdup(t1_buf_array); counter++; @@ -730,8 +752,7 @@ static void t1_builtin_enc(void) t1_getline(); r = t1_line_array; } - } - else { /* the second case */ + } else { /* the second case */ p = strchr(t1_line_array, 10); for (;;) { if (*p == 10) { @@ -739,7 +760,7 @@ static void t1_builtin_enc(void) p = t1_line_array; } /* - check for `dup put' + check for `dup put' */ if (sscanf(p, "dup %i%256s put", &i, t1_buf_array) == 2 && *t1_buf_array == '/' && valid_code(i)) { @@ -749,33 +770,33 @@ static void t1_builtin_enc(void) skip(p, ' '); } /* - check for `dup dup exch get put' + check for `dup dup exch get put' */ - else if (sscanf(p, "dup dup %i exch %i get put", &b, &a) == 2 && - valid_code(a) && valid_code(b)) { + else if (sscanf(p, "dup dup %i exch %i get put", &b, &a) == 2 + && valid_code(a) && valid_code(b)) { copy_glyph_names(t1_builtin_glyph_names, a, b); p = strstr(p, " get put") + strlen(" get put"); skip(p, ' '); } /* - check for `dup dup getinterval exch putinterval' + check for `dup dup getinterval 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)) { + &a, &c, &b) == 3 + && valid_code(a) && valid_code(b) && valid_code(c)) { for (i = 0; i < c; i++) copy_glyph_names(t1_builtin_glyph_names, a + i, b + i); p = strstr(p, " putinterval") + strlen(" putinterval"); skip(p, ' '); } /* - check for `def' or `readonly def' + check for `def' or `readonly def' */ - else if ((p == t1_line_array || (p > t1_line_array && p[-1] == ' ')) && - strcmp(p, "def\n") == 0) + else if ((p == t1_line_array || (p > t1_line_array && p[-1] == ' ')) + && strcmp(p, "def\n") == 0) return; /* - skip an unrecognizable word + skip an unrecognizable word */ else { while (*p != ' ' && *p != 10) @@ -805,6 +826,8 @@ static boolean t1_open_fontfile(const char *open_name_prefix) return true; /* font file found */ } +#define t1_include() + #define check_subr(subr) \ if (subr >= subr_size || subr < 0) \ pdftex_fail("Subrs array: entry index out of range (%i)", subr); @@ -921,7 +944,7 @@ static void cc_init(void) set_cc(CS_RETURN, false, 0, false); /* set_cc(CS_ESCAPE, false, 0, false); - */ + */ set_cc(CS_HSBW, true, 2, true); set_cc(CS_ENDCHAR, false, 0, true); set_cc(CS_RMOVETO, true, 2, true); @@ -945,7 +968,7 @@ static void cc_init(void) #define mark_subr(n) cs_mark(0, n) #define mark_cs(s) cs_mark(s, 0) -static void cs_warn(const char *cs_name, int subr, const char *fmt,...) +static void cs_fail(const char *cs_name, int subr, const char *fmt, ...) { char buf[SMALL_BUF_SIZE]; va_list args; @@ -1061,22 +1084,22 @@ static void cs_mark(const char *cs_name, int subr) cs_len--; } if (b >= CS_MAX) { - cs_warn(cs_name, subr, "command value out of range: %i", + cs_fail(cs_name, subr, "command value out of range: %i", (int) b); goto cs_error; } cc = cc_tab + b; if (!cc->valid) { - cs_warn(cs_name, subr, "command not valid: %i", (int) b); + cs_fail(cs_name, subr, "command not valid: %i", (int) b); goto cs_error; } if (cc->bottom) { if (stack_ptr - cc_stack < cc->nargs) - cs_warn(cs_name, subr, + cs_fail(cs_name, subr, "less arguments on stack (%i) than required (%i)", (int) (stack_ptr - cc_stack), (int) cc->nargs); else if (stack_ptr - cc_stack > cc->nargs) - cs_warn(cs_name, subr, + cs_fail(cs_name, subr, "more arguments on stack (%i) than required (%i)", (int) (stack_ptr - cc_stack), (int) cc->nargs); } @@ -1087,7 +1110,7 @@ static void cs_mark(const char *cs_name, int subr) cc_pop(1); mark_subr(a1); if (!subr_tab[a1].valid) { - cs_warn(cs_name, subr, "cannot call subr (%i)", (int) a1); + cs_fail(cs_name, subr, "cannot call subr (%i)", (int) a1); goto cs_error; } break; @@ -1156,32 +1179,27 @@ static void t1_subset_ascii_part(void) t1_puts("/Encoding StandardEncoding def\n"); else { t1_puts("/Encoding 256 array\n0 1 255 {1 index exch /.notdef put} for\n"); - for (i = 0, j = 0; i <= MAX_CHAR_CODE; i++) { + for (i = 0, j = 0; i < 256; i++) { if (is_used_char(i) && t1_glyph_names[i] != notdef) { j++; t1_printf("dup %i /%s put\n", (int)t1_char(i), t1_glyph_names[i]); } } - /* We didn't mark anything for the Encoding array. */ - /* We add "dup 0 /.notdef put" for compatibility */ - /* with Acrobat 5.0. */ if (j == 0) + /* We didn't mark anything for the Encoding array. */ + /* We add "dup 0 /.notdef put" for compatibility */ + /* with Acrobat 5.0. */ t1_puts("dup 0 /.notdef put\n"); t1_puts("readonly def\n"); } do { t1_getline(); t1_scan_param(); - if (!t1_prefix("/UniqueID")) /* ignore UniqueID for subsetted fonts */ + if (!t1_prefix("/UniqueID")) /* ignore UniqueID for subsetted fonts */ t1_putline(); } while (t1_in_eexec == 0); } -#define t1_subr_flush() t1_flush_cs(true) -#define t1_cs_flush() t1_flush_cs(false) - -static void t1_flush_cs(boolean); - static void cs_init(void) { cs_ptr = cs_tab = NULL; @@ -1203,8 +1221,6 @@ static void init_cs_entry(cs_entry *cs) cs->valid = false; } -static void t1_mark_glyphs(void); - static void t1_read_subrs(void) { int i, s; @@ -1278,6 +1294,9 @@ static void t1_read_subrs(void) } } +#define t1_subr_flush() t1_flush_cs(true) +#define t1_cs_flush() t1_flush_cs(false) + static void t1_flush_cs(boolean is_subr) { char *p; @@ -1312,9 +1331,9 @@ static void t1_flush_cs(boolean is_subr) t1_putline(); /* create return_cs to replace unused subr's */ - cs_len = 0; 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); @@ -1382,7 +1401,7 @@ static void t1_mark_glyphs(void) return; } mark_cs(notdef); - for (i = 0; i <= MAX_CHAR_CODE; i++) + for (i = 0; i < 256; i++) if (is_used_char(i)) { if (t1_glyph_names[i] == notdef) pdftex_warn("character %i is mapped to %s", i, notdef); @@ -1400,7 +1419,7 @@ static void t1_mark_glyphs(void) mark_cs(g); g = s + 1; } -set_subr_max: + set_subr_max: if (subr_tab != NULL) for (subr_max = -1, ptr = subr_tab; ptr - subr_tab < subr_size; ptr++) if (ptr->used && ptr - subr_tab > subr_max) @@ -1412,7 +1431,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); @@ -1478,12 +1497,14 @@ static void t1_subset_end(void) t1_putline(); } t1_stop_eexec(); - while (!t1_cleartomark()) { - t1_getline(); - t1_putline(); + if (fixedcontent) { /* copy 512 zeros (not needed for PDF) */ + while (!t1_cleartomark()) { + t1_getline(); + t1_putline(); + } + if (!t1_synthetic) /* don't check "{restore}if" for synthetic fonts */ + t1_check_end(); /* write "{restore}if" if found */ } - if (!t1_synthetic) /* don't check "{restore}if" for synthetic fonts */ - t1_check_end(); /* write "{restore}if" if found */ get_length3(); } @@ -1517,45 +1538,17 @@ static void writet1(void) t1_close_font_file(">"); } -#if 0 /* unused */ -static void t1_free(void) -{ - xfree(t1_line_array); - xfree(t1_buf_array); -} -#endif /* 0 */ - -#if 0 /* unused */ -static boolean t1_subset(char *fontfile, char *encfile, unsigned char *g) -{ - int i; - cur_enc_name = encfile; - for (i = 0; i <= MAX_CHAR_CODE; i++) - ext_glyph_names[i] = (char*) notdef; - if (cur_enc_name != NULL) - load_enc(cur_enc_name, (const char **) ext_glyph_names); - grid = g; - cur_file_name = fontfile; - hexline_length = 0; - writet1(); - for (i = 0; i <= MAX_CHAR_CODE; i++) - if (ext_glyph_names[i] != notdef) - free(ext_glyph_names[i]); - return 1; /* note: there *is* no unsuccessful return */ -} -#endif /* 0 */ - boolean t1_subset_2(char *fontfile, unsigned char *g, char *extraGlyphs) { int i; - for (i = 0; i <= MAX_CHAR_CODE; i++) + for (i = 0; i < 256; i++) ext_glyph_names[i] = (char*) notdef; grid = g; cur_file_name = fontfile; hexline_length = 0; dvips_extra_charset = extraGlyphs; writet1(); - for (i = 0; i <= MAX_CHAR_CODE; i++) + for (i = 0; i < 256; i++) if (ext_glyph_names[i] != notdef) free(ext_glyph_names[i]); return 1; /* note: there *is* no unsuccessful return */ 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 + + * 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 * 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, +Copyright 1996-2007, 2009-2010 Han The Thanh 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 . */ #include "ptexlib.h" #include @@ -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 getinterval 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); -- cgit v1.2.3