diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2013-06-24 11:30:55 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2013-06-24 11:30:55 +0000 |
commit | 76b55956ae3d8decfc46202c9252ec4aa6b19102 (patch) | |
tree | bbc5b79c052035a96e495a89648f046c4a19fb93 /Build/source/texk/web2c | |
parent | b3500af8f475211c508744d8685510d9780b8045 (diff) |
xdv2pdf: Removed (obsolete)
git-svn-id: svn://tug.org/texlive/trunk@30901 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c')
-rw-r--r-- | Build/source/texk/web2c/lib/ChangeLog | 8 | ||||
-rw-r--r-- | Build/source/texk/web2c/lib/texmfmp.c | 252 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/ChangeLog | 10 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/ptexlib.h | 8 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/utils.c | 192 | ||||
-rw-r--r-- | Build/source/texk/web2c/texmfmp.h | 12 |
6 files changed, 282 insertions, 200 deletions
diff --git a/Build/source/texk/web2c/lib/ChangeLog b/Build/source/texk/web2c/lib/ChangeLog index 67e1214af4c..3d19d8073b4 100644 --- a/Build/source/texk/web2c/lib/ChangeLog +++ b/Build/source/texk/web2c/lib/ChangeLog @@ -1,3 +1,11 @@ +2013-06-11 Peter Breitenlohner <peb@mppmu.mpg.de> + + Update to e-pTeX and e-upTeX 130605 from Hironori Kitagawa. + * texmfmp.c (pdftex_fail): Adapted from ../pdftexdir/utils.c. + (initstarttime, makecstring, makecfilename, getcreationdate, + getfilemoddate, getfilesize): Move definition of these functions + also used by e-(u)pTeX from ../pdftexdir/utils.c to here. + 2013-04-09 Akira Kakuto <kakuto@fuk.kinidai.ac.jp> * printversion.c: 2012 ---> 2013. diff --git a/Build/source/texk/web2c/lib/texmfmp.c b/Build/source/texk/web2c/lib/texmfmp.c index 47d52321930..515d68b0b50 100644 --- a/Build/source/texk/web2c/lib/texmfmp.c +++ b/Build/source/texk/web2c/lib/texmfmp.c @@ -2726,7 +2726,257 @@ makesrcspecial (strnumber srcfilename, int lineno) return (oldpoolptr); } -#endif + +/* pdfTeX routines also used for e-pTeX and e-upTeX */ +#if defined (pdfTeX) || defined (epTeX) || defined (eupTeX) + +#include <kpathsea/c-stat.h> + +#define check_nprintf(size_get, size_want) \ + if ((unsigned)(size_get) >= (unsigned)(size_want)) \ + pdftex_fail ("snprintf failed: file %s, line %d", __FILE__, __LINE__); +# define check_buf(size, buf_size) \ + if ((unsigned)(size) > (unsigned)(buf_size)) \ + pdftex_fail("buffer overflow at file %s, line %d", __FILE__, __LINE__ ) +# define xfree(p) do { if (p != NULL) free(p); p = NULL; } while (0) +# define MAX_CSTRING_LEN 1024 * 1024 + +#if !defined (pdfTeX) +# define PRINTF_BUF_SIZE 1024 +static char print_buf[PRINTF_BUF_SIZE]; + +/* Helper for pdftex_fail. */ +static void safe_print(const char *str) +{ + const char *c; + for (c = str; *c; ++c) + print(*c); +} +/* pdftex_fail may be called when a buffer overflow has happened/is + happening, therefore may not call mktexstring. However, with the + current implementation it appears that error messages are misleading, + possibly because pool overflows are detected too late. + + The output format of this fuction must be the same as pdf_error in + pdftex.web! */ +__attribute__ ((noreturn, format(printf, 1, 2))) +void pdftex_fail(const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + println(); + safe_print("!error: "); + vsnprintf(print_buf, PRINTF_BUF_SIZE, fmt, args); + safe_print(print_buf); + va_end(args); + println(); + safe_print(" ==> Fatal error occurred, output file will be damaged!"); + println(); + if (kpathsea_debug) { + safe_print("kpathsea_debug enabled, calling abort()..."); + println(); + abort(); + } else { + exit(EXIT_FAILURE); + } +} +#endif /* not pdfTeX */ + +static time_t start_time = 0; +#define TIME_STR_SIZE 30 +char start_time_str[TIME_STR_SIZE]; +static char time_str[TIME_STR_SIZE]; + /* minimum size for time_str is 24: "D:YYYYmmddHHMMSS+HH'MM'" */ + +static void makepdftime(time_t t, char *time_str) +{ + + struct tm lt, gmt; + size_t size; + int i, off, off_hours, off_mins; + + /* get the time */ + lt = *localtime(&t); + size = strftime(time_str, TIME_STR_SIZE, "D:%Y%m%d%H%M%S", <); + /* expected format: "YYYYmmddHHMMSS" */ + if (size == 0) { + /* unexpected, contents of time_str is undefined */ + time_str[0] = '\0'; + return; + } + + /* correction for seconds: %S can be in range 00..61, + the PDF reference expects 00..59, + therefore we map "60" and "61" to "59" */ + if (time_str[14] == '6') { + time_str[14] = '5'; + time_str[15] = '9'; + time_str[16] = '\0'; /* for safety */ + } + + /* get the time zone offset */ + gmt = *gmtime(&t); + + /* this calculation method was found in exim's tod.c */ + off = 60 * (lt.tm_hour - gmt.tm_hour) + lt.tm_min - gmt.tm_min; + if (lt.tm_year != gmt.tm_year) { + off += (lt.tm_year > gmt.tm_year) ? 1440 : -1440; + } else if (lt.tm_yday != gmt.tm_yday) { + off += (lt.tm_yday > gmt.tm_yday) ? 1440 : -1440; + } + + if (off == 0) { + time_str[size++] = 'Z'; + time_str[size] = 0; + } else { + off_hours = off / 60; + off_mins = abs(off - off_hours * 60); + i = snprintf(&time_str[size], 9, "%+03d'%02d'", off_hours, off_mins); + check_nprintf(i, 9); + } +} + +void initstarttime(void) +{ + if (start_time == 0) { + start_time = time((time_t *) NULL); + makepdftime(start_time, start_time_str); + } +} + +char *makecstring(integer s) +{ + static char *cstrbuf = NULL; + char *p; + static int allocsize; + int allocgrow, i, l = strstart[s + 1] - strstart[s]; + check_buf(l + 1, MAX_CSTRING_LEN); + if (cstrbuf == NULL) { + allocsize = l + 1; + cstrbuf = xmallocarray(char, allocsize); + } else if (l + 1 > allocsize) { + allocgrow = allocsize * 0.2; + if (l + 1 - allocgrow > allocsize) + allocsize = l + 1; + else if (allocsize < MAX_CSTRING_LEN - allocgrow) + allocsize += allocgrow; + else + allocsize = MAX_CSTRING_LEN; + cstrbuf = xreallocarray(cstrbuf, char, allocsize); + } + p = cstrbuf; + for (i = 0; i < l; i++) + *p++ = strpool[i + strstart[s]]; + *p = 0; + return cstrbuf; +} + +/* makecfilename + input/ouput same as makecstring: + input: string number + output: C string with quotes removed. + That means, file names that are legal on some operation systems + cannot any more be used since pdfTeX version 1.30.4. +*/ +char *makecfilename(integer s) +{ + char *name = makecstring(s); + char *p = name; + char *q = name; + + while (*p) { + if (*p != '"') + *q++ = *p; + p++; + } + *q = '\0'; + return name; +} + +void getcreationdate(void) +{ + size_t len; + initstarttime(); + /* put creation date on top of string pool and update poolptr */ + len = strlen(start_time_str); + + /* In e-pTeX, "init len => call initstarttime()" (as pdftexdir/utils.c) + yields unintentional output. */ + + if ((unsigned) (poolptr + len) >= (unsigned) (poolsize)) { + poolptr = poolsize; + /* error by str_toks that calls str_room(1) */ + return; + } + + memcpy(&strpool[poolptr], start_time_str, len); + poolptr += len; +} + +void getfilemoddate(integer s) +{ + struct stat file_data; + + char *file_name = kpse_find_tex(makecfilename(s)); + if (file_name == NULL) { + return; /* empty string */ + } + + recorder_record_input(file_name); + /* get file status */ + if (stat(file_name, &file_data) == 0) { + size_t len; + + makepdftime(file_data.st_mtime, time_str); + len = strlen(time_str); + if ((unsigned) (poolptr + len) >= (unsigned) (poolsize)) { + poolptr = poolsize; + /* error by str_toks that calls str_room(1) */ + } else { + memcpy(&strpool[poolptr], time_str, len); + poolptr += len; + } + } + /* else { errno contains error code } */ + + xfree(file_name); +} + +void getfilesize(integer s) +{ + struct stat file_data; + int i; + + char *file_name = kpse_find_tex(makecfilename(s)); + if (file_name == NULL) { + return; /* empty string */ + } + + recorder_record_input(file_name); + /* get file status */ + if (stat(file_name, &file_data) == 0) { + size_t len; + char buf[20]; + + /* st_size has type off_t */ + i = snprintf(buf, sizeof(buf), + "%lu", (long unsigned int) file_data.st_size); + check_nprintf(i, sizeof(buf)); + len = strlen(buf); + if ((unsigned) (poolptr + len) >= (unsigned) (poolsize)) { + poolptr = poolsize; + /* error by str_toks that calls str_room(1) */ + } else { + memcpy(&strpool[poolptr], buf, len); + poolptr += len; + } + } + /* else { errno contains error code } */ + + xfree(file_name); +} +#endif /* e-pTeX or e-upTeX */ +#endif /* TeX */ /* Metafont/MetaPost fraction routines. Replaced either by assembler or C. The assembler syntax doesn't work on Solaris/x86. */ diff --git a/Build/source/texk/web2c/pdftexdir/ChangeLog b/Build/source/texk/web2c/pdftexdir/ChangeLog index b36fe16a784..27d4d2c3f45 100644 --- a/Build/source/texk/web2c/pdftexdir/ChangeLog +++ b/Build/source/texk/web2c/pdftexdir/ChangeLog @@ -1,3 +1,13 @@ +2013-06-12 Peter Breitenlohner <peb@mppmu.mpg.de> + + Update to e-pTeX and e-upTeX 130605 from Hironori Kitagawa. + * ptexlib.h (initstarttime, makecstring, makecfilename, + getcreationdate, getfilemoddate, getfilesize): Move declarations + of functions also used by e-(u)pTeX from here to ../texmfmp.h. + * utils.c (initstarttime, makecstring, makecfilename, + getcreationdate, getfilemoddate, getfilesize): Move definition + of these functions from here to ../lib/texmfmp.c. + 2013-04-22 Akira Kakuto <kakuto@fuk.kindai.ac.jp> * pdftex.web: pdftex_revision = "14" diff --git a/Build/source/texk/web2c/pdftexdir/ptexlib.h b/Build/source/texk/web2c/pdftexdir/ptexlib.h index c8164381f6b..04be8a94269 100644 --- a/Build/source/texk/web2c/pdftexdir/ptexlib.h +++ b/Build/source/texk/web2c/pdftexdir/ptexlib.h @@ -1,5 +1,5 @@ /* -Copyright (c) 1996-2011 Han The Thanh, <thanh@pdftex.org> +Copyright (c) 1996-2013 Han The Thanh, <thanh@pdftex.org> This file is part of pdfTeX. @@ -197,7 +197,6 @@ extern integer write_tounicode(char **, const char *, const char *); /* utils.c */ extern boolean str_eq_cstr(strnumber, char *); -extern char *makecstring(integer); extern int xfflush(FILE *); extern int xgetc(FILE *); extern int xputc(int, FILE *); @@ -210,7 +209,6 @@ extern void fb_flush(void); extern void fb_putchar(eightbits b); extern void fb_seek(integer); extern void libpdffinish(void); -extern char *makecfilename(strnumber s); extern void make_subset_tag(fd_entry *); extern void setjobid(int, int, int, int); extern void writestreamlength(longinteger, longinteger); @@ -221,15 +219,11 @@ extern void escapename(poolpointer in); extern void escapestring(poolpointer in); extern void escapehex(poolpointer in); extern void unescapehex(poolpointer in); -extern void getcreationdate(void); -extern void getfilemoddate(strnumber s); -extern void getfilesize(strnumber s); extern void getmd5sum(strnumber s, boolean file); extern void getfiledump(strnumber s, int offset, int length); extern void matchstrings(strnumber s, strnumber t, int subcount, boolean icase); extern void getmatch(int i); extern void makepdftexbanner(void); -extern void initstarttime(void); extern void removepdffile(void); extern void garbagewarning(void); extern void initversionstring(char **versions); diff --git a/Build/source/texk/web2c/pdftexdir/utils.c b/Build/source/texk/web2c/pdftexdir/utils.c index 5fc23f229f1..b8dc994c2a3 100644 --- a/Build/source/texk/web2c/pdftexdir/utils.c +++ b/Build/source/texk/web2c/pdftexdir/utils.c @@ -278,33 +278,6 @@ void garbagewarning(void) removepdffile(); } -char *makecstring(integer s) -{ - static char *cstrbuf = NULL; - char *p; - static int allocsize; - int allocgrow, i, l = strstart[s + 1] - strstart[s]; - check_buf(l + 1, MAX_CSTRING_LEN); - if (cstrbuf == NULL) { - allocsize = l + 1; - cstrbuf = xmallocarray(char, allocsize); - } else if (l + 1 > allocsize) { - allocgrow = allocsize * 0.2; - if (l + 1 - allocgrow > allocsize) - allocsize = l + 1; - else if (allocsize < MAX_CSTRING_LEN - allocgrow) - allocsize += allocgrow; - else - allocsize = MAX_CSTRING_LEN; - cstrbuf = xreallocarray(cstrbuf, char, allocsize); - } - p = cstrbuf; - for (i = 0; i < l; i++) - *p++ = strpool[i + strstart[s]]; - *p = 0; - return cstrbuf; -} - void setjobid(int year, int month, int day, int time) { char *name_string, *format_string, *s; @@ -839,68 +812,6 @@ void printID(strnumber filename) Solaris 2.5). */ -static time_t start_time = 0; -#define TIME_STR_SIZE 30 -static char start_time_str[TIME_STR_SIZE]; -static char time_str[TIME_STR_SIZE]; - /* minimum size for time_str is 24: "D:YYYYmmddHHMMSS+HH'MM'" */ - -static void makepdftime(time_t t, char *time_str) -{ - - struct tm lt, gmt; - size_t size; - int i, off, off_hours, off_mins; - - /* get the time */ - lt = *localtime(&t); - size = strftime(time_str, TIME_STR_SIZE, "D:%Y%m%d%H%M%S", <); - /* expected format: "YYYYmmddHHMMSS" */ - if (size == 0) { - /* unexpected, contents of time_str is undefined */ - time_str[0] = '\0'; - return; - } - - /* correction for seconds: %S can be in range 00..61, - the PDF reference expects 00..59, - therefore we map "60" and "61" to "59" */ - if (time_str[14] == '6') { - time_str[14] = '5'; - time_str[15] = '9'; - time_str[16] = '\0'; /* for safety */ - } - - /* get the time zone offset */ - gmt = *gmtime(&t); - - /* this calculation method was found in exim's tod.c */ - off = 60 * (lt.tm_hour - gmt.tm_hour) + lt.tm_min - gmt.tm_min; - if (lt.tm_year != gmt.tm_year) { - off += (lt.tm_year > gmt.tm_year) ? 1440 : -1440; - } else if (lt.tm_yday != gmt.tm_yday) { - off += (lt.tm_yday > gmt.tm_yday) ? 1440 : -1440; - } - - if (off == 0) { - time_str[size++] = 'Z'; - time_str[size] = 0; - } else { - off_hours = off / 60; - off_mins = abs(off - off_hours * 60); - i = snprintf(&time_str[size], 9, "%+03d'%02d'", off_hours, off_mins); - check_nprintf(i, 9); - } -} - -void initstarttime(void) -{ - if (start_time == 0) { - start_time = time((time_t *) NULL); - makepdftime(start_time, start_time_str); - } -} - void printcreationdate(void) { initstarttime(); @@ -913,86 +824,6 @@ void printmoddate(void) pdf_printf("/ModDate (%s)\n", start_time_str); } -void getcreationdate(void) -{ - /* put creation date on top of string pool and update poolptr */ - size_t len = strlen(start_time_str); - - initstarttime(); - - if ((unsigned) (poolptr + len) >= (unsigned) (poolsize)) { - poolptr = poolsize; - /* error by str_toks that calls str_room(1) */ - return; - } - - memcpy(&strpool[poolptr], start_time_str, len); - poolptr += len; -} - -void getfilemoddate(strnumber s) -{ - struct stat file_data; - - char *file_name = kpse_find_tex(makecfilename(s)); - if (file_name == NULL) { - return; /* empty string */ - } - - recorder_record_input(file_name); - /* get file status */ - if (stat(file_name, &file_data) == 0) { - size_t len; - - makepdftime(file_data.st_mtime, time_str); - len = strlen(time_str); - if ((unsigned) (poolptr + len) >= (unsigned) (poolsize)) { - poolptr = poolsize; - /* error by str_toks that calls str_room(1) */ - } else { - memcpy(&strpool[poolptr], time_str, len); - poolptr += len; - } - } - /* else { errno contains error code } */ - - xfree(file_name); -} - -void getfilesize(strnumber s) -{ - struct stat file_data; - int i; - - char *file_name = kpse_find_tex(makecfilename(s)); - if (file_name == NULL) { - return; /* empty string */ - } - - recorder_record_input(file_name); - /* get file status */ - if (stat(file_name, &file_data) == 0) { - size_t len; - char buf[20]; - - /* st_size has type off_t */ - i = snprintf(buf, sizeof(buf), - "%lu", (long unsigned int) file_data.st_size); - check_nprintf(i, sizeof(buf)); - len = strlen(buf); - if ((unsigned) (poolptr + len) >= (unsigned) (poolsize)) { - poolptr = poolsize; - /* error by str_toks that calls str_room(1) */ - } else { - memcpy(&strpool[poolptr], buf, len); - poolptr += len; - } - } - /* else { errno contains error code } */ - - xfree(file_name); -} - #define DIGEST_SIZE 16 #define FILE_BUF_SIZE 1024 @@ -1188,29 +1019,6 @@ void getmatch(int i) strpool[poolptr++] = '>'; } - -/* makecfilename - input/ouput same as makecstring: - input: string number - output: C string with quotes removed. - That means, file names that are legal on some operation systems - cannot any more be used since pdfTeX version 1.30.4. -*/ -char *makecfilename(strnumber s) -{ - char *name = makecstring(s); - char *p = name; - char *q = name; - - while (*p) { - if (*p != '"') - *q++ = *p; - p++; - } - *q = '\0'; - return name; -} - /* function strips trailing zeros in string with numbers; */ /* leading zeros are not stripped (as in real life) */ char *stripzeros(char *a) diff --git a/Build/source/texk/web2c/texmfmp.h b/Build/source/texk/web2c/texmfmp.h index 0f261619226..73fdeec9aea 100644 --- a/Build/source/texk/web2c/texmfmp.h +++ b/Build/source/texk/web2c/texmfmp.h @@ -110,6 +110,18 @@ typedef void* voidpointer; /* Hacks for TeX that are better not to #ifdef, see lib/openclose.c. */ extern int tfmtemp, texinputtype; +/* pdfTeX routines also used for e-pTeX and e-upTeX */ +#if defined (pdfTeX) || defined (epTeX) || defined (eupTeX) +extern char start_time_str[]; +extern void pdftex_fail(const char *fmt, ...); +extern void initstarttime(void); +extern char *makecstring(integer s); +extern char *makecfilename(integer s); +extern void getcreationdate(void); +extern void getfilemoddate(integer s); +extern void getfilesize(integer s); +#endif + /* pdftex etc. except for tex use these for pipe support */ #if defined(TeX) && !defined(onlyTeX) extern boolean open_in_or_pipe (FILE **, int, const_string fopen_mode); |