From 1b54746a7a7087af138fe21c002cd967fdaf6597 Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Sat, 4 Jul 2015 11:28:05 +0000 Subject: e-(u)pTeX: Add \pdfmdfivesum as in pdfTeX (from Hironori Kitagawa) git-svn-id: svn://tug.org/texlive/trunk@37756 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/ChangeLog | 4 ++ Build/source/texk/web2c/Makefile.in | 10 +-- Build/source/texk/web2c/eptexdir/ChangeLog | 7 ++ Build/source/texk/web2c/eptexdir/am/eptex.am | 4 +- Build/source/texk/web2c/eptexdir/eptex.defines | 1 + Build/source/texk/web2c/eptexdir/eptex.ech | 2 +- Build/source/texk/web2c/eptexdir/eptex_version.h | 2 +- Build/source/texk/web2c/eptexdir/pdfutils.ch | 37 ++++++++++- Build/source/texk/web2c/euptexdir/ChangeLog | 5 ++ Build/source/texk/web2c/euptexdir/am/euptex.am | 4 +- Build/source/texk/web2c/euptexdir/euptex.defines | 1 + Build/source/texk/web2c/lib/ChangeLog | 5 ++ Build/source/texk/web2c/lib/texmfmp.c | 78 +++++++++++++++++++++- Build/source/texk/web2c/pdftexdir/ChangeLog | 5 ++ Build/source/texk/web2c/pdftexdir/utils.c | 84 ++---------------------- Build/source/texk/web2c/texmfmp.h | 2 + 16 files changed, 158 insertions(+), 93 deletions(-) diff --git a/Build/source/texk/web2c/ChangeLog b/Build/source/texk/web2c/ChangeLog index dccfd2d4a9a..c01bbe1fd49 100644 --- a/Build/source/texk/web2c/ChangeLog +++ b/Build/source/texk/web2c/ChangeLog @@ -1,3 +1,7 @@ +2015-07-04 Peter Breitenlohner + + * texmfmp.h: Declare convertStringToHexString() and getmd5sum(). + 2015-07-03 Peter Breitenlohner * am/texmf.am: Always create mf-nowin, either as extra program diff --git a/Build/source/texk/web2c/Makefile.in b/Build/source/texk/web2c/Makefile.in index ffcec0e2146..08d8ca93899 100644 --- a/Build/source/texk/web2c/Makefile.in +++ b/Build/source/texk/web2c/Makefile.in @@ -2997,11 +2997,12 @@ ptftopl_DEPENDENCIES = $(ptex_dependencies) # e-pTeX Tests # eptex_tests = eptexdir/eptriptest -eptex_CPPFLAGS = $(PTEXENC_INCLUDES) $(AM_CPPFLAGS) $(am__append_142) +eptex_CPPFLAGS = $(PTEXENC_INCLUDES) $(AM_CPPFLAGS) -I$(srcdir)/libmd5 \ + $(am__append_142) # With --enable-ipc, e-pTeX may need to link with -lsocket. eptex_LDADD = libkanji.a $(pproglib) $(PTEXENC_LIBS) $(LDADD) \ - $(ipc_socketlibs) $(am__append_143) + $(ipc_socketlibs) libmd5.a $(am__append_143) eptex_DEPENDENCIES = libkanji.a $(pproglib) $(PTEXENC_DEPEND) $(default_dependencies) # e-pTeX C sources @@ -3093,11 +3094,12 @@ uptftopl_DEPENDENCIES = $(uptex_dependencies) # e-upTeX Tests # euptex_tests = euptexdir/euptriptest -euptex_CPPFLAGS = $(PTEXENC_INCLUDES) $(AM_CPPFLAGS) $(am__append_146) +euptex_CPPFLAGS = $(PTEXENC_INCLUDES) $(AM_CPPFLAGS) \ + -I$(srcdir)/libmd5 $(am__append_146) # With --enable-ipc, e-upTeX may need to link with -lsocket. euptex_LDADD = libukanji.a $(pproglib) $(PTEXENC_LIBS) $(LDADD) \ - $(ipc_socketlibs) $(am__append_147) + $(ipc_socketlibs) libmd5.a $(am__append_147) euptex_DEPENDENCIES = libukanji.a $(pproglib) $(PTEXENC_DEPEND) $(default_dependencies) # e-upTeX C sources diff --git a/Build/source/texk/web2c/eptexdir/ChangeLog b/Build/source/texk/web2c/eptexdir/ChangeLog index 5e396f88c43..22511983d84 100644 --- a/Build/source/texk/web2c/eptexdir/ChangeLog +++ b/Build/source/texk/web2c/eptexdir/ChangeLog @@ -1,3 +1,10 @@ +2015-07-02 Hironori Kitagawa + + * am/eptex.am: Add libmd5.a. + * pdfutils.ch: Add primitive \pdfmdfivesum to e-(u)pTeX. + * eptex.defines: Add getmd5sum(). + * eptex.ech, eptex_version.h: Change version to 150702. + 2015-06-22 Peter Breitenlohner * am/eptx.am: Use $(tie_c) and $(tie_m). diff --git a/Build/source/texk/web2c/eptexdir/am/eptex.am b/Build/source/texk/web2c/eptexdir/am/eptex.am index b3837a3a4ea..6a50e2ac08c 100644 --- a/Build/source/texk/web2c/eptexdir/am/eptex.am +++ b/Build/source/texk/web2c/eptexdir/am/eptex.am @@ -16,10 +16,10 @@ eptex_tests = eptexdir/eptriptest EXTRA_DIST += $(eptex_tests) -eptex_CPPFLAGS = $(PTEXENC_INCLUDES) $(AM_CPPFLAGS) +eptex_CPPFLAGS = $(PTEXENC_INCLUDES) $(AM_CPPFLAGS) -I$(srcdir)/libmd5 # With --enable-ipc, e-pTeX may need to link with -lsocket. -eptex_LDADD = libkanji.a $(pproglib) $(PTEXENC_LIBS) $(LDADD) $(ipc_socketlibs) +eptex_LDADD = libkanji.a $(pproglib) $(PTEXENC_LIBS) $(LDADD) $(ipc_socketlibs) libmd5.a eptex_DEPENDENCIES = libkanji.a $(pproglib) $(PTEXENC_DEPEND) $(default_dependencies) # e-pTeX C sources diff --git a/Build/source/texk/web2c/eptexdir/eptex.defines b/Build/source/texk/web2c/eptexdir/eptex.defines index 0d288a3e6f8..8b4e16e0a95 100644 --- a/Build/source/texk/web2c/eptexdir/eptex.defines +++ b/Build/source/texk/web2c/eptexdir/eptex.defines @@ -41,3 +41,4 @@ @define procedure getfilemoddate(); @define procedure getfilesize(); @define procedure getfiledump(); +@define procedure getmd5sum(); diff --git a/Build/source/texk/web2c/eptexdir/eptex.ech b/Build/source/texk/web2c/eptexdir/eptex.ech index 96d12f9154d..b432bda6c48 100644 --- a/Build/source/texk/web2c/eptexdir/eptex.ech +++ b/Build/source/texk/web2c/eptexdir/eptex.ech @@ -19,7 +19,7 @@ @y @d eTeX_version_string=='-2.6' {current \eTeX\ version} @# -@d epTeX_version_string=='-141210' +@d epTeX_version_string=='-150702' @z @x e-pTeX: banner diff --git a/Build/source/texk/web2c/eptexdir/eptex_version.h b/Build/source/texk/web2c/eptexdir/eptex_version.h index abf14fd3be5..a5ca0955da0 100644 --- a/Build/source/texk/web2c/eptexdir/eptex_version.h +++ b/Build/source/texk/web2c/eptexdir/eptex_version.h @@ -1 +1 @@ -#define EPTEX_VERSION "141210" +#define EPTEX_VERSION "150702" diff --git a/Build/source/texk/web2c/eptexdir/pdfutils.ch b/Build/source/texk/web2c/eptexdir/pdfutils.ch index fa978ac6348..5667fe427a2 100644 --- a/Build/source/texk/web2c/eptexdir/pdfutils.ch +++ b/Build/source/texk/web2c/eptexdir/pdfutils.ch @@ -14,6 +14,9 @@ %% %% \pdfshellescape: by doraTeX's request %% +%% \pdfmdfivesum: by Akira's request +%% As \pdfstrcmp, Japanese characters will be always encoded in UTF-8 in +%% \pdfmdfivesum {...}. (no conversion for \pdfmdfivesum file ) @x @* \[12] Displaying boxes. @@ -69,8 +72,9 @@ pdf_page_height_code: print_esc("pdfpageheight"); @d pdf_creation_date_code = etex_convert_base+2 {command code for \.{\\pdfcreationdate}} @d pdf_file_mod_date_code = etex_convert_base+3 {command code for \.{\\pdffilemoddate}} @d pdf_file_size_code = etex_convert_base+4 {command code for \.{\\pdffilesize}} -@d pdf_file_dump_code = etex_convert_base+5 {command code for \.{\\pdffiledump}} -@d etex_convert_codes=etex_convert_base+6 {end of \eTeX's command codes} +@d pdf_mdfive_sum_code = etex_convert_base+5 {command code for \.{\\pdfmdfivesum}} +@d pdf_file_dump_code = etex_convert_base+6 {command code for \.{\\pdffiledump}} +@d etex_convert_codes=etex_convert_base+7 {end of \eTeX's command codes} @z @x @@ -81,6 +85,7 @@ pdf_page_height_code: print_esc("pdfpageheight"); pdf_creation_date_code: print_esc("pdfcreationdate"); pdf_file_mod_date_code: print_esc("pdffilemoddate"); pdf_file_size_code: print_esc("pdffilesize"); + pdf_mdfive_sum_code: print_esc("pdfmdfivesum"); pdf_file_dump_code: print_esc("pdffiledump"); @z @@ -104,6 +109,7 @@ we have to create a temporary string that is destroyed immediately after. @!save_scanner_status:small_number; {|scanner_status| upon entry} @!save_def_ref: pointer; {|def_ref| upon entry, important if inside `\.{\\message}'} @!save_warning_index: pointer; +@!bool: boolean; {temp boolean} @!u: str_number; {saved current string string} @!s: str_number; {first temp string} @!i: integer; @@ -179,7 +185,30 @@ pdf_file_size_code: restore_cur_string; return; end; - +pdf_mdfive_sum_code: + begin + save_scanner_status := scanner_status; + save_warning_index := warning_index; + save_def_ref := def_ref; + save_cur_string; + bool := scan_keyword("file"); + scan_pdf_ext_toks; + if bool then s := tokens_to_string(def_ref) + else begin + isprint_utf8:=true; s := tokens_to_string(def_ref); isprint_utf8:=false; + end; + delete_token_ref(def_ref); + def_ref := save_def_ref; + warning_index := save_warning_index; + scanner_status := save_scanner_status; + b := pool_ptr; + getmd5sum(s, bool); + link(garbage) := str_toks(b); + flush_str(s); + ins_list(link(temp_head)); + restore_cur_string; + return; + end; pdf_file_dump_code: begin save_scanner_status := scanner_status; @@ -354,6 +383,8 @@ primitive("pdffilemoddate",convert,pdf_file_mod_date_code);@/ @!@:pdf_file_mod_date_}{\.{\\pdffilemoddate} primitive@> primitive("pdffilesize",convert,pdf_file_size_code);@/ @!@:pdf_file_size_}{\.{\\pdffilesize} primitive@> +primitive("pdfmdfivesum",convert,pdf_mdfive_sum_code);@/ +@!@:pdf_mdfive_sum_}{\.{\\pdfmdfivesum} primitive@> primitive("pdffiledump",convert,pdf_file_dump_code);@/ @!@:pdf_file_dump_}{\.{\\pdffiledump} primitive@> primitive("pdfsavepos",extension,pdf_save_pos_node);@/ diff --git a/Build/source/texk/web2c/euptexdir/ChangeLog b/Build/source/texk/web2c/euptexdir/ChangeLog index 0f2c7c4ef9f..608d5eb11c6 100644 --- a/Build/source/texk/web2c/euptexdir/ChangeLog +++ b/Build/source/texk/web2c/euptexdir/ChangeLog @@ -1,3 +1,8 @@ +2015-07-02 Hironori Kitagawa + + * am/euptex.am: Add libmd5.a. + * euptex.defines: Add getmd5sum(). + 2015-06-22 Peter Breitenlohner * am/euptex.am: Use $(tie_c) and $(tie_m). diff --git a/Build/source/texk/web2c/euptexdir/am/euptex.am b/Build/source/texk/web2c/euptexdir/am/euptex.am index 63667007f54..6752fb0ec8d 100644 --- a/Build/source/texk/web2c/euptexdir/am/euptex.am +++ b/Build/source/texk/web2c/euptexdir/am/euptex.am @@ -16,10 +16,10 @@ euptex_tests = euptexdir/euptriptest EXTRA_DIST += $(euptex_tests) -euptex_CPPFLAGS = $(PTEXENC_INCLUDES) $(AM_CPPFLAGS) +euptex_CPPFLAGS = $(PTEXENC_INCLUDES) $(AM_CPPFLAGS) -I$(srcdir)/libmd5 # With --enable-ipc, e-upTeX may need to link with -lsocket. -euptex_LDADD = libukanji.a $(pproglib) $(PTEXENC_LIBS) $(LDADD) $(ipc_socketlibs) +euptex_LDADD = libukanji.a $(pproglib) $(PTEXENC_LIBS) $(LDADD) $(ipc_socketlibs) libmd5.a euptex_DEPENDENCIES = libukanji.a $(pproglib) $(PTEXENC_DEPEND) $(default_dependencies) # e-upTeX C sources diff --git a/Build/source/texk/web2c/euptexdir/euptex.defines b/Build/source/texk/web2c/euptexdir/euptex.defines index 3647f9c4f30..84b3f0a9949 100644 --- a/Build/source/texk/web2c/euptexdir/euptex.defines +++ b/Build/source/texk/web2c/euptexdir/euptex.defines @@ -52,3 +52,4 @@ @define procedure getfilemoddate(); @define procedure getfilesize(); @define procedure getfiledump(); +@define procedure getmd5sum(); diff --git a/Build/source/texk/web2c/lib/ChangeLog b/Build/source/texk/web2c/lib/ChangeLog index 7771412da7a..2bb8387c24f 100644 --- a/Build/source/texk/web2c/lib/ChangeLog +++ b/Build/source/texk/web2c/lib/ChangeLog @@ -1,3 +1,8 @@ +2015-07-02 Hironori Kitagawa + + * texmfmp.c: Moved convertStringToHexString() and getmd5sum() + from ../pdftexdir/utils.c to here. + 2015-06-12 Peter Breitenlohner Integrate MFLua and MFLuaJIT. diff --git a/Build/source/texk/web2c/lib/texmfmp.c b/Build/source/texk/web2c/lib/texmfmp.c index b81526a8519..bbe10eb376a 100644 --- a/Build/source/texk/web2c/lib/texmfmp.c +++ b/Build/source/texk/web2c/lib/texmfmp.c @@ -2836,6 +2836,7 @@ makesrcspecial (strnumber srcfilename, int lineno) #if defined (pdfTeX) || defined (epTeX) || defined (eupTeX) #include +#include "md5.h" #define check_nprintf(size_get, size_want) \ if ((unsigned)(size_get) >= (unsigned)(size_want)) \ @@ -3135,7 +3136,82 @@ void getfiledump(integer s, int offset, int length) } xfree(file_name); } -#endif /* e-pTeX or e-upTeX */ + + +/* Converts any given string in into an allowed PDF string which is + * hexadecimal encoded; + * sizeof(out) should be at least lin*2+1. + */ +void convertStringToHexString(const char *in, char *out, int lin) +{ + int i, j, k; + char buf[3]; + j = 0; + for (i = 0; i < lin; i++) { + k = snprintf(buf, sizeof(buf), + "%02X", (unsigned int) (unsigned char) in[i]); + check_nprintf(k, sizeof(buf)); + out[j++] = buf[0]; + out[j++] = buf[1]; + } + out[j] = '\0'; +} + +#define DIGEST_SIZE 16 +#define FILE_BUF_SIZE 1024 + +void getmd5sum(strnumber s, boolean file) +{ + md5_state_t state; + md5_byte_t digest[DIGEST_SIZE]; + char outbuf[2 * DIGEST_SIZE + 1]; + int len = 2 * DIGEST_SIZE; + + if (file) { + char file_buf[FILE_BUF_SIZE]; + int read = 0; + FILE *f; + + char *file_name = kpse_find_tex(makecfilename(s)); + if (file_name == NULL) { + return; /* empty string */ + } + /* in case of error the empty string is returned, + no need for xfopen that aborts on error. + */ + f = fopen(file_name, FOPEN_RBIN_MODE); + if (f == NULL) { + xfree(file_name); + return; + } + recorder_record_input(file_name); + md5_init(&state); + while ((read = fread(&file_buf, sizeof(char), FILE_BUF_SIZE, f)) > 0) { + md5_append(&state, (const md5_byte_t *) file_buf, read); + } + md5_finish(&state, digest); + fclose(f); + + xfree(file_name); + } else { + /* s contains the data */ + md5_init(&state); + md5_append(&state, + (const md5_byte_t *) &strpool[strstart[s]], + strstart[s + 1] - strstart[s]); + md5_finish(&state, digest); + } + + if (poolptr + len >= poolsize) { + /* error by str_toks that calls str_room(1) */ + return; + } + convertStringToHexString((char *) digest, outbuf, DIGEST_SIZE); + memcpy(&strpool[poolptr], outbuf, len); + poolptr += len; +} + +#endif /* pdfTeX or e-pTeX or e-upTeX */ #endif /* TeX */ /* Metafont/MetaPost fraction routines. Replaced either by assembler or C. diff --git a/Build/source/texk/web2c/pdftexdir/ChangeLog b/Build/source/texk/web2c/pdftexdir/ChangeLog index 88d0b961636..3a4de28e65c 100644 --- a/Build/source/texk/web2c/pdftexdir/ChangeLog +++ b/Build/source/texk/web2c/pdftexdir/ChangeLog @@ -1,3 +1,8 @@ +2015-07-02 Hironori Kitagawa + + * utils.c: Moved convertStringToHexString() and getmd5sum() + from here to ../lib/texmfmp.c. + 2015-06-30 Peter Breitenlohner * pdftex.defines, ptexlib.h, pdftex.web, utils.c: Sync with diff --git a/Build/source/texk/web2c/pdftexdir/utils.c b/Build/source/texk/web2c/pdftexdir/utils.c index 31fbae2237a..43b9ba4b73f 100644 --- a/Build/source/texk/web2c/pdftexdir/utils.c +++ b/Build/source/texk/web2c/pdftexdir/utils.c @@ -1,5 +1,5 @@ /* -Copyright 1996-2014 Han The Thanh, +Copyright 1996-2015 Han The Thanh, This file is part of pdfTeX. @@ -29,15 +29,15 @@ with this program. If not, see . #include #include /* for DBL_EPSILON */ #include "md5.h" -#include "zlib.h" +#include #include "ptexlib.h" -#include "png.h" +#include #ifdef POPPLER_VERSION -#include "poppler-config.h" +#include #define xpdfVersion POPPLER_VERSION #define xpdfString "poppler" #else -#include "xpdf/config.h" /* just to get the xpdf version */ +#include /* just to get the xpdf version */ #define xpdfString "xpdf" #endif @@ -670,26 +670,6 @@ void unescapehex(poolpointer in) } } - -/* Converts any string given in in in an allowed PDF string which is - * hexadecimal encoded; - * sizeof(out) should be at least lin*2+1. - */ -static void convertStringToHexString(const char *in, char *out, int lin) -{ - int i, j, k; - char buf[3]; - j = 0; - for (i = 0; i < lin; i++) { - k = snprintf(buf, sizeof(buf), - "%02X", (unsigned int) (unsigned char) in[i]); - check_nprintf(k, sizeof(buf)); - out[j++] = buf[0]; - out[j++] = buf[1]; - } - out[j] = '\0'; -} - /* Compute the ID string as per PDF1.4 9.3:
File identifers are defined by the optional ID entry in a PDF file's @@ -841,60 +821,6 @@ void printmoddate(void) pdf_printf("/ModDate (%s)\n", start_time_str); } -#define DIGEST_SIZE 16 -#define FILE_BUF_SIZE 1024 - -void getmd5sum(strnumber s, boolean file) -{ - md5_state_t state; - md5_byte_t digest[DIGEST_SIZE]; - char outbuf[2 * DIGEST_SIZE + 1]; - int len = 2 * DIGEST_SIZE; - - if (file) { - char file_buf[FILE_BUF_SIZE]; - int read = 0; - FILE *f; - - char *file_name = kpse_find_tex(makecfilename(s)); - if (file_name == NULL) { - return; /* empty string */ - } - /* in case of error the empty string is returned, - no need for xfopen that aborts on error. - */ - f = fopen(file_name, FOPEN_RBIN_MODE); - if (f == NULL) { - xfree(file_name); - return; - } - recorder_record_input(file_name); - md5_init(&state); - while ((read = fread(&file_buf, sizeof(char), FILE_BUF_SIZE, f)) > 0) { - md5_append(&state, (const md5_byte_t *) file_buf, read); - } - md5_finish(&state, digest); - fclose(f); - - xfree(file_name); - } else { - /* s contains the data */ - md5_init(&state); - md5_append(&state, - (const md5_byte_t *) &strpool[strstart[s]], - strstart[s + 1] - strstart[s]); - md5_finish(&state, digest); - } - - if (poolptr + len >= poolsize) { - /* error by str_toks that calls str_room(1) */ - return; - } - convertStringToHexString((char *) digest, outbuf, DIGEST_SIZE); - memcpy(&strpool[poolptr], outbuf, len); - poolptr += len; -} - #define DEFAULT_SUB_MATCH_COUNT 10 static int sub_match_count = DEFAULT_SUB_MATCH_COUNT; static regmatch_t *pmatch = NULL; diff --git a/Build/source/texk/web2c/texmfmp.h b/Build/source/texk/web2c/texmfmp.h index 4f5f4b21f6b..438dcb741e2 100644 --- a/Build/source/texk/web2c/texmfmp.h +++ b/Build/source/texk/web2c/texmfmp.h @@ -130,6 +130,8 @@ extern void getcreationdate(void); extern void getfilemoddate(integer s); extern void getfilesize(integer s); extern void getfiledump(integer s, int offset, int length); +extern void convertStringToHexString(const char *in, char *out, int lin); +extern void getmd5sum(integer s, int file); #endif /* pdftex etc. except for tex use these for pipe support */ -- cgit v1.2.3