diff options
author | Karl Berry <karl@freefriends.org> | 2010-04-05 00:34:08 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-04-05 00:34:08 +0000 |
commit | 48ea893cd463bd15617d436f31113b64173f2fc5 (patch) | |
tree | 3892eb0cb1298c9740316aca3ec5258a0e2e9266 /Build | |
parent | b9337f4db98cc2f48a8d8a11f91b601ffe0b1fba (diff) |
attempt to update to dvipdfmx-20100328, while preserving const changes
git-svn-id: svn://tug.org/texlive/trunk@17693 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
38 files changed, 593 insertions, 365 deletions
diff --git a/Build/source/texk/README b/Build/source/texk/README index 73bbdd08b44..4b8091fde40 100644 --- a/Build/source/texk/README +++ b/Build/source/texk/README @@ -1,5 +1,5 @@ $Id$ -Copyright 2006, 2007, 2008, 2009 TeX Users Group. +Copyright 2006, 2007, 2008, 2009, 2010 TeX Users Group. You may freely use, modify and/or distribute this file. This TeX Live directory contains the programs that use the kpathsea @@ -45,10 +45,10 @@ dvidvi - ? dviljk - maintained here, by Joachim Schrod -dvipdfmx - checked 17jul09 +dvipdfmx - checked 5apr10 http://project.ktug.or.kr/dvipdfmx/snapshot/latest/ - http://project.ktug.or.kr/dvipdfmx/snapshot/latest/dvipdfmx-20090708.tar.gz - dvipdfmx@project.ktug.or.kr (ChoF, Hirata, Matthias) + http://project.ktug.or.kr/dvipdfmx/snapshot/latest/dvipdfmx-20100328.tar.gz + dvipdfmx@project.ktug.or.kr (ChoF, Matthias, Hirata) dvipng - checked 18mar10 http://www.ctan.org/tex-archive/dviware/dvipng/ (but maybe stale) diff --git a/Build/source/texk/dvipdfmx/ChangeLog b/Build/source/texk/dvipdfmx/ChangeLog index 6b9814b30d7..5a784ea974a 100644 --- a/Build/source/texk/dvipdfmx/ChangeLog +++ b/Build/source/texk/dvipdfmx/ChangeLog @@ -1,8 +1,118 @@ -$Header: /home/cvsroot/dvipdfmx/ChangeLog,v 1.263 2009/07/08 09:33:22 chofchof Exp $ +$Header: /home/cvsroot/dvipdfmx/ChangeLog,v 1.281 2010/03/28 06:03:57 chofchof Exp $ ChangeLog: Changes for DVIPDFMx =============================== +2010-03-28 Jin-Hwan Cho + + * dvi.c, dvi.h, dvipdfmx.c, spc_pdfm.c: + Implemented a new special \special{pdf: minorversion num} which + will override the value given either by the configuration file + or by the command line option; requested by Karl Berry. + +2010-03-21 Jin-Hwan Cho + + * cidtype2.c: + Assume that the output encoding of CMap files is UTF-16, not UCS2 + as the recent Adobe-Japan1-UCS2 shows; reported by Haruhiko Okumura + and the patch were prepared by Akira Kakuto. + +2010-02-22 Matthias Franz + + * pngimage.c: + Made PNG code work with libpng14, as suggested by Karl Berry. + +2010-02-07 Matthias Franz + + * type1.c: + Fixed bug caused by fonts without data for private dictionary. + (The private dictionary was omitted instead of inserting an + empty dictionary.) This caused problems with Acrobat Reader, for + example with the dsrom10 font. Bug reported by Vladimir Vlasov. + +2010-02-07 Jin-Hwan Cho + + * dvipdfmx.c, pdfdoc.c, pdfobj.h, pdfobj.c, pdfencrypt.h, pdfenctypr.c: + Now the trailer always contains ID array to work Screen annotations + under Adobe Reader 9. + +2009-12-14 Matthias Franz + + * dvipdfmx.c: + Turn on quiet mode earlier if "-q" option is given. + +2009-11-28 Matthias Franz + + * spc_dvips.c: + Fixed bug in "ps: plotfile" special, found by Alexander Bostroem. + +2009-11-18 Matthias Franz + + * man/extractbb.1, man/Makefile.am, Makefile.am, configure.in: + Added man page for extractbb in new directory man. This + addresses Debian bug #512357 and a request by Karl Berry. + +2009-10-10 Jin-Hwan Cho + + * dvipdfmx.c, xbb.c: + Change usage() as suggested by Matthias Franz and Karl Berry. + +2009-10-09 Jin-Hwan Cho + + * dvipdfmx.c: + Implemented the usual options --version and --help + (suggested by Karl Berry.) + +2009-09-19 Matthias Franz + + * epdf.c, pdfdoc.c, pdfdoc.h, xbb.c: + Bug fix: The number of pages in a PDF document as reported by + extractbb was always 0. (The code for reporting the number of + pages of a PDF file was accidentally removed during a previous + modification.) + +2009-09-18 Matthias Franz + + * dpxutil.c, dpxutil.h and all calls to the changed functions: + Polished code for hash tables. Now the function for freeing + values is defined with ht_init_table. ht_append_table now + produces an error if the key is already in use (but this + could be changed easily). A new insert mode where a value + does _not_ replace an existing value for the same key has + been introduced, but there is no short name for it yet. + +2009-08-30 Matthias Franz + + * dvipdfmx.cfg: + Turned on optimization of PDF destinations by default. + +2009-08-27 Matthias Franz + + * truetype.c, type1.c, type1c.c: + Changed precision in font widths arrays from 1.0 to 0.1. + (Applies only to Type 1, Type 1C and TrueType, not PK fonts.) + +2009-08-23 Matthias Franz + + * epdf.c, pdfdoc.c, pdfdoc.h, pdfximage.c, pdfximage.h, xbb.c: + Removed the feature of negative page numbers for PDF inclusion. + It was never used and made the code more complicated. + + * dvipdfmx.c, pdfximage.c: + Changed the code for PS and PDF page inclusion: + The function mkstemp on NetBSD may return the same name twice + if the file has been deleted after the first call. (Reported + by Jukka Salmi.) This interfered with our file name caching. + Now we don't delete the temporary file after PS->PDF conversion, + but cache the temporary file name instead. An advantage is that + we don't have to convert the same file multiple times if several + pages are imported. + +2009-08-17 Jin-Hwan Cho + + * tt_post.c: + Fixed the crashing bug with Mona font found by Alexis Ballier. + 2009-07-08 Jin-Hwan Cho * dvipdfmx.c: diff --git a/Build/source/texk/dvipdfmx/Makefile.in b/Build/source/texk/dvipdfmx/Makefile.in index d161c03f951..494ec9b9830 100644 --- a/Build/source/texk/dvipdfmx/Makefile.in +++ b/Build/source/texk/dvipdfmx/Makefile.in @@ -46,7 +46,7 @@ DIST_COMMON = README $(am__configure_deps) \ ../../build-aux/install-sh ../../build-aux/ltmain.sh \ ../../build-aux/missing ../../build-aux/texinfo.tex \ ../../build-aux/ylwrap AUTHORS COPYING ChangeLog INSTALL NEWS \ - TODO + TODO compile depcomp install-sh missing mkinstalldirs ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/../../m4/cho-libs.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ diff --git a/Build/source/texk/dvipdfmx/configure b/Build/source/texk/dvipdfmx/configure index 1d3b92c7f4b..066fcc0ae6f 100755 --- a/Build/source/texk/dvipdfmx/configure +++ b/Build/source/texk/dvipdfmx/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65 for dvipdfmx 20090708. +# Generated by GNU Autoconf 2.65 for dvipdfmx 20100328. # # Report bugs to <dvipdfmx@project.ktug.or.kr>. # @@ -701,8 +701,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='dvipdfmx' PACKAGE_TARNAME='dvipdfmx' -PACKAGE_VERSION='20090708' -PACKAGE_STRING='dvipdfmx 20090708' +PACKAGE_VERSION='20100328' +PACKAGE_STRING='dvipdfmx 20100328' PACKAGE_BUGREPORT='dvipdfmx@project.ktug.or.kr' PACKAGE_URL='' @@ -1444,7 +1444,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures dvipdfmx 20090708 to adapt to many kinds of systems. +\`configure' configures dvipdfmx 20100328 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1514,7 +1514,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of dvipdfmx 20090708:";; + short | recursive ) echo "Configuration of dvipdfmx 20100328:";; esac cat <<\_ACEOF @@ -1634,7 +1634,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -dvipdfmx configure 20090708 +dvipdfmx configure 20100328 generated by GNU Autoconf 2.65 Copyright (C) 2009 Free Software Foundation, Inc. @@ -2333,7 +2333,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by dvipdfmx $as_me 20090708, which was +It was created by dvipdfmx $as_me 20100328, which was generated by GNU Autoconf 2.65. Invocation command line was $ $0 $@ @@ -7058,7 +7058,7 @@ fi # Define the identity of the package. PACKAGE='dvipdfmx' - VERSION='20090708' + VERSION='20100328' cat >>confdefs.h <<_ACEOF @@ -13153,7 +13153,7 @@ Usage: $0 [OPTIONS] Report bugs to <bug-libtool@gnu.org>." lt_cl_version="\ -dvipdfmx config.lt 20090708 +dvipdfmx config.lt 20100328 configured by $0, generated by GNU Autoconf 2.65. Copyright (C) 2008 Free Software Foundation, Inc. @@ -15022,7 +15022,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by dvipdfmx $as_me 20090708, which was +This file was extended by dvipdfmx $as_me 20100328, which was generated by GNU Autoconf 2.65. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15088,7 +15088,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -dvipdfmx config.status 20090708 +dvipdfmx config.status 20100328 configured by $0, generated by GNU Autoconf 2.65, with options \\"\$ac_cs_config\\" diff --git a/Build/source/texk/dvipdfmx/configure.ac b/Build/source/texk/dvipdfmx/configure.ac index 6980d314b7e..1c5d8690c26 100644 --- a/Build/source/texk/dvipdfmx/configure.ac +++ b/Build/source/texk/dvipdfmx/configure.ac @@ -6,7 +6,7 @@ dnl This file is free software; the copyright holder dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl -AC_INIT([dvipdfmx], [20090708], [dvipdfmx@project.ktug.or.kr]) +AC_INIT([dvipdfmx], [20100328], [dvipdfmx@project.ktug.or.kr]) AC_PREREQ([2.65]) AC_CONFIG_SRCDIR([src/dvipdfmx.c]) AC_CONFIG_AUX_DIR([../../build-aux]) diff --git a/Build/source/texk/dvipdfmx/data/dvipdfmx.cfg b/Build/source/texk/dvipdfmx/data/dvipdfmx.cfg index 8b7c9d74c53..e1754ca8afd 100644 --- a/Build/source/texk/dvipdfmx/data/dvipdfmx.cfg +++ b/Build/source/texk/dvipdfmx/data/dvipdfmx.cfg @@ -17,10 +17,10 @@ %% This is only for backward compatibility. Don't use that. %% 0x0008 Do not replace duplicate fontmap entries. %% Dvipdfm's (not 'x') behaviour. -%% 0x0010 Do not optimize PDF destinations. -%% (Optimization is still experimental.) +%% 0x0010 Do not optimize PDF destinations. Use this if you want to +%% refer from other files to destinations in the current file. -C 0x0010 +%C 0x0000 %% PDF Document Settings %% @@ -112,10 +112,10 @@ P 0x003C %% %v The PDF version to be converted to, e.g. "1.4" for PDF 1.4. %% %% Replaced with single '%'. -%% GhostScript (PS-to-PDF and PDF-to-PDF): +%% Ghostscript (PS-to-PDF and PDF-to-PDF): %% %% ps2pdf is a front-end to gs. For a complete list of options, see -%% http://pages.cs.wisc.edu/~ghost/doc/cvs/Ps2pdf.htm#Options +%% http://ghostscript.com/doc/current/Ps2pdf.htm#Options %% %% By default, gs encodes all images contained in a PS file using %% the lossy DCT (i.e., JPEG) filter. This often leads to inferior @@ -127,7 +127,7 @@ P 0x003C %% will also be re-encoded using Flate. To turn the conversion off, %% simply remove the options mentioned above. %% -%% Also note that PAPERSIZE=a0 is specified below. This convert PS +%% Also note that PAPERSIZE=a0 is specified below. This converts PS %% files (including EPS) to A0 papersize PDF. This is necessary to %% prevent gs from clipping PS figure at some papersize. (A0 above %% simply means large size paper.) If you have figures even larger diff --git a/Build/source/texk/dvipdfmx/src/Makefile.am b/Build/source/texk/dvipdfmx/src/Makefile.am index 614a47f0216..6dae1185185 100644 --- a/Build/source/texk/dvipdfmx/src/Makefile.am +++ b/Build/source/texk/dvipdfmx/src/Makefile.am @@ -1,6 +1,6 @@ ## Makefile.am for the TeX Live subdirectory texk/dvipdfmx/src/ ## -## Copyright (C) 2009 Peter Breitenlohner <tex-live@tug.org> +## Copyright (C) 2009, 2010 Peter Breitenlohner <tex-live@tug.org> ## You may freely use, modify and/or distribute this file. ## INCLUDES = $(KPATHSEA_INCLUDES) $(LIBPNG_INCLUDES) $(ZLIB_INCLUDES) @@ -14,24 +14,37 @@ dvipdfmx_SOURCES = \ agl.c bmpimage.c cff.c cff_dict.c cid.c cidtype0.c cidtype2.c \ cmap.c cmap_read.c cmap_write.c cs_type2.c \ dpxconf.c dpxcrypt.c dpxfile.c dpxutil.c \ - dvi.c dvipdfmx.c epdf.c error.c fontmap.c jpegimage.c mem.c mfileio.c mpost.c \ - numbers.c otl_conf.c otl_opt.c pdfcolor.c pdfdev.c pdfdoc.c pdfdraw.c pdfencoding.c \ - pdfencrypt.c pdffont.c pdfnames.c pdfobj.c pdfparse.c pdfresource.c pdfximage.c \ + dvi.c dvipdfmx.c epdf.c error.c fontmap.c jpegimage.c mem.c \ + mfileio.c mpost.c \ + numbers.c otl_conf.c otl_opt.c pdfcolor.c pdfdev.c pdfdoc.c \ + pdfdraw.c pdfencoding.c \ + pdfencrypt.c pdffont.c pdfnames.c pdfobj.c pdfparse.c \ + pdfresource.c pdfximage.c \ pkfont.c pngimage.c pst.c pst_obj.c sfnt.c \ - spc_color.c spc_dvips.c spc_html.c spc_misc.c spc_pdfm.c spc_tpic.c spc_util.c specials.c \ + spc_color.c spc_dvips.c spc_html.c spc_misc.c spc_pdfm.c \ + spc_tpic.c spc_util.c specials.c \ subfont.c tfm.c \ - tt_aux.c tt_cmap.c tt_glyf.c tt_gsub.c tt_post.c tt_table.c truetype.c \ + tt_aux.c tt_cmap.c tt_glyf.c tt_gsub.c tt_post.c tt_table.c \ + truetype.c \ type0.c t1_char.c t1_load.c type1.c type1c.c \ unicode.c vf.c xbb.c \ - agl.h bmpimage.h cff.h cff_dict.h cff_limits.h cff_stdstr.h cff_types.h \ - cid.h cid_basefont.h cid_p.h cidtype0.h cidtype2.h cmap.h cmap_p.h cmap_read.h cmap_write.h \ - cs_type2.h dpxconf.h dpxcrypt.h dpxutil.h dpxfile.h dvi.h dvicodes.h dvipdfmx.h epdf.h error.h fontmap.h \ - jpegimage.h mem.h mfileio.h mpost.h numbers.h otl_conf.h otl_opt.h pdfcolor.h pdfdev.h \ - pdfdoc.h pdfdraw.h pdfencoding.h pdfencrypt.h pdffont.h pdflimits.h pdfnames.h pdfobj.h \ - pdfparse.h pdfresource.h pdfximage.h pkfont.h pngimage.h pst.h pst_obj.h sfnt.h \ - spc_color.h spc_dvips.h spc_html.h spc_misc.h spc_pdfm.h spc_tpic.h spc_util.h specials.h \ + agl.h bmpimage.h cff.h cff_dict.h cff_limits.h cff_stdstr.h \ + cff_types.h \ + cid.h cid_basefont.h cid_p.h cidtype0.h cidtype2.h cmap.h \ + cmap_p.h cmap_read.h cmap_write.h \ + cs_type2.h dpxconf.h dpxcrypt.h dpxutil.h dpxfile.h dvi.h \ + dvicodes.h dvipdfmx.h epdf.h error.h fontmap.h \ + jpegimage.h mem.h mfileio.h mpost.h numbers.h otl_conf.h \ + otl_opt.h pdfcolor.h pdfdev.h \ + pdfdoc.h pdfdraw.h pdfencoding.h pdfencrypt.h pdffont.h \ + pdflimits.h pdfnames.h pdfobj.h \ + pdfparse.h pdfresource.h pdfximage.h pkfont.h pngimage.h pst.h \ + pst_obj.h sfnt.h \ + spc_color.h spc_dvips.h spc_html.h spc_misc.h spc_pdfm.h \ + spc_tpic.h spc_util.h specials.h \ subfont.h system.h tfm.h \ - tt_aux.h tt_cmap.h tt_glyf.h tt_gsub.h tt_post.h tt_table.h truetype.h \ + tt_aux.h tt_cmap.h tt_glyf.h tt_gsub.h tt_post.h tt_table.h \ + truetype.h \ type0.h t1_char.h t1_load.h type1.h type1c.h \ unicode.h vf.h xbb.h @@ -57,4 +70,3 @@ uninstall-hook: rm -f $(DESTDIR)$(bindir)/ebb$(EXEEXT) rm -f $(DESTDIR)$(bindir)/extractbb$(EXEEXT) rm -f $(DESTDIR)$(bindir)/dvipdfm$(EXEEXT) - diff --git a/Build/source/texk/dvipdfmx/src/Makefile.in b/Build/source/texk/dvipdfmx/src/Makefile.in index e1c46657194..a3ca1075871 100644 --- a/Build/source/texk/dvipdfmx/src/Makefile.in +++ b/Build/source/texk/dvipdfmx/src/Makefile.in @@ -258,24 +258,37 @@ dvipdfmx_SOURCES = \ agl.c bmpimage.c cff.c cff_dict.c cid.c cidtype0.c cidtype2.c \ cmap.c cmap_read.c cmap_write.c cs_type2.c \ dpxconf.c dpxcrypt.c dpxfile.c dpxutil.c \ - dvi.c dvipdfmx.c epdf.c error.c fontmap.c jpegimage.c mem.c mfileio.c mpost.c \ - numbers.c otl_conf.c otl_opt.c pdfcolor.c pdfdev.c pdfdoc.c pdfdraw.c pdfencoding.c \ - pdfencrypt.c pdffont.c pdfnames.c pdfobj.c pdfparse.c pdfresource.c pdfximage.c \ + dvi.c dvipdfmx.c epdf.c error.c fontmap.c jpegimage.c mem.c \ + mfileio.c mpost.c \ + numbers.c otl_conf.c otl_opt.c pdfcolor.c pdfdev.c pdfdoc.c \ + pdfdraw.c pdfencoding.c \ + pdfencrypt.c pdffont.c pdfnames.c pdfobj.c pdfparse.c \ + pdfresource.c pdfximage.c \ pkfont.c pngimage.c pst.c pst_obj.c sfnt.c \ - spc_color.c spc_dvips.c spc_html.c spc_misc.c spc_pdfm.c spc_tpic.c spc_util.c specials.c \ + spc_color.c spc_dvips.c spc_html.c spc_misc.c spc_pdfm.c \ + spc_tpic.c spc_util.c specials.c \ subfont.c tfm.c \ - tt_aux.c tt_cmap.c tt_glyf.c tt_gsub.c tt_post.c tt_table.c truetype.c \ + tt_aux.c tt_cmap.c tt_glyf.c tt_gsub.c tt_post.c tt_table.c \ + truetype.c \ type0.c t1_char.c t1_load.c type1.c type1c.c \ unicode.c vf.c xbb.c \ - agl.h bmpimage.h cff.h cff_dict.h cff_limits.h cff_stdstr.h cff_types.h \ - cid.h cid_basefont.h cid_p.h cidtype0.h cidtype2.h cmap.h cmap_p.h cmap_read.h cmap_write.h \ - cs_type2.h dpxconf.h dpxcrypt.h dpxutil.h dpxfile.h dvi.h dvicodes.h dvipdfmx.h epdf.h error.h fontmap.h \ - jpegimage.h mem.h mfileio.h mpost.h numbers.h otl_conf.h otl_opt.h pdfcolor.h pdfdev.h \ - pdfdoc.h pdfdraw.h pdfencoding.h pdfencrypt.h pdffont.h pdflimits.h pdfnames.h pdfobj.h \ - pdfparse.h pdfresource.h pdfximage.h pkfont.h pngimage.h pst.h pst_obj.h sfnt.h \ - spc_color.h spc_dvips.h spc_html.h spc_misc.h spc_pdfm.h spc_tpic.h spc_util.h specials.h \ + agl.h bmpimage.h cff.h cff_dict.h cff_limits.h cff_stdstr.h \ + cff_types.h \ + cid.h cid_basefont.h cid_p.h cidtype0.h cidtype2.h cmap.h \ + cmap_p.h cmap_read.h cmap_write.h \ + cs_type2.h dpxconf.h dpxcrypt.h dpxutil.h dpxfile.h dvi.h \ + dvicodes.h dvipdfmx.h epdf.h error.h fontmap.h \ + jpegimage.h mem.h mfileio.h mpost.h numbers.h otl_conf.h \ + otl_opt.h pdfcolor.h pdfdev.h \ + pdfdoc.h pdfdraw.h pdfencoding.h pdfencrypt.h pdffont.h \ + pdflimits.h pdfnames.h pdfobj.h \ + pdfparse.h pdfresource.h pdfximage.h pkfont.h pngimage.h pst.h \ + pst_obj.h sfnt.h \ + spc_color.h spc_dvips.h spc_html.h spc_misc.h spc_pdfm.h \ + spc_tpic.h spc_util.h specials.h \ subfont.h system.h tfm.h \ - tt_aux.h tt_cmap.h tt_glyf.h tt_gsub.h tt_post.h tt_table.h truetype.h \ + tt_aux.h tt_cmap.h tt_glyf.h tt_gsub.h tt_post.h tt_table.h \ + truetype.h \ type0.h t1_char.h t1_load.h type1.h type1c.h \ unicode.h vf.h xbb.h diff --git a/Build/source/texk/dvipdfmx/src/agl.c b/Build/source/texk/dvipdfmx/src/agl.c index 0cbb262e63d..e3aee674752 100644 --- a/Build/source/texk/dvipdfmx/src/agl.c +++ b/Build/source/texk/dvipdfmx/src/agl.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/agl.c,v 1.33 2007/11/14 02:07:14 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/agl.c,v 1.34 2009/09/18 23:56:02 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -364,10 +364,16 @@ agl_normalized_name (char *glyphname) static struct ht_table aglmap; +static void CDECL +hval_free (void *hval) +{ + agl_release_name((struct agl_name *) hval); +} + void agl_init_map (void) { - ht_init_table(&aglmap); + ht_init_table(&aglmap, hval_free); agl_load_listfile(AGL_EXTRA_LISTFILE, 0); if (agl_load_listfile(AGL_PREDEF_LISTFILE, 1) < 0) { WARN("Failed to load AGL file \"%s\"...", AGL_PREDEF_LISTFILE); @@ -377,16 +383,10 @@ agl_init_map (void) } } -static void CDECL -hval_free (void *hval) -{ - agl_release_name((struct agl_name *) hval); -} - void agl_close_map (void) { - ht_clear_table(&aglmap, hval_free); + ht_clear_table(&aglmap); } #define WBUF_SIZE 1024 diff --git a/Build/source/texk/dvipdfmx/src/cidtype2.c b/Build/source/texk/dvipdfmx/src/cidtype2.c index 420f46f66ff..2f68537e667 100644 --- a/Build/source/texk/dvipdfmx/src/cidtype2.c +++ b/Build/source/texk/dvipdfmx/src/cidtype2.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/cidtype2.c,v 1.36 2008/05/17 04:18:47 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/cidtype2.c,v 1.37 2010/03/21 13:16:12 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -469,8 +469,15 @@ cid_to_code (CMap *cmap, CID cid) return (long) outbuf[0]; else if (outbytesleft == 30) return (long) (outbuf[0] << 8|outbuf[1]); - else if (outbytesleft == 28) - return (long) (outbuf[0] << 24|outbuf[1] << 16|outbuf[2] << 8|outbuf[3]); + else if (outbytesleft == 28) { /* We assume the output encoding is UTF-16. */ + CID hi, lo; + hi = outbuf[0] << 8|outbuf[1]; + lo = outbuf[2] << 8|outbuf[3]; + if (hi >= 0xd800 && hi <= 0xdbff && lo >= 0xdc00 && lo <= 0xdfff) + return (long) ((hi - 0xd800) * 0x400 + 0x10000 + lo - 0xdc00); + else + return (long) (hi << 16|lo); + } return 0; } diff --git a/Build/source/texk/dvipdfmx/src/dpxutil.c b/Build/source/texk/dvipdfmx/src/dpxutil.c index 7e8a81624d5..1a0af42aebf 100644 --- a/Build/source/texk/dvipdfmx/src/dpxutil.c +++ b/Build/source/texk/dvipdfmx/src/dpxutil.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/dpxutil.c,v 1.11 2009/04/26 21:23:29 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/dpxutil.c,v 1.13 2009/09/20 14:52:41 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -161,7 +161,7 @@ skip_white_spaces (unsigned char **s, unsigned char *endptr) } void -ht_init_table (struct ht_table *ht) +ht_init_table (struct ht_table *ht, void (*hval_free_fn) (void *)) { int i; @@ -171,10 +171,11 @@ ht_init_table (struct ht_table *ht) ht->table[i] = NULL; } ht->count = 0; + ht->hval_free_fn = hval_free_fn; } void -ht_clear_table (struct ht_table *ht, void (*hval_free_fn) (void *)) +ht_clear_table (struct ht_table *ht) { int i; @@ -185,8 +186,8 @@ ht_clear_table (struct ht_table *ht, void (*hval_free_fn) (void *)) hent = ht->table[i]; while (hent) { - if (hent->value && hval_free_fn) { - hval_free_fn(hent->value); + if (hent->value && ht->hval_free_fn) { + ht->hval_free_fn(hent->value); } hent->value = NULL; if (hent->key) { @@ -200,6 +201,7 @@ ht_clear_table (struct ht_table *ht, void (*hval_free_fn) (void *)) ht->table[i] = NULL; } ht->count = 0; + ht->hval_free_fn = NULL; } long ht_table_size (struct ht_table *ht) @@ -245,7 +247,7 @@ ht_lookup_table (struct ht_table *ht, const void *key, int keylen) int ht_remove_table (struct ht_table *ht, - const void *key, int keylen, void (*hval_free_fn) (void *)) + const void *key, int keylen) /* returns 1 if the element was found and removed and 0 otherwise */ { struct ht_entry *hent, *prev; @@ -269,8 +271,8 @@ ht_remove_table (struct ht_table *ht, RELEASE(hent->key); hent->key = NULL; hent->keylen = 0; - if (hent->value && hval_free_fn) { - hval_free_fn(hent->value); + if (hent->value && ht->hval_free_fn) { + ht->hval_free_fn(hent->value); } hent->value = NULL; if (prev) { @@ -285,11 +287,9 @@ ht_remove_table (struct ht_table *ht, return 0; } -/* replace... */ void -ht_insert_table (struct ht_table *ht, - const void *key, int keylen, void *value, - void (*hval_free_fn) (void *)) +ht_modify_table (struct ht_table *ht, + const void *key, int keylen, void *value, int mode) { struct ht_entry *hent, *prev; unsigned int hkey; @@ -308,9 +308,20 @@ ht_insert_table (struct ht_table *ht, hent = hent->next; } if (hent) { - if (hent->value && hval_free_fn) - hval_free_fn(hent->value); - hent->value = value; + switch (mode) { + case HT_NEW: + ASSERT(0); /* duplicates not allowed in this mode */ + break; + case HT_REPLACE: { + if (hent->value && ht->hval_free_fn) + ht->hval_free_fn(hent->value); + hent->value = value; + break; + } + case HT_KEEP: + ht->hval_free_fn(value); + break; + } } else { hent = NEW(1, struct ht_entry); hent->key = NEW(keylen, char); @@ -327,35 +338,6 @@ ht_insert_table (struct ht_table *ht, } } -void -ht_append_table (struct ht_table *ht, - const void *key, int keylen, void *value) -{ - struct ht_entry *hent, *last; - unsigned int hkey; - - hkey = get_hash(key, keylen); - hent = ht->table[hkey]; - if (!hent) { - hent = NEW(1, struct ht_entry); - ht->table[hkey] = hent; - } else { - while (hent) { - last = hent; - hent = hent->next; - } - hent = NEW(1, struct ht_entry); - last->next = hent; - } - hent->key = NEW(keylen, char); - memcpy(hent->key, key, keylen); - hent->keylen = keylen; - hent->value = value; - hent->next = NULL; - - ht->count++; -} - int ht_set_iter (struct ht_table *ht, struct ht_iter *iter) { diff --git a/Build/source/texk/dvipdfmx/src/dpxutil.h b/Build/source/texk/dvipdfmx/src/dpxutil.h index a082d12d49d..3785367c1b6 100644 --- a/Build/source/texk/dvipdfmx/src/dpxutil.h +++ b/Build/source/texk/dvipdfmx/src/dpxutil.h @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/dpxutil.h,v 1.9 2009/04/26 21:23:29 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/dpxutil.h,v 1.11 2009/09/20 14:24:51 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -68,20 +68,31 @@ struct ht_entry { struct ht_table { long count; + void (*hval_free_fn) (void *); struct ht_entry *table[HASH_TABLE_SIZE]; }; -extern void ht_init_table (struct ht_table *ht); -extern void ht_clear_table (struct ht_table *ht, void (*hval_free_fn) (void *)); +typedef struct ht_table ht_table; + +#define HT_NEW 0 +#define HT_REPLACE 1 +#define HT_KEEP 2 + +extern void ht_init_table (struct ht_table *ht, + void (*hval_free_fn) (void *)); +extern void ht_clear_table (struct ht_table *ht); extern long ht_table_size (struct ht_table *ht); -extern void *ht_lookup_table (struct ht_table *ht, const void *key, int keylen); -extern void ht_append_table (struct ht_table *ht, - const void *key, int keylen, void *value) ; +extern void *ht_lookup_table (struct ht_table *ht, + const void *key, int keylen); +extern void ht_modify_table (struct ht_table *ht, + const void *key, int keylen, + void *value, int mode); +#define ht_append_table(ht, key, keylen, value) \ + ht_modify_table(ht, key, keylen, value, HT_NEW) +#define ht_insert_table(ht, key, keylen, value) \ + ht_modify_table(ht, key, keylen, value, HT_REPLACE) extern int ht_remove_table (struct ht_table *ht, - const void *key, int keylen, void (*hval_free_fn) (void*)); -extern void ht_insert_table (struct ht_table *ht, - const void *key, int keylen, void *value, - void (*hval_free_fn) (void *)); + const void *key, int keylen); struct ht_iter { int index; diff --git a/Build/source/texk/dvipdfmx/src/dvi.c b/Build/source/texk/dvipdfmx/src/dvi.c index e7cc0fa1258..f9ecc831985 100644 --- a/Build/source/texk/dvipdfmx/src/dvi.c +++ b/Build/source/texk/dvipdfmx/src/dvi.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/dvi.c,v 1.40 2009/04/04 02:10:44 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/dvi.c,v 1.41 2010/03/28 06:03:57 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -1688,7 +1688,7 @@ read_length (double *vp, double mag, const char **pp, const char *endptr) static int -scan_special (double *wd, double *ht, double *xo, double *yo, char *lm, const char *buf, UNSIGNED_QUAD size) +scan_special (double *wd, double *ht, double *xo, double *yo, char *lm, unsigned *minorversion, const char *buf, UNSIGNED_QUAD size) { char *q; const char *p = buf, *endptr; @@ -1762,6 +1762,15 @@ scan_special (double *wd, double *ht, double *xo, double *yo, char *lm, const ch if (p >= endptr || *p != qchr) error = -1; } + } else if (minorversion && ns_pdf && !strcmp(q, "minorversion")) { + char *kv; + if (*p == '=') p++; + skip_white(&p, endptr); + kv = parse_float_decimal(&p, endptr); + if (kv) { + *minorversion = (unsigned)strtol(kv, NULL, 10); + RELEASE(kv); + } } RELEASE(q); } @@ -1771,9 +1780,10 @@ scan_special (double *wd, double *ht, double *xo, double *yo, char *lm, const ch void -dvi_scan_paper_size (unsigned page_no, - double *page_width, double *page_height, - double *x_offset, double *y_offset, char *landscape) +dvi_scan_specials (unsigned page_no, + double *page_width, double *page_height, + double *x_offset, double *y_offset, char *landscape, + unsigned *minorversion) { FILE *fp = dvi_file; long offset; @@ -1802,7 +1812,7 @@ dvi_scan_paper_size (unsigned page_no, size = MIN(size, 1024); if (fread(buf, sizeof(char), size, fp) != size) ERROR("Reading DVI file failed!"); - scan_special(page_width, page_height, x_offset, y_offset, landscape, buf, size); + scan_special(page_width, page_height, x_offset, y_offset, landscape, minorversion, buf, size); continue; } diff --git a/Build/source/texk/dvipdfmx/src/dvi.h b/Build/source/texk/dvipdfmx/src/dvi.h index 13ae1526a96..35873e9bd1c 100644 --- a/Build/source/texk/dvipdfmx/src/dvi.h +++ b/Build/source/texk/dvipdfmx/src/dvi.h @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/dvi.h,v 1.14 2008/11/30 21:12:27 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/dvi.h,v 1.15 2010/03/28 06:03:57 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -70,10 +70,10 @@ extern void dvi_dir (UNSIGNED_BYTE dir); extern void dvi_do_page (unsigned page_no, double paper_width, double paper_height, double x_offset, double y_offset); -extern void dvi_scan_paper_size (unsigned page_no, - double *width, double *height, - double *x_offset, double *y_offset, - char *landscape); +extern void dvi_scan_specials (unsigned page_no, + double *width, double *height, + double *x_offset, double *y_offset, + char *landscape, unsigned *minorversion); extern int dvi_locate_font (const char *name, spt_t ptsize); /* link or nolink: diff --git a/Build/source/texk/dvipdfmx/src/dvipdfmx.c b/Build/source/texk/dvipdfmx/src/dvipdfmx.c index 113f109d783..5c02000369d 100644 --- a/Build/source/texk/dvipdfmx/src/dvipdfmx.c +++ b/Build/source/texk/dvipdfmx/src/dvipdfmx.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/dvipdfmx.c,v 1.77 2009/07/08 09:33:22 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/dvipdfmx.c,v 1.83 2010/03/28 06:03:57 chofchof Exp $ This is DVIPDFMx, an eXtended version of DVIPDFM by Mark A. Wicks. - Copyright (C) 2008 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata, + Copyright (C) 2009 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata, the DVIPDFMx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -127,57 +127,66 @@ set_default_pdf_filename(void) } static void +show_version (void) +{ + fprintf(stdout, "\nThis is %s-%s by the DVIPDFMx project team,\n", PACKAGE, VERSION); + fprintf(stdout, "an extended version of dvipdfm-0.13.2c developed by Mark A. Wicks.\n"); + fprintf(stdout, "\nCopyright (C) 2002-2009 by the DVIPDFMx project team\n"); + fprintf(stdout, "\nThis is free software; you can redistribute it and/or modify\n"); + fprintf(stdout, "it under the terms of the GNU General Public License as published by\n"); + fprintf(stdout, "the Free Software Foundation; either version 2 of the License, or\n"); + fprintf(stdout, "(at your option) any later version.\n"); +} + +static void +show_usage (void) +{ + fprintf(stdout, "\nUsage: dvipdfmx [options] dvifile\n"); + fprintf(stdout, "-c \t\tIgnore color specials (for B&W printing)\n"); + fprintf(stdout, "-d number\tSet PDF decimal digits (0-5) [2]\n"); + fprintf(stdout, "-f filename\tSet font map file name [cid-x.map]\n"); + fprintf(stdout, "-g dimension\tAnnotation \"grow\" amount [0.0in]\n"); + fprintf(stdout, "-l \t\tLandscape mode\n"); + fprintf(stdout, "-m number\tSet additional magnification\n"); + fprintf(stdout, "-o filename\tSet output file name [dvifile.pdf]\n"); + fprintf(stdout, "-p papersize\tSet papersize [a4]\n"); + fprintf(stdout, "-q \t\tBe quiet\n"); + fprintf(stdout, "-r resolution\tSet resolution (in DPI) for raster fonts [600]\n"); + fprintf(stdout, "-s pages\tSelect page ranges (-)\n"); + fprintf(stdout, "-t \t\tEmbed thumbnail images of PNG format [dvifile.1] \n"); + fprintf(stdout, "-x dimension\tSet horizontal offset [1.0in]\n"); + fprintf(stdout, "-y dimension\tSet vertical offset [1.0in]\n"); + fprintf(stdout, "-z number \tSet zlib compression level (0-9) [9]\n"); + + fprintf(stdout, "-v \t\tBe verbose\n"); + fprintf(stdout, "-vv\t\tBe more verbose\n"); + fprintf(stdout, "-C number\tSpecify miscellaneous option flags [0]:\n"); + fprintf(stdout, "\t\t 0x0001 reserved\n"); + fprintf(stdout, "\t\t 0x0002 Use semi-transparent filling for tpic shading command,\n"); + fprintf(stdout, "\t\t\t instead of opaque gray color. (requires PDF 1.4)\n"); + fprintf(stdout, "\t\t 0x0004 Treat all CIDFont as fixed-pitch font.\n"); + fprintf(stdout, "\t\t 0x0008 Do not replace duplicate fontmap entries.\n"); + fprintf(stdout, "\t\t 0x0010 Do not optimize PDF destinations.\n"); + fprintf(stdout, "\t\tPositive values are always ORed with previously given flags.\n"); + fprintf(stdout, "\t\tAnd negative values replace old values.\n"); + fprintf(stdout, "-D template\tPS->PDF conversion command line template [none]\n"); + fprintf(stdout, "-E \t\tEnable DVIPDFM emulation mode\n"); + fprintf(stdout, "-K number\tEncryption key bits [40]\n"); + fprintf(stdout, "-O number\tSet maximum depth of open bookmark items [0]\n"); + fprintf(stdout, "-P number\tSet permission flags for PDF encryption [0x003C]\n"); + fprintf(stdout, "-S \t\tEnable PDF encryption\n"); + fprintf(stdout, "-V number\tSet PDF minor version [4]\n"); + fprintf(stdout, "\nAll dimensions entered on the command line are \"true\" TeX dimensions.\n"); + fprintf(stdout, "Argument of \"-s\" lists physical page ranges separated by commas, e.g., \"-s 1-3,5-6\"\n"); + fprintf(stdout, "Papersize is specified by paper format (e.g., \"a4\") or by w<unit>,h<unit> (e.g., \"20cm,30cm\").\n"); +} + +static void usage (void) { if (really_quiet) return; - - fprintf (stdout, "\nThis is %s-%s by the DVIPDFMx project team,\n", PACKAGE, VERSION); - fprintf (stdout, "an extended version of dvipdfm-0.13.2c developed by Mark A. Wicks.\n"); - fprintf (stdout, "\nCopyright (C) 2002-2009 by the DVIPDFMx project team\n"); - fprintf (stdout, "\nThis is free software; you can redistribute it and/or modify\n"); - fprintf (stdout, "it under the terms of the GNU General Public License as published by\n"); - fprintf (stdout, "the Free Software Foundation; either version 2 of the License, or\n"); - fprintf (stdout, "(at your option) any later version.\n"); - fprintf (stdout, "\nUsage: dvipdfmx [options] dvifile\n"); - fprintf (stdout, "-c \t\tIgnore color specials (for B&W printing)\n"); - fprintf (stdout, "-d number\tSet PDF decimal digits (0-5) [2]\n"); - fprintf (stdout, "-f filename\tSet font map file name [cid-x.map]\n"); - fprintf (stdout, "-g dimension\tAnnotation \"grow\" amount [0.0in]\n"); - fprintf (stdout, "-l \t\tLandscape mode\n"); - fprintf (stdout, "-m number\tSet additional magnification\n"); - fprintf (stdout, "-o filename\tSet output file name [dvifile.pdf]\n"); - fprintf (stdout, "-p papersize\tSet papersize [a4]\n"); - fprintf (stdout, "-q \t\tBe quiet\n"); - fprintf (stdout, "-r resolution\tSet resolution (in DPI) for raster fonts [600]\n"); - fprintf (stdout, "-s pages\tSelect page ranges (-)\n"); - fprintf (stdout, "-t \t\tEmbed thumbnail images of PNG format [dvifile.1] \n"); - fprintf (stdout, "-x dimension\tSet horizontal offset [1.0in]\n"); - fprintf (stdout, "-y dimension\tSet vertical offset [1.0in]\n"); - fprintf (stdout, "-z number \tSet zlib compression level (0-9) [9]\n"); - - fprintf (stdout, "-v \t\tBe verbose\n"); - fprintf (stdout, "-vv\t\tBe more verbose\n"); - fprintf (stdout, "-C number\tSpecify miscellaneous option flags [0]:\n"); - fprintf (stdout, "\t\t 0x0001 reserved\n"); - fprintf (stdout, "\t\t 0x0002 Use semi-transparent filling for tpic shading command,\n"); - fprintf (stdout, "\t\t\t instead of opaque gray color. (requires PDF 1.4)\n"); - fprintf (stdout, "\t\t 0x0004 Treat all CIDFont as fixed-pitch font.\n"); - fprintf (stdout, "\t\t 0x0008 Do not replace duplicate fontmap entries.\n"); - fprintf (stdout, "\t\t 0x0010 Do not optimize PDF destinations.\n"); - fprintf (stdout, "\t\tPositive values are always ORed with previously given flags.\n"); - fprintf (stdout, "\t\tAnd negative values replace old values.\n"); - fprintf (stdout, "-D template\tPS->PDF conversion command line template [none]\n"); - fprintf (stdout, "-E \t\tEnable DVIPDFM emulation mode\n"); - fprintf (stdout, "-K number\tEncryption key bits [40]\n"); - fprintf (stdout, "-O number\tSet maximum depth of open bookmark items [0]\n"); - fprintf (stdout, "-P number\tSet permission flags for PDF encryption [0x003C]\n"); - fprintf (stdout, "-S \t\tEnable PDF encryption\n"); - fprintf (stdout, "-V number\tSet PDF minor version [4]\n"); - fprintf (stdout, "\nAll dimensions entered on the command line are \"true\" TeX dimensions.\n"); - fprintf (stdout, "Argument of \"-s\" lists physical page ranges separated by commas, e.g., \"-s 1-3,5-6\"\n"); - fprintf (stdout, "Papersize is specified by paper format (e.g., \"a4\") or by w<unit>,h<unit> (e.g., \"20cm,30cm\").\n"); - + fprintf(stdout, "\nTry \"dvipdfmx --help\" for more information.\n"); exit(1); } @@ -322,7 +331,7 @@ select_pages (const char *pagespec) /* It doesn't work as expected (due to dvi filename). */ #define CHECK_ARG(n,m) if (argc < (n) + 1) {\ if (!really_quiet)\ - fprintf (stderr, "\nMissing %s after \"-%c\".\n", (m), *flag);\ + fprintf(stderr, "\nMissing %s after \"-%c\".\n", (m), *flag);\ usage();\ } @@ -334,6 +343,8 @@ set_verbose (int argc, char *argv[]) char *flag; for (flag = argv[0] + 1; *flag != 0; flag++) { + if (*flag == '-') + break; if (*flag == 'q') really_quiet = 1; if (*flag == 'v') @@ -367,6 +378,21 @@ do_args (int argc, char *argv[]) for (flag = argv[0] + 1; *flag != 0; flag++) { switch (*flag) { + case '-': + if (++flag) { + if (!strcmp(flag, "help")) { + show_version(); + show_usage(); + exit(0); + } else if (!strcmp(flag, "version")) { + show_version(); + exit(0); + } + } + if (!really_quiet) + fprintf(stderr, "Unknown option in \"--%s\"", flag); + usage(); + break; case 'D': CHECK_ARG(1, "PS->PDF conversion command line template"); set_distiller_template(argv[1]); @@ -543,7 +569,7 @@ do_args (int argc, char *argv[]) } /* else fall through */ default: if (!really_quiet) - fprintf (stderr, "Unknown option in \"%s\"", flag); + fprintf(stderr, "Unknown option in \"-%s\"", flag); usage(); break; } @@ -644,6 +670,7 @@ system_default (void) void error_cleanup (void) { + pdf_close_images(); /* delete temporary files */ pdf_error_cleanup(); if (pdf_filename) { remove(pdf_filename); @@ -703,7 +730,7 @@ do_dvi_pages (void) /* Users want to change page size even after page is started! */ w = page_width; h = page_height; lm = landscape_mode; xo = x_offset; yo = y_offset; - dvi_scan_paper_size(page_no, &w, &h, &xo, &yo, &lm); + dvi_scan_specials(page_no, &w, &h, &xo, &yo, &lm, NULL); if (lm != landscape_mode) { SWAP(w, h); landscape_mode = lm; @@ -840,6 +867,9 @@ main (int argc, char *argv[]) argc-=1; set_verbose(argc, argv); + /* quiet mode cannot be set in config file */ + if (really_quiet) + shut_up(); pdf_init_fontmaps(); /* This must come before parsing options... */ @@ -847,9 +877,6 @@ main (int argc, char *argv[]) do_args (argc, argv); - if (really_quiet) - shut_up(); - #ifndef MIKTEX kpse_init_prog("", font_dpi, NULL, NULL); kpse_set_program_enabled(kpse_pk_format, true, kpse_src_texmf_cnf); @@ -868,6 +895,7 @@ main (int argc, char *argv[]) MESG("%s -> %s\n", dvi_filename, pdf_filename); + pdf_enc_compute_id_string(dvi_filename, pdf_filename); if (do_encryption) { if (key_bits > 40 && pdf_get_version() < 4) ERROR("Chosen key length requires at least PDF 1.4. " @@ -880,6 +908,7 @@ main (int argc, char *argv[]) y_offset = 0.0; dvi2pts = 0.01; /* dvi2pts controls accuracy. */ } else { + unsigned ver_minor = 0; /* Dependency between DVI and PDF side is rather complicated... */ dvi2pts = dvi_init(dvi_filename, mag); if (dvi2pts == 0.0) @@ -887,7 +916,10 @@ main (int argc, char *argv[]) pdf_doc_set_creator(dvi_comment()); - dvi_scan_paper_size(0, &paper_width, &paper_height, &x_offset, &y_offset, &landscape_mode); + dvi_scan_specials(0, &paper_width, &paper_height, &x_offset, &y_offset, &landscape_mode, &ver_minor); + if (ver_minor >= PDF_VERSION_MIN && ver_minor <= PDF_VERSION_MAX) { + pdf_set_version(ver_minor); + } if (landscape_mode) { SWAP(paper_width, paper_height); } diff --git a/Build/source/texk/dvipdfmx/src/epdf.c b/Build/source/texk/dvipdfmx/src/epdf.c index 938ae319c27..aa2d8bf80f2 100644 --- a/Build/source/texk/dvipdfmx/src/epdf.c +++ b/Build/source/texk/dvipdfmx/src/epdf.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/epdf.c,v 1.28 2009/05/10 21:35:12 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/epdf.c,v 1.30 2009/09/19 18:48:27 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -57,7 +57,6 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file, const char *filename) xform_info info; pdf_obj *contents = NULL, *catalog; pdf_obj *page = NULL, *resources = NULL, *markinfo = NULL; - long page_no, count; pf = pdf_open(filename, image_file); if (!pf) @@ -68,9 +67,8 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file, const char *filename) pdf_ximage_init_form_info(&info); - page_no = pdf_ximage_get_page(ximage); - - page = pdf_doc_get_page(pf, &page_no, &count, &info.bbox, &resources); + page = pdf_doc_get_page(pf, pdf_ximage_get_page(ximage), NULL, + &info.bbox, &resources); if(!page) goto error_silent; @@ -89,12 +87,6 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file, const char *filename) pdf_release_obj(tmp); } - /* - * We must update ximage because page_no might have been changed - * by pdf_doc_get_page from negative to positive. - */ - pdf_ximage_set_page(ximage, page_no, count); - contents = pdf_deref_obj(pdf_lookup_dict(page, "Contents")); pdf_release_obj(page); diff --git a/Build/source/texk/dvipdfmx/src/fontmap.c b/Build/source/texk/dvipdfmx/src/fontmap.c index 76cfc8ad57d..2813fbc16c7 100644 --- a/Build/source/texk/dvipdfmx/src/fontmap.c +++ b/Build/source/texk/dvipdfmx/src/fontmap.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/fontmap.c,v 1.41 2008/11/30 21:12:27 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/fontmap.c,v 1.42 2009/09/18 23:56:02 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -743,7 +743,7 @@ pdf_append_fontmap_record (const char *kp, const fontmap_rec *vp) mrec->map_name = mstrdup(kp); /* link */ mrec->charmap.sfd_name = mstrdup(sfd_name); mrec->charmap.subfont_id = mstrdup(subfont_ids[n]); - ht_insert_table(fontmap, tfm_name, strlen(tfm_name), mrec, hval_free); + ht_insert_table(fontmap, tfm_name, strlen(tfm_name), mrec); } RELEASE(tfm_name); } @@ -759,7 +759,7 @@ pdf_append_fontmap_record (const char *kp, const fontmap_rec *vp) RELEASE(mrec->map_name); mrec->map_name = NULL; } - ht_insert_table(fontmap, kp, strlen(kp), mrec, hval_free); + ht_insert_table(fontmap, kp, strlen(kp), mrec); } if (verbose > 3) MESG("\n"); @@ -794,14 +794,14 @@ pdf_remove_fontmap_record (const char *kp) continue; if (verbose > 3) MESG(" %s", tfm_name); - ht_remove_table(fontmap, tfm_name, strlen(tfm_name), hval_free); + ht_remove_table(fontmap, tfm_name, strlen(tfm_name)); RELEASE(tfm_name); } RELEASE(fnt_name); RELEASE(sfd_name); } - ht_remove_table(fontmap, kp, strlen(kp), hval_free); + ht_remove_table(fontmap, kp, strlen(kp)); if (verbose > 3) MESG("\n"); @@ -847,7 +847,7 @@ pdf_insert_fontmap_record (const char *kp, const fontmap_rec *vp) mrec->map_name = mstrdup(kp); /* link to this entry */ mrec->charmap.sfd_name = mstrdup(sfd_name); mrec->charmap.subfont_id = mstrdup(subfont_ids[n]); - ht_insert_table(fontmap, tfm_name, strlen(tfm_name), mrec, hval_free); + ht_insert_table(fontmap, tfm_name, strlen(tfm_name), mrec); RELEASE(tfm_name); } RELEASE(fnt_name); @@ -860,7 +860,7 @@ pdf_insert_fontmap_record (const char *kp, const fontmap_rec *vp) RELEASE(mrec->map_name); mrec->map_name = NULL; } - ht_insert_table(fontmap, kp, strlen(kp), mrec, hval_free); + ht_insert_table(fontmap, kp, strlen(kp), mrec); if (verbose > 3) MESG("\n"); @@ -1101,14 +1101,14 @@ void pdf_init_fontmaps (void) { fontmap = NEW(1, struct ht_table); - ht_init_table(fontmap); + ht_init_table(fontmap, hval_free); } void pdf_close_fontmaps (void) { if (fontmap) { - ht_clear_table(fontmap, hval_free); + ht_clear_table(fontmap); RELEASE(fontmap); } fontmap = NULL; diff --git a/Build/source/texk/dvipdfmx/src/mem.c b/Build/source/texk/dvipdfmx/src/mem.c index c3a2cec8d10..078bc2fa619 100644 --- a/Build/source/texk/dvipdfmx/src/mem.c +++ b/Build/source/texk/dvipdfmx/src/mem.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/mem.c,v 1.7 2009/03/24 07:55:52 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/mem.c,v 1.8 2009/09/18 23:56:02 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -45,7 +45,7 @@ void mem_debug_init(void) mem_event = 0; mem_internal = 0; mem_ht = malloc(sizeof(struct ht_table)); - ht_init_table(mem_ht); + ht_init_table(mem_ht, NULL); fprintf(stderr, "*** Memory debugging started ***\n"); } @@ -69,18 +69,6 @@ void mem_debug_check(void) fprintf(stderr, "*** End of used memory ***\n"); } -static void -mem_noop (void *vp) -{ -} - -static void -mem_error (void *vp) -{ - ERROR("Internal memory debugging error\n1: %s\n2: %s\n", - vp, (char *) vp, mem_str); -} - void *mem_add(void *ptr, const char *file, const char *function, int line) { if (ptr && !mem_internal) { mem_internal = 1; @@ -96,7 +84,7 @@ void *mem_add(void *ptr, const char *file, const char *function, int line) { , __builtin_return_address(1) //, __builtin_return_address(2) #endif ); - ht_insert_table(mem_ht, p, sizeof(ptr), mem_str, mem_error); + ht_append_table(mem_ht, p, sizeof(ptr), mem_str); mem_internal = 0; } @@ -106,7 +94,7 @@ void *mem_add(void *ptr, const char *file, const char *function, int line) { void *mem_remove(void *ptr, const char *file, const char *function, int line) { if (ptr && !mem_internal) { mem_internal = 1; - if (!(mem_ht && ht_remove_table(mem_ht, &ptr, sizeof(ptr), mem_noop))) { + if (!(mem_ht && ht_remove_table(mem_ht, &ptr, sizeof(ptr)))) { WARN("Trying to free non-allocated memory\n" "%p %s (%s, %d)" #ifdef __GNUC__ diff --git a/Build/source/texk/dvipdfmx/src/mem.h b/Build/source/texk/dvipdfmx/src/mem.h index 6380e9e9125..852a011e168 100644 --- a/Build/source/texk/dvipdfmx/src/mem.h +++ b/Build/source/texk/dvipdfmx/src/mem.h @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/mem.h,v 1.5 2007/11/17 18:08:58 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/mem.h,v 1.6 2009/11/29 01:18:20 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -33,8 +33,6 @@ extern void *renew (void *p, size_t size); extern void mem_debug_init(void); extern void mem_debug_check(void); -#undef MEM_DEBUG - #ifdef MEM_DEBUG extern void *mem_add (void *ptr, diff --git a/Build/source/texk/dvipdfmx/src/pdfdoc.c b/Build/source/texk/dvipdfmx/src/pdfdoc.c index 2aa3af1150c..ceac03466ac 100644 --- a/Build/source/texk/dvipdfmx/src/pdfdoc.c +++ b/Build/source/texk/dvipdfmx/src/pdfdoc.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.c,v 1.70 2009/05/04 00:41:42 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.c,v 1.75 2010/03/28 06:42:59 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -929,12 +929,11 @@ pdf_doc_close_page_tree (pdf_doc *p) */ pdf_obj * -pdf_doc_get_page (pdf_file *pf, long *page_p, long *count_p, +pdf_doc_get_page (pdf_file *pf, long page_no, long *count_p, pdf_rect *bbox, pdf_obj **resources_p) { pdf_obj *page_tree = NULL; pdf_obj *resources = NULL, *box = NULL, *rotate = NULL; pdf_obj *catalog; - long page_no = *page_p, page_idx; catalog = pdf_file_get_catalog(pf); @@ -943,12 +942,9 @@ pdf_doc_get_page (pdf_file *pf, long *page_p, long *count_p, if (!PDF_OBJ_DICTTYPE(page_tree)) goto error; - /* - * Negative page numbers are counted from the back. - */ { - pdf_obj *tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "Count")); long count; + pdf_obj *tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "Count")); if (!PDF_OBJ_NUMBERTYPE(tmp)) { if (tmp) pdf_release_obj(tmp); @@ -956,14 +952,12 @@ pdf_doc_get_page (pdf_file *pf, long *page_p, long *count_p, } count = pdf_number_value(tmp); pdf_release_obj(tmp); - page_idx = page_no + (page_no >= 0 ? -1 : count); - if (page_idx < 0 || page_idx >= count) { + if (count_p) + *count_p = count; + if (page_no <= 0 || page_no > count) { WARN("Page %ld does not exist.", page_no); goto error_silent; } - page_no = page_idx+1; - *page_p = page_no; - *count_p = count; } /* @@ -973,7 +967,7 @@ pdf_doc_get_page (pdf_file *pf, long *page_p, long *count_p, { pdf_obj *media_box = NULL, *crop_box = NULL, *kids, *tmp; int depth = PDF_OBJ_MAX_DEPTH; - long kids_length = 1, i = 0; + long page_idx = page_no-1, kids_length = 1, i = 0; while (--depth && i != kids_length) { if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "MediaBox")))) { @@ -1429,7 +1423,7 @@ pdf_doc_init_names (pdf_doc *p, int check_gotos) p->names[NUM_NAME_CATEGORY].data = NULL; p->check_gotos = check_gotos; - ht_init_table(&p->gotos); + ht_init_table(&p->gotos, (void (*) (void *)) pdf_release_obj); return; } @@ -1531,8 +1525,7 @@ pdf_doc_add_goto (pdf_obj *annot_dict) */ sprintf(buf, "%lx", ht_table_size(&pdoc.gotos)); D_new = pdf_new_string(buf, strlen(buf)); - ht_insert_table(&pdoc.gotos, dest, strlen(dest), - D_new, (void (*) (void *)) pdf_release_obj); + ht_append_table(&pdoc.gotos, dest, strlen(dest), D_new); } { @@ -1644,7 +1637,7 @@ pdf_doc_close_names (pdf_doc *p) RELEASE(p->names); p->names = NULL; - ht_clear_table(&p->gotos, (void (*) (void *)) pdf_release_obj); + ht_clear_table(&p->gotos); return; } @@ -2413,9 +2406,10 @@ pdf_open_document (const char *filename, if (do_encryption) { pdf_obj *encrypt = pdf_encrypt_obj(); - pdf_set_encrypt(encrypt, pdf_enc_id_array()); + pdf_set_encrypt(encrypt); pdf_release_obj(encrypt); } + pdf_set_id(pdf_enc_id_array()); /* Create a default name for thumbnail image files */ if (manual_thumb_enabled) { diff --git a/Build/source/texk/dvipdfmx/src/pdfdoc.h b/Build/source/texk/dvipdfmx/src/pdfdoc.h index b824888bd9e..e6d06ed648b 100644 --- a/Build/source/texk/dvipdfmx/src/pdfdoc.h +++ b/Build/source/texk/dvipdfmx/src/pdfdoc.h @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.h,v 1.31 2009/05/04 00:41:43 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.h,v 1.33 2009/09/19 18:48:27 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -56,8 +56,7 @@ extern pdf_obj *pdf_doc_get_reference (const char *category); #define pdf_doc_names() pdf_doc_get_dictionary("Names") #define pdf_doc_this_page() pdf_doc_get_dictionary("@THISPAGE") -extern pdf_obj *pdf_doc_get_page (pdf_file *pf, - long *page_p, long *count_p, +extern pdf_obj *pdf_doc_get_page (pdf_file *pf, long page_no, long *count_p, pdf_rect *bbox, pdf_obj **resources_p); extern long pdf_doc_current_page_number (void); diff --git a/Build/source/texk/dvipdfmx/src/pdfdraw.c b/Build/source/texk/dvipdfmx/src/pdfdraw.c index 6474282ffe1..b3e16963420 100644 --- a/Build/source/texk/dvipdfmx/src/pdfdraw.c +++ b/Build/source/texk/dvipdfmx/src/pdfdraw.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfdraw.c,v 1.19 2009/03/16 22:26:40 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfdraw.c,v 1.20 2009/11/28 17:17:30 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -992,7 +992,7 @@ m_stack_top (m_stack *stack) return data; } -#define m_stack_depth(s) ((s) ? (s)->size : 0) +#define m_stack_depth(s) (((s) != NULL) ? (s)->size : 0) static m_stack gs_stack; diff --git a/Build/source/texk/dvipdfmx/src/pdfencrypt.c b/Build/source/texk/dvipdfmx/src/pdfencrypt.c index 87fa644f007..0f07683c2e9 100644 --- a/Build/source/texk/dvipdfmx/src/pdfencrypt.c +++ b/Build/source/texk/dvipdfmx/src/pdfencrypt.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfencrypt.c,v 1.13 2009/03/27 23:47:01 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfencrypt.c,v 1.14 2010/02/07 12:58:48 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -79,8 +79,8 @@ void pdf_enc_set_verbose (void) if (verbose < 255) verbose++; } -#define PRODUCER "%s-%s, Copyright \251 2002 by Jin-Hwan Cho and Shunsaku Hirata" -static void compute_id_string (char *dviname, char *pdfname) +#define PRODUCER "%s-%s, Copyright \251 2002-2010 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata" +void pdf_enc_compute_id_string (char *dviname, char *pdfname) { char *date_string, *producer; time_t current_time; @@ -394,7 +394,6 @@ void pdf_enc_set_passwd (unsigned bits, unsigned perm, char *dviname, char *pdfn if (revision == 3) permission |= ~0xFFFL; - compute_id_string(dviname, pdfname); compute_owner_password(); compute_user_password(); } diff --git a/Build/source/texk/dvipdfmx/src/pdfencrypt.h b/Build/source/texk/dvipdfmx/src/pdfencrypt.h index b0c9a429223..7abdc433dad 100644 --- a/Build/source/texk/dvipdfmx/src/pdfencrypt.h +++ b/Build/source/texk/dvipdfmx/src/pdfencrypt.h @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfencrypt.h,v 1.3 2007/04/03 05:25:50 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfencrypt.h,v 1.4 2010/02/07 12:53:44 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -27,6 +27,7 @@ extern void pdf_enc_set_verbose (void); extern pdf_obj *pdf_enc_id_array (void); +extern void pdf_enc_compute_id_string (char *dviname, char *pdfname); extern void pdf_enc_set_label (unsigned long label); extern void pdf_enc_set_generation (unsigned generation); extern void pdf_enc_set_passwd (unsigned size, unsigned perm, char *dviname, char *pdfname); diff --git a/Build/source/texk/dvipdfmx/src/pdfnames.c b/Build/source/texk/dvipdfmx/src/pdfnames.c index 905664cc948..16468b24bb8 100644 --- a/Build/source/texk/dvipdfmx/src/pdfnames.c +++ b/Build/source/texk/dvipdfmx/src/pdfnames.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfnames.c,v 1.6 2009/04/26 21:23:29 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfnames.c,v 1.7 2009/09/18 23:56:02 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -73,13 +73,30 @@ printable_key (const char *key, int keylen) return (char *) pkey; } +static void CDECL +hval_free (void *hval) +{ + struct obj_data *value; + + value = (struct obj_data *) hval; + + if (value->object) { + pdf_release_obj(value->object); + value->object = NULL; + } + + RELEASE(value); + + return; +} + struct ht_table * pdf_new_name_tree (void) { struct ht_table *names; names = NEW(1, struct ht_table); - ht_init_table(names); + ht_init_table(names, hval_free); return names; } @@ -108,23 +125,6 @@ check_objects_defined (struct ht_table *ht_tab) } } -static void CDECL -hval_free (void *hval) -{ - struct obj_data *value; - - value = (struct obj_data *) hval; - - if (value->object) { - pdf_release_obj(value->object); - value->object = NULL; - } - - RELEASE(value); - - return; -} - void pdf_delete_name_tree (struct ht_table **names) { @@ -132,7 +132,7 @@ pdf_delete_name_tree (struct ht_table **names) check_objects_defined(*names); - ht_clear_table(*names, hval_free); + ht_clear_table(*names); RELEASE(*names); *names = NULL; } diff --git a/Build/source/texk/dvipdfmx/src/pdfobj.c b/Build/source/texk/dvipdfmx/src/pdfobj.c index 7f4915aceb4..8a340352f4b 100644 --- a/Build/source/texk/dvipdfmx/src/pdfobj.c +++ b/Build/source/texk/dvipdfmx/src/pdfobj.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.c,v 1.70 2009/05/06 06:07:09 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.c,v 1.72 2010/02/07 12:53:44 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -505,14 +505,20 @@ pdf_set_info (pdf_obj *object) } void -pdf_set_encrypt (pdf_obj *encrypt, pdf_obj *id) +pdf_set_id (pdf_obj *id) +{ + if (pdf_add_dict(trailer_dict, pdf_new_name("ID"), id)) { + ERROR ("ID already set!"); + } +} + +void +pdf_set_encrypt (pdf_obj *encrypt) { if (pdf_add_dict(trailer_dict, pdf_new_name("Encrypt"), pdf_ref_obj(encrypt))) { ERROR("Encrypt object already set!"); } encrypt->flags |= OBJ_NO_ENCRYPT; - - pdf_add_dict(trailer_dict, pdf_new_name("ID"), id); } static @@ -2888,7 +2894,7 @@ void pdf_files_init (void) { pdf_files = NEW(1, struct ht_table); - ht_init_table(pdf_files); + ht_init_table(pdf_files, (void (*)(void *)) pdf_file_free); } int @@ -2990,7 +2996,7 @@ void pdf_files_close (void) { ASSERT(pdf_files); - ht_clear_table(pdf_files, (void (*)(void *)) pdf_file_free); + ht_clear_table(pdf_files); RELEASE(pdf_files); } diff --git a/Build/source/texk/dvipdfmx/src/pdfobj.h b/Build/source/texk/dvipdfmx/src/pdfobj.h index a50220bfcd8..3afe6c91d21 100644 --- a/Build/source/texk/dvipdfmx/src/pdfobj.h +++ b/Build/source/texk/dvipdfmx/src/pdfobj.h @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.h,v 1.34 2009/05/03 00:13:04 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.h,v 1.35 2010/02/07 12:53:44 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -185,8 +185,9 @@ extern int pdf_compare_reference (pdf_obj *ref1, pdf_obj *ref2); extern void pdf_set_compression (int level); extern void pdf_set_info (pdf_obj *obj); +extern void pdf_set_id (pdf_obj *id); extern void pdf_set_root (pdf_obj *obj); -extern void pdf_set_encrypt (pdf_obj *encrypt, pdf_obj *id); +extern void pdf_set_encrypt (pdf_obj *encrypt); extern void pdf_files_init (void); extern void pdf_files_close (void); diff --git a/Build/source/texk/dvipdfmx/src/pdfximage.c b/Build/source/texk/dvipdfmx/src/pdfximage.c index 8052e1a9bb0..798ffd577af 100644 --- a/Build/source/texk/dvipdfmx/src/pdfximage.c +++ b/Build/source/texk/dvipdfmx/src/pdfximage.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.c,v 1.25 2009/07/07 11:48:34 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.c,v 1.26 2009/08/24 01:38:26 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -48,7 +48,7 @@ /* From psimage.h */ static int check_for_ps (FILE *fp); -static int ps_include_page (pdf_ximage *ximage, const char *file_name); +static int ps_include_page (pdf_ximage *ximage); #define IMAGE_TYPE_UNKNOWN -1 @@ -71,7 +71,7 @@ struct pdf_ximage_ { char *ident; char res_name[16]; - long page_no, page_count; + long page_no; int subtype; @@ -81,6 +81,8 @@ struct pdf_ximage_ pdf_obj *reference; pdf_obj *resource; pdf_obj *attr_dict; + + char tempfile; }; @@ -109,14 +111,16 @@ static struct ic_ _ic = { }; static void -pdf_init_ximage_struct (pdf_ximage *I, const char *ident, const char *filename, pdf_obj *dict) +pdf_init_ximage_struct (pdf_ximage *I, + const char *ident, const char *filename, + long page_no, pdf_obj *dict) { if (ident) { I->ident = NEW(strlen(ident)+1, char); strcpy(I->ident, ident); } else I ->ident = NULL; - I->page_no = I->page_count = 0; + I->page_no = page_no; if (filename) { I->filename = NEW(strlen(filename)+1, char); strcpy(I->filename, filename); @@ -132,6 +136,18 @@ pdf_init_ximage_struct (pdf_ximage *I, const char *ident, const char *filename, I->attr.xdensity = I->attr.ydensity = 1.0; I->attr.bbox.llx = I->attr.bbox.lly = 0; I->attr.bbox.urx = I->attr.bbox.ury = 0; + + I->tempfile = 0; +} + +static void +pdf_set_ximage_tempfile (pdf_ximage *I, const char *filename) +{ + if (I->filename) + RELEASE(I->filename); + I->filename = NEW(strlen(filename)+1, char); + strcpy(I->filename, filename); + I->tempfile = 1; } static void @@ -147,7 +163,7 @@ pdf_clean_ximage_struct (pdf_ximage *I) pdf_release_obj(I->resource); if (I->attr_dict) pdf_release_obj(I->attr_dict); - pdf_init_ximage_struct(I, NULL, NULL, NULL); + pdf_init_ximage_struct(I, NULL, NULL, 0, NULL); } @@ -166,12 +182,28 @@ pdf_close_images (void) struct ic_ *ic = &_ic; if (ic->ximages) { int i; - for (i = 0; i < ic->count; i++) - pdf_clean_ximage_struct(&ic->ximages[i]); + for (i = 0; i < ic->count; i++) { + pdf_ximage *I = ic->ximages+i; + if (I->tempfile) { + /* + * It is important to remove temporary files at the end because + * we cache file names. Since we use mkstemp to create them, we + * might get the same file name again if delete the first file. + * (This happens on NetBSD, reported by Jukka Salmi.) + * We also use this to convert a PS file only once if multiple + * pages are imported from that file. + */ + if (_opts.verbose > 1) + MESG("pdf_image>> deleting temporary file \"%s\"\n", I->filename); + dpx_delete_temp_file(I->filename); /* temporary filename freed here */ + I->filename = NULL; + } + pdf_clean_ximage_struct(I); + } RELEASE(ic->ximages); + ic->ximages = NULL; + ic->count = ic->capacity = 0; } - ic->ximages = NULL; - ic->count = ic->capacity = 0; if (_opts.cmdtmpl) RELEASE(_opts.cmdtmpl); @@ -231,8 +263,7 @@ load_image (const char *ident, const char *fullname, int format, FILE *fp, } I = &ic->ximages[id]; - pdf_init_ximage_struct(I, ident, ident, dict); - pdf_ximage_set_page(I, page_no, 0); + pdf_init_ximage_struct(I, ident, fullname, page_no, dict); switch (format) { case IMAGE_TYPE_JPEG: @@ -262,10 +293,10 @@ load_image (const char *ident, const char *fullname, int format, FILE *fp, if (_opts.verbose) MESG("[PDF]"); { - int result = pdf_include_page(I, fp, ident); + int result = pdf_include_page(I, fp, fullname); if (result > 0) /* PDF version too recent */ - result = ps_include_page(I, fullname); + result = ps_include_page(I); if (result < 0) goto error; } @@ -277,7 +308,7 @@ load_image (const char *ident, const char *fullname, int format, FILE *fp, default: if (_opts.verbose) MESG(format == IMAGE_TYPE_EPS ? "[PS]" : "[UNKNOWN]"); - if (ps_include_page(I, fullname) < 0) + if (ps_include_page(I) < 0) goto error; if (_opts.verbose) MESG(",Page:%ld", I->page_no); @@ -316,24 +347,31 @@ pdf_ximage_findresource (const char *ident, long page_no, pdf_obj *dict) struct ic_ *ic = &_ic; int id = -1; pdf_ximage *I; - char *fullname; + char *fullname, *f = NULL; int format; FILE *fp; for (id = 0; id < ic->count; id++) { I = &ic->ximages[id]; - if (I->ident && !strcmp(ident, I->ident) && - I->page_no == page_no + (page_no < 0 ? I->page_count+1 : 0) && - I->attr_dict == dict) { - return id; + if (I->ident && !strcmp(ident, I->ident)) { + f = I->filename; + if (I->page_no == page_no && I->attr_dict == dict) { + return id; + } } } - /* try loading image */ - fullname = dpx_find_file(ident, "_pic_", ""); - if (!fullname) { - WARN("Error locating image file \"%s\"", ident); - return -1; + if (f) { + /* we already have converted this file; f is the temporary file name */ + fullname = NEW(strlen(f)+1, char); + strcpy(fullname, f); + } else { + /* try loading image */ + fullname = dpx_find_file(ident, "_pic_", ""); + if (!fullname) { + WARN("Error locating image file \"%s\"", ident); + return -1; + } } fp = dpx_fopen(fullname, FOPEN_RBIN_MODE); @@ -505,14 +543,6 @@ pdf_ximage_get_page (pdf_ximage *I) return I->page_no; } -void -pdf_ximage_set_page (pdf_ximage *I, long page_no, long page_count) -{ - I->page_no = page_no; - I->page_count = page_count; -} - - #define CHECK_ID(c,n) do {\ if ((n) < 0 || (n) >= (c)->count) {\ ERROR("Invalid XObject ID: %d", (n));\ @@ -552,7 +582,7 @@ pdf_ximage_defineresource (const char *ident, I = &ic->ximages[id]; - pdf_init_ximage_struct(I, ident, NULL, NULL); + pdf_init_ximage_struct(I, ident, NULL, 0, NULL); switch (subtype) { case PDF_XOBJECT_TYPE_IMAGE: @@ -832,9 +862,10 @@ void set_distiller_template (char *s) } static int -ps_include_page (pdf_ximage *ximage, const char *filename) +ps_include_page (pdf_ximage *ximage) { char *distiller_template = _opts.cmdtmpl; + char *filename = ximage->filename; char *temp; FILE *fp; int error = 0; @@ -872,13 +903,13 @@ ps_include_page (pdf_ximage *ximage, const char *filename) dpx_delete_temp_file(temp); return -1; } + pdf_set_ximage_tempfile(ximage, temp); error = pdf_include_page(ximage, fp, temp); MFCLOSE(fp); - if (_opts.verbose > 1) { - MESG("pdf_image>> deleting file \"%s\"", temp); - } - dpx_delete_temp_file(temp); /* temp freed here */ + /* See pdf_close_images for why we cannot delete temporary files here. */ + + RELEASE(temp); if (error) { WARN("Failed to include image file \"%s\"", filename); diff --git a/Build/source/texk/dvipdfmx/src/pdfximage.h b/Build/source/texk/dvipdfmx/src/pdfximage.h index 3d320907a6b..730fa013cac 100644 --- a/Build/source/texk/dvipdfmx/src/pdfximage.h +++ b/Build/source/texk/dvipdfmx/src/pdfximage.h @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.h,v 1.16 2009/07/07 11:48:34 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.h,v 1.18 2009/09/19 18:43:04 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -73,7 +73,6 @@ extern void pdf_ximage_init_image_info (ximage_info *info); extern void pdf_ximage_init_form_info (xform_info *info); extern void pdf_ximage_set_image (pdf_ximage *ximage, void *info, pdf_obj *resource); extern void pdf_ximage_set_form (pdf_ximage *ximage, void *info, pdf_obj *resource); -extern void pdf_ximage_set_page (pdf_ximage *ximage, long page_no, long page_count); extern long pdf_ximage_get_page (pdf_ximage *I); /* from psimage.h */ @@ -90,6 +89,6 @@ pdf_ximage_scale_image (int id, extern void pdf_ximage_disable_ebb (void); /* from spc_pdfm.c */ -extern void pdf_ximgge_get_subtype (int xobj_id); +extern int pdf_ximage_get_subtype (int xobj_id); extern void pdf_ximage_set_attr (int xobj_id, long width, long height, double xdensity, double ydensity, double llx, double lly, double urx, double ury); #endif /* _PDFXIMAGE_H_ */ diff --git a/Build/source/texk/dvipdfmx/src/pngimage.c b/Build/source/texk/dvipdfmx/src/pngimage.c index a72a622b825..8ed846b7c6d 100644 --- a/Build/source/texk/dvipdfmx/src/pngimage.c +++ b/Build/source/texk/dvipdfmx/src/pngimage.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pngimage.c,v 1.27 2009/05/10 17:04:54 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pngimage.c,v 1.28 2010/02/23 03:28:10 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. diff --git a/Build/source/texk/dvipdfmx/src/spc_dvips.c b/Build/source/texk/dvipdfmx/src/spc_dvips.c index da4c84b3f68..2802ec468d9 100644 --- a/Build/source/texk/dvipdfmx/src/spc_dvips.c +++ b/Build/source/texk/dvipdfmx/src/spc_dvips.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/spc_dvips.c,v 1.12 2008/11/30 21:17:58 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/spc_dvips.c,v 1.13 2009/11/28 22:41:44 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include <string.h> + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -149,7 +151,7 @@ spc_handler_ps_plotfile (struct spc_env *spe, struct spc_arg *args) ASSERT(spe && args); - spc_warn(spe, "ps:plotfile found (not properly implemented)"); + spc_warn(spe, "\"ps: plotfile\" found (not properly implemented)"); skip_white(&args->curptr, args->endptr); filename = parse_filename(&args->curptr, args->endptr); @@ -185,10 +187,7 @@ spc_handler_ps_literal (struct spc_env *spe, struct spc_arg *args) int st_depth, gs_depth; double x_user, y_user; - ASSERT(spe && args); - - if (args->curptr >= args->endptr) - return -1; + ASSERT(spe && args && args->curptr <= args->endptr); if (args->curptr + strlen(":[begin]") <= args->endptr && !strncmp(args->curptr, ":[begin]", strlen(":[begin]"))) { @@ -286,8 +285,8 @@ spc_handler_ps_default (struct spc_env *spe, struct spc_arg *args) static struct spc_handler dvips_handlers[] = { {"PSfile", spc_handler_ps_file}, {"psfile", spc_handler_ps_file}, - {"ps: plotfile", spc_handler_ps_plotfile}, /* FIXME */ - {"PS: plotfile", spc_handler_ps_plotfile}, /* FIXME */ + {"ps: plotfile ", spc_handler_ps_plotfile}, + {"PS: plotfile ", spc_handler_ps_plotfile}, {"PS:", spc_handler_ps_literal}, {"ps:", spc_handler_ps_literal}, {"\" ", spc_handler_ps_default} @@ -342,10 +341,14 @@ spc_dvips_setup_handler (struct spc_handler *handle, isalpha(args->curptr[0])) { args->curptr++; } - /* ps:: --> : */ + /* Test for "ps:". The "ps::" special is subsumed under this case. */ if (args->curptr < args->endptr && args->curptr[0] == ':') { args->curptr++; + if (args->curptr+strlen(" plotfile ") <= args->endptr && + !strncmp(args->curptr, " plotfile ", strlen(" plotfile "))) { + args->curptr += strlen(" plotfile "); + } } else if (args->curptr+1 < args->endptr && args->curptr[0] == '"' && args->curptr[1] == ' ') { args->curptr += 2; diff --git a/Build/source/texk/dvipdfmx/src/spc_pdfm.c b/Build/source/texk/dvipdfmx/src/spc_pdfm.c index da5f242296b..b2c9eedba59 100644 --- a/Build/source/texk/dvipdfmx/src/spc_pdfm.c +++ b/Build/source/texk/dvipdfmx/src/spc_pdfm.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/spc_pdfm.c,v 1.50 2009/07/07 11:48:34 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/spc_pdfm.c,v 1.52 2010/03/28 06:03:57 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -150,7 +150,7 @@ spc_handler_pdfm__init (struct spc_env *spe, struct spc_arg *ap, void *dp) sd->annot_dict = NULL; sd->lowest_level = 255; sd->resourcemap = NEW(1, struct ht_table); - ht_init_table(sd->resourcemap); + ht_init_table(sd->resourcemap, hval_free); #ifdef ENABLE_TOUNICODE sd->cd.taintkeys = pdf_new_array(); @@ -175,7 +175,7 @@ spc_handler_pdfm__clean (struct spc_env *spe, struct spc_arg *ap, void *dp) sd->lowest_level = 255; sd->annot_dict = NULL; if (sd->resourcemap) { - ht_clear_table(sd->resourcemap, hval_free); + ht_clear_table(sd->resourcemap); RELEASE(sd->resourcemap); } sd->resourcemap = NULL; @@ -1349,6 +1349,13 @@ spc_handler_pdfm_code (struct spc_env *spe, struct spc_arg *args) return 0; } +static int +spc_handler_pdfm_do_nothing (struct spc_env *spe, struct spc_arg *args) +{ + args->curptr = args->endptr; + return 0; +} + #define STRING_STREAM 0 #define FILE_STREAM 1 @@ -1944,6 +1951,8 @@ static struct spc_handler pdfm_handlers[] = { {"bcontent", spc_handler_pdfm_bcontent}, {"econtent", spc_handler_pdfm_econtent}, {"code", spc_handler_pdfm_code}, + + {"minorversion", spc_handler_pdfm_do_nothing}, }; int diff --git a/Build/source/texk/dvipdfmx/src/truetype.c b/Build/source/texk/dvipdfmx/src/truetype.c index d8811ddb0e3..a76f7ec272f 100644 --- a/Build/source/texk/dvipdfmx/src/truetype.c +++ b/Build/source/texk/dvipdfmx/src/truetype.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/truetype.c,v 1.10 2008/05/22 11:03:09 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/truetype.c,v 1.11 2009/08/28 00:26:17 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -254,7 +254,7 @@ do_widths (pdf_font *font, double *widths) else width = 1000. * tfm_get_width(tfm_id, code); pdf_add_array(tmparray, - pdf_new_number(ROUND(width, 1.0))); + pdf_new_number(ROUND(width, 0.1))); } else { pdf_add_array(tmparray, pdf_new_number(0.0)); } diff --git a/Build/source/texk/dvipdfmx/src/tt_cmap.c b/Build/source/texk/dvipdfmx/src/tt_cmap.c index ff1aa9ba664..c887e039e17 100644 --- a/Build/source/texk/dvipdfmx/src/tt_cmap.c +++ b/Build/source/texk/dvipdfmx/src/tt_cmap.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/tt_cmap.c,v 1.26 2008/05/08 18:51:59 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/tt_cmap.c,v 1.27 2009/09/18 23:56:02 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -1801,7 +1801,7 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon load_gsub(opt_conf, gsub_list, sfont); } - ht_init_table(&unencoded); + ht_init_table(&unencoded, hval_free); handle_gsub(conf, ttcmap, gsub_list, &unencoded); if (opt_tag) { @@ -1831,7 +1831,7 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon } create_cmaps(cmap, tounicode, &unencoded, GIDToCIDMap); - ht_clear_table(&unencoded, hval_free); + ht_clear_table(&unencoded); RELEASE(conf_name); } diff --git a/Build/source/texk/dvipdfmx/src/tt_post.c b/Build/source/texk/dvipdfmx/src/tt_post.c index 489e77bccd6..aa06f2e2500 100644 --- a/Build/source/texk/dvipdfmx/src/tt_post.c +++ b/Build/source/texk/dvipdfmx/src/tt_post.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/tt_post.c,v 1.2 2004/09/11 15:23:48 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/tt_post.c,v 1.3 2009/08/17 00:49:45 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. diff --git a/Build/source/texk/dvipdfmx/src/type1.c b/Build/source/texk/dvipdfmx/src/type1.c index b5e683092aa..89e4e7d80ca 100644 --- a/Build/source/texk/dvipdfmx/src/type1.c +++ b/Build/source/texk/dvipdfmx/src/type1.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/type1.c,v 1.45 2008/10/13 19:42:48 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/type1.c,v 1.47 2010/02/08 02:51:37 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -335,7 +335,7 @@ add_metrics (pdf_font *font, cff_font *cffont, char **enc_vec, double *widths, l else width = 1000. * tfm_get_width(tfm_id, code); pdf_add_array(tmp_array, - pdf_new_number(ROUND(width, 1.0))); + pdf_new_number(ROUND(width, 0.1))); } else { pdf_add_array(tmp_array, pdf_new_number(0.0)); } @@ -381,7 +381,8 @@ write_fontfile (pdf_font *font, cff_font *cffont, long num_glyphs) if (!cff_dict_known(cffont->topdict, "Encoding")) cff_dict_add(cffont->topdict, "Encoding", 1); private_size = cff_dict_pack((cffont->private)[0], wbuf, WBUF_SIZE); - if (private_size > 0 && !cff_dict_known(cffont->topdict, "Private")) + /* Private dict is required (but may have size 0) */ + if (!cff_dict_known(cffont->topdict, "Private")) cff_dict_add(cffont->topdict, "Private", 2); topdict->offset[1] = cff_dict_pack(cffont->topdict, wbuf, WBUF_SIZE) + 1; diff --git a/Build/source/texk/dvipdfmx/src/type1c.c b/Build/source/texk/dvipdfmx/src/type1c.c index 979336c1975..081f0a4870b 100644 --- a/Build/source/texk/dvipdfmx/src/type1c.c +++ b/Build/source/texk/dvipdfmx/src/type1c.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/type1c.c,v 1.29 2008/10/13 19:42:48 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/type1c.c,v 1.30 2009/08/28 00:26:17 matthias Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -203,7 +203,7 @@ add_SimpleMetrics (pdf_font *font, cff_font *cffont, else width = 1000. * tfm_get_width(tfm_id, code); pdf_add_array(tmp_array, - pdf_new_number(ROUND(width, 1.0))); + pdf_new_number(ROUND(width, 0.1))); } else { pdf_add_array(tmp_array, pdf_new_number(0.0)); } diff --git a/Build/source/texk/dvipdfmx/src/xbb.c b/Build/source/texk/dvipdfmx/src/xbb.c index 70a87f0344a..efe4f8096b3 100644 --- a/Build/source/texk/dvipdfmx/src/xbb.c +++ b/Build/source/texk/dvipdfmx/src/xbb.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/xbb.c,v 1.26 2009/05/10 17:04:54 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/xbb.c,v 1.29 2009/10/10 09:58:48 chofchof Exp $ This is extractbb, a bounding box extraction program. - Copyright (C) 2008 by Jin-Hwan Cho <chofchof@ktug.or.kr> + Copyright (C) 2009 by Jin-Hwan Cho and Matthias Franz This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,6 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include <stdio.h> #include <time.h> #include <string.h> @@ -45,24 +46,35 @@ static int really_quiet = 0; +static void show_version(void) +{ + if (really_quiet) return; + + fprintf(stdout, "%s, version %s, Copyright (C) 2009 by Jin-Hwan Cho and Matthias Franz\n", XBB_PROGRAM, XBB_VERSION); + fprintf(stdout, "A bounding box extraction utility from PDF, PNG, and JPEG.\n"); + fprintf(stdout, "\nThis is free software; you can redistribute it and/or modify\n"); + fprintf(stdout, "it under the terms of the GNU General Public License as published by\n"); + fprintf(stdout, "the Free Software Foundation; either version 2 of the License, or\n"); + fprintf(stdout, "(at your option) any later version.\n"); +} + +static void show_usage(void) +{ + if (really_quiet) return; + + fprintf(stdout, "\nUsage: %s [-v|-q] [-O] [-m|-x] [files]\n", XBB_PROGRAM); + fprintf(stdout, "\t-v\tBe verbose\n"); + fprintf(stdout, "\t-q\tBe quiet\n"); + fprintf(stdout, "\t-O\tWrite output to stdout\n"); + fprintf(stdout, "\t-m\tOutput .bb file used in DVIPDFM\n"); + fprintf(stdout, "\t-x\tOutput .xbb file used in DVIPDFMx (default)\n"); +} + static void usage(void) { - if (really_quiet) - return; + if (really_quiet) return; - printf("%s, version %s, Copyright (C) 2008 by Jin-Hwan Cho\n", - XBB_PROGRAM, XBB_VERSION); - printf("A bounding box extraction utility from PDF, PNG, and JPEG.\n"); - printf("\nThis is free software; you can redistribute it and/or modify\n"); - printf("it under the terms of the GNU General Public License as published by\n"); - printf("the Free Software Foundation; either version 2 of the License, or\n"); - printf("(at your option) any later version.\n"); - printf("\nUsage: %s [-v|-q] [-O] [-m|-x] [files]\n", XBB_PROGRAM); - printf("\t-v\tBe verbose\n"); - printf("\t-q\tBe quiet\n"); - printf("\t-O\tWrite output to stdout\n"); - printf("\t-m\tOutput .bb file used in DVIPDFM\n"); - printf("\t-x\tOutput .xbb file used in DVIPDFMx (default)\n"); + fprintf(stdout, "\nTry \"%s --help\" for more information.\n", XBB_PROGRAM); exit(1); } @@ -206,7 +218,7 @@ static void do_pdf (FILE *fp, char *filename) return; } - page = pdf_doc_get_page(pf, &page_no, &count, &bbox, NULL); + page = pdf_doc_get_page(pf, page_no, &count, &bbox, NULL); pdf_close(pf); @@ -233,7 +245,23 @@ int extractbb (int argc, char *argv[]) usage(); while (argc > 0 && *argv[0] == '-') { - switch (*(argv[0]+1)) { + char *flag = argv[0] + 1; + switch (*flag) { + case '-': + if (++flag) { + if (!strcmp(flag, "help")) { + show_version(); + show_usage(); + exit(0); + } else if (!strcmp(flag, "version")) { + show_version(); + exit(0); + } + } + if (!really_quiet) + fprintf(stderr, "Unknown option in \"--%s\"", flag); + usage(); + break; case 'O': xbb_to_file = 0; argc -= 1; argv += 1; @@ -267,6 +295,8 @@ int extractbb (int argc, char *argv[]) } /* else fall through */ default: + if (!really_quiet) + fprintf(stderr, "Unknown option in \"-%s\"", flag); usage(); } } |