From 393f15ebb52f333071ef3f2880b3f92995f96333 Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Wed, 30 Aug 2017 05:35:00 +0000 Subject: t1utils: Try not to use system memmem git-svn-id: svn://tug.org/texlive/trunk@45170 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/utils/t1utils/ChangeLog | 4 +++ Build/source/utils/t1utils/Makefile.am | 2 ++ Build/source/utils/t1utils/Makefile.in | 13 ++++++--- Build/source/utils/t1utils/TLpatches/ChangeLog | 4 +++ Build/source/utils/t1utils/TLpatches/TL-Changes | 1 - .../utils/t1utils/TLpatches/patch-03-warnings | 2 +- .../utils/t1utils/TLpatches/patch-04-TL-binary | 6 ++-- .../utils/t1utils/TLpatches/patch-07-warnings | 13 +++++++-- .../TLpatches/patch-08-notuse-system-memmem | 25 ++++++++++++++++ Build/source/utils/t1utils/config.h.in | 9 ++---- Build/source/utils/t1utils/configure | 13 --------- Build/source/utils/t1utils/configure.ac | 8 ++--- Build/source/utils/t1utils/memmem.c | 32 -------------------- Build/source/utils/t1utils/t1utils-src/memmem.c | 34 ++++++++++++++++++++++ Build/source/utils/t1utils/t1utils-src/t1asmhelp.h | 2 ++ 15 files changed, 99 insertions(+), 69 deletions(-) create mode 100644 Build/source/utils/t1utils/TLpatches/patch-08-notuse-system-memmem delete mode 100644 Build/source/utils/t1utils/memmem.c create mode 100644 Build/source/utils/t1utils/t1utils-src/memmem.c diff --git a/Build/source/utils/t1utils/ChangeLog b/Build/source/utils/t1utils/ChangeLog index 2baa9f0f178..a5d2bf0cd48 100644 --- a/Build/source/utils/t1utils/ChangeLog +++ b/Build/source/utils/t1utils/ChangeLog @@ -1,3 +1,7 @@ +2017-08-30 Akira Kakuto + + * Makefile.am, configure.ac: Do not use system memmem. + 2017-08-28 Akira Kakuto Import t1utils-1.41. diff --git a/Build/source/utils/t1utils/Makefile.am b/Build/source/utils/t1utils/Makefile.am index dc492b09495..1ffc632fcb9 100644 --- a/Build/source/utils/t1utils/Makefile.am +++ b/Build/source/utils/t1utils/Makefile.am @@ -50,11 +50,13 @@ t1binary_SOURCES = \ t1asm_SOURCES = \ @T1UTILS_TREE@/clp.c \ @T1UTILS_TREE@/t1lib.c \ + @T1UTILS_TREE@/memmem.c \ @T1UTILS_TREE@/t1asm.c t1disasm_SOURCES = \ @T1UTILS_TREE@/clp.c \ @T1UTILS_TREE@/t1lib.c \ + @T1UTILS_TREE@/memmem.c \ @T1UTILS_TREE@/t1disasm.c t1unmac_SOURCES = \ diff --git a/Build/source/utils/t1utils/Makefile.in b/Build/source/utils/t1utils/Makefile.in index fed1515172a..45c33556109 100644 --- a/Build/source/utils/t1utils/Makefile.in +++ b/Build/source/utils/t1utils/Makefile.in @@ -113,7 +113,8 @@ t1ascii_OBJECTS = $(am_t1ascii_OBJECTS) t1ascii_LDADD = $(LDADD) t1ascii_DEPENDENCIES = @LIBOBJS@ am_t1asm_OBJECTS = @T1UTILS_TREE@/clp.$(OBJEXT) \ - @T1UTILS_TREE@/t1lib.$(OBJEXT) @T1UTILS_TREE@/t1asm.$(OBJEXT) + @T1UTILS_TREE@/t1lib.$(OBJEXT) @T1UTILS_TREE@/memmem.$(OBJEXT) \ + @T1UTILS_TREE@/t1asm.$(OBJEXT) t1asm_OBJECTS = $(am_t1asm_OBJECTS) t1asm_LDADD = $(LDADD) t1asm_DEPENDENCIES = @LIBOBJS@ @@ -124,7 +125,7 @@ t1binary_OBJECTS = $(am_t1binary_OBJECTS) t1binary_LDADD = $(LDADD) t1binary_DEPENDENCIES = @LIBOBJS@ am_t1disasm_OBJECTS = @T1UTILS_TREE@/clp.$(OBJEXT) \ - @T1UTILS_TREE@/t1lib.$(OBJEXT) \ + @T1UTILS_TREE@/t1lib.$(OBJEXT) @T1UTILS_TREE@/memmem.$(OBJEXT) \ @T1UTILS_TREE@/t1disasm.$(OBJEXT) t1disasm_OBJECTS = $(am_t1disasm_OBJECTS) t1disasm_LDADD = $(LDADD) @@ -415,7 +416,7 @@ am__DIST_COMMON = $(dist_man_MANS) $(srcdir)/../../am/dist_hook.am \ ../../build-aux/depcomp ../../build-aux/install-sh \ ../../build-aux/ltmain.sh ../../build-aux/missing \ ../../build-aux/texinfo.tex ../../build-aux/ylwrap ChangeLog \ - memmem.c strerror.c + strerror.c DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) @@ -560,11 +561,13 @@ t1binary_SOURCES = \ t1asm_SOURCES = \ @T1UTILS_TREE@/clp.c \ @T1UTILS_TREE@/t1lib.c \ + @T1UTILS_TREE@/memmem.c \ @T1UTILS_TREE@/t1asm.c t1disasm_SOURCES = \ @T1UTILS_TREE@/clp.c \ @T1UTILS_TREE@/t1lib.c \ + @T1UTILS_TREE@/memmem.c \ @T1UTILS_TREE@/t1disasm.c t1unmac_SOURCES = \ @@ -692,6 +695,8 @@ clean-binPROGRAMS: t1ascii$(EXEEXT): $(t1ascii_OBJECTS) $(t1ascii_DEPENDENCIES) $(EXTRA_t1ascii_DEPENDENCIES) @rm -f t1ascii$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t1ascii_OBJECTS) $(t1ascii_LDADD) $(LIBS) +@T1UTILS_TREE@/memmem.$(OBJEXT): @T1UTILS_TREE@/$(am__dirstamp) \ + @T1UTILS_TREE@/$(DEPDIR)/$(am__dirstamp) @T1UTILS_TREE@/t1asm.$(OBJEXT): @T1UTILS_TREE@/$(am__dirstamp) \ @T1UTILS_TREE@/$(DEPDIR)/$(am__dirstamp) @@ -730,9 +735,9 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/memmem.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strerror.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@T1UTILS_TREE@/$(DEPDIR)/clp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@@T1UTILS_TREE@/$(DEPDIR)/memmem.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@T1UTILS_TREE@/$(DEPDIR)/t1ascii.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@T1UTILS_TREE@/$(DEPDIR)/t1asm.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@T1UTILS_TREE@/$(DEPDIR)/t1binary.Po@am__quote@ diff --git a/Build/source/utils/t1utils/TLpatches/ChangeLog b/Build/source/utils/t1utils/TLpatches/ChangeLog index e56f7c8cbd1..18f3ab141bc 100644 --- a/Build/source/utils/t1utils/TLpatches/ChangeLog +++ b/Build/source/utils/t1utils/TLpatches/ChangeLog @@ -1,3 +1,7 @@ +2017-08-30 Akira Kakuto + + * patch-08-notuse-system-memmem: Added. + 2017-08-28 Akira Kakuto Import t1utils-1.41. diff --git a/Build/source/utils/t1utils/TLpatches/TL-Changes b/Build/source/utils/t1utils/TLpatches/TL-Changes index 7c4de062f7e..c2c75e73544 100644 --- a/Build/source/utils/t1utils/TLpatches/TL-Changes +++ b/Build/source/utils/t1utils/TLpatches/TL-Changes @@ -14,4 +14,3 @@ Removed: Moved this file to ../: strerror.c - memmem.c diff --git a/Build/source/utils/t1utils/TLpatches/patch-03-warnings b/Build/source/utils/t1utils/TLpatches/patch-03-warnings index ae2f72f454c..da2e03e98d6 100644 --- a/Build/source/utils/t1utils/TLpatches/patch-03-warnings +++ b/Build/source/utils/t1utils/TLpatches/patch-03-warnings @@ -2,7 +2,7 @@ diff -ur t1utils-1.41.orig/clp.c t1utils-1.41/clp.c --- t1utils-1.41.orig/clp.c Thu Aug 17 00:20:27 2017 -+++ t1utils-1.41/clp.c Mon Aug 28 14:14:04 2017 ++++ t1utils-1.41/clp.c Mon Aug 28 15:43:58 2017 @@ -1095,22 +1095,28 @@ parse_int(Clp_Parser* clp, const char* arg, int complain, void* user_data) { diff --git a/Build/source/utils/t1utils/TLpatches/patch-04-TL-binary b/Build/source/utils/t1utils/TLpatches/patch-04-TL-binary index c941f59ddf5..150d3d4747d 100644 --- a/Build/source/utils/t1utils/TLpatches/patch-04-TL-binary +++ b/Build/source/utils/t1utils/TLpatches/patch-04-TL-binary @@ -2,7 +2,7 @@ diff -ur t1utils-1.41.orig/t1ascii.c t1utils-1.41/t1ascii.c --- t1utils-1.41.orig/t1ascii.c Thu Aug 17 01:31:02 2017 -+++ t1utils-1.41/t1ascii.c Mon Aug 28 14:22:17 2017 ++++ t1utils-1.41/t1ascii.c Mon Aug 28 15:43:58 2017 @@ -286,6 +286,7 @@ /* As we are processing a PFB (binary) input */ /* file, we must set its file mode to binary. */ @@ -13,7 +13,7 @@ diff -ur t1utils-1.41.orig/t1ascii.c t1utils-1.41/t1ascii.c /* prepare font reader */ diff -ur t1utils-1.41.orig/t1disasm.c t1utils-1.41/t1disasm.c --- t1utils-1.41.orig/t1disasm.c Thu Aug 17 01:31:24 2017 -+++ t1utils-1.41/t1disasm.c Mon Aug 28 14:23:22 2017 ++++ t1utils-1.41/t1disasm.c Mon Aug 28 15:43:58 2017 @@ -727,6 +727,7 @@ /* As we might be processing a PFB (binary) input file, we must set its file mode to binary. */ @@ -24,7 +24,7 @@ diff -ur t1utils-1.41.orig/t1disasm.c t1utils-1.41/t1disasm.c /* prepare font reader */ diff -ur t1utils-1.41.orig/t1unmac.c t1utils-1.41/t1unmac.c --- t1utils-1.41.orig/t1unmac.c Thu Aug 17 01:31:39 2017 -+++ t1utils-1.41/t1unmac.c Mon Aug 28 14:26:09 2017 ++++ t1utils-1.41/t1unmac.c Mon Aug 28 15:43:58 2017 @@ -656,8 +655,7 @@ _setmode(_fileno(ifp), _O_BINARY); /* If we are processing a PFB (binary) output */ diff --git a/Build/source/utils/t1utils/TLpatches/patch-07-warnings b/Build/source/utils/t1utils/TLpatches/patch-07-warnings index 931af1db983..0d5bbf7fb4f 100644 --- a/Build/source/utils/t1utils/TLpatches/patch-07-warnings +++ b/Build/source/utils/t1utils/TLpatches/patch-07-warnings @@ -2,8 +2,8 @@ diff -ur t1utils-1.41.orig/t1asmhelp.h t1utils-1.41/t1asmhelp.h --- t1utils-1.41.orig/t1asmhelp.h Thu Aug 17 00:20:27 2017 -+++ t1utils-1.41/t1asmhelp.h Mon Aug 28 14:30:14 2017 -@@ -26,7 +26,8 @@ ++++ t1utils-1.41/t1asmhelp.h Wed Aug 30 13:42:34 2017 +@@ -26,7 +28,8 @@ } @@ -13,7 +13,14 @@ diff -ur t1utils-1.41.orig/t1asmhelp.h t1utils-1.41/t1asmhelp.h static void set_cs_start(const char* line, size_t line_len) -@@ -43,7 +44,7 @@ +@@ -37,13 +40,13 @@ + if ((p = memmem(line, line_len, "string currentfile", 18)) + && memmem(line, line_len, "readstring", 10)) { + /* locate the name of the charstring start command */ +- for (q = p; q != line && q[-1] != '/'; --q) ++ for (q = p; q != line && *(q-1) != '/'; --q) + /* nada */; + if (q != line) { for (r = q; r != p && !isspace((unsigned char) *r) && *r != '{'; ++r) /* nada */; if (cs_start_set) diff --git a/Build/source/utils/t1utils/TLpatches/patch-08-notuse-system-memmem b/Build/source/utils/t1utils/TLpatches/patch-08-notuse-system-memmem new file mode 100644 index 00000000000..ed4a780c4fb --- /dev/null +++ b/Build/source/utils/t1utils/TLpatches/patch-08-notuse-system-memmem @@ -0,0 +1,25 @@ +diff -ur t1utils-1.41.orig/memmem.c t1utils-1.41/memmem.c +--- t1utils-1.41.orig/memmem.c Thu Aug 17 00:20:27 2017 ++++ t1utils-1.41/memmem.c Wed Aug 30 13:40:56 2017 +@@ -9,6 +9,8 @@ + extern "C" { + #endif + ++#define memmem my_memmem ++ + void* + memmem(const void* haystack, size_t haystack_len, + const void* needle, size_t needle_len) +diff -ur t1utils-1.41.orig/t1asmhelp.h t1utils-1.41/t1asmhelp.h +--- t1utils-1.41.orig/t1asmhelp.h Thu Aug 17 00:20:27 2017 ++++ t1utils-1.41/t1asmhelp.h Wed Aug 30 13:42:34 2017 +@@ -7,6 +7,8 @@ + lenIV to . This indicates the number of random bytes at the beginning + of each charstring. */ + ++#define memmem my_memmem ++ + static void + set_lenIV(const char* line, size_t line_len) + { + diff --git a/Build/source/utils/t1utils/config.h.in b/Build/source/utils/t1utils/config.h.in index 3755607576b..a1b4a1e01d1 100644 --- a/Build/source/utils/t1utils/config.h.in +++ b/Build/source/utils/t1utils/config.h.in @@ -9,9 +9,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H -/* Define to 1 if you have the `memmem' function. */ -#undef HAVE_MEMMEM - /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H @@ -98,11 +95,9 @@ extern "C" { char *strerror(int errno); #endif -/* Prototype memmem if we don't have it. */ -#if !HAVE_MEMMEM -void *memmem(const void* haystack, size_t haystack_len, +/* Prototype my_memmem */ +void *my_memmem(const void* haystack, size_t haystack_len, const void* needle, size_t needle_len); -#endif #ifdef __cplusplus } diff --git a/Build/source/utils/t1utils/configure b/Build/source/utils/t1utils/configure index 8978891b1aa..382a152412e 100755 --- a/Build/source/utils/t1utils/configure +++ b/Build/source/utils/t1utils/configure @@ -4989,19 +4989,6 @@ esac fi -ac_fn_c_check_func "$LINENO" "memmem" "ac_cv_func_memmem" -if test "x$ac_cv_func_memmem" = xyes; then : - $as_echo "#define HAVE_MEMMEM 1" >>confdefs.h - -else - case " $LIBOBJS " in - *" memmem.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS memmem.$ac_objext" - ;; -esac - -fi - for ac_func in strtoul diff --git a/Build/source/utils/t1utils/configure.ac b/Build/source/utils/t1utils/configure.ac index e1b0ef98a05..2124286841b 100644 --- a/Build/source/utils/t1utils/configure.ac +++ b/Build/source/utils/t1utils/configure.ac @@ -28,7 +28,7 @@ dnl dnl strerror()? dnl -AC_REPLACE_FUNCS([strerror memmem]) +AC_REPLACE_FUNCS([strerror]) AC_CHECK_FUNCS([strtoul]) @@ -105,11 +105,9 @@ extern "C" { char *strerror(int errno); #endif -/* Prototype memmem if we don't have it. */ -#if !HAVE_MEMMEM -void *memmem(const void* haystack, size_t haystack_len, +/* Prototype my_memmem */ +void *my_memmem(const void* haystack, size_t haystack_len, const void* needle, size_t needle_len); -#endif #ifdef __cplusplus } diff --git a/Build/source/utils/t1utils/memmem.c b/Build/source/utils/t1utils/memmem.c deleted file mode 100644 index af9808c56be..00000000000 --- a/Build/source/utils/t1utils/memmem.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Some operating systems might not have memmem. */ - -#ifdef HAVE_CONFIG_H -# include -#endif -#include -#include -#ifdef __cplusplus -extern "C" { -#endif - -void* -memmem(const void* haystack, size_t haystack_len, - const void* needle, size_t needle_len) -{ - const unsigned char* s = (const unsigned char*) haystack; - const unsigned char* ends = s + haystack_len - needle_len; - const unsigned char* p = (const unsigned char*) needle; - void* try; - if (needle_len == 0) - return (void*) haystack; - while (s <= ends && (try = memchr(s, *p, ends - s + 1))) - if (memcmp(try, p, needle_len) == 0) - return (void*) try; - else - s = (const unsigned char*) try + 1; - return 0; -} - -#ifdef __cplusplus -} -#endif diff --git a/Build/source/utils/t1utils/t1utils-src/memmem.c b/Build/source/utils/t1utils/t1utils-src/memmem.c new file mode 100644 index 00000000000..a724dc6f517 --- /dev/null +++ b/Build/source/utils/t1utils/t1utils-src/memmem.c @@ -0,0 +1,34 @@ +/* Some operating systems might not have memmem. */ + +#ifdef HAVE_CONFIG_H +# include +#endif +#include +#include +#ifdef __cplusplus +extern "C" { +#endif + +#define memmem my_memmem + +void* +memmem(const void* haystack, size_t haystack_len, + const void* needle, size_t needle_len) +{ + const unsigned char* s = (const unsigned char*) haystack; + const unsigned char* ends = s + haystack_len - needle_len; + const unsigned char* p = (const unsigned char*) needle; + void* try; + if (needle_len == 0) + return (void*) haystack; + while (s <= ends && (try = memchr(s, *p, ends - s + 1))) + if (memcmp(try, p, needle_len) == 0) + return (void*) try; + else + s = (const unsigned char*) try + 1; + return 0; +} + +#ifdef __cplusplus +} +#endif diff --git a/Build/source/utils/t1utils/t1utils-src/t1asmhelp.h b/Build/source/utils/t1utils/t1utils-src/t1asmhelp.h index a5b271f8ee7..1cb5b09b180 100644 --- a/Build/source/utils/t1utils/t1utils-src/t1asmhelp.h +++ b/Build/source/utils/t1utils/t1utils-src/t1asmhelp.h @@ -7,6 +7,8 @@ static int lenIV = 4; lenIV to . This indicates the number of random bytes at the beginning of each charstring. */ +#define memmem my_memmem + static void set_lenIV(const char* line, size_t line_len) { -- cgit v1.2.3