texlive[56274] Build/source/texk/dvipdfm-x: Add a new special

commits+kakuto at tug.org commits+kakuto at tug.org
Sun Sep 6 06:59:35 CEST 2020


Revision: 56274
          http://tug.org/svn/texlive?view=revision&revision=56274
Author:   kakuto
Date:     2020-09-06 06:59:35 +0200 (Sun, 06 Sep 2020)
Log Message:
-----------
Add a new special pdfcolorstack. (S. Hirata)

Modified Paths:
--------------
    trunk/Build/source/texk/dvipdfm-x/ChangeLog
    trunk/Build/source/texk/dvipdfm-x/configure
    trunk/Build/source/texk/dvipdfm-x/configure.ac
    trunk/Build/source/texk/dvipdfm-x/spc_misc.c
    trunk/Build/source/texk/dvipdfm-x/spc_misc.h
    trunk/Build/source/texk/dvipdfm-x/spc_pdfm.c
    trunk/Build/source/texk/dvipdfm-x/specials.c
    trunk/Build/source/texk/dvipdfm-x/specials.h

Modified: trunk/Build/source/texk/dvipdfm-x/ChangeLog
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/ChangeLog	2020-09-05 23:47:31 UTC (rev 56273)
+++ trunk/Build/source/texk/dvipdfm-x/ChangeLog	2020-09-06 04:59:35 UTC (rev 56274)
@@ -1,3 +1,13 @@
+2020-09-06  Shunsaku Hirata  <shunsaku.hirata74 at gmail.com>
+
+	* spc_pdfm.c: pdf:bcolor and pdf:scolor now accept new
+	keywords "fill" and "stroke" to indicate either of fill/stroke
+	color is specified.
+	* spc_misc.[ch], specials.[ch]: New special commands for
+	pdfcolorstack are added. This is a compatibility feature to
+	pdfcolorstack in pdftex.
+	* configure.ac: Version 20200906.
+
 2020-09-05  Shunsaku Hirata  <shunsaku.hirata74 at gmail.com>
 
 	* spc_pdfm.c: Workaround for an issue that occurs when an

Modified: trunk/Build/source/texk/dvipdfm-x/configure
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/configure	2020-09-05 23:47:31 UTC (rev 56273)
+++ trunk/Build/source/texk/dvipdfm-x/configure	2020-09-06 04:59:35 UTC (rev 56274)
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20200905.
+# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20200906.
 #
 # Report bugs to <dvipdfmx at tug.org>.
 #
@@ -590,8 +590,8 @@
 # Identity of this package.
 PACKAGE_NAME='dvipdfm-x (TeX Live)'
 PACKAGE_TARNAME='dvipdfm-x--tex-live-'
-PACKAGE_VERSION='20200905'
-PACKAGE_STRING='dvipdfm-x (TeX Live) 20200905'
+PACKAGE_VERSION='20200906'
+PACKAGE_STRING='dvipdfm-x (TeX Live) 20200906'
 PACKAGE_BUGREPORT='dvipdfmx at tug.org'
 PACKAGE_URL=''
 
@@ -1350,7 +1350,7 @@
   # 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 dvipdfm-x (TeX Live) 20200905 to adapt to many kinds of systems.
+\`configure' configures dvipdfm-x (TeX Live) 20200906 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1421,7 +1421,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20200905:";;
+     short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20200906:";;
    esac
   cat <<\_ACEOF
 
@@ -1551,7 +1551,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-dvipdfm-x (TeX Live) configure 20200905
+dvipdfm-x (TeX Live) configure 20200906
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2390,7 +2390,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by dvipdfm-x (TeX Live) $as_me 20200905, which was
+It was created by dvipdfm-x (TeX Live) $as_me 20200906, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -8077,7 +8077,7 @@
 
 # Define the identity of the package.
  PACKAGE='dvipdfm-x--tex-live-'
- VERSION='20200905'
+ VERSION='20200906'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -14746,7 +14746,7 @@
 Report bugs to <bug-libtool at gnu.org>."
 
 lt_cl_version="\
-dvipdfm-x (TeX Live) config.lt 20200905
+dvipdfm-x (TeX Live) config.lt 20200906
 configured by $0, generated by GNU Autoconf 2.69.
 
 Copyright (C) 2011 Free Software Foundation, Inc.
@@ -16636,7 +16636,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by dvipdfm-x (TeX Live) $as_me 20200905, which was
+This file was extended by dvipdfm-x (TeX Live) $as_me 20200906, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -16706,7 +16706,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-dvipdfm-x (TeX Live) config.status 20200905
+dvipdfm-x (TeX Live) config.status 20200906
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 

Modified: trunk/Build/source/texk/dvipdfm-x/configure.ac
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/configure.ac	2020-09-05 23:47:31 UTC (rev 56273)
+++ trunk/Build/source/texk/dvipdfm-x/configure.ac	2020-09-06 04:59:35 UTC (rev 56274)
@@ -8,7 +8,7 @@
 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([dvipdfm-x (TeX Live)], [20200905], [dvipdfmx at tug.org])
+AC_INIT([dvipdfm-x (TeX Live)], [20200906], [dvipdfmx at tug.org])
 AC_PREREQ([2.65])
 AC_CONFIG_SRCDIR([agl.c])
 AC_CONFIG_AUX_DIR([../../build-aux])

Modified: trunk/Build/source/texk/dvipdfm-x/spc_misc.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/spc_misc.c	2020-09-05 23:47:31 UTC (rev 56273)
+++ trunk/Build/source/texk/dvipdfm-x/spc_misc.c	2020-09-06 04:59:35 UTC (rev 56274)
@@ -32,6 +32,8 @@
 
 #include "mfileio.h"
 
+#include "dpxutil.h"
+
 #include "pdfparse.h"
 #include "pdfobj.h"
 
@@ -47,7 +49,341 @@
 #include "spc_util.h"
 #include "spc_misc.h"
 
+/* pdfcolorstack:
+ * This special is provoded as a compatibility feature to pdftex.
+ */
+struct stack
+{
+  int       page;
+  int       direct;
+  dpx_stack stack;
+};
+
+#define PDFCOLORSTACK_MAX_STACK 256
+struct spc_stack
+{
+  struct stack stacks[PDFCOLORSTACK_MAX_STACK];
+};
+
+static struct spc_stack spc_stack;
+
 static int
+pdfcolorstack__get_id (struct spc_env *spe, int *id, struct spc_arg *args)
+{
+  char *q;
+
+  if (args->curptr >= args->endptr) {
+    spc_warn(spe, "Stack ID number expected but not found.");
+    return -1;
+  }
+  q = parse_number(&args->curptr, args->endptr);
+  if (!q) {
+    spc_warn(spe, "Stack ID number expected but not found.");
+    return -1;
+  }
+  *id = atoi(q);
+  RELEASE(q);
+
+  skip_white(&args->curptr, args->endptr);
+
+  return 0;
+}
+
+static int
+pdfcolorstack__init (void *dp)
+{
+  struct spc_stack *sd = dp;
+  int  i;
+
+  for (i = 0; i < 64; i++) {
+    sd->stacks[i].page    = 0;
+    sd->stacks[i].direct  = 0;
+    dpx_stack_init(&sd->stacks[i].stack);
+  }
+
+  return 0;
+}
+
+static int
+pdfcolorstack__clean (void *dp)
+{
+  struct spc_stack *sd = dp;
+  int  i;
+
+  for (i = 0; i < PDFCOLORSTACK_MAX_STACK; i++) {
+    pdf_obj   *litstr;
+    dpx_stack *stk = &sd->stacks[i].stack;
+
+    while ((litstr = dpx_stack_pop(stk)) != NULL) {
+      pdf_release_obj(litstr);
+    }
+  }
+
+  return 0;
+}
+
+static void
+pdfcolorstack__set_litstr (pdf_coord cp, pdf_obj *litstr, int direct)
+{
+  pdf_tmatrix M;
+
+  if (!litstr)
+    return;
+
+  if (!direct) {
+    M.a = M.d = 1.0; M.b = M.c = 0.0;
+    M.e = cp.x; M.f = cp.y;
+    pdf_dev_concat(&M);
+  }
+  pdf_doc_add_page_content(" ", 1);
+  pdf_doc_add_page_content(pdf_string_value(litstr), pdf_string_length(litstr));
+  if (!direct) {
+    M.e = -cp.x; M.f = -cp.y;
+    pdf_dev_concat(&M);
+  }
+}
+
+static int
+spc_handler_pdfcolorstackinit (struct spc_env *spe, struct spc_arg *args)
+{
+  int           id = -1;
+  struct stack *st;
+  char         *q;
+  pdf_coord     cp = {0.0, 0.0};
+  pdf_obj      *litstr;
+
+  skip_white(&args->curptr, args->endptr);
+  if (args->curptr >= args->endptr)
+    return -1;
+
+  if (pdfcolorstack__get_id(spe, &id, args) < 0)
+    return -1;
+  if (id < 0 || id >= PDFCOLORSTACK_MAX_STACK) {
+    spc_warn(spe, "Invalid stack number specified: %d", id);
+    return -1;
+  }
+  skip_white(&args->curptr, args->endptr);
+
+  st = &spc_stack.stacks[id];
+  if (dpx_stack_depth(&st->stack) > 0) {
+    spc_warn(spe, "Stadk ID=%d already initialized?", id);
+    return -1;
+  }
+
+  while ((q = parse_c_ident(&args->curptr, args->endptr)) != NULL) {
+    if (!strcmp(q, "page")) {
+      st->page = 1;
+    } else if (!strcmp(q, "direct")) {
+      st->direct = 1;
+    } else {
+      spc_warn(spe, "Ignoring unknown option for pdfcolorstack special (init): %s", q);
+    }
+    RELEASE(q);
+    skip_white(&args->curptr, args->endptr);
+  }
+
+  if (args->curptr < args->endptr) {
+    litstr = parse_pdf_string(&args->curptr, args->endptr);
+    if (litstr) {
+      dpx_stack_push(&st->stack, litstr);
+      pdfcolorstack__set_litstr(cp, litstr, st->direct);
+    }
+    skip_white(&args->curptr, args->endptr);
+  }  else {
+    spc_warn(spe, "No valid PDF literal specified.");
+    return -1;
+  }
+
+  return 0;
+}
+
+static int
+pdfcolorstack__set (struct spc_env *spe, struct stack *st, pdf_coord cp, struct spc_arg *args)
+{
+  pdf_obj *litstr;
+
+  skip_white(&args->curptr, args->endptr);
+  if (args->curptr >= args->endptr)
+    return -1;
+
+  litstr = dpx_stack_pop(&st->stack);
+  if (!litstr) {
+    spc_warn(spe, "Stack empty!");
+    return -1;
+  }
+  pdf_release_obj(litstr);
+
+  litstr = parse_pdf_string(&args->curptr, args->endptr);
+  if (litstr) {
+    dpx_stack_push(&st->stack, litstr);
+    pdfcolorstack__set_litstr(cp, litstr, st->direct);
+    skip_white(&args->curptr, args->endptr);
+  }
+
+  return 0;
+}
+
+static int
+pdfcolorstack__push (struct spc_env *spe, struct stack *st, pdf_coord cp, struct spc_arg *args)
+{
+  pdf_obj *litstr;
+
+  skip_white(&args->curptr, args->endptr);
+  if (args->curptr >= args->endptr)
+    return -1;
+
+  litstr = parse_pdf_string(&args->curptr, args->endptr);
+  if (litstr) {
+    dpx_stack_push(&st->stack, litstr);
+    pdfcolorstack__set_litstr(cp, litstr, st->direct);
+    skip_white(&args->curptr, args->endptr);
+  }
+
+  return 0;
+}
+
+static int
+pdfcolorstack__current (struct spc_env *spe, struct stack *st, pdf_coord cp, struct spc_arg *args)
+{
+  pdf_obj *litstr;
+
+  litstr = dpx_stack_top(&st->stack);
+  if (litstr) {
+    pdfcolorstack__set_litstr(cp, litstr, st->direct);
+    skip_white(&args->curptr, args->endptr);
+  } else {
+    spc_warn(spe, "Stack empty!");
+    return -1;
+  }
+
+  return 0;
+}
+
+static int
+pdfcolorstack__pop (struct spc_env *spe, struct stack *st, pdf_coord cp, struct spc_arg *args)
+{
+  int      error = 0;
+  pdf_obj *litstr;
+
+  /* "default" at the bottom */
+  if (dpx_stack_depth(&st->stack) < 2) {
+    spc_warn(spe, "Stack underflow");
+    return -1;
+  }
+  litstr = dpx_stack_pop(&st->stack);
+  if (litstr) {
+    pdf_release_obj(litstr);
+  }
+  litstr = dpx_stack_top(&st->stack);
+  if (litstr) {
+    pdfcolorstack__set_litstr(cp, litstr, st->direct);
+  }
+
+  return error;
+}
+
+static int
+spc_handler_pdfcolorstack (struct spc_env *spe, struct spc_arg *args)
+{
+  int           error = 0;
+  int           id;
+  char          *command;
+  struct stack *st;
+  pdf_coord     cp;
+
+  skip_white(&args->curptr, args->endptr);
+  if (args->curptr >= args->endptr)
+    return -1;
+
+  if (pdfcolorstack__get_id(spe, &id, args) < 0)
+    return -1;
+  if (id < 0 || id >= PDFCOLORSTACK_MAX_STACK) {
+    spc_warn(spe, "Invalid stack ID specified: %d", id);
+    return -1;
+  }
+  skip_white(&args->curptr, args->endptr);
+
+  st = &spc_stack.stacks[id];
+  if (dpx_stack_depth(&st->stack) < 1) {
+    spc_warn(spe, "Stack ID=%d not properly initialized?", id);
+    return -1;
+  }
+
+  command = parse_c_ident(&args->curptr, args->endptr);
+  if (!command)
+    return -1;
+
+  spc_get_current_point(spe, &cp);
+  if (!strcmp(command, "set")) {
+    error = pdfcolorstack__set(spe, st, cp, args);
+  } else if (!strcmp(command, "push")) {
+    error = pdfcolorstack__push(spe, st, cp, args);
+  } else if (!strcmp(command, "pop")) {
+    error = pdfcolorstack__pop(spe, st, cp, args);
+  } else if (!strcmp(command, "current")) {
+    error = pdfcolorstack__current(spe, st, cp, args);
+  } else {
+    spc_warn(spe, "Unknown action: %s", command);
+  }
+
+  if (error) {
+    spc_warn(spe, "Error occurred while processing pdfcolorstack: id=%d command=\"%s\"", id, command);
+  }
+
+  RELEASE(command);
+
+  return error;
+}
+
+
+int
+spc_misc_at_begin_document (void)
+{
+  struct spc_stack *sd = &spc_stack;
+  return  pdfcolorstack__init(sd);
+}
+
+int
+spc_misc_at_end_document (void)
+{
+  struct spc_stack *sd = &spc_stack;
+  return pdfcolorstack__clean(sd);
+}
+
+int
+spc_misc_at_begin_page (void)
+{
+  struct spc_stack *sd = &spc_stack;
+  int  i;
+
+  for (i = 0; i < 64; i++) {
+    dpx_stack *stk = &sd->stacks[i].stack;
+
+    if (sd->stacks[i].page) {
+      pdf_obj   *litstr = dpx_stack_top(stk);
+      pdf_coord  cp     = {0.0, 0.0};
+
+      if (litstr)
+        pdfcolorstack__set_litstr(cp, litstr, sd->stacks[i].direct);
+    }
+  }
+
+  return 0;
+}
+
+int
+spc_misc_at_begin_form (void)
+{
+  return spc_misc_at_begin_page();
+}
+
+int
+spc_misc_at_end_form (void)
+{
+  return spc_misc_at_begin_page();
+}
+
+static int
 spc_handler_postscriptbox (struct spc_env *spe, struct spc_arg *ap)
 {
   int            form_id, len;
@@ -130,12 +466,14 @@
 }
 
 static struct spc_handler misc_handlers[] = {
-  {"postscriptbox", spc_handler_postscriptbox},
-  {"landscape",     spc_handler_null}, /* handled at bop */
-  {"papersize",     spc_handler_null}, /* handled at bop */
-  {"src:",          spc_handler_null}, /* simply ignore  */
-  {"pos:",          spc_handler_null}, /* simply ignore  */
-  {"om:",           spc_handler_null}  /* simply ignore  */
+  {"postscriptbox",     spc_handler_postscriptbox},
+  {"pdfcolorstackinit", spc_handler_pdfcolorstackinit},
+  {"pdfcolorstack",     spc_handler_pdfcolorstack},
+  {"landscape",         spc_handler_null}, /* handled at bop */
+  {"papersize",         spc_handler_null}, /* handled at bop */
+  {"src:",              spc_handler_null}, /* simply ignore  */
+  {"pos:",              spc_handler_null}, /* simply ignore  */
+  {"om:",               spc_handler_null}  /* simply ignore  */
 };
 
 
@@ -143,18 +481,16 @@
 spc_misc_check_special (const char *buffer, int size)
 {
   const char *p, *endptr;
-  int    i;
+  int         i;
 
   p      = buffer;
   endptr = p + size;
 
   skip_white(&p, endptr);
-  size   = (int) (endptr - p);
-  for (i = 0;
-       i < sizeof(misc_handlers)/sizeof(struct spc_handler); i++) {
+  size = (int) (endptr - p);
+  for (i = 0; i < sizeof(misc_handlers)/sizeof(struct spc_handler); i++) {
     if (size >= strlen(misc_handlers[i].key) &&
-	!strncmp(p, misc_handlers[i].key,
-		 strlen(misc_handlers[i].key))) {
+        !strncmp(p, misc_handlers[i].key, strlen(misc_handlers[i].key))) {
       return 1;
     }
   }
@@ -163,11 +499,10 @@
 }
 
 int
-spc_misc_setup_handler (struct spc_handler *handle,
-			struct spc_env *spe, struct spc_arg *args)
+spc_misc_setup_handler (struct spc_handler *handle, struct spc_env *spe, struct spc_arg *args)
 {
   const char *key;
-  int    i, keylen;
+  int         i, keylen;
 
   ASSERT(handle && spe && args);
 
@@ -174,8 +509,7 @@
   skip_white(&args->curptr, args->endptr);
 
   key = args->curptr;
-  while (args->curptr < args->endptr &&
-	 isalpha((unsigned char)args->curptr[0])) {
+  while (args->curptr < args->endptr && isalpha((unsigned char)args->curptr[0])) {
     args->curptr++;
   }
 
@@ -189,10 +523,9 @@
     return -1;
   }
 
-  for (i = 0;
-       i < sizeof(misc_handlers)/sizeof(struct spc_handler); i++) {
+  for (i = 0; i < sizeof(misc_handlers)/sizeof(struct spc_handler); i++) {
     if (keylen == strlen(misc_handlers[i].key) &&
-	!strncmp(key, misc_handlers[i].key, keylen)) {
+        !strncmp(key, misc_handlers[i].key, keylen)) {
 
       skip_white(&args->curptr, args->endptr);
 

Modified: trunk/Build/source/texk/dvipdfm-x/spc_misc.h
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/spc_misc.h	2020-09-05 23:47:31 UTC (rev 56273)
+++ trunk/Build/source/texk/dvipdfm-x/spc_misc.h	2020-09-06 04:59:35 UTC (rev 56274)
@@ -26,7 +26,11 @@
 #include "specials.h"
 
 extern int spc_misc_check_special (const char *buffer, int size);
-extern int spc_misc_setup_handler (struct spc_handler *handle,
-				   struct spc_env *spe, struct spc_arg *args);
+extern int spc_misc_setup_handler (struct spc_handler *handle, struct spc_env *spe, struct spc_arg *args);
+extern int spc_misc_at_begin_document (void);
+extern int spc_misc_at_end_document (void);
+extern int spc_misc_at_begin_page (void);
+extern int spc_misc_at_begin_form (void);
+extern int spc_misc_at_end_form (void);
 
 #endif /* _SPC_MISC_H_ */

Modified: trunk/Build/source/texk/dvipdfm-x/spc_pdfm.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/spc_pdfm.c	2020-09-05 23:47:31 UTC (rev 56273)
+++ trunk/Build/source/texk/dvipdfm-x/spc_pdfm.c	2020-09-06 04:59:35 UTC (rev 56274)
@@ -891,23 +891,38 @@
 static int
 spc_handler_pdfm_bcolor (struct spc_env *spe, struct spc_arg *ap)
 {
-  int       error;
-  pdf_color fc, sc;
+  int        error = 0;
+  pdf_color  fc, sc;
   pdf_color *pfc, *psc;
 
   pdf_color_get_current(&psc, &pfc);
-  error = spc_util_read_pdfcolor(spe, &fc, ap, pfc);
-  if (!error) {
-    if (ap->curptr < ap->endptr) {
-      error = spc_util_read_pdfcolor(spe, &sc, ap, psc);
-    } else {
-      pdf_color_copycolor(&sc, &fc);
+  if (ap->curptr <= ap->endptr + strlen("fill") &&
+      !memcmp(ap->curptr, "fill", strlen("fill"))) {
+    ap->curptr += strlen("fill");
+    skip_white(&ap->curptr, ap->endptr);
+    error = spc_util_read_pdfcolor(spe, &fc, ap, pfc);
+    pdf_color_copycolor(&sc, psc);
+  } else if (ap->curptr <= ap->endptr + strlen("stroke") &&
+             !memcmp(ap->curptr, "stroke", strlen("stroke"))) {
+    ap->curptr += strlen("stroke");
+    skip_white(&ap->curptr, ap->endptr);
+    error = spc_util_read_pdfcolor(spe, &sc, ap, psc);
+    pdf_color_copycolor(&fc, pfc);
+  } else {
+    error = spc_util_read_pdfcolor(spe, &fc, ap, pfc);
+    if (!error) {
+      if (ap->curptr < ap->endptr) {
+        error = spc_util_read_pdfcolor(spe, &sc, ap, psc);
+      } else {
+        pdf_color_copycolor(&sc, &fc);
+      }
     }
   }
 
-  if (error)
+  if (error) {
     spc_warn(spe, "Invalid color specification?");
-  else {
+  } else {
+    skip_white(&ap->curptr, ap->endptr);
     pdf_color_push(&sc, &fc); /* save currentcolor */
   }
 
@@ -921,24 +936,39 @@
 static int
 spc_handler_pdfm_scolor (struct spc_env *spe, struct spc_arg *ap)
 {
-  int       error;
-  pdf_color fc, sc;
+  int        error = 0;
+  pdf_color  fc, sc;
   pdf_color *pfc, *psc;
 
   pdf_color_get_current(&psc, &pfc);
-  error = spc_util_read_pdfcolor(spe, &fc, ap, pfc);
-  if (!error) {
-    if (ap->curptr < ap->endptr) {
-      error = spc_util_read_pdfcolor(spe, &sc, ap, psc);
-    } else {
-      pdf_color_copycolor(&sc, &fc);
+  if (ap->curptr <= ap->endptr + strlen("fill") &&
+      !memcmp(ap->curptr, "fill", strlen("fill"))) {
+    ap->curptr += strlen("fill");
+    skip_white(&ap->curptr, ap->endptr);
+    error = spc_util_read_pdfcolor(spe, &fc, ap, pfc);
+    pdf_color_copycolor(&sc, psc);
+  } else if (ap->curptr <= ap->endptr + strlen("stroke") &&
+             !memcmp(ap->curptr, "stroke", strlen("stroke"))) {
+    ap->curptr += strlen("stroke");
+    skip_white(&ap->curptr, ap->endptr);
+    error = spc_util_read_pdfcolor(spe, &sc, ap, psc);
+    pdf_color_copycolor(&fc, pfc);
+  } else {
+    error = spc_util_read_pdfcolor(spe, &fc, ap, pfc);
+    if (!error) {
+      if (ap->curptr < ap->endptr) {
+        error = spc_util_read_pdfcolor(spe, &sc, ap, psc);
+      } else {
+        pdf_color_copycolor(&sc, &fc);
+      }
     }
   }
 
-  if (error)
+  if (error) {
     spc_warn(spe, "Invalid color specification?");
-  else
+  } else {
     pdf_color_set(&sc, &fc);
+  }
 
   return  error;
 }
@@ -1736,7 +1766,7 @@
 static int
 spc_handler_pdfm_bform (struct spc_env *spe, struct spc_arg *args)
 {
-  int             xobj_id;
+  int             error;
   char           *ident;
   pdf_rect        cropbox;
   pdf_coord       cp;
@@ -1786,16 +1816,14 @@
   }
 
   spc_get_current_point(spe, &cp);
-  xobj_id = pdf_doc_begin_grabbing(ident, cp.x, cp.y, &cropbox);
+  error = spc_begin_form(spe, ident, cp, &cropbox);
 
-  if (xobj_id < 0) {
-    RELEASE(ident);
+  if (error)
     spc_warn(spe, "Couldn't start form object.");
-    return -1;
-  }
+
   RELEASE(ident);
 
-  return 0;
+  return error;
 }
 
 /* An extra dictionary after exobj must be merged to the form dictionary,
@@ -1805,6 +1833,7 @@
 static int
 spc_handler_pdfm_eform (struct spc_env *spe, struct spc_arg *args)
 {
+  int              error;
   pdf_obj         *attrib = NULL;
   struct spc_pdf_ *sd     = &_pdf_stat;
 
@@ -1821,9 +1850,9 @@
   if (sd->pageresources) {
     pdf_foreach_dict(sd->pageresources, forallresourcecategory, NULL);
   }
-  pdf_doc_end_grabbing(attrib);
+  error = spc_end_form(spe, attrib);
 
-  return 0;
+  return error;
 }
 
 /* Saved XObjects can be used as follows:

Modified: trunk/Build/source/texk/dvipdfm-x/specials.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/specials.c	2020-09-05 23:47:31 UTC (rev 56273)
+++ trunk/Build/source/texk/dvipdfm-x/specials.c	2020-09-06 04:59:35 UTC (rev 56274)
@@ -528,6 +528,8 @@
   int (*eodhk_func) (void);
   int (*bophk_func) (void);
   int (*eophk_func) (void);
+  int (*bofhk_func) (void);
+  int (*eofhk_func) (void);
   int (*check_func) (const char *, int);
   int (*setup_func) (struct spc_handler *, struct spc_env *, struct spc_arg *);
 } known_specials[] = {
@@ -537,6 +539,8 @@
    spc_pdfm_at_end_document,
    NULL,
    spc_pdfm_at_end_page,
+   NULL,
+   NULL,
    spc_pdfm_check_special,
    spc_pdfm_setup_handler
   },
@@ -546,6 +550,8 @@
    NULL,
    NULL,
    NULL,
+   NULL,
+   NULL,
    spc_xtx_check_special,
    spc_xtx_setup_handler
   },
@@ -555,6 +561,8 @@
    NULL,
    NULL,
    NULL,
+   NULL,
+   NULL,
    spc_dvipdfmx_check_special,
    spc_dvipdfmx_setup_handler
   },
@@ -564,6 +572,8 @@
    spc_dvips_at_end_document,
    spc_dvips_at_begin_page,
    spc_dvips_at_end_page,
+   NULL,
+   NULL,
    spc_dvips_check_special,
    spc_dvips_setup_handler
   },
@@ -573,6 +583,8 @@
    NULL,
    NULL,
    NULL,
+   NULL,
+   NULL,
    spc_color_check_special,
    spc_color_setup_handler
   },
@@ -582,6 +594,8 @@
    spc_tpic_at_end_document,
    spc_tpic_at_begin_page,
    spc_tpic_at_end_page,
+   NULL,
+   NULL,
    spc_tpic_check_special,
    spc_tpic_setup_handler
   },
@@ -591,15 +605,19 @@
    spc_html_at_end_document,
    spc_html_at_begin_page,
    spc_html_at_end_page,
+   NULL,
+   NULL,
    spc_html_check_special,
    spc_html_setup_handler
   },
 
-  {"unknown",
+  {"compat",
+   spc_misc_at_begin_document,
+   spc_misc_at_end_document,
+   spc_misc_at_begin_page,
    NULL,
-   NULL,
-   NULL,
-   NULL,
+   spc_misc_at_begin_form,
+   spc_misc_at_end_form,
    spc_misc_check_special,
    spc_misc_setup_handler
   },
@@ -608,6 +626,44 @@
 };
 
 int
+spc_begin_form (struct spc_env *spe, const char *ident, pdf_coord cp, pdf_rect *cropbox)
+{
+  int  error = 0;
+  int  i, xobj_id;
+
+  xobj_id = pdf_doc_begin_grabbing(ident, cp.x, cp.y, cropbox);
+
+  if (xobj_id < 0) {
+    error = -1;
+  } else {
+    for (i = 0; known_specials[i].key != NULL; i++) {
+      if (known_specials[i].bofhk_func) {
+        error = known_specials[i].bofhk_func();
+      }
+    }
+  }
+
+  return error;
+}
+
+int
+spc_end_form (struct spc_env *spe, pdf_obj *attr)
+{
+  int  error = 0;
+  int  i;
+
+  pdf_doc_end_grabbing(attr);
+
+  for (i = 0; known_specials[i].key != NULL; i++) {
+    if (known_specials[i].eofhk_func) {
+      error = known_specials[i].eofhk_func();
+    }
+  }
+
+  return error;
+}
+
+int
 spc_exec_at_begin_page (void)
 {
   int  error = 0;

Modified: trunk/Build/source/texk/dvipdfm-x/specials.h
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/specials.h	2020-09-05 23:47:31 UTC (rev 56273)
+++ trunk/Build/source/texk/dvipdfm-x/specials.h	2020-09-06 04:59:35 UTC (rev 56274)
@@ -63,6 +63,9 @@
 extern int      spc_resume_annot  (struct spc_env *spe);
 extern int      spc_suspend_annot (struct spc_env *spe);
 
+extern int      spc_begin_form    (struct spc_env *spe, const char *ident, pdf_coord cp, pdf_rect *cropbox);
+extern int      spc_end_form      (struct spc_env *spe, pdf_obj *attr);
+
 extern int      spc_is_tracking_boxes (struct spc_env *spe);
 
 /* linkmode 0: normal, 1: capture phantom texts */



More information about the tex-live-commits mailing list.