diff options
Diffstat (limited to 'Build/source')
42 files changed, 463 insertions, 1430 deletions
diff --git a/Build/source/texk/ttfdump/ChangeLog b/Build/source/texk/ttfdump/ChangeLog index ece0f643243..a9cc2d5786c 100644 --- a/Build/source/texk/ttfdump/ChangeLog +++ b/Build/source/texk/ttfdump/ChangeLog @@ -1,3 +1,16 @@ +2011-11-08 Peter Breitenlohner <peb@mppmu.mpg.de> + + Major update. + * include/*, libttf/*, src/ttfdump.c: Drop <dmalloc.h> and vcid. + Copy or adapt xfseek(), xmalloc(), xcalloc(), and xstrdup() from + kpathsea. Add functions to allocate and/or read arrays. + Add FT_MAKE_TAG macro as used in freetype2. Drop unused funcs(). + Require sizeof(int)==4. Fix various typos. + * configure.ac: Drop AC_C_BIGENDIAN, AC_CHECK_SIZEOF([long]), + and AC_CHECK_SIZEOF([long long]). + * Makefile.am: Adapt. + * docs/ttfdump.1: Fix typos. + 2011-05-12 Peter Breitenlohner <peb@mppmu.mpg.de> * tests/ttfdump.test: Use 'diff -b' for Dos line endings. diff --git a/Build/source/texk/ttfdump/Makefile.am b/Build/source/texk/ttfdump/Makefile.am index bcc47f9aa97..e5d7547ca8a 100644 --- a/Build/source/texk/ttfdump/Makefile.am +++ b/Build/source/texk/ttfdump/Makefile.am @@ -5,27 +5,21 @@ ## ACLOCAL_AMFLAGS = -I ../../m4 -## We want to distribute the whole subdirectories. -## -## With current automake (1.10.2) 'make distcheck' fails when -## DISTFILES contains a directory and files in that directory. -EXTRA_DIST = docs include libttf src - -# in case of an SVN repository -dist-hook: - rm -rf `find $(distdir) -name .svn` - rm -f $(distdir)/libttf/Makefile.in - rm -f $(distdir)/src/Makefile.in - INCLUDES = -I$(top_srcdir)/include -AM_CPPFLAGS = -Dlint AM_CFLAGS = $(WARNING_CFLAGS) noinst_LIBRARIES = libttf.a -# libttf/interp.c is not used (would just produce compiler warnings). -# -nodist_libttf_a_SOURCES = \ +libttf_a_SOURCES = \ + include/gcache.h \ + include/gstate.h \ + include/loadtable.h \ + include/os2_P.h \ + include/protos.h \ + include/tables.h \ + include/ttc.h \ + include/ttf.h \ + include/ttfutil.h \ libttf/cmap.c \ libttf/cvt.c \ libttf/disasm.c \ @@ -48,7 +42,6 @@ nodist_libttf_a_SOURCES = \ libttf/pclt.c \ libttf/post.c \ libttf/prep.c \ - libttf/stack.c \ libttf/tabledir.c \ libttf/ttc.c \ libttf/ttfread.c \ @@ -57,13 +50,27 @@ nodist_libttf_a_SOURCES = \ libttf/vhea.c \ libttf/vmtx.c +## Not used (interp.c would just produce compiler warnings). +## +EXTRA_DIST = \ + libttf/fixed.c \ + libttf/interp.c \ + libttf/stack.c + bin_PROGRAMS = ttfdump -nodist_ttfdump_SOURCES = src/ttfdump.c +ttfdump_SOURCES = src/ttfdump.c LDADD = libttf.a -nodist_man1_MANS = docs/ttfdump.1 +dist_man1_MANS = docs/ttfdump.1 + +## Not used +## +EXTRA_DIST += \ + docs/ttfdump.dvi \ + docs/ttfdump.html \ + docs/ttfdump.ps ## Tests. ## diff --git a/Build/source/texk/ttfdump/Makefile.in b/Build/source/texk/ttfdump/Makefile.in index 399b2830bff..28090ee782f 100644 --- a/Build/source/texk/ttfdump/Makefile.in +++ b/Build/source/texk/ttfdump/Makefile.in @@ -37,7 +37,7 @@ build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = ttfdump$(EXEEXT) subdir = . -DIST_COMMON = README $(am__configure_deps) \ +DIST_COMMON = README $(am__configure_deps) $(dist_man1_MANS) \ $(srcdir)/../../build-aux/config.guess \ $(srcdir)/../../build-aux/config.sub \ $(srcdir)/../../build-aux/depcomp \ @@ -71,20 +71,19 @@ LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru libttf_a_AR = $(AR) $(ARFLAGS) libttf_a_LIBADD = -nodist_libttf_a_OBJECTS = cmap.$(OBJEXT) cvt.$(OBJEXT) \ - disasm.$(OBJEXT) font.$(OBJEXT) fpgm.$(OBJEXT) gasp.$(OBJEXT) \ - gcache.$(OBJEXT) glyf.$(OBJEXT) gstate.$(OBJEXT) \ - hdmx.$(OBJEXT) head.$(OBJEXT) hhea.$(OBJEXT) hmtx.$(OBJEXT) \ - kern.$(OBJEXT) loca.$(OBJEXT) ltsh.$(OBJEXT) maxp.$(OBJEXT) \ - name.$(OBJEXT) os2.$(OBJEXT) pclt.$(OBJEXT) post.$(OBJEXT) \ - prep.$(OBJEXT) stack.$(OBJEXT) tabledir.$(OBJEXT) \ - ttc.$(OBJEXT) ttfread.$(OBJEXT) ttfutil.$(OBJEXT) \ - vdmx.$(OBJEXT) vhea.$(OBJEXT) vmtx.$(OBJEXT) -libttf_a_OBJECTS = $(nodist_libttf_a_OBJECTS) +am_libttf_a_OBJECTS = cmap.$(OBJEXT) cvt.$(OBJEXT) disasm.$(OBJEXT) \ + font.$(OBJEXT) fpgm.$(OBJEXT) gasp.$(OBJEXT) gcache.$(OBJEXT) \ + glyf.$(OBJEXT) gstate.$(OBJEXT) hdmx.$(OBJEXT) head.$(OBJEXT) \ + hhea.$(OBJEXT) hmtx.$(OBJEXT) kern.$(OBJEXT) loca.$(OBJEXT) \ + ltsh.$(OBJEXT) maxp.$(OBJEXT) name.$(OBJEXT) os2.$(OBJEXT) \ + pclt.$(OBJEXT) post.$(OBJEXT) prep.$(OBJEXT) \ + tabledir.$(OBJEXT) ttc.$(OBJEXT) ttfread.$(OBJEXT) \ + ttfutil.$(OBJEXT) vdmx.$(OBJEXT) vhea.$(OBJEXT) vmtx.$(OBJEXT) +libttf_a_OBJECTS = $(am_libttf_a_OBJECTS) am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" PROGRAMS = $(bin_PROGRAMS) -nodist_ttfdump_OBJECTS = ttfdump.$(OBJEXT) -ttfdump_OBJECTS = $(nodist_ttfdump_OBJECTS) +am_ttfdump_OBJECTS = ttfdump.$(OBJEXT) +ttfdump_OBJECTS = $(am_ttfdump_OBJECTS) ttfdump_LDADD = $(LDADD) ttfdump_DEPENDENCIES = libttf.a DEFAULT_INCLUDES = -I.@am__isrc@ @@ -100,8 +99,8 @@ CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ -SOURCES = $(nodist_libttf_a_SOURCES) $(nodist_ttfdump_SOURCES) -DIST_SOURCES = +SOURCES = $(libttf_a_SOURCES) $(ttfdump_SOURCES) +DIST_SOURCES = $(libttf_a_SOURCES) $(ttfdump_SOURCES) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -125,7 +124,7 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' man1dir = $(mandir)/man1 NROFF = nroff -MANS = $(nodist_man1_MANS) +MANS = $(dist_man1_MANS) ETAGS = etags CTAGS = ctags am__tty_colors = \ @@ -258,17 +257,19 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I ../../m4 -EXTRA_DIST = docs include libttf src $(TESTS) \ - tests/FonetikaDaniaIwonaeRegular.ttf tests/ttfdump.glyf \ - tests/ttfdump.head ILX NOTE README.bg5 INCLUDES = -I$(top_srcdir)/include -AM_CPPFLAGS = -Dlint AM_CFLAGS = $(WARNING_CFLAGS) noinst_LIBRARIES = libttf.a - -# libttf/interp.c is not used (would just produce compiler warnings). -# -nodist_libttf_a_SOURCES = \ +libttf_a_SOURCES = \ + include/gcache.h \ + include/gstate.h \ + include/loadtable.h \ + include/os2_P.h \ + include/protos.h \ + include/tables.h \ + include/ttc.h \ + include/ttf.h \ + include/ttfutil.h \ libttf/cmap.c \ libttf/cvt.c \ libttf/disasm.c \ @@ -291,7 +292,6 @@ nodist_libttf_a_SOURCES = \ libttf/pclt.c \ libttf/post.c \ libttf/prep.c \ - libttf/stack.c \ libttf/tabledir.c \ libttf/ttc.c \ libttf/ttfread.c \ @@ -300,9 +300,13 @@ nodist_libttf_a_SOURCES = \ libttf/vhea.c \ libttf/vmtx.c -nodist_ttfdump_SOURCES = src/ttfdump.c +EXTRA_DIST = libttf/fixed.c libttf/interp.c libttf/stack.c \ + docs/ttfdump.dvi docs/ttfdump.html docs/ttfdump.ps $(TESTS) \ + tests/FonetikaDaniaIwonaeRegular.ttf tests/ttfdump.glyf \ + tests/ttfdump.head ILX NOTE README.bg5 +ttfdump_SOURCES = src/ttfdump.c LDADD = libttf.a -nodist_man1_MANS = docs/ttfdump.1 +dist_man1_MANS = docs/ttfdump.1 TESTS = tests/ttfdump.test DISTCLEANFILES = FonetikaDaniaIwonaeRegular.ttf ttfdump.glyf \ ttfdump.head @@ -444,7 +448,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pclt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/post.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prep.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tabledir.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ttc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ttfdump.Po@am__quote@ @@ -783,20 +786,6 @@ prep.obj: libttf/prep.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o prep.obj `if test -f 'libttf/prep.c'; then $(CYGPATH_W) 'libttf/prep.c'; else $(CYGPATH_W) '$(srcdir)/libttf/prep.c'; fi` -stack.o: libttf/stack.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT stack.o -MD -MP -MF $(DEPDIR)/stack.Tpo -c -o stack.o `test -f 'libttf/stack.c' || echo '$(srcdir)/'`libttf/stack.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/stack.Tpo $(DEPDIR)/stack.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libttf/stack.c' object='stack.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o stack.o `test -f 'libttf/stack.c' || echo '$(srcdir)/'`libttf/stack.c - -stack.obj: libttf/stack.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT stack.obj -MD -MP -MF $(DEPDIR)/stack.Tpo -c -o stack.obj `if test -f 'libttf/stack.c'; then $(CYGPATH_W) 'libttf/stack.c'; else $(CYGPATH_W) '$(srcdir)/libttf/stack.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/stack.Tpo $(DEPDIR)/stack.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libttf/stack.c' object='stack.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o stack.obj `if test -f 'libttf/stack.c'; then $(CYGPATH_W) 'libttf/stack.c'; else $(CYGPATH_W) '$(srcdir)/libttf/stack.c'; fi` - tabledir.o: libttf/tabledir.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tabledir.o -MD -MP -MF $(DEPDIR)/tabledir.Tpo -c -o tabledir.o `test -f 'libttf/tabledir.c' || echo '$(srcdir)/'`libttf/tabledir.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tabledir.Tpo $(DEPDIR)/tabledir.Po @@ -917,10 +906,10 @@ clean-libtool: distclean-libtool: -rm -f libtool config.lt -install-man1: $(nodist_man1_MANS) +install-man1: $(dist_man1_MANS) @$(NORMAL_INSTALL) test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)" - @list='$(nodist_man1_MANS)'; test -n "$(man1dir)" || exit 0; \ + @list='$(dist_man1_MANS)'; test -n "$(man1dir)" || exit 0; \ { for i in $$list; do echo "$$i"; done; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ @@ -944,7 +933,7 @@ install-man1: $(nodist_man1_MANS) uninstall-man1: @$(NORMAL_UNINSTALL) - @list='$(nodist_man1_MANS)'; test -n "$(man1dir)" || exit 0; \ + @list='$(dist_man1_MANS)'; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ @@ -1141,9 +1130,6 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$(top_distdir)" distdir="$(distdir)" \ - dist-hook -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ @@ -1374,11 +1360,11 @@ uninstall-man: uninstall-man1 .PHONY: CTAGS GTAGS all all-am am--refresh check check-TESTS check-am \ clean clean-binPROGRAMS clean-generic clean-libtool \ clean-noinstLIBRARIES ctags dist dist-all dist-bzip2 dist-gzip \ - dist-hook dist-lzma dist-shar dist-tarZ dist-xz dist-zip \ - distcheck distclean distclean-compile distclean-generic \ - distclean-hdr distclean-libtool distclean-tags distcleancheck \ - distdir distuninstallcheck dvi dvi-am html html-am info \ - info-am install install-am install-binPROGRAMS install-data \ + dist-lzma dist-shar dist-tarZ dist-xz dist-zip distcheck \ + distclean distclean-compile distclean-generic distclean-hdr \ + distclean-libtool distclean-tags distcleancheck distdir \ + distuninstallcheck dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-man1 install-pdf \ @@ -1390,12 +1376,6 @@ uninstall-man: uninstall-man1 uninstall-man uninstall-man1 -# in case of an SVN repository -dist-hook: - rm -rf `find $(distdir) -name .svn` - rm -f $(distdir)/libttf/Makefile.in - rm -f $(distdir)/src/Makefile.in - # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/Build/source/texk/ttfdump/config.h.in b/Build/source/texk/ttfdump/config.h.in index b2a6e811289..95b1456bde8 100644 --- a/Build/source/texk/ttfdump/config.h.in +++ b/Build/source/texk/ttfdump/config.h.in @@ -1,8 +1,5 @@ /* config.h.in. Generated from configure.ac by autoheader. */ -/* Define if building universal (internal helper macro) */ -#undef AC_APPLE_UNIVERSAL_BUILD - /* Define to 1 if the `closedir' function returns void instead of `int'. */ #undef CLOSEDIR_VOID @@ -151,30 +148,12 @@ /* The size of `int', as computed by sizeof. */ #undef SIZEOF_INT -/* The size of `long', as computed by sizeof. */ -#undef SIZEOF_LONG - -/* The size of `long long', as computed by sizeof. */ -#undef SIZEOF_LONG_LONG - /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Version number of package */ #undef VERSION -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -# undef WORDS_BIGENDIAN -# endif -#endif - /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS diff --git a/Build/source/texk/ttfdump/configure b/Build/source/texk/ttfdump/configure index d769b6e2cc5..cfda824419b 100755 --- a/Build/source/texk/ttfdump/configure +++ b/Build/source/texk/ttfdump/configure @@ -12726,230 +12726,6 @@ WARNING_CFLAGS=$kpse_cv_warning_cflags - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 -$as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if ${ac_cv_c_bigendian+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_c_bigendian=unknown - # See if we're dealing with a universal compiler. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifndef __APPLE_CC__ - not a universal capable compiler - #endif - typedef int dummy; - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - # Check for potential -arch flags. It is not universal unless - # there are at least two -arch flags with different values. - ac_arch= - ac_prev= - for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do - if test -n "$ac_prev"; then - case $ac_word in - i?86 | x86_64 | ppc | ppc64) - if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then - ac_arch=$ac_word - else - ac_cv_c_bigendian=universal - break - fi - ;; - esac - ac_prev= - elif test "x$ac_word" = "x-arch"; then - ac_prev=arch - fi - done -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test $ac_cv_c_bigendian = unknown; then - # See if sys/param.h defines the BYTE_ORDER macro. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <sys/types.h> - #include <sys/param.h> - -int -main () -{ -#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ - && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ - && LITTLE_ENDIAN) - bogus endian macros - #endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - # It does; now see whether it defined to BIG_ENDIAN or not. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <sys/types.h> - #include <sys/param.h> - -int -main () -{ -#if BYTE_ORDER != BIG_ENDIAN - not big endian - #endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_bigendian=yes -else - ac_cv_c_bigendian=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - fi - if test $ac_cv_c_bigendian = unknown; then - # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <limits.h> - -int -main () -{ -#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) - bogus endian macros - #endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - # It does; now see whether it defined to _BIG_ENDIAN or not. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <limits.h> - -int -main () -{ -#ifndef _BIG_ENDIAN - not big endian - #endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_bigendian=yes -else - ac_cv_c_bigendian=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - fi - if test $ac_cv_c_bigendian = unknown; then - # Compile a test program. - if test "$cross_compiling" = yes; then : - # Try to guess by grepping values from an object file. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -short int ascii_mm[] = - { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; - short int ascii_ii[] = - { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; - int use_ascii (int i) { - return ascii_mm[i] + ascii_ii[i]; - } - short int ebcdic_ii[] = - { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; - short int ebcdic_mm[] = - { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; - int use_ebcdic (int i) { - return ebcdic_mm[i] + ebcdic_ii[i]; - } - extern int foo; - -int -main () -{ -return use_ascii (foo) == use_ebcdic (foo); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then - ac_cv_c_bigendian=yes - fi - if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then - if test "$ac_cv_c_bigendian" = unknown; then - ac_cv_c_bigendian=no - else - # finding both strings is unlikely to happen, but who knows? - ac_cv_c_bigendian=unknown - fi - fi -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ - - /* Are we little or big endian? From Harbison&Steele. */ - union - { - long int l; - char c[sizeof (long int)]; - } u; - u.l = 1; - return u.c[sizeof (long int) - 1] == 1; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_c_bigendian=no -else - ac_cv_c_bigendian=yes -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 -$as_echo "$ac_cv_c_bigendian" >&6; } - case $ac_cv_c_bigendian in #( - yes) - $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h -;; #( - no) - ;; #( - universal) - -$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h - - ;; #( - *) - as_fn_error $? "unknown endianness - presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; - esac - # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. @@ -12983,72 +12759,6 @@ cat >>confdefs.h <<_ACEOF _ACEOF -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 -$as_echo_n "checking size of long... " >&6; } -if ${ac_cv_sizeof_long+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_long" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (long) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_long=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5 -$as_echo "$ac_cv_sizeof_long" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_LONG $ac_cv_sizeof_long -_ACEOF - - -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5 -$as_echo_n "checking size of long long... " >&6; } -if ${ac_cv_sizeof_long_long+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_long_long" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (long long) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_long_long=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5 -$as_echo "$ac_cv_sizeof_long_long" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long -_ACEOF - - ac_config_headers="$ac_config_headers config.h" @@ -13186,7 +12896,6 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi - : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files diff --git a/Build/source/texk/ttfdump/configure.ac b/Build/source/texk/ttfdump/configure.ac index 23d60f744e5..7417407c1c8 100644 --- a/Build/source/texk/ttfdump/configure.ac +++ b/Build/source/texk/ttfdump/configure.ac @@ -16,10 +16,7 @@ dnl Common code for all programs using libkpathsea. KPSE_COMMON([ttfdump]) dnl Checks for typedefs, structures, and compiler characteristics. -AC_C_BIGENDIAN AC_CHECK_SIZEOF([int]) -AC_CHECK_SIZEOF([long]) -AC_CHECK_SIZEOF([long long]) AC_CONFIG_HEADERS([config.h]) diff --git a/Build/source/texk/ttfdump/docs/ttfdump.1 b/Build/source/texk/ttfdump/docs/ttfdump.1 index 5d19e112197..45ce77ce811 100644 --- a/Build/source/texk/ttfdump/docs/ttfdump.1 +++ b/Build/source/texk/ttfdump/docs/ttfdump.1 @@ -33,7 +33,7 @@ dump every tables in \fIttfile\fP. \fBRequired Tables\fR .TP \fIcmap\fP -character to glhph mapping table +character to glyph mapping table .TP \fIglyf\fP glyph data @@ -131,5 +131,5 @@ ttfdump -g 50 times.ttf TrueType 1.0 Font Files, \fI Technical Specification Revision 1.66 November 1995\fR .SH NOTE Instruction disassembler in not implemented. -.SH AOTHOR +.SH AUTHOR Li-Da Lho, ollie@ms1.hinet.net diff --git a/Build/source/texk/ttfdump/include/ttf.h b/Build/source/texk/ttfdump/include/ttf.h index 8658345874b..dd226235b23 100644 --- a/Build/source/texk/ttfdump/include/ttf.h +++ b/Build/source/texk/ttfdump/include/ttf.h @@ -23,16 +23,12 @@ typedef signed short SHORT; #if SIZEOF_INT==4 typedef unsigned int ULONG; typedef signed int LONG; -typedef ULONG Fixed; /* 16.16 fixed point number used for - * version information */ +#else +#error "Unsupported size of `int' type!" +#endif -#elif SIZEOF_LONG==4 -typedef unsigned long ULONG; -typedef signed long LONG; typedef ULONG Fixed; /* 16.16 fixed point number used for * version information */ -#endif - typedef USHORT FUnit; typedef SHORT FWord; /* pixel position in the unit of FUnit */ typedef USHORT uFWord; @@ -44,7 +40,7 @@ typedef LONG F26Dot6; /* 26.6 fixed point number to specify BYTE ttfGetBYTE(FILE *fp); CHAR ttfGetCHAR(FILE *fp); USHORT ttfGetUSHORT(FILE *fp); -USHORT ttfGetSHORT(FILE *fp); +SHORT ttfGetSHORT(FILE *fp); ULONG ttfGetULONG(FILE *fp); LONG ttfGetLONG(FILE *fp); Fixed ttfGetFixed(FILE *fp); @@ -53,8 +49,17 @@ FWord ttfGetFWord(FILE *fp); uFWord ttfGetuFWord(FILE *fp); F2Dot14 ttfGetF2Dot14(FILE *fp); -short ttfGetLSB16(FILE *fp); -int ttfGetLSB32(FILE *fp); +/* Read arrays. */ +void ttfReadUSHORT(USHORT *array, size_t nelem, FILE *fp); +void ttfReadULONG(ULONG *array, size_t nelem, FILE *fp); +void ttfReadFWord(FWord *array, size_t nelem, FILE *fp); + +/* Allocate and read arrays. */ +BYTE *ttfMakeBYTE(size_t nelem, FILE *fp); +USHORT *ttfMakeUSHORT(size_t nelem, FILE *fp); +SHORT *ttfMakeSHORT(size_t nelem, FILE *fp); +ULONG *ttfMakeULONG(size_t nelem, FILE *fp); +LONG *ttfMakeLONG(size_t nelem, FILE *fp); #include "tables.h" #include "gcache.h" diff --git a/Build/source/texk/ttfdump/include/ttfutil.h b/Build/source/texk/ttfdump/include/ttfutil.h index 17cd47e5575..e660bfce5fa 100644 --- a/Build/source/texk/ttfdump/include/ttfutil.h +++ b/Build/source/texk/ttfdump/include/ttfutil.h @@ -5,11 +5,26 @@ /* $Id: ttfutil.h,v 1.2 1998/07/06 06:07:01 werner Exp $ */ +#if !defined(EXIT_FAILURE) +#define EXIT_FAILURE 1 +#endif + void FixedSplit(Fixed f, int b[]); -void TwoByteSwap(unsigned char *buf, int nbytes); -void FourByteSwap(unsigned char *buf, int nbytes); -void FourByteSwap(unsigned char *buf, int nbytes); void ttfError(const char *msg); +#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) _x1 << 24 | _x2 << 16 | _x3 << 8 | _x4 +char *TagToStr(ULONG tag); + +/* Functions copied or adapted from kpathsea. */ +void xfseek (FILE *fp, long offset, int wherefrom, const char *funcname); +void *xmalloc (size_t size); +void *xcalloc (size_t nelem, size_t elsize); +char *xstrdup(const char *s); + +#define FATAL_PERROR(str) do { perror (str); exit (EXIT_FAILURE); } while (0) +#define XTALLOC(n, t) ((t *) xmalloc ((n) * sizeof (t))) +#define XCALLOC(n, t) ((t *) xcalloc (n, sizeof (t))) +#define XTALLOC1(t) XTALLOC (1, t) +#define XCALLOC1(t) XCALLOC (1, t) #include "protos.h" diff --git a/Build/source/texk/ttfdump/libttf/cmap.c b/Build/source/texk/ttfdump/libttf/cmap.c index 0fa44d50369..d876cfb8a96 100644 --- a/Build/source/texk/ttfdump/libttf/cmap.c +++ b/Build/source/texk/ttfdump/libttf/cmap.c @@ -12,7 +12,7 @@ * true data to map character code to glyph index * USHORT PlatformID shows which platform the subtable is to be used * (e.g. Mac, PC) - * USHORT Platfrom specofic EncodingID shows what kind of encoding scheme + * USHORT Platfrom specific EncodingID shows what kind of encoding scheme * this table uses (e.g. Big5, iso8859, Unicode etc.) * ULONG offset is the offset from the beginning of the whole cmap table * to the beginning of the corresponding subtable @@ -47,26 +47,20 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: cmap.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: cmap.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ +typedef union _TwoBytes { + USHORT u; + unsigned char c[2]; +} TwoBytes; -static CMAPPtr ttfAllocCMAP(TTFontPtr font); static void ttfLoadCMAP(FILE *fp,CMAPPtr cmap,ULONG offset); static void ttfLoadEncodingTable(FILE *fp,SubTablePtr subTable,ULONG offset); -static SubTablePtr ttfAllocSubTable(CMAPPtr cmap); static void ttfLoadSubTable(FILE *fp,SubTablePtr subTable,ULONG offset); static void ttfPrintSubTable(FILE* fp,SubTablePtr ptable); static void ttfFreeSubTable(SubTablePtr ptable); -static CMAP0 * ttfAllocCMAP0(SubTablePtr subTable); static void ttfLoadCMAP0(FILE *fp,SubTablePtr subTable,ULONG offset); static void ttfPrintCMAP0(FILE *fp,SubTablePtr subTable); static USHORT ttfLookUpCMAP0(SubTablePtr subTable,USHORT cc); @@ -89,37 +83,27 @@ static void ttfFreeCMAP6(SubTablePtr subTable); void ttfInitCMAP(TTFontPtr font) { - ULONG tag = 'c' | 'm' << 8 | 'a' << 16 | 'p' << 24; + ULONG tag = FT_MAKE_TAG ('c', 'm', 'a', 'p'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->cmap = ttfAllocCMAP(font); + font->cmap = XCALLOC1 (CMAP); ttfLoadCMAP(font->fp,font->cmap,ptd->offset); } } -static CMAPPtr ttfAllocCMAP(TTFontPtr font) -{ - CMAPPtr cmap; - if ((cmap = (CMAPPtr) calloc(1,sizeof(CMAP))) == NULL) - { - ttfError("Out Of Memory in __FILE_ : __LINE__ \n"); - return NULL; - } - return cmap; -} + static void ttfLoadCMAP(FILE *fp,CMAPPtr cmap,ULONG offset) { USHORT i,n; ULONG posEnc; /* beginning of the Encoding Table */ ULONG baseSub = offset; /* base of SubTable offset */ - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLOADCMAP \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadCMAP"); cmap->version = ttfGetUSHORT(fp); cmap->numberOfEncodings = n = ttfGetUSHORT(fp); - cmap->subTables = ttfAllocSubTable(cmap); + cmap->subTables = XCALLOC (cmap->numberOfEncodings, SubTable); posEnc = baseSub + sizeof(USHORT)*2; /* step over the beginning of encoding * table */ @@ -198,24 +182,13 @@ void ttfFreeCMAP(CMAPPtr cmap) /* actually, EncodingTable is a part of SubTable */ static void ttfLoadEncodingTable(FILE *fp,SubTablePtr subTable,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadEncodingTable \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadEncodingTable"); subTable->PlatformID = ttfGetUSHORT(fp); subTable->EncodingID = ttfGetUSHORT(fp); subTable->offset = ttfGetULONG(fp); } -static SubTablePtr ttfAllocSubTable(CMAPPtr cmap) -{ - SubTablePtr subTable; - - if ((subTable = (SubTablePtr) calloc(cmap->numberOfEncodings,sizeof(SubTable))) == NULL) - { - ttfError("Out Of Memory in __FILE__ : __LINE__ \n"); - return NULL; - } - return subTable; -} + /* should this one be static ? */ static void ttfLoadSubTable(FILE *fp,SubTablePtr subTable,ULONG base) { @@ -226,8 +199,7 @@ static void ttfLoadSubTable(FILE *fp,SubTablePtr subTable,ULONG base) * base: beginning of cmap * offset: offset field of each encoding table */ pos = base + subTable->offset; - if (fseek(fp,pos,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadSubTable\n"); + xfseek(fp, pos, SEEK_SET, "ttfLoadSubTable"); subTable->format = format = ttfGetUSHORT(fp); subTable->length = ttfGetUSHORT(fp); @@ -309,32 +281,20 @@ static void ttfFreeSubTable(SubTablePtr ptable) } } -static CMAP0 * ttfAllocCMAP0(SubTablePtr subTable) -{ - CMAP0 * cmap0; - - if ((cmap0 = (CMAP0 *) calloc(1,sizeof(CMAP0))) == NULL) - { - ttfError("Out Of Memory in __FILE__ : __LINE__ \n"); - return NULL; - } - return cmap0; -} static void ttfLoadCMAP0(FILE *fp,SubTablePtr subTable,ULONG offset) { BYTE * array; - subTable->map.cmap0 = ttfAllocCMAP0(subTable); + subTable->map.cmap0 = XCALLOC1 (CMAP0); array = subTable->map.cmap0->glyphIndexArray; - if (fseek(fp,offset,SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadCMAP0 \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadCMAP0"); /* Attention: we get lots of bytes at once as a work around of the * usual ttfGet*, this cause byte sex trouble as will be seen * in the fellowing procedures */ if (fread(array,sizeof(BYTE),256,fp) != 256) - ttfError("Error when getting glyphIndexArray \n"); + ttfError("Error when getting glyphIndexArray\n"); } static void ttfPrintCMAP0(FILE *fp,SubTablePtr subTable) { @@ -344,7 +304,7 @@ static void ttfPrintCMAP0(FILE *fp,SubTablePtr subTable) for (i=0;i<256;i++) { index = ttfLookUpCMAP(subTable,i); - fprintf(fp,"\t\t Char %3d -> Index %4d \n",i,index); + fprintf(fp,"\t\t Char %3d -> Index %4d\n",i,index); } } static USHORT ttfLookUpCMAP0(SubTablePtr subTable,USHORT cc) @@ -362,17 +322,12 @@ static void ttfLoadCMAP2(FILE *fp,SubTablePtr subTable,ULONG offset) USHORT numGlyphId; SubHeaderPtr header; - if (fseek(fp,offset,SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadCMAP2 \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadCMAP2"); - subTable->map.cmap2 = (CMAP2 *) calloc(1,sizeof(CMAP2)); + subTable->map.cmap2 = XCALLOC1 (CMAP2); array = subTable->map.cmap2->subHeaderKeys; - if (fread(array,sizeof(USHORT),256,fp) != 256) - ttfError("Error when getting subHeaderKeys \n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) array,256*sizeof(USHORT)); -#endif + ttfReadUSHORT (array, 256, fp); for (i=0;i<256;i++) { @@ -382,8 +337,7 @@ static void ttfLoadCMAP2(FILE *fp,SubTablePtr subTable,ULONG offset) } n += 1; /* the number of subHeaders is one plus the max of subHeaderKeys */ - subTable->map.cmap2->subHeaders = header = - (SubHeaderPtr) calloc(n,sizeof(SubHeader)); + subTable->map.cmap2->subHeaders = header = XCALLOC (n, SubHeader); for (i=0;i<n;i++) { (header+i)->firstCode = ttfGetUSHORT(fp); @@ -403,8 +357,7 @@ static void ttfLoadCMAP2(FILE *fp,SubTablePtr subTable,ULONG offset) numGlyphId = subTable->length - (256 + 3) * sizeof(USHORT) - n * sizeof(SubHeader); numGlyphId /= sizeof(USHORT); - subTable->map.cmap2->glyphIndexArray = - (USHORT *) calloc(numGlyphId,sizeof(USHORT)); + subTable->map.cmap2->glyphIndexArray = XCALLOC (numGlyphId, USHORT); for (i=0;i<numGlyphId;i++) { subTable->map.cmap2->glyphIndexArray[i] = ttfGetUSHORT(fp); @@ -415,7 +368,7 @@ static void ttfPrintCMAP2(FILE *fp,SubTablePtr subTable) USHORT i,j,numGlyphId; USHORT *array,n=0,index; SubHeaderPtr header; - unsigned short cc; + TwoBytes tb; array = subTable->map.cmap2->subHeaderKeys; header = subTable->map.cmap2->subHeaders; @@ -454,27 +407,21 @@ static void ttfPrintCMAP2(FILE *fp,SubTablePtr subTable) i = 0; fprintf(fp,"\t\t First Byte:\t %2x\n",i); + tb.c[1] = i; for(j=0;j<=255;j++) { -#ifndef WORDS_BIGENDIAN - cc = i + (j << 8); -#else - cc = j + (i << 8); -#endif - index = ttfLookUpCMAP2(subTable,cc); + tb.c[0] = j; + index = ttfLookUpCMAP2(subTable,tb.u); fprintf(fp,"\t\t Char %2x -> Index %d\n",j,index); } for (i=128;i<=255;i++) { fprintf(fp,"\t\t First Byte:\t %2x\n",i); + tb.c[1] = i; for(j=0;j<=255;j++) { -#ifndef WORDS_BIGENDIAN - cc = i + (j << 8); -#else - cc = j + (i << 8); -#endif - index = ttfLookUpCMAP2(subTable,cc); + tb.c[0] = j; + index = ttfLookUpCMAP2(subTable,tb.u); fprintf(fp,"\t\t Char %2x -> Index %d\n",j,index); } } @@ -486,25 +433,22 @@ static USHORT ttfLookUpCMAP2(SubTablePtr subTable,USHORT cc) SubHeaderPtr headers = subTable->map.cmap2->subHeaders; SHORT idDelta; USHORT firstCode, entryCount, idRangeOffset; + TwoBytes tb; unsigned char first,second; /* On little endian platforms "low byte" is the "first byte". - * It determines that if it is necessary to use the second byte to - * fully interprete the character code, for expamle, if the first byte - * is obivously an ASCII character then it is not necessary to + * It determines if it is necessary to use the second byte to + * fully interprete the character code; for example, if the first byte + * is obviously an ASCII character then it is not necessary to * interpret the second byte, on the other hand, if the first byte is * zero then the second byte is a ASCII char, when the first byte * is not an ASCII char nor zero, those two bytes together determine * the meanning of the character code */ -#ifndef WORDS_BIGENDIAN - first = cc & 0x00ff; - second = cc >> 8; -#else - first = cc >> 8; - second = cc & 0x00ff; -#endif + tb.u = cc; + first = tb.c[1]; + second = tb.c[0]; /* select which subHeader to use */ idx = array[first]; @@ -542,12 +486,11 @@ static void ttfFreeCMAP2(SubTablePtr subTable) static void ttfLoadCMAP4(FILE *fp,SubTablePtr subTable,ULONG offset) { USHORT segCount; - USHORT * array,len; + USHORT len; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadCMAP4 \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadCMAP4"); - subTable->map.cmap4 = (CMAP4 *) calloc(1,sizeof(CMAP4)); + subTable->map.cmap4 = XCALLOC1 (CMAP4); subTable->map.cmap4->segCountX2 = segCount = ttfGetUSHORT(fp); subTable->map.cmap4->searchRange = ttfGetUSHORT(fp); @@ -555,51 +498,21 @@ static void ttfLoadCMAP4(FILE *fp,SubTablePtr subTable,ULONG offset) subTable->map.cmap4->rangeShift = ttfGetUSHORT(fp); segCount /= 2; - subTable->map.cmap4->endCount = array = - (USHORT *) calloc(segCount,sizeof(USHORT)); - if (fread(array,sizeof(USHORT),segCount,fp) != segCount) - ttfError("Error when getting endCount\n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) array,segCount*sizeof(USHORT)); -#endif + subTable->map.cmap4->endCount = ttfMakeUSHORT (segCount, fp); subTable->map.cmap4->reservedPad = ttfGetUSHORT(fp); - subTable->map.cmap4->startCount = array = - (USHORT *) calloc(segCount,sizeof(USHORT)); - if (fread(array,sizeof(USHORT),segCount,fp) != segCount) - ttfError("Error when getting startCount\n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) array,segCount*sizeof(USHORT)); -#endif - - subTable->map.cmap4->idDelta = array = - (USHORT *) calloc(segCount,sizeof(USHORT)); - if (fread(array,sizeof(USHORT),segCount,fp) != segCount) - ttfError("Error when getting idDelta\n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) array,segCount*sizeof(USHORT)); -#endif - - subTable->map.cmap4->idRangeOffset = array = - (USHORT *) calloc(segCount,sizeof(USHORT)); - if (fread(array,sizeof(USHORT),segCount,fp) != segCount) - ttfError("Error when getting idRangeOffset\n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) array,segCount*sizeof(USHORT)); -#endif + subTable->map.cmap4->startCount = ttfMakeUSHORT (segCount, fp); + + subTable->map.cmap4->idDelta = ttfMakeUSHORT (segCount, fp); + + subTable->map.cmap4->idRangeOffset = ttfMakeUSHORT (segCount, fp); /* caculate the length of glyphIndexArray, this is ugly, there should be * a better way to get this information. */ len = subTable->length - 8*sizeof(USHORT) - 4*segCount*sizeof(USHORT); len /= sizeof(USHORT); - subTable->map.cmap4->glyphIndexArray = array = - (USHORT *) calloc(len,sizeof(USHORT)); - if (fread(array,sizeof(USHORT),len,fp) != len) - ttfError("Error when getting idRangeOffset\n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) array,len*sizeof(USHORT)); -#endif + subTable->map.cmap4->glyphIndexArray = ttfMakeUSHORT (len, fp); } static void ttfPrintCMAP4(FILE *fp,SubTablePtr subTable) { @@ -700,22 +613,14 @@ static void ttfFreeCMAP4(SubTablePtr subTable) static void ttfLoadCMAP6(FILE *fp,SubTablePtr subTable,ULONG offset) { - USHORT * array,len; + USHORT len; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadCMAP6 \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadCMAP6"); - subTable->map.cmap6 = (CMAP6 *) calloc(1,sizeof(CMAP6)); + subTable->map.cmap6 = XCALLOC1 (CMAP6); subTable->map.cmap6->firstCode = ttfGetUSHORT(fp); subTable->map.cmap6->entryCount = len = ttfGetUSHORT(fp); - subTable->map.cmap6->glyphIndexArray = array = - (USHORT *) calloc(subTable->map.cmap6->entryCount,sizeof(USHORT)); - - if (fread(array,sizeof(USHORT),len,fp) != len) - ttfError("Error when getting idRangeOffset\n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) array,len*sizeof(USHORT)); -#endif + subTable->map.cmap6->glyphIndexArray = ttfMakeUSHORT (len, fp); } static void ttfPrintCMAP6(FILE *fp, SubTablePtr subTable) { diff --git a/Build/source/texk/ttfdump/libttf/cvt.c b/Build/source/texk/ttfdump/libttf/cvt.c index 0e9c2f14782..2621a938e62 100644 --- a/Build/source/texk/ttfdump/libttf/cvt.c +++ b/Build/source/texk/ttfdump/libttf/cvt.c @@ -7,42 +7,28 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: cvt.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: cvt.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ static void ttfLoadCVT(FILE *fp,FWord *cvt,USHORT lenght,ULONG offset); void ttfInitCVT(TTFontPtr font) { - ULONG tag = 'c' | 'v' << 8 | 't' << 16 | ' ' << 24; + ULONG tag = FT_MAKE_TAG ('c', 'v', 't', ' '); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { font->cvtLength = ptd->length / sizeof(FWord); - font->cvt = (FWord *) calloc(font->cvtLength, sizeof(FWord)); - if (font->cvt != NULL) - ttfLoadCVT(font->fp,font->cvt,font->cvtLength,ptd->offset); + font->cvt = XCALLOC (font->cvtLength, FWord); + ttfLoadCVT(font->fp,font->cvt,font->cvtLength,ptd->offset); } } static void ttfLoadCVT(FILE *fp,FWord *cvt,USHORT length,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadCVT \n"); - - if (fread(cvt, sizeof(FWord), length, fp) != length) - ttfError("Error when getting CVT\n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadCVT"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) cvt,length*sizeof(FWord)); -#endif + ttfReadFWord (cvt, length, fp); } void ttfPrintCVT(FILE *fp, FWord *cvt, USHORT cvtLength) diff --git a/Build/source/texk/ttfdump/libttf/disasm.c b/Build/source/texk/ttfdump/libttf/disasm.c index fc263ddcda9..e716ea72a04 100644 --- a/Build/source/texk/ttfdump/libttf/disasm.c +++ b/Build/source/texk/ttfdump/libttf/disasm.c @@ -4,16 +4,8 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: disasm.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: disasm.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - void ttfPrintInstructions(FILE *fp, BYTE * ins) { /* not implemented yet */ diff --git a/Build/source/texk/ttfdump/libttf/fixed.c b/Build/source/texk/ttfdump/libttf/fixed.c index 3b5276ff209..3ff834b300a 100644 --- a/Build/source/texk/ttfdump/libttf/fixed.c +++ b/Build/source/texk/ttfdump/libttf/fixed.c @@ -5,12 +5,4 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: fixed.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ - -#ifndef lint -static char vcid[] = "$Id: fixed.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ diff --git a/Build/source/texk/ttfdump/libttf/font.c b/Build/source/texk/ttfdump/libttf/font.c index c8b3784a6eb..0ee6c25ec02 100644 --- a/Build/source/texk/ttfdump/libttf/font.c +++ b/Build/source/texk/ttfdump/libttf/font.c @@ -9,23 +9,15 @@ #include "ttfutil.h" #include "protos.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: font.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: font.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - static void ttfInitInterpreter(TTFontPtr font); TTFontPtr ttfInitFont(char *filename) { TTFontPtr font; - font = (TTFontPtr) calloc(1,sizeof(TTFont)); + font = XCALLOC1 (TTFont); font->ttfname = filename; if ((font->fp = fopen (filename,"r")) == NULL) @@ -40,8 +32,7 @@ TTFontPtr ttfInitFont(char *filename) } void ttfLoadFont(TTFontPtr font, ULONG offset) { - if (fseek(font->fp,offset,SEEK_SET) != 0) - ttfError("Fseek Failed\n"); + xfseek(font->fp, offset, SEEK_SET, "ttfLoadFont"); /* offset table */ font->version = ttfGetFixed(font->fp); @@ -55,7 +46,7 @@ void ttfLoadFont(TTFontPtr font, ULONG offset) ttfInitInterpreter(font); /* initialize the reference count to 1 */ - font->refcount = (int *) calloc(1, sizeof(int)); + font->refcount = XCALLOC1 (int); *(font->refcount) = 1; } void ttfFreeFont(TTFontPtr font) @@ -147,7 +138,7 @@ TTFontPtr ttfCloneFont(TTFontPtr font) { TTFontPtr newfont; - newfont = (TTFontPtr) calloc(1,sizeof(TTFont)); + newfont = XTALLOC1 (TTFont); memcpy(newfont, font, sizeof(TTFont)); newfont->refcount += 1; diff --git a/Build/source/texk/ttfdump/libttf/fpgm.c b/Build/source/texk/ttfdump/libttf/fpgm.c index ad6ed3ee68d..0eb35ea1c8f 100644 --- a/Build/source/texk/ttfdump/libttf/fpgm.c +++ b/Build/source/texk/ttfdump/libttf/fpgm.c @@ -7,35 +7,26 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: fpgm.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: fpgm.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ static void ttfLoadFPGM(FILE *fp,BYTE *fpgm,USHORT lenght,ULONG offset); void ttfInitFPGM(TTFontPtr font) { - ULONG tag = 'f' | 'p' << 8 | 'g' << 16 | 'm' << 24; + ULONG tag = FT_MAKE_TAG ('f', 'p', 'g', 'm'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { font->fpgmLength = ptd->length; - font->fpgm = (BYTE *) calloc(font->fpgmLength, sizeof(BYTE)); - if (font->fpgm != NULL) - ttfLoadFPGM(font->fp,font->fpgm,font->fpgmLength,ptd->offset); + font->fpgm = XCALLOC (font->fpgmLength, BYTE); + ttfLoadFPGM(font->fp,font->fpgm,font->fpgmLength,ptd->offset); } } static void ttfLoadFPGM(FILE *fp,BYTE *fpgm,USHORT length,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadCVT \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadFPGM"); if (fread(fpgm, sizeof(BYTE), length, fp) != length) ttfError("Error when getting CVT\n"); diff --git a/Build/source/texk/ttfdump/libttf/gasp.c b/Build/source/texk/ttfdump/libttf/gasp.c index 4ab1aaaf11e..34bf5111237 100644 --- a/Build/source/texk/ttfdump/libttf/gasp.c +++ b/Build/source/texk/ttfdump/libttf/gasp.c @@ -7,61 +7,38 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: gasp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: gasp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static GASPPtr ttfAllocGASP(TTFontPtr font); static void ttfLoadGASP(FILE *fp,GASPPtr gasp,ULONG offset); void ttfInitGASP(TTFontPtr font) { - ULONG tag = 'g' | 'a' << 8 | 's' << 16 | 'p' << 24; + ULONG tag = FT_MAKE_TAG ('g', 'a', 's', 'p'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->gasp = ttfAllocGASP(font); + font->gasp = XCALLOC1 (GASP); ttfLoadGASP(font->fp,font->gasp,ptd->offset); } } -static GASPPtr ttfAllocGASP(TTFontPtr font) -{ - GASPPtr gasp; - - if ((gasp = (GASPPtr) calloc(1,sizeof(GASP))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return gasp; -} + static void ttfLoadGASP (FILE *fp,GASPPtr gasp,ULONG offset) { int i; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadGASP \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadGASP"); gasp->version = ttfGetUSHORT(fp); gasp->numRanges = ttfGetUSHORT(fp); - gasp->gaspRange = (GASPRANGE *) calloc(gasp->numRanges, sizeof(GASPRANGE)); + gasp->gaspRange = XCALLOC (gasp->numRanges, GASPRANGE); - if (gasp->gaspRange == NULL) - ttfError("Out of Memory in __FILE__:__LINE__\n"); - else - for (i=0;i<gasp->numRanges;i++) - { - gasp->gaspRange[i].rangeMaxPPEM = ttfGetUSHORT(fp); - gasp->gaspRange[i].rangeGaspBehavior = ttfGetUSHORT(fp); - } + for (i=0;i<gasp->numRanges;i++) + { + gasp->gaspRange[i].rangeMaxPPEM = ttfGetUSHORT(fp); + gasp->gaspRange[i].rangeGaspBehavior = ttfGetUSHORT(fp); + } } void ttfPrintGASP(FILE *fp,GASPPtr gasp) diff --git a/Build/source/texk/ttfdump/libttf/gcache.c b/Build/source/texk/ttfdump/libttf/gcache.c index 7ecdb0a8ed7..5666d040a42 100644 --- a/Build/source/texk/ttfdump/libttf/gcache.c +++ b/Build/source/texk/ttfdump/libttf/gcache.c @@ -7,7 +7,7 @@ * Basically the cache can be divided onto two parts, the first one is a * linear part which is a least recently utilitied list (LRU), * the second part is the nonlinear one which is a binary serach tree. - * Normally each cache element is one the LRU as well as on the BST. + * Normally each cache element is on the LRU as well as on the BST. * Those glyph elements are allocated at once as an array of glyph cache * elements at the init phase of glyph cache. * @@ -83,17 +83,8 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: gcache.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: gcache.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static GlyphCachePtr ttfAllocCache(TTFontPtr font); static void ttfInitCache(TTFontPtr font); static void ttfFreeCache(TTFontPtr font); static void ttfRotateCache(TTFontPtr font); @@ -116,12 +107,13 @@ void ttfInitGlyphCache(TTFontPtr font) else font->numCacheElements = 64; - font->gcache = ttfAllocCache(font); + font->gcache = XCALLOC (font->numCacheElements+1, GlyphCache); ttfInitCache(font); ttfAllocCacheData(font); ttfInitCacheData(font); } + void ttfCleanUpGlyphCache(TTFontPtr font) { ttfFreeCacheData(font); @@ -157,19 +149,6 @@ GLYFPtr ttfLoadGlyphCached(TTFontPtr font,ULONG offset) #endif } -/* alloc GlyphCache headers */ -static GlyphCachePtr ttfAllocCache(TTFontPtr font) -{ - USHORT numCache = font->numCacheElements+1; - GlyphCachePtr gcache; - - if ((gcache = (GlyphCachePtr) calloc(numCache,sizeof(GlyphCache))) == NULL) - { - ttfError("Out of Memory"); - return NULL; - } - return gcache; -} /* threading glyph cache headers */ static void ttfInitCache(TTFontPtr font) { @@ -222,16 +201,11 @@ static void ttfAllocCacheData(TTFontPtr font) USHORT maxContours = font->maxp->maxContours; USHORT insLength = font->maxp->maxSizeOfInstructions; - font->gcache->glyf.endPtsOfContours = (USHORT *) calloc(numCache*maxContours, - sizeof(USHORT)); - font->gcache->glyf.instructions = (BYTE *) calloc(numCache*insLength, - sizeof(BYTE)); - font->gcache->glyf.flags = (BYTE *) calloc(numCache*maxPoints, - sizeof(BYTE)); - font->gcache->glyf.xCoordinates = (SHORT *) calloc(numCache*maxPoints, - sizeof(SHORT)); - font->gcache->glyf.yCoordinates = (SHORT *) calloc(numCache*maxPoints, - sizeof(SHORT)); + font->gcache->glyf.endPtsOfContours = XCALLOC (numCache*maxContours, USHORT); + font->gcache->glyf.instructions = XCALLOC (numCache*insLength, BYTE); + font->gcache->glyf.flags = XCALLOC (numCache*maxPoints, BYTE); + font->gcache->glyf.xCoordinates = XCALLOC (numCache*maxPoints, SHORT); + font->gcache->glyf.yCoordinates = XCALLOC (numCache*maxPoints, SHORT); font->gcache->glyf.comp = NULL; } static void ttfInitCacheData(TTFontPtr font) diff --git a/Build/source/texk/ttfdump/libttf/glyf.c b/Build/source/texk/ttfdump/libttf/glyf.c index e19eb7fb170..9804d1bb126 100644 --- a/Build/source/texk/ttfdump/libttf/glyf.c +++ b/Build/source/texk/ttfdump/libttf/glyf.c @@ -8,16 +8,8 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: glyf.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: glyf.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - static void ttfLoadSimpleGlyph(FILE *fp,GLYFPtr glyf,ULONG offset); static void ttfPrintSimpleGlyph(FILE *fp,GLYFPtr glyf); static void ttfLoadCompositeGlyph(FILE *fp,GLYFPtr glyf,ULONG offset); @@ -33,7 +25,7 @@ double fix2dbl(F2Dot14 fixed); */ void ttfInitGLYF(TTFontPtr font) { - ULONG tag = 'g' | 'l' << 8 | 'y' << 16 | 'f' << 24; + ULONG tag = FT_MAKE_TAG ('g', 'l', 'y', 'f'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag, font)) != NULL) @@ -45,8 +37,7 @@ void ttfInitGLYF(TTFontPtr font) * callers should compute this themself form the loca tables */ void ttfLoadGLYF(FILE *fp, GLYFPtr glyf, ULONG offset) { - if (fseek(fp, offset, SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadGLYF\n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadGLYF"); glyf->numberOfContours = ttfGetSHORT(fp); glyf->xMin = ttfGetFWord(fp); @@ -85,18 +76,13 @@ static void ttfLoadSimpleGlyph(FILE *fp, GLYFPtr glyf, ULONG offset) SHORT nCnts = glyf->numberOfContours; USHORT i,nIns,nPts; - if (fseek(fp, offset, SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadSimpleGlyph\n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadSimpleGlyph"); - if (fread(glyf->endPtsOfContours, sizeof(USHORT), nCnts, fp) != nCnts) - ttfError("Error when getting endPtsOfContours\n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) glyf->endPtsOfContours, - nCnts*sizeof(USHORT)); -#endif - if (nCnts != 0) - nPts = (glyf->endPtsOfContours)[nCnts-1]+1; + { + ttfReadUSHORT (glyf->endPtsOfContours, nCnts, fp); + nPts = (glyf->endPtsOfContours)[nCnts-1]+1; + } else /* there seems to be something wrong with my interpretation of * NOGLYPH chars, doing this way in case there is a char that has @@ -214,7 +200,7 @@ static void ttfPrintSimpleGlyph(FILE *fp, GLYFPtr glyf) else strcat(buf," "); if (flag & FLAGS_ON_CURVE) - strcat(buf,"On \n"); + strcat(buf,"On\n"); else strcat(buf,"Off\n"); @@ -238,11 +224,9 @@ static void ttfLoadCompositeGlyph(FILE *fp, GLYFPtr glyf, ULONG offset) USHORT nIns,flags; Component *cur; - if (fseek(fp, offset, SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadCompositeGlyph\n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadCompositeGlyph"); - if((glyf->comp = cur = (Component *) calloc(1, sizeof(Component))) == NULL) - ttfError("Out Of Memory\n"); + glyf->comp = cur = XCALLOC1 (Component); cur->previous = NULL; /* beginning of a linked list */ do { @@ -273,9 +257,7 @@ static void ttfLoadCompositeGlyph(FILE *fp, GLYFPtr glyf, ULONG offset) (cur->data).transform.tensor.yscale = ttfGetF2Dot14(fp); } /* allocate next component */ - if ((cur->next = (Component *) calloc(1, sizeof(Component))) == NULL) - ttfError("Out Of Memory\n"); - + cur->next = XCALLOC1 (Component); cur->next->previous = cur; cur = cur->next; /* move to next component */ } while (flags & MORE_COMPONENT); diff --git a/Build/source/texk/ttfdump/libttf/gstate.c b/Build/source/texk/ttfdump/libttf/gstate.c index ba94ca69c79..d436bae3569 100644 --- a/Build/source/texk/ttfdump/libttf/gstate.c +++ b/Build/source/texk/ttfdump/libttf/gstate.c @@ -6,38 +6,30 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: gstate.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: gstate.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - GraphicsState gsdefault; void ttfInitGraphicsState(TTFontPtr font) { - /*font->gstate = GS_DEFAULT; - font->gstate_init = GS_DEFAULT;*/ +#if 0 + font->gstate = GS_DEFAULT; + font->gstate_init = GS_DEFAULT; +#endif - /*ttfExecuteInstruction(font, font->fpgm); - ttfExecuteInstruction(font, font->prep);*/ +#if 0 + ttfExecuteInstruction(font, font->fpgm); + ttfExecuteInstruction(font, font->prep); +#endif } void ttfInitStack(TTFontPtr font) { font->vm.sp = 0; - font->vm.Stack = (LONG *) calloc (font->maxp->maxStackElements, sizeof(LONG)); - if (font->vm.Stack == NULL) - ttfError("Out of memory\n"); + font->vm.Stack = XCALLOC (font->maxp->maxStackElements, LONG); } void ttfInitStorageArea(TTFontPtr font) { - font->vm.StorageArea = (LONG *) calloc (font->maxp->maxStorage, sizeof(LONG)); - if (font->vm.StorageArea == NULL) - ttfError("Out of memory\n"); + font->vm.StorageArea = XCALLOC (font->maxp->maxStorage, LONG); } diff --git a/Build/source/texk/ttfdump/libttf/hdmx.c b/Build/source/texk/ttfdump/libttf/hdmx.c index a1bd36d6ae7..f4d7b0ef3a2 100644 --- a/Build/source/texk/ttfdump/libttf/hdmx.c +++ b/Build/source/texk/ttfdump/libttf/hdmx.c @@ -7,68 +7,42 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: hdmx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: hdmx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static HDMXPtr ttfAllocHDMX(TTFontPtr font); static void ttfLoadHDMX(FILE *fp,HDMXPtr hdmx,ULONG offset); void ttfInitHDMX(TTFontPtr font) { - ULONG tag = 'h' | 'd' << 8 | 'm' << 16 | 'x' << 24; + ULONG tag = FT_MAKE_TAG ('h', 'd', 'm', 'x'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->hdmx = ttfAllocHDMX(font); + font->hdmx = XCALLOC1 (HDMX); font->hdmx->numGlyphs = font->maxp->numGlyphs; ttfLoadHDMX(font->fp,font->hdmx,ptd->offset); } } -static HDMXPtr ttfAllocHDMX(TTFontPtr font) -{ - HDMXPtr hdmx; - - if ((hdmx = (HDMXPtr) calloc(1,sizeof(HDMX))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return hdmx; -} + static void ttfLoadHDMX (FILE *fp,HDMXPtr hdmx,ULONG offset) { int i; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadHDMX \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadHDMX"); hdmx->version = ttfGetUSHORT(fp); hdmx->numDevices = ttfGetUSHORT(fp); hdmx->size = ttfGetLONG(fp); - hdmx->Records = (DeviceRecord *) calloc(hdmx->numDevices, - sizeof(DeviceRecord)); + hdmx->Records = XCALLOC (hdmx->numDevices, DeviceRecord); - if (hdmx->Records == NULL) - ttfError("Out of Memory in __FILE__:__LINE__\n"); - else - for (i=0;i<hdmx->numDevices;i++) - { - hdmx->Records[i].PixelSize = ttfGetBYTE(fp); - hdmx->Records[i].MaxWidth = ttfGetBYTE(fp); - hdmx->Records[i].Width = (BYTE *) calloc(hdmx->size, - sizeof(BYTE)); - fread ((hdmx->Records+i)->Width, sizeof(BYTE), - hdmx->numGlyphs+1,fp); - } + for (i=0;i<hdmx->numDevices;i++) + { + hdmx->Records[i].PixelSize = ttfGetBYTE(fp); + hdmx->Records[i].MaxWidth = ttfGetBYTE(fp); + hdmx->Records[i].Width = XCALLOC (hdmx->size, BYTE); + fread ((hdmx->Records+i)->Width, sizeof(BYTE), hdmx->numGlyphs+1,fp); + } } void ttfPrintHDMX(FILE *fp,HDMXPtr hdmx) diff --git a/Build/source/texk/ttfdump/libttf/head.c b/Build/source/texk/ttfdump/libttf/head.c index 93365d8f485..ec4b33bcbaa 100644 --- a/Build/source/texk/ttfdump/libttf/head.c +++ b/Build/source/texk/ttfdump/libttf/head.c @@ -7,45 +7,25 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: head.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: head.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static HEADPtr ttfAllocHEAD(TTFontPtr font); static void ttfLoadHEAD(FILE *fp,HEADPtr head,ULONG offset); void ttfInitHEAD(TTFontPtr font) { - ULONG tag = 'h' | 'e' << 8 | 'a' << 16 | 'd' << 24; + ULONG tag = FT_MAKE_TAG ('h', 'e', 'a', 'd'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->head = ttfAllocHEAD(font); + font->head = XCALLOC1 (HEAD); ttfLoadHEAD(font->fp,font->head,ptd->offset); } } -static HEADPtr ttfAllocHEAD(TTFontPtr font) -{ - HEADPtr head; - if ((head = (HEADPtr) calloc(1,sizeof(HEAD))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return head; -} static void ttfLoadHEAD(FILE *fp,HEADPtr head,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadHEAD \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadHEAD"); head->version = ttfGetFixed(fp); head->fontRevision = ttfGetFixed(fp); @@ -54,8 +34,10 @@ static void ttfLoadHEAD(FILE *fp,HEADPtr head,ULONG offset) head->flags = ttfGetUSHORT(fp); head->unitsPerEm = ttfGetUSHORT(fp); - fread(head->created,sizeof(char),8,fp); - fread(head->modified,sizeof(char),8,fp); + if (fread(head->created,sizeof(char),8,fp) != 8) + ttfError("Error when getting HEAD created\n"); + if (fread(head->modified,sizeof(char),8,fp) != 8) + ttfError("Error when getting HEAD modified\n"); head->xMin = ttfGetFWord(fp); head->yMin = ttfGetFWord(fp); diff --git a/Build/source/texk/ttfdump/libttf/hhea.c b/Build/source/texk/ttfdump/libttf/hhea.c index 086f3b7c300..9b056dde6ab 100644 --- a/Build/source/texk/ttfdump/libttf/hhea.c +++ b/Build/source/texk/ttfdump/libttf/hhea.c @@ -7,47 +7,27 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: hhea.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: hhea.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static HHEAPtr ttfAllocHHEA(TTFontPtr font); static void ttfLoadHHEA(FILE *fp,HHEAPtr hhea,ULONG offset); void ttfInitHHEA(TTFontPtr font) { - ULONG tag = 'h' | 'h' << 8 | 'e' << 16 | 'a' << 24; + ULONG tag = FT_MAKE_TAG ('h', 'h', 'e', 'a'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->hhea = ttfAllocHHEA(font); + font->hhea = XCALLOC1 (HHEA); ttfLoadHHEA(font->fp,font->hhea,ptd->offset); } } -static HHEAPtr ttfAllocHHEA(TTFontPtr font) -{ - HHEAPtr hhea; - - if ((hhea = (HHEAPtr) calloc(1,sizeof(HHEA))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return hhea; -} + static void ttfLoadHHEA (FILE *fp,HHEAPtr hhea,ULONG offset) { int i; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLOADCMAP \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadHHEA"); hhea->version = ttfGetFixed(fp); hhea->Ascender = ttfGetFWord(fp); diff --git a/Build/source/texk/ttfdump/libttf/hmtx.c b/Build/source/texk/ttfdump/libttf/hmtx.c index 4d71edfe956..1dc40d06d8d 100644 --- a/Build/source/texk/ttfdump/libttf/hmtx.c +++ b/Build/source/texk/ttfdump/libttf/hmtx.c @@ -7,17 +7,8 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: hmtx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: hmtx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static HMTXPtr ttfAllocHMTX(TTFontPtr font); static void ttfLoadHMTX(FILE *fp,HMTXPtr hmtx,ULONG offset); /* Caution: Because of interdependency between tables, @@ -26,52 +17,36 @@ static void ttfLoadHMTX(FILE *fp,HMTXPtr hmtx,ULONG offset); */ void ttfInitHMTX(TTFontPtr font) { - ULONG tag = 'h' | 'm' << 8 | 't' << 16 | 'x' << 24; + ULONG tag = FT_MAKE_TAG ('h', 'm', 't', 'x'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->hmtx = ttfAllocHMTX(font); + font->hmtx = XCALLOC1 (HMTX); font->hmtx->numberOfHMetrics = font->hhea->numberOfHMetrics; font->hmtx->numberOfLSB = font->maxp->numGlyphs - font->hhea->numberOfHMetrics; ttfLoadHMTX(font->fp,font->hmtx,ptd->offset); } } -static HMTXPtr ttfAllocHMTX(TTFontPtr font) -{ - HMTXPtr hmtx; - if ((hmtx = (HMTXPtr) calloc(1,sizeof(HMTX))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return hmtx; -} static void ttfLoadHMTX(FILE *fp,HMTXPtr hmtx,ULONG offset) { USHORT i,n = hmtx->numberOfHMetrics,m=hmtx->numberOfLSB; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLOADHMTX \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadHMTX"); - if ((hmtx->hMetrics = (longHorMetric *) calloc(n,sizeof(longHorMetric))) != NULL) - { - for (i=0;i<n;i++) - { - (hmtx->hMetrics+i)->advanceWidth = ttfGetuFWord(fp); - (hmtx->hMetrics+i)->lsb = ttfGetFWord(fp); - } - } - else + hmtx->hMetrics = XCALLOC (n, longHorMetric); + for (i=0;i<n;i++) { - ttfError("Out Of Memory in __FILE__ : __LINE__\n"); + (hmtx->hMetrics+i)->advanceWidth = ttfGetuFWord(fp); + (hmtx->hMetrics+i)->lsb = ttfGetFWord(fp); } /* codes dealing with leftSideBearing entry */ - if (m && ((hmtx->leftSideBearing = (FWord *) calloc(m,sizeof(FWord))) != NULL)) + if (m) { + hmtx->leftSideBearing = XCALLOC (m, FWord); for (i=0;i<m;i++) { (hmtx->leftSideBearing)[i] = ttfGetFWord(fp); diff --git a/Build/source/texk/ttfdump/libttf/interp.c b/Build/source/texk/ttfdump/libttf/interp.c index 6adfbee38bc..030c4bbadde 100644 --- a/Build/source/texk/ttfdump/libttf/interp.c +++ b/Build/source/texk/ttfdump/libttf/interp.c @@ -5,19 +5,11 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: interp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: interp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - /* A bit about error checking: The execution of a TrueType instruction is - * "atomic" which mean that we don't process the error until a single - * instruction is fully decoded and exectued */ + * "atomic" which means that we don't process the error until a single + * instruction is fully decoded and executed */ /* Pushing data onto the interpreter stack */ diff --git a/Build/source/texk/ttfdump/libttf/kern.c b/Build/source/texk/ttfdump/libttf/kern.c index 79e8cb6ebd3..54104a0aba4 100644 --- a/Build/source/texk/ttfdump/libttf/kern.c +++ b/Build/source/texk/ttfdump/libttf/kern.c @@ -7,53 +7,32 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: kern.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: kern.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static KERNPtr ttfAllocKERN(TTFontPtr font); static void ttfLoadKERN(FILE *fp,KERNPtr kern,ULONG offset); void ttfInitKERN(TTFontPtr font) { - ULONG tag = 'k' | 'e' << 8 | 'r' << 16 | 'n' << 24; + ULONG tag = FT_MAKE_TAG ('k', 'e', 'r', 'n'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->kern = ttfAllocKERN(font); + font->kern = XCALLOC1 (KERN); ttfLoadKERN(font->fp,font->kern,ptd->offset); } } -static KERNPtr ttfAllocKERN(TTFontPtr font) -{ - KERNPtr kern; - - if ((kern = (KERNPtr) calloc(1,sizeof(KERN))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return kern; -} + static void ttfLoadKERN (FILE *fp,KERNPtr kern,ULONG offset) { int i; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadKERN \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadKERN"); kern->version = ttfGetUSHORT(fp); kern->nTables = ttfGetUSHORT(fp); - kern->subtable = (KernSubtable *) calloc(kern->nTables, - sizeof(KernSubtable)); + kern->subtable = XCALLOC (kern->nTables, KernSubtable); for (i=0;i<kern->nTables;i++) { @@ -75,7 +54,7 @@ static void ttfLoadKERN (FILE *fp,KERNPtr kern,ULONG offset) (kern->subtable+i)->kern.kern0.rangeShift = ttfGetUSHORT(fp); (kern->subtable+i)->kern.kern0.pairs = pairs = - (struct kernpair *) calloc(n,sizeof (struct kernpair)); + XCALLOC (n, struct kernpair); for (j=0;j<n;j++) { @@ -114,7 +93,7 @@ void ttfPrintKERN(FILE *fp,KERNPtr kern) (kern->subtable+i)->version); fprintf(fp,"\t Bytes in subtable \t %d\n", (kern->subtable+i)->length); - fprintf(fp,"\t Coverage bits \t 0x%x \n", + fprintf(fp,"\t Coverage bits \t 0x%x\n", (kern->subtable+i)->coverage); switch ((kern->subtable+i)->coverage >> 8) { diff --git a/Build/source/texk/ttfdump/libttf/loca.c b/Build/source/texk/ttfdump/libttf/loca.c index 3d09b8959a8..44ec5e05fcc 100644 --- a/Build/source/texk/ttfdump/libttf/loca.c +++ b/Build/source/texk/ttfdump/libttf/loca.c @@ -4,22 +4,14 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: loca.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: loca.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - static LOCAPtr ttfAllocLOCA(TTFontPtr font); static void ttfLoadLOCA(FILE *fp,LOCAPtr loca,ULONG offset); void ttfInitLOCA(TTFontPtr font) { - ULONG tag = 'l' | 'o' << 8 | 'c' << 16 | 'a' <<24; + ULONG tag = FT_MAKE_TAG ('l', 'o', 'c', 'a'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) @@ -33,33 +25,21 @@ static LOCAPtr ttfAllocLOCA(TTFontPtr font) USHORT n=0; LOCAPtr loca; - if ((loca = (LOCAPtr) calloc(1,sizeof(LOCA))) == NULL) - { - ttfError("Out of Memory\n"); - } - else - { - loca->indexToLocFormat = font->head->indexToLocFormat; - loca->numGlyphs = n = font->maxp->numGlyphs; - } + loca = XCALLOC1 (LOCA); + loca->indexToLocFormat = font->head->indexToLocFormat; + loca->numGlyphs = n = font->maxp->numGlyphs; n += 1;/* the number of loca entry is numberOfGlyph+1 */ - if ((loca->offset = (ULONG *) calloc(n,sizeof(ULONG))) == NULL) - { - ttfError("Out Of Memory\n"); - free (loca); - return NULL; - } + loca->offset = XCALLOC (n, ULONG); return loca; } static void ttfLoadLOCA(FILE *fp,LOCAPtr loca,ULONG offset) { - /* warrning: the number of loca entry is numberOfGlyph+1 !! */ + /* warning: the number of loca entry is numberOfGlyph+1 !! */ USHORT i,n = loca->numGlyphs+1; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLOADLOCA \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadLOCA"); switch (loca->indexToLocFormat) { @@ -70,11 +50,7 @@ static void ttfLoadLOCA(FILE *fp,LOCAPtr loca,ULONG offset) } break; case LOCA_OFFSET_LONG: - if (fread(loca->offset,sizeof(ULONG),n,fp) != n) - ttfError("Error reading loca data\n"); -#ifndef WORDS_BIGENDIAN - FourByteSwap((unsigned char *) loca->offset,n*sizeof(ULONG)); -#endif + ttfReadULONG (loca->offset, n, fp); break; } } diff --git a/Build/source/texk/ttfdump/libttf/ltsh.c b/Build/source/texk/ttfdump/libttf/ltsh.c index 7f50b22f73b..a433c32a06a 100644 --- a/Build/source/texk/ttfdump/libttf/ltsh.c +++ b/Build/source/texk/ttfdump/libttf/ltsh.c @@ -7,53 +7,30 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: ltsh.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: ltsh.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static LTSHPtr ttfAllocLTSH(TTFontPtr font); static void ttfLoadLTSH(FILE *fp,LTSHPtr ltsh,ULONG offset); void ttfInitLTSH(TTFontPtr font) { - ULONG tag = 'L' | 'T' << 8 | 'S' << 16 | 'H' << 24; + ULONG tag = FT_MAKE_TAG ('L', 'T', 'S', 'H'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->ltsh = ttfAllocLTSH(font); + font->ltsh = XCALLOC1 (LTSH); ttfLoadLTSH(font->fp,font->ltsh,ptd->offset); } } -static LTSHPtr ttfAllocLTSH(TTFontPtr font) -{ - LTSHPtr ltsh; - - if ((ltsh = (LTSHPtr) calloc(1,sizeof(LTSH))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return ltsh; -} + static void ttfLoadLTSH (FILE *fp,LTSHPtr ltsh,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadLTSH \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadLTSH"); ltsh->version = ttfGetUSHORT(fp); ltsh->numGlyphs = ttfGetUSHORT(fp); - ltsh->yPels = (BYTE *) calloc(ltsh->numGlyphs, sizeof(BYTE)); - - if(fread(ltsh->yPels, sizeof(BYTE), ltsh->numGlyphs, fp) != ltsh->numGlyphs) - ttfError("Error when getting yPels\n"); + ltsh->yPels = ttfMakeBYTE (ltsh->numGlyphs, fp); } void ttfPrintLTSH(FILE *fp,LTSHPtr ltsh) diff --git a/Build/source/texk/ttfdump/libttf/maxp.c b/Build/source/texk/ttfdump/libttf/maxp.c index 8a8a81eb74a..cefa38a4c0d 100644 --- a/Build/source/texk/ttfdump/libttf/maxp.c +++ b/Build/source/texk/ttfdump/libttf/maxp.c @@ -4,45 +4,25 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: maxp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: maxp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static MAXPPtr ttfAllocMAXP(TTFontPtr font); static void ttfLoadMAXP(FILE *fp,MAXPPtr maxp,ULONG offset); void ttfInitMAXP(TTFontPtr font) { - ULONG tag = 'm' | 'a' << 8 | 'x' << 16 | 'p' << 24; + ULONG tag = FT_MAKE_TAG ('m', 'a', 'x', 'p'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->maxp = ttfAllocMAXP(font); + font->maxp = XCALLOC1 (MAXP); ttfLoadMAXP(font->fp,font->maxp,ptd->offset); } } -static MAXPPtr ttfAllocMAXP(TTFontPtr font) -{ - MAXPPtr maxp; - if ((maxp = (MAXPPtr) calloc(1,sizeof(MAXP))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return maxp; -} static void ttfLoadMAXP(FILE *fp,MAXPPtr maxp,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLOADCMAP \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadMAXP"); maxp->version = ttfGetFixed(fp); maxp->numGlyphs = ttfGetUSHORT(fp); diff --git a/Build/source/texk/ttfdump/libttf/name.c b/Build/source/texk/ttfdump/libttf/name.c index 968af094c7e..2ccc971c688 100644 --- a/Build/source/texk/ttfdump/libttf/name.c +++ b/Build/source/texk/ttfdump/libttf/name.c @@ -6,17 +6,8 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: name.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: name.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static NAMEPtr ttfAllocNAME(TTFontPtr font); static void ttfLoadNAME(FILE *fp,NAMEPtr name,ULONG offset); static void ttfLoadNameRecord(FILE *fp,NameRecordPtr rec,ULONG offset); static void ttfPrintNameRecord(FILE *fp,NameRecordPtr rec); @@ -27,40 +18,28 @@ static void HexDump(char *p,char *hex,char *asc,int len); void ttfInitNAME(TTFontPtr font) { - ULONG tag = 'n' | 'a' << 8 | 'm' << 16 | 'e' <<24; + ULONG tag = FT_MAKE_TAG ('n', 'a', 'm', 'e'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->name = ttfAllocNAME(font); + font->name = XCALLOC1 (NAME); ttfLoadNAME(font->fp,font->name,ptd->offset); } } -static NAMEPtr ttfAllocNAME(TTFontPtr font) -{ - NAMEPtr name; - if((name = (NAMEPtr) calloc(1,sizeof(NAME))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return name; -} static void ttfLoadNAME(FILE *fp,NAMEPtr name,ULONG offset) { USHORT i,n; ULONG pos; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLOADNAME \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadNAME"); name->format = ttfGetUSHORT(fp); name->numberOfRecords = n = ttfGetUSHORT(fp); name->offset = ttfGetUSHORT(fp); - if ((name->NameRecords = (NameRecordPtr) calloc(n,sizeof(NameRecord))) == NULL) - ttfError("Out Of Memory\n"); + name->NameRecords = XCALLOC (n, NameRecord); pos = offset + sizeof(USHORT)*3; @@ -98,8 +77,7 @@ void ttfFreeNAME(NAMEPtr name) /* offset: address of the beginning of the name record */ static void ttfLoadNameRecord(FILE *fp,NameRecordPtr rec,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadNameRecord \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadNameRecord"); rec->PlatformID = ttfGetUSHORT(fp); rec->EncodingID = ttfGetUSHORT(fp); @@ -126,11 +104,9 @@ static void ttfLoadNameRecordData(FILE *fp,NameRecordPtr rec,ULONG offset) ULONG pos; pos = offset + rec->offset; - if (fseek(fp,pos,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLoadSubTable\n"); + xfseek(fp, pos, SEEK_SET, "ttfLoadNameRecordData"); - if ((rec->data = (char *) calloc(rec->length,sizeof(char))) == NULL) - ttfError("Out Of Memory\n"); + rec->data = XTALLOC (rec->length, char); if (fread(rec->data,sizeof(char),rec->length,fp) != rec->length) ttfError("Error when getting Name Record Data\n"); } diff --git a/Build/source/texk/ttfdump/libttf/os2.c b/Build/source/texk/ttfdump/libttf/os2.c index b6d21072e5f..b140c356d6b 100644 --- a/Build/source/texk/ttfdump/libttf/os2.c +++ b/Build/source/texk/ttfdump/libttf/os2.c @@ -8,47 +8,25 @@ #define __TTF_OS2 #include "os2_P.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: os2.c,v 1.2 1998/07/06 06:07:01 werner Exp $ */ -#ifndef lint -static char vcid[] = "$Id: os2.c,v 1.2 1998/07/06 06:07:01 werner Exp $"; -#endif /* lint */ - -static OS_2Ptr ttfAllocOS2(TTFontPtr font); static void ttfLoadOS2(FILE *fp, OS_2Ptr os2, ULONG offset); void ttfInitOS2(TTFontPtr font) { - ULONG tag = 'O' | 'S' << 8 | '/' << 16 | '2' << 24; + ULONG tag = FT_MAKE_TAG ('O', 'S', '/', '2'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag, font)) != NULL) { - font->os2 = ttfAllocOS2(font); + font->os2 = XCALLOC1 (OS_2); ttfLoadOS2(font->fp, font->os2, ptd->offset); } } -static OS_2Ptr ttfAllocOS2(TTFontPtr font) -{ - OS_2Ptr os2; - - if ((os2 = (OS_2Ptr) calloc(1, sizeof(OS_2))) == NULL) - { - ttfError("Out of Memofy in __FILE__:__LINE__\n"); - return NULL; - } - return os2; -} - static void ttfLoadOS2(FILE *fp, OS_2Ptr os2, ULONG offset) { - if (fseek(fp, offset, SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadGLYF\n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadOS2"); os2->version = ttfGetUSHORT(fp); os2->xAvgCharWidth = ttfGetSHORT(fp); diff --git a/Build/source/texk/ttfdump/libttf/pclt.c b/Build/source/texk/ttfdump/libttf/pclt.c index e62574a7f04..b2108d43a45 100644 --- a/Build/source/texk/ttfdump/libttf/pclt.c +++ b/Build/source/texk/ttfdump/libttf/pclt.c @@ -7,47 +7,27 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: pclt.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: pclt.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static PCLTPtr ttfAllocPCLT(TTFontPtr font); static void ttfLoadPCLT(FILE *fp,PCLTPtr pclt,ULONG offset); void ttfInitPCLT(TTFontPtr font) { - ULONG tag = 'P' | 'C' << 8 | 'L' << 16 | 'T' << 24; + ULONG tag = FT_MAKE_TAG ('P', 'C', 'L', 'T'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->pclt = ttfAllocPCLT(font); + font->pclt = XCALLOC1 (PCLT); ttfLoadPCLT(font->fp,font->pclt,ptd->offset); } } -static PCLTPtr ttfAllocPCLT(TTFontPtr font) -{ - PCLTPtr pclt; - if ((pclt = (PCLTPtr) calloc(1,sizeof(PCLT))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return pclt; -} static void ttfLoadPCLT(FILE *fp,PCLTPtr pclt,ULONG offset) { int i; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLOADCMAP \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadPCLT"); pclt->version = ttfGetFixed(fp); pclt->FontNumber = ttfGetULONG(fp); @@ -78,7 +58,7 @@ void ttfPrintPCLT(FILE *fp,PCLTPtr pclt) fprintf(fp,"`PCLT' Table - Printer Command Language Table\n"); fprintf(fp,"---------------------------------------------\n"); fprintf(fp,"\t version \t %d.%d\n",b[1],b[0]); - fprintf(fp,"\t fontNumber \t %d (0x%x) \n",pclt->FontNumber, + fprintf(fp,"\t fontNumber \t %d (0x%x)\n",pclt->FontNumber, pclt->FontNumber ); fprintf(fp,"\t pitch \t %d\n",pclt->Pitch); fprintf(fp,"\t xHeight \t %d\n",pclt->xHeight); diff --git a/Build/source/texk/ttfdump/libttf/post.c b/Build/source/texk/ttfdump/libttf/post.c index 6757ddd5979..e1a54f5ed31 100644 --- a/Build/source/texk/ttfdump/libttf/post.c +++ b/Build/source/texk/ttfdump/libttf/post.c @@ -4,46 +4,26 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: post.c,v 1.3 1998/06/06 12:55:53 werner Exp $ */ -#ifndef lint -static char vcid[] = "$Id: post.c,v 1.3 1998/06/06 12:55:53 werner Exp $"; -#endif /* lint */ - -static POSTPtr ttfAllocPOST(TTFontPtr font); static void ttfLoadPOST(FILE *fp, POSTPtr post, ULONG offset); void ttfInitPOST(TTFontPtr font) { - ULONG tag = 'p' | 'o' << 8 | 's' << 16 | 't' << 24; + ULONG tag = FT_MAKE_TAG ('p', 'o', 's', 't'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag, font)) != NULL) { - font->post = ttfAllocPOST(font); + font->post = XCALLOC1 (POST); ttfLoadPOST(font->fp, font->post, ptd->offset); } } -static POSTPtr ttfAllocPOST(TTFontPtr font) -{ - POSTPtr post; - if ((post = (POSTPtr) calloc(1, sizeof(POST))) == NULL) - { - ttfError("Out of Memofy in __FILE__:__LINE__\n"); - return NULL; - } - return post; -} static void ttfLoadPOST(FILE *fp, POSTPtr post, ULONG offset) { USHORT i,numGlyphs; - if (fseek(fp, offset, SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadPOST\n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadPOST"); post->format = ttfGetFixed(fp); post->italicAngle = ttfGetFixed(fp); @@ -58,19 +38,11 @@ static void ttfLoadPOST(FILE *fp, POSTPtr post, ULONG offset) switch (post->format) { case 0x00020000: - post->name.format20 = (Format20 *) calloc(1, sizeof(Format20)); + post->name.format20 = XCALLOC1 (Format20); post->name.format20->numGlyphs = numGlyphs = ttfGetUSHORT(fp); - post->name.format20->glyphNameIndex = - (USHORT *) calloc(numGlyphs, sizeof(USHORT)); - post->name.format20->GlyphName = - (CHAR **) calloc(numGlyphs, sizeof(CHAR *)); - fread(post->name.format20->glyphNameIndex, sizeof(USHORT), - numGlyphs, fp); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) post->name.format20->glyphNameIndex, - numGlyphs*sizeof(USHORT)); -#endif + post->name.format20->glyphNameIndex = ttfMakeUSHORT (numGlyphs, fp); + post->name.format20->GlyphName = XCALLOC (numGlyphs, CHAR *); for (i=0;i<numGlyphs;i++) { unsigned char len; @@ -86,8 +58,7 @@ static void ttfLoadPOST(FILE *fp, POSTPtr post, ULONG offset) * but the string is not ended with a null * character */ len = (unsigned char) ttfGetCHAR(fp); - post->name.format20->GlyphName[i] = - (CHAR *) calloc(len+1, sizeof(CHAR)); + post->name.format20->GlyphName[i] = XTALLOC (len+1, CHAR); if (len) fread(post->name.format20->GlyphName[i], sizeof(CHAR), len, fp); diff --git a/Build/source/texk/ttfdump/libttf/prep.c b/Build/source/texk/ttfdump/libttf/prep.c index 55d674b7521..03a123ea044 100644 --- a/Build/source/texk/ttfdump/libttf/prep.c +++ b/Build/source/texk/ttfdump/libttf/prep.c @@ -7,35 +7,26 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: prep.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: prep.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ static void ttfLoadPREP(FILE *fp,BYTE *prep,USHORT lenght,ULONG offset); void ttfInitPREP(TTFontPtr font) { - ULONG tag = 'p' | 'r' << 8 | 'e' << 16 | 'p' << 24; + ULONG tag = FT_MAKE_TAG ('p', 'r', 'e', 'p'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { font->prepLength = ptd->length; - font->prep = (BYTE *) calloc(font->prepLength, sizeof(BYTE)); - if (font->prep != NULL) - ttfLoadPREP(font->fp,font->prep,font->prepLength,ptd->offset); + font->prep = XCALLOC (font->prepLength, BYTE); + ttfLoadPREP(font->fp,font->prep,font->prepLength,ptd->offset); } } static void ttfLoadPREP(FILE *fp,BYTE *prep,USHORT length,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadPREP \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadPREP"); if (fread(prep, sizeof(BYTE), length, fp) != length) ttfError("Error when getting PREP\n"); diff --git a/Build/source/texk/ttfdump/libttf/stack.c b/Build/source/texk/ttfdump/libttf/stack.c index 5ca56deb90a..e560fc854e7 100644 --- a/Build/source/texk/ttfdump/libttf/stack.c +++ b/Build/source/texk/ttfdump/libttf/stack.c @@ -5,16 +5,8 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: stack.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: stack.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - #define stack (vm->Stack) #define sp (vm->sp) #define limit (vm->stklimit) diff --git a/Build/source/texk/ttfdump/libttf/tabledir.c b/Build/source/texk/ttfdump/libttf/tabledir.c index e950a8a7aab..390d43aa414 100644 --- a/Build/source/texk/ttfdump/libttf/tabledir.c +++ b/Build/source/texk/ttfdump/libttf/tabledir.c @@ -9,17 +9,8 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: tabledir.c,v 1.2 1998/07/04 13:17:51 werner Exp $ */ -#ifndef lint -static char vcid[] = "$Id: tabledir.c,v 1.2 1998/07/04 13:17:51 werner Exp $"; -#endif /* lint */ - -static TableDirPtr ttfAllocTableDir(TTFontPtr font); static void ttfLoadTableDir(FILE *fp,TableDirPtr p,ULONG offset); #define Offset 12 /* start point of table dir */ @@ -28,7 +19,7 @@ void ttfInitTableDir(TTFontPtr font, ULONG offset) { int i,pos; /* table directory starts form position 12 */ - font->dir = ttfAllocTableDir(font); + font->dir = XCALLOC (font->numTables, TableDir); pos = Offset + offset; for (i=0;i<font->numTables;i++) { @@ -37,24 +28,11 @@ void ttfInitTableDir(TTFontPtr font, ULONG offset) } } -static TableDirPtr ttfAllocTableDir(TTFontPtr font) -{ - TableDirPtr ptable; - - if ((ptable = (TableDirPtr) calloc(font->numTables,sizeof(TableDir))) == NULL) - { - ttfError("Out Of memory\n in __FILE__:__LINE__"); - return NULL; - } - return ptable; -} - static void ttfLoadTableDir(FILE *fp,TableDirPtr p,ULONG offset) { - if (fseek(fp,offset,SEEK_SET) != 0) - ttfError("Fseek Failed\n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadTableDir"); - p -> tag = (ULONG) ttfGetLSB32(fp); + p -> tag = ttfGetULONG(fp); p -> checksum = ttfGetULONG(fp); p -> offset = ttfGetULONG(fp); p -> length = ttfGetULONG(fp); @@ -62,17 +40,8 @@ static void ttfLoadTableDir(FILE *fp,TableDirPtr p,ULONG offset) void ttfPrintTableDir(FILE *fp,TableDirPtr p) { - char tagname[5]; - - /* make ULONG tag names more like a string */ - memcpy(tagname,&(p->tag),4); - tagname[4] = '\0'; -#ifdef WORDS_BIGENDIAN - FourByteSwap((unsigned char *)tagname,4); -#endif - - fprintf(fp,"'%s' - checksum = 0x%08x, offset = 0x%08x, len = %9u \n", - tagname,p->checksum,p->offset,p->length); + fprintf(fp,"'%s' - checksum = 0x%08x, offset = 0x%08x, len = %9u\n", + TagToStr(p->tag),p->checksum,p->offset,p->length); } void ttfFreeTableDir(TableDirPtr p) @@ -112,7 +81,7 @@ ULONG ttfCalcTableCheckSum(ULONG tagname,TTFontPtr font) Length = ((ptable->length+3) & ~3) / sizeof(ULONG); ptable = ttfLookUpTableDir(tagname, font); - fseek(font->fp,ptable->offset,SEEK_SET); + xfseek(font->fp, ptable->offset, SEEK_SET, "ttfCalcTableCheckSum"); while (Length--) { diff --git a/Build/source/texk/ttfdump/libttf/ttc.c b/Build/source/texk/ttfdump/libttf/ttc.c index 853fcc103b5..72741083869 100644 --- a/Build/source/texk/ttfdump/libttf/ttc.c +++ b/Build/source/texk/ttfdump/libttf/ttc.c @@ -10,19 +10,11 @@ #include "ttfutil.h" #include "ttc.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: ttc.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: ttc.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - TTCHeaderPtr ttfLoadTTCHeader(char * filename) { - ULONG tag = 't' | 't' << 8 | 'c' << 16 | 'f' << 24; + ULONG tag = FT_MAKE_TAG ('t', 't', 'c', 'f'); TTCHeaderPtr ttc; FILE *fp; @@ -31,24 +23,14 @@ TTCHeaderPtr ttfLoadTTCHeader(char * filename) fprintf(stderr,"Can't open ttc file %s\n",filename); return NULL; } - ttc = (TTCHeaderPtr) calloc(1, sizeof(TTCHeader)); + ttc = XCALLOC1 (TTCHeader); /* True Type Collection's TTCHeader */ - if ((ttc->TTCTag = (ULONG) ttfGetLSB32(fp)) == tag) + if ((ttc->TTCTag = ttfGetULONG(fp)) == tag) { ttc->version = ttfGetFixed(fp); ttc->DirCount = (USHORT) ttfGetULONG(fp); - ttc->offset = (ULONG *) calloc(ttc->DirCount, - sizeof(ULONG)); - if (fread(ttc->offset, sizeof(ULONG), - ttc->DirCount,fp) != ttc->DirCount) - { - ttfError("Error when reading Table Direcotry Offset/n"); - } -#ifndef WORDS_BIGENDIAN - FourByteSwap((unsigned char *) ttc->offset, - ttc->DirCount*sizeof(ULONG)); -#endif + ttc->offset = ttfMakeULONG (ttc->DirCount, fp); ttfLoadTTCFont(ttc,fp); return ttc; } @@ -61,13 +43,8 @@ void ttfLoadTTCFont(TTCHeaderPtr ttc,FILE *fp) { int i; - ttc->font = (TTFontPtr) calloc(ttc->DirCount, sizeof(TTFont)); + ttc->font = XCALLOC (ttc->DirCount, TTFont); - if (ttc->font == NULL) - { - ttfError("Out of Memory"); - return; - } /* currently, we are loading all fonts in a TTC file. * I still can't find a good way to share the data. */ for (i=0;i<ttc->DirCount;i++) diff --git a/Build/source/texk/ttfdump/libttf/ttfread.c b/Build/source/texk/ttfdump/libttf/ttfread.c index aabad984041..a707113fffc 100644 --- a/Build/source/texk/ttfdump/libttf/ttfread.c +++ b/Build/source/texk/ttfdump/libttf/ttfread.c @@ -15,39 +15,18 @@ typedef long blkcnt_t; /* number of blocks in the file */ /* $Id: ttfread.c,v 1.2 1998/07/04 13:17:51 werner Exp $ */ -#ifndef lint -static char vcid[] = "$Id: ttfread.c,v 1.2 1998/07/04 13:17:51 werner Exp $"; -#endif /* lint */ - BYTE ttfGetBYTE(FILE *fp) { int cc; if ((cc = fgetc(fp)) == EOF) { - /*if (feof(fp) != 0) - ttfError("Unexpected EOF \n"); + if (feof(fp) != 0) + ttfError("Unexpected EOF\n"); else - ttfError("Error Getting BYTE\n");*/ + ttfError("Error Getting BYTE\n"); } return (BYTE) cc; } -short ttfGetLSB16(FILE *fp) -{ - int cc; - cc = ttfGetBYTE(fp); - cc |= ttfGetBYTE(fp) <<8; - return cc; -} - -int ttfGetLSB32(FILE *fp) -{ - int cc; - cc = ttfGetBYTE(fp); - cc |= ttfGetBYTE(fp) << 8; - cc |= ttfGetBYTE(fp) << 16; - cc |= ttfGetBYTE(fp) << 24; - return cc; -} CHAR ttfGetCHAR(FILE *fp) { @@ -55,7 +34,7 @@ CHAR ttfGetCHAR(FILE *fp) if ((cc = fgetc(fp)) == EOF) { if (feof(fp) != 0) - ttfError("Unexpected EOF \n"); + ttfError("Unexpected EOF\n"); else ttfError("Error Getting CHAR\n"); } @@ -71,7 +50,7 @@ USHORT ttfGetUSHORT(FILE *fp) return (USHORT) cc; } -USHORT ttfGetSHORT(FILE *fp) +SHORT ttfGetSHORT(FILE *fp) { int cc; cc = ttfGetBYTE(fp) << 8; @@ -127,3 +106,71 @@ F2Dot14 ttfGetF2Dot14(FILE *fp) return (F2Dot14) ttfGetUSHORT(fp); } +/* Read arrays. */ +void ttfReadUSHORT(USHORT *array, size_t nelem, FILE *fp) +{ + int i; + for (i = 0; i < nelem; i++) + array[i] = ttfGetUSHORT (fp); +} + +void ttfReadULONG(ULONG *array, size_t nelem, FILE *fp) +{ + int i; + for (i = 0; i < nelem; i++) + array[i] = ttfGetULONG (fp); +} + +void ttfReadFWord(FWord *array, size_t nelem, FILE *fp) +{ + int i; + for (i = 0; i < nelem; i++) + array[i] = ttfGetFWord (fp); +} + +/* Allocate and read arrays. */ +BYTE *ttfMakeBYTE(size_t nelem, FILE *fp) +{ + int i; + BYTE *array = XTALLOC (nelem, BYTE); + for (i = 0; i < nelem; i++) + array[i] = ttfGetBYTE (fp); + return array; +} + +USHORT *ttfMakeUSHORT(size_t nelem, FILE *fp) +{ + int i; + USHORT *array = XTALLOC (nelem, USHORT); + for (i = 0; i < nelem; i++) + array[i] = ttfGetUSHORT (fp); + return array; +} + +SHORT *ttfMakeSHORT(size_t nelem, FILE *fp) +{ + int i; + SHORT *array = XTALLOC (nelem, SHORT); + for (i = 0; i < nelem; i++) + array[i] = ttfGetSHORT (fp); + return array; +} + +ULONG *ttfMakeULONG(size_t nelem, FILE *fp) +{ + int i; + ULONG *array = XTALLOC (nelem, ULONG); + for (i = 0; i < nelem; i++) + array[i] = ttfGetULONG (fp); + return array; +} + +LONG *ttfMakeLONG(size_t nelem, FILE *fp) +{ + int i; + LONG *array = XTALLOC (nelem, LONG); + for (i = 0; i < nelem; i++) + array[i] = ttfGetLONG (fp); + return array; +} + diff --git a/Build/source/texk/ttfdump/libttf/ttfutil.c b/Build/source/texk/ttfdump/libttf/ttfutil.c index 1c3402b5521..96a1bd3eb53 100644 --- a/Build/source/texk/ttfdump/libttf/ttfutil.c +++ b/Build/source/texk/ttfdump/libttf/ttfutil.c @@ -1,13 +1,11 @@ #include <stdio.h> +#include <stdlib.h> +#include <string.h> #include "ttf.h" #include "ttfutil.h" /* $Id: ttfutil.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: ttfutil.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - /* FixedSplit: split Fixed in to two interger (16.16) */ void FixedSplit(Fixed f,int b[]) { @@ -15,43 +13,65 @@ void FixedSplit(Fixed f,int b[]) b[1] = f >> 16; } -/* - * Invert byte order within each 16-bits of an array. - */ -void -TwoByteSwap(unsigned char *buf, int nbytes) +char * +TagToStr(ULONG tag) { - register unsigned char c; - - for (; nbytes > 0; nbytes -= 2, buf += 2) - { - c = buf[0]; - buf[0] = buf[1]; - buf[1] = c; - } + static char str[5] = "XXXX"; + + str[0] = (tag >> 24) & 0xff; + str[1] = (tag >> 16) & 0xff; + str[2] = (tag >> 8) & 0xff; + str[3] = tag & 0xff; + return str; } -/* - * Invert byte order within each 32-bits of an array. - */ +void ttfError(const char * msg) +{ + fprintf(stderr,"%s",msg); + exit(EXIT_FAILURE); +} +/* Functions copied or adapted from kpathsea. */ void -FourByteSwap(unsigned char *buf, int nbytes) +xfseek (FILE *f, long offset, int wherefrom, const char *funcname) { - register unsigned char c; - - for (; nbytes > 0; nbytes -= 4, buf += 4) - { - c = buf[0]; - buf[0] = buf[3]; - buf[3] = c; - c = buf[1]; - buf[1] = buf[2]; - buf[2] = c; - } + if (fseek (f, offset, wherefrom) < 0) { + FATAL_PERROR(funcname); + } } -void ttfError(const char * msg) +void * +xmalloc (size_t size) { - fprintf(stderr,"%s",msg); + void *new_mem = (void *)malloc(size ? size : 1); + + if (new_mem == NULL) { + fprintf(stderr, "fatal: memory exhausted (xmalloc of %lu bytes).\n", + (unsigned long)size); + exit(EXIT_FAILURE); + } + + return new_mem; +} + +void * +xcalloc (size_t nelem, size_t elsize) +{ + void *new_mem = (void*)calloc(nelem ? nelem : 1, elsize ? elsize : 1); + + if (new_mem == NULL) { + fprintf(stderr, + "xcalloc: request for %lu elements of size %lu failed.\n", + (unsigned long)nelem, (unsigned long)elsize); + exit(EXIT_FAILURE); + } + + return new_mem; +} + +char * +xstrdup (const char *s) +{ + char *new_string = xmalloc(strlen (s) + 1); + return strcpy(new_string, s); } diff --git a/Build/source/texk/ttfdump/libttf/vdmx.c b/Build/source/texk/ttfdump/libttf/vdmx.c index ad5629acfe7..2cfc0ef34e7 100644 --- a/Build/source/texk/ttfdump/libttf/vdmx.c +++ b/Build/source/texk/ttfdump/libttf/vdmx.c @@ -7,55 +7,33 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: vdmx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: vdmx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static VDMXPtr ttfAllocVDMX(TTFontPtr font); static void ttfLoadVDMX(FILE *fp,VDMXPtr vdmx,ULONG offset); void ttfInitVDMX(TTFontPtr font) { - ULONG tag = 'V' | 'D' << 8 | 'M' << 16 | 'X' << 24; + ULONG tag = FT_MAKE_TAG ('V', 'D', 'M', 'X'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->vdmx = ttfAllocVDMX(font); + font->vdmx = XCALLOC1 (VDMX); ttfLoadVDMX(font->fp,font->vdmx,ptd->offset); } } -static VDMXPtr ttfAllocVDMX(TTFontPtr font) -{ - VDMXPtr vdmx; - - if ((vdmx = (VDMXPtr) calloc(1,sizeof(VDMX))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return vdmx; -} + static void ttfLoadVDMX (FILE *fp,VDMXPtr vdmx,ULONG offset) { int i; - if (fseek(fp,offset,SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadVDMX \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadVDMX"); vdmx->version = ttfGetUSHORT(fp); vdmx->numRecs = ttfGetUSHORT(fp); vdmx->numRatios = ttfGetUSHORT(fp); - vdmx->ratRange = (Ratios *) calloc(vdmx->numRatios, sizeof(Ratios)); - vdmx->offset = (USHORT *) calloc(vdmx->numRatios, sizeof(USHORT)); - vdmx->groups = (Vdmx *) calloc(vdmx->numRecs, sizeof(Vdmx)); + vdmx->ratRange = XCALLOC (vdmx->numRatios, Ratios); for (i=0;i<vdmx->numRatios;i++) { (vdmx->ratRange+i)->CharSet = ttfGetBYTE(fp); @@ -64,14 +42,10 @@ static void ttfLoadVDMX (FILE *fp,VDMXPtr vdmx,ULONG offset) (vdmx->ratRange+i)->yEndRatio = ttfGetBYTE(fp); } - if (fread(vdmx->offset, sizeof(USHORT), vdmx->numRatios,fp) != - vdmx->numRatios) - ttfError("Error when getting Offset\n"); -#ifndef WORDS_BIGENDIAN - TwoByteSwap((unsigned char *) vdmx->offset, - vdmx->numRatios*sizeof(USHORT)); -#endif + vdmx->offset = ttfMakeUSHORT (vdmx->numRatios, fp); + + vdmx->groups = XCALLOC (vdmx->numRecs, Vdmx); for (i=0;i<vdmx->numRecs;i++) { int j; @@ -79,8 +53,7 @@ static void ttfLoadVDMX (FILE *fp,VDMXPtr vdmx,ULONG offset) (vdmx->groups+i)->startsz = ttfGetBYTE(fp); (vdmx->groups+i)->endsz = ttfGetBYTE(fp); - (vdmx->groups+i)->entry = - (vTable *) calloc((vdmx->groups+i)->recs, sizeof(vTable)); + (vdmx->groups+i)->entry = XCALLOC ((vdmx->groups+i)->recs, vTable); for (j=0;j<(vdmx->groups+i)->recs;j++) { diff --git a/Build/source/texk/ttfdump/libttf/vhea.c b/Build/source/texk/ttfdump/libttf/vhea.c index e00c4f2268f..374c2c1bef7 100644 --- a/Build/source/texk/ttfdump/libttf/vhea.c +++ b/Build/source/texk/ttfdump/libttf/vhea.c @@ -7,48 +7,27 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: vhea.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: vhea.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - - -static VHEAPtr ttfAllocVHEA(TTFontPtr font); static void ttfLoadVHEA(FILE *fp,VHEAPtr vhea,ULONG offset); void ttfInitVHEA(TTFontPtr font) { - ULONG tag = 'v' | 'h' << 8 | 'e' << 16 | 'a' << 24; + ULONG tag = FT_MAKE_TAG ('v', 'h', 'e', 'a'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->vhea = ttfAllocVHEA(font); + font->vhea = XCALLOC1 (VHEA); ttfLoadVHEA(font->fp,font->vhea,ptd->offset); } } -static VHEAPtr ttfAllocVHEA(TTFontPtr font) -{ - VHEAPtr vhea; - - if ((vhea = (VHEAPtr) calloc(1,sizeof(VHEA))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return vhea; -} + static void ttfLoadVHEA (FILE *fp,VHEAPtr vhea,ULONG offset) { int i; - if (fseek(fp,offset,SEEK_SET) != 0) - ttfError("Fseek Failed in ttfLoadVHEA \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadVHEA"); vhea->version = ttfGetFixed(fp); vhea->ascent = ttfGetSHORT(fp); diff --git a/Build/source/texk/ttfdump/libttf/vmtx.c b/Build/source/texk/ttfdump/libttf/vmtx.c index 990f824a66a..d1dae4082a5 100644 --- a/Build/source/texk/ttfdump/libttf/vmtx.c +++ b/Build/source/texk/ttfdump/libttf/vmtx.c @@ -7,17 +7,8 @@ #include "ttf.h" #include "ttfutil.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - /* $Id: vmtx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ -#ifndef lint -static char vcid[] = "$Id: vmtx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $"; -#endif /* lint */ - -static VMTXPtr ttfAllocVMTX(TTFontPtr font); static void ttfLoadVMTX(FILE *fp,VMTXPtr vmtx,ULONG offset); /* Caution: Because of interdependency between tables, @@ -26,12 +17,12 @@ static void ttfLoadVMTX(FILE *fp,VMTXPtr vmtx,ULONG offset); */ void ttfInitVMTX(TTFontPtr font) { - ULONG tag = 'v' | 'm' << 8 | 't' << 16 | 'x' << 24; + ULONG tag = FT_MAKE_TAG ('v', 'm', 't', 'x'); TableDirPtr ptd; if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) { - font->vmtx = ttfAllocVMTX(font); + font->vmtx = XCALLOC1 (VMTX); font->vmtx->numOfLongVerMetrics = font->vhea->numOfLongVerMetrics; font->vmtx->numOfTSB = font->maxp->numGlyphs - @@ -39,40 +30,24 @@ void ttfInitVMTX(TTFontPtr font) ttfLoadVMTX(font->fp,font->vmtx,ptd->offset); } } -static VMTXPtr ttfAllocVMTX(TTFontPtr font) -{ - VMTXPtr vmtx; - if ((vmtx = (VMTXPtr) calloc(1,sizeof(VMTX))) == NULL) - { - ttfError("Out of Memory in __FILE__:__LINE__\n"); - return NULL; - } - return vmtx; -} static void ttfLoadVMTX(FILE *fp,VMTXPtr vmtx,ULONG offset) { USHORT i,n = vmtx->numOfLongVerMetrics,m=vmtx->numOfTSB; - if (fseek(fp,offset,SEEK_SET) !=0) - ttfError("Fseek Failed in ttfLOADVMTX \n"); + xfseek(fp, offset, SEEK_SET, "ttfLoadVMTX"); - if ((vmtx->vMetrics = (longVerMetric *) calloc(n,sizeof(longVerMetric))) != NULL) - { - for (i=0;i<n;i++) - { - (vmtx->vMetrics+i)->advanceHeight = ttfGetuFWord(fp); - (vmtx->vMetrics+i)->topSideBearing = ttfGetFWord(fp); - } - } - else + vmtx->vMetrics = XCALLOC (n, longVerMetric); + for (i=0;i<n;i++) { - ttfError("Out Of Memory in __FILE__ : __LINE__\n"); + (vmtx->vMetrics+i)->advanceHeight = ttfGetuFWord(fp); + (vmtx->vMetrics+i)->topSideBearing = ttfGetFWord(fp); } - /* codes dealing with leftSideBearing entry */ - if (m && ((vmtx->topSideBearing = (FWord *) calloc(m,sizeof(FWord))) != NULL)) + /* codes dealing with topSideBearing entry */ + if (m) { + vmtx->topSideBearing = XCALLOC (m, FWord); for (i=0;i<m;i++) { (vmtx->topSideBearing)[i] = ttfGetFWord(fp); diff --git a/Build/source/texk/ttfdump/src/ttfdump.c b/Build/source/texk/ttfdump/src/ttfdump.c index ad68c0d6566..d603483dc28 100644 --- a/Build/source/texk/ttfdump/src/ttfdump.c +++ b/Build/source/texk/ttfdump/src/ttfdump.c @@ -12,21 +12,8 @@ #include "ttfutil.h" #include "ttc.h" -#ifdef MEMCHECK -#include <dmalloc.h> -#endif - - /* $Id: ttfdump.c,v 1.2 1998/07/04 13:17:52 werner Exp $ */ - -#ifndef lint - -static char vcid[] = "$Id: ttfdump.c,v 1.2 1998/07/04 13:17:52 werner Exp $"; - -#endif /* lint */ - - #define MAXLEN 256 #define ALL_GLYF -1 #define NO_GLYF -2 @@ -65,43 +52,7 @@ static void print_vdmx(FILE *out); static void print_vhea(FILE *out); static void print_vmtx(FILE *out); -#if 0 -/* Not used */ -static void dialog (int argc, char *argv[]); -#endif static void usage (void); -#if 0 -/* Not used */ -static void add_suffix (char *name, char *suffix); -#endif - - -#if !defined(EXIT_FAILURE) -#define EXIT_FAILURE 1 -#endif - -#if !defined(EXIT_SUCCESS) -#define EXIT_SUCCESS 0 -#endif - - -/* strdup() is not available on all platforms; this version has been - * contributed by Nelson Beebe. */ - -static char * -Strdup(const char *s) -{ - char *p; - - - p = malloc(((s == (const char *)NULL) ? 0 : strlen (s)) + 1); - if (p == (char *)NULL) - { - (void)fprintf(stderr, "Out of memory in Strdup()\n"); - exit(EXIT_FAILURE); - } - return strcpy(p, s); -} int @@ -131,7 +82,7 @@ main(int argc, char *argv[]) switch (c) { case 't': - tablename = Strdup(optarg); + tablename = xstrdup(optarg); break; case 'g': if (strcmp(optarg, "x") == 0) @@ -240,7 +191,7 @@ main(int argc, char *argv[]) { ttfFreeFont(font); } - exit(EXIT_SUCCESS); + return 0; } @@ -336,7 +287,7 @@ static void print_prologue(FILE *out) { fprintf(out, "True Type Font File Dumper: v 0.5.5\n"); - fprintf(out, "Copyright 1996-1998 ollie@ms1.hinet.net \n"); + fprintf(out, "Copyright 1996-1998 ollie@ms1.hinet.net\n"); fprintf(out, "Dumping File:%s\n\n\n", font->ttfname); } @@ -344,8 +295,8 @@ print_prologue(FILE *out) static void print_offset(FILE *out) { - fprintf(out, "Offset Table \n"); - fprintf(out, "------------ \n"); + fprintf(out, "Offset Table\n"); + fprintf(out, "------------\n"); fprintf(out, "\t sfnt version:\n"); fprintf(out, "\t number of tables: %d\n", font->numTables); } @@ -553,59 +504,11 @@ print_vmtx(FILE *out) } -#if 0 -/* Not used */ -static void -dialog(int argc, char *argv[]) -{ - if (--argc < 1) - usage(); - - strcpy(ttfname, *++argv); - add_suffix(ttfname, "ttf"); - - if (--argc < 1) - strcpy(dumpname, "-"); - else - strcpy(dumpname, *++argv); -} -#endif - - static void usage(void) { fprintf(stderr, "Usage: ttfdump ttfname dumpname [options]\n"); - exit(EXIT_FAILURE); -} - - -#if 0 -/* Not used */ -static void -add_suffix(char *name, char *suffix) -{ - int haveext = 0; - - - if (name && strcmp(name, "-")) - { - while (*name) - { - if (*name == '/') - haveext = 0; - else if (*name == '.') - haveext = 1; - name++; - } - if (!haveext) - { - *name++ = '.'; - strcpy(name, suffix); - } - } } -#endif /* end of ttfdump.c */ |