From d028ec401e5bef3c2504f3fc95d65f632c8cfd53 Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Sun, 8 May 2016 13:35:57 +0000 Subject: dvipdfm-x: patch from M. Hosoda. git-svn-id: svn://tug.org/texlive/trunk@40941 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/dvipdfm-x/ChangeLog | 8 +++ Build/source/texk/dvipdfm-x/Makefile.am | 2 + Build/source/texk/dvipdfm-x/Makefile.in | 21 +++--- Build/source/texk/dvipdfm-x/dvi.c | 13 +++- Build/source/texk/dvipdfm-x/dvipdfmx.c | 37 ++++++++++ Build/source/texk/dvipdfm-x/dvipdfmx.h | 1 + Build/source/texk/dvipdfm-x/spc_dvipdfmx.c | 104 +++++++++++++++++++++++++++++ Build/source/texk/dvipdfm-x/spc_dvipdfmx.h | 30 +++++++++ Build/source/texk/dvipdfm-x/specials.c | 10 +++ 9 files changed, 216 insertions(+), 10 deletions(-) create mode 100644 Build/source/texk/dvipdfm-x/spc_dvipdfmx.c create mode 100644 Build/source/texk/dvipdfm-x/spc_dvipdfmx.h (limited to 'Build/source') diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog index 61f92c33317..d6af5307706 100644 --- a/Build/source/texk/dvipdfm-x/ChangeLog +++ b/Build/source/texk/dvipdfm-x/ChangeLog @@ -1,3 +1,11 @@ +2016-05-08 Masamichi HOSODA + + * dvi.c, dvipdfmx.c, dvipdfmx.h, special.c: Add new specials to handle + command line options. + * spc_dvipdfmx.c, spc_dvipdfmx.h: Add for the new specials. + * Makefile.am, Makefile.in: Change for the added spc_dvipdfmx.c, + and spc_dvipdfmx.h. + 2016-05-06 Akira Kakuto * pdffont.c: Avoid to crash for too large a value of SOURCE_DATE_EPOCH. diff --git a/Build/source/texk/dvipdfm-x/Makefile.am b/Build/source/texk/dvipdfm-x/Makefile.am index 7f96ccf0a69..3c3ec895d01 100644 --- a/Build/source/texk/dvipdfm-x/Makefile.am +++ b/Build/source/texk/dvipdfm-x/Makefile.am @@ -112,6 +112,8 @@ xdvipdfmx_SOURCES = \ sfnt.h \ spc_color.c \ spc_color.h \ + spc_dvipdfmx.c \ + spc_dvipdfmx.h \ spc_dvips.c \ spc_dvips.h \ spc_html.c \ diff --git a/Build/source/texk/dvipdfm-x/Makefile.in b/Build/source/texk/dvipdfm-x/Makefile.in index b38db3defa1..929db459f3a 100644 --- a/Build/source/texk/dvipdfm-x/Makefile.in +++ b/Build/source/texk/dvipdfm-x/Makefile.in @@ -151,15 +151,15 @@ am_xdvipdfmx_OBJECTS = agl.$(OBJEXT) bmpimage.$(OBJEXT) cff.$(OBJEXT) \ pdfobj.$(OBJEXT) pdfparse.$(OBJEXT) pdfresource.$(OBJEXT) \ pdfximage.$(OBJEXT) pkfont.$(OBJEXT) pngimage.$(OBJEXT) \ pst.$(OBJEXT) pst_obj.$(OBJEXT) sfnt.$(OBJEXT) \ - spc_color.$(OBJEXT) spc_dvips.$(OBJEXT) spc_html.$(OBJEXT) \ - spc_misc.$(OBJEXT) spc_pdfm.$(OBJEXT) spc_tpic.$(OBJEXT) \ - spc_util.$(OBJEXT) spc_xtx.$(OBJEXT) specials.$(OBJEXT) \ - subfont.$(OBJEXT) t1_char.$(OBJEXT) t1_load.$(OBJEXT) \ - tfm.$(OBJEXT) truetype.$(OBJEXT) tt_aux.$(OBJEXT) \ - tt_cmap.$(OBJEXT) tt_glyf.$(OBJEXT) tt_gsub.$(OBJEXT) \ - tt_post.$(OBJEXT) tt_table.$(OBJEXT) type0.$(OBJEXT) \ - type1.$(OBJEXT) type1c.$(OBJEXT) unicode.$(OBJEXT) \ - vf.$(OBJEXT) xbb.$(OBJEXT) + spc_color.$(OBJEXT) spc_dvipdfmx.$(OBJEXT) spc_dvips.$(OBJEXT) \ + spc_html.$(OBJEXT) spc_misc.$(OBJEXT) spc_pdfm.$(OBJEXT) \ + spc_tpic.$(OBJEXT) spc_util.$(OBJEXT) spc_xtx.$(OBJEXT) \ + specials.$(OBJEXT) subfont.$(OBJEXT) t1_char.$(OBJEXT) \ + t1_load.$(OBJEXT) tfm.$(OBJEXT) truetype.$(OBJEXT) \ + tt_aux.$(OBJEXT) tt_cmap.$(OBJEXT) tt_glyf.$(OBJEXT) \ + tt_gsub.$(OBJEXT) tt_post.$(OBJEXT) tt_table.$(OBJEXT) \ + type0.$(OBJEXT) type1.$(OBJEXT) type1c.$(OBJEXT) \ + unicode.$(OBJEXT) vf.$(OBJEXT) xbb.$(OBJEXT) xdvipdfmx_OBJECTS = $(am_xdvipdfmx_OBJECTS) xdvipdfmx_LDADD = $(LDADD) xdvipdfmx_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ @@ -705,6 +705,8 @@ xdvipdfmx_SOURCES = \ sfnt.h \ spc_color.c \ spc_color.h \ + spc_dvipdfmx.c \ + spc_dvipdfmx.h \ spc_dvips.c \ spc_dvips.h \ spc_html.c \ @@ -1011,6 +1013,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pst_obj.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfnt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spc_color.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spc_dvipdfmx.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spc_dvips.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spc_html.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spc_misc.Po@am__quote@ diff --git a/Build/source/texk/dvipdfm-x/dvi.c b/Build/source/texk/dvipdfm-x/dvi.c index 87eca839595..cea0ef0a3e5 100644 --- a/Build/source/texk/dvipdfm-x/dvi.c +++ b/Build/source/texk/dvipdfm-x/dvi.c @@ -2216,7 +2216,7 @@ scan_special (double *wd, double *ht, double *xo, double *yo, int *lm, { char *q; const char *p = buf, *endptr; - int ns_pdf = 0, error = 0; + int ns_pdf = 0, ns_dvipdfmx = 0, error = 0; double tmp; endptr = p + size; @@ -2242,6 +2242,15 @@ scan_special (double *wd, double *ht, double *xo, double *yo, int *lm, q = parse_c_ident(&p, endptr); } } + else if (q && !strcmp(q, "dvipdfmx")) { + skip_white(&p, endptr); + if (p < endptr && *p == ':') { + p++; + skip_white(&p, endptr); + RELEASE(q); + q = parse_c_ident(&p, endptr); ns_dvipdfmx = 1; + } + } skip_white(&p, endptr); if (q) { @@ -2372,6 +2381,8 @@ scan_special (double *wd, double *ht, double *xo, double *yo, int *lm, } skip_white(&p, endptr); } + } else if (ns_dvipdfmx && !strcmp(q, "config")) { + read_config_special(&p, endptr); } RELEASE(q); } diff --git a/Build/source/texk/dvipdfm-x/dvipdfmx.c b/Build/source/texk/dvipdfm-x/dvipdfmx.c index 393de215a91..644c92cf98c 100644 --- a/Build/source/texk/dvipdfm-x/dvipdfmx.c +++ b/Build/source/texk/dvipdfm-x/dvipdfmx.c @@ -705,6 +705,43 @@ read_config_file (const char *config) MFCLOSE(fp); } +void +read_config_special (const char **start, const char *end) +{ + char *option; + static char argv0[] = "config_special"; + char *argv[3]; + int argc = 1; + + argv[0] = argv0; + + skip_white (start, end); + if (*start >= end) + return; + /* Build up an argument list as if it were passed on the command + line */ + if ((option = parse_ident (start, end))) { + argc = 2; + argv[1] = NEW (strlen(option)+2, char); + strcpy (argv[1]+1, option); + RELEASE (option); + *argv[1] = '-'; + skip_white (start, end); + if (*start < end) { + argc += 1; + if (**start == '"') { + argv[2] = parse_c_string (start, end); + } + else + argv[2] = parse_ident (start, end); + } + } + do_args (argc, argv, argv0); + while (argc > 1) { + RELEASE (argv[--argc]); + } +} + static void system_default (void) { diff --git a/Build/source/texk/dvipdfm-x/dvipdfmx.h b/Build/source/texk/dvipdfm-x/dvipdfmx.h index 85b56410ff1..c32800ae41d 100644 --- a/Build/source/texk/dvipdfm-x/dvipdfmx.h +++ b/Build/source/texk/dvipdfm-x/dvipdfmx.h @@ -31,5 +31,6 @@ extern int translate_origin; extern const char *my_name; extern int extractbb(int argc, char *argv[]); +extern void read_config_special(const char **start, const char *end); #endif /* _DVIPDFMX_H_ */ diff --git a/Build/source/texk/dvipdfm-x/spc_dvipdfmx.c b/Build/source/texk/dvipdfm-x/spc_dvipdfmx.c new file mode 100644 index 00000000000..456d0fc4361 --- /dev/null +++ b/Build/source/texk/dvipdfm-x/spc_dvipdfmx.c @@ -0,0 +1,104 @@ +/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. + + Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + the dvipdfmx project team. + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "system.h" +#include "mem.h" +#include "error.h" + +#include "dpxutil.h" +#include "pdfparse.h" + +#include "specials.h" + +#include "spc_util.h" +#include "spc_dvipdfmx.h" + +static int +spc_handler_null (struct spc_env *spe, struct spc_arg *args) +{ + args->curptr = args->endptr; + + return 0; +} + +static struct spc_handler dvipdfmx_handlers[] = { + {"config", spc_handler_null}, /* handled at bop */ +}; + +int +spc_dvipdfmx_check_special (const char *buf, int len) +{ + int r = 0; + const char *p, *endptr; + + p = buf; + endptr = p + len; + + skip_white(&p, endptr); + if (p + strlen("dvipdfmx:") <= endptr && + !memcmp(p, "dvipdfmx:", strlen("dvipdfmx:"))) { + r = 1; + } + + return r; +} + +int +spc_dvipdfmx_setup_handler (struct spc_handler *sph, + struct spc_env *spe, struct spc_arg *ap) +{ + int error = -1, i; + char *q; + + ASSERT(sph && spe && ap); + + skip_white(&ap->curptr, ap->endptr); + if (ap->curptr + strlen("dvipdfmx:") >= ap->endptr || + memcmp(ap->curptr, "dvipdfmx:", strlen("dvipdfmx:"))) { + spc_warn(spe, "Not dvipdfmx: special???"); + return -1; + } + ap->curptr += strlen("dvipdfmx:"); + + skip_white(&ap->curptr, ap->endptr); + q = parse_c_ident(&ap->curptr, ap->endptr); + if (q) { + for (i = 0; + i < sizeof(dvipdfmx_handlers) / sizeof(struct spc_handler); i++) { + if (!strcmp(q, dvipdfmx_handlers[i].key)) { + ap->command = dvipdfmx_handlers[i].key; + sph->key = "dvipdfmx:"; + sph->exec = dvipdfmx_handlers[i].exec; + skip_white(&ap->curptr, ap->endptr); + error = 0; + break; + } + } + RELEASE(q); + } + + return error; +} diff --git a/Build/source/texk/dvipdfm-x/spc_dvipdfmx.h b/Build/source/texk/dvipdfm-x/spc_dvipdfmx.h new file mode 100644 index 00000000000..4a6c4c0e13b --- /dev/null +++ b/Build/source/texk/dvipdfm-x/spc_dvipdfmx.h @@ -0,0 +1,30 @@ +/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. + + Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + the dvipdfmx project team. + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +*/ + +#ifndef _SPC_DVIPDFMX_H_ +#define _SPC_DVIPDFMX_H_ + +#include "specials.h" + +extern int spc_dvipdfmx_check_special (const char *buf, int len); +extern int spc_dvipdfmx_setup_handler (struct spc_handler *sph, + struct spc_env *spe, struct spc_arg *ap); + +#endif /* _SPC_DVIPDFMX_H_ */ diff --git a/Build/source/texk/dvipdfm-x/specials.c b/Build/source/texk/dvipdfm-x/specials.c index 0e0b0ae5c17..138df2cbfc5 100644 --- a/Build/source/texk/dvipdfm-x/specials.c +++ b/Build/source/texk/dvipdfm-x/specials.c @@ -47,6 +47,7 @@ #include "spc_misc.h" #include "spc_color.h" #include "spc_dvips.h" +#include "spc_dvipdfmx.h" #include "spc_xtx.h" #include "specials.h" @@ -384,6 +385,15 @@ static struct { spc_xtx_setup_handler }, + {"dvipdfmx:", + NULL, + NULL, + NULL, + NULL, + spc_dvipdfmx_check_special, + spc_dvipdfmx_setup_handler + }, + {"ps:", spc_dvips_at_begin_document, spc_dvips_at_end_document, -- cgit v1.2.3