texlive[41418] Build/source/texk/web2c: \pdflastmatch: more checks if
commits+karl at tug.org
commits+karl at tug.org
Sun Jun 12 20:19:07 CEST 2016
Revision: 41418
http://tug.org/svn/texlive?view=revision&revision=41418
Author: karl
Date: 2016-06-12 20:19:07 +0200 (Sun, 12 Jun 2016)
Log Message:
-----------
\pdflastmatch: more checks if no preceding match, from pdftex r759
Revision Links:
--------------
http://tug.org/svn/texlive?view=revision&revision=759
Modified Paths:
--------------
trunk/Build/source/texk/web2c/lib/ChangeLog
trunk/Build/source/texk/web2c/pdftexdir/ChangeLog
trunk/Build/source/texk/web2c/pdftexdir/NEWS
trunk/Build/source/texk/web2c/pdftexdir/utils.c
Modified: trunk/Build/source/texk/web2c/lib/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/lib/ChangeLog 2016-06-12 17:01:19 UTC (rev 41417)
+++ trunk/Build/source/texk/web2c/lib/ChangeLog 2016-06-12 18:19:07 UTC (rev 41418)
@@ -5,6 +5,10 @@
http://tug.org/pipermail/tex-k/2016-June/002722.html
(and surrounding thread, starting in May)
+2016-05-20 Karl Berry <karl at tug.org>
+
+ * TeX Live 2016 release.
+
2016-05-06 Akira Kakuto <kakuto at fuk.kinidai.ac.jp>
* texmfmp.c: Avoid crash for too large a value of SOURCE_DATE_EPOCH.
Modified: trunk/Build/source/texk/web2c/pdftexdir/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/ChangeLog 2016-06-12 17:01:19 UTC (rev 41417)
+++ trunk/Build/source/texk/web2c/pdftexdir/ChangeLog 2016-06-12 18:19:07 UTC (rev 41418)
@@ -1,3 +1,17 @@
+2016-06-12 Karl Berry <karl at freefriends.org>
+ and Akira Kakuto <kakuto at fuk.kindai.ac.jp>
+
+ * utils.c (last_match_succeeded): new static boolean.
+ (matchstrings): set it.
+ (getmatch): use it, plus check for non-NULL match_string sooner,
+ plus check that rm_eo >= rm_so.
+ Original bug report from David Carlisle,
+ http://tug.org/pipermail/tex-live/2016-June/038664.html
+
+2016-05-20 Karl Berry <karl at tug.org>
+
+ * TeX Live 2016 release.
+
2016-04-06 Karl Berry <karl at tug.org>
* pdftexextra.h (COPYRIGHT_HOLDER): don't specifically mention peb
Modified: trunk/Build/source/texk/web2c/pdftexdir/NEWS
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/NEWS 2016-06-12 17:01:19 UTC (rev 41417)
+++ trunk/Build/source/texk/web2c/pdftexdir/NEWS 2016-06-12 18:19:07 UTC (rev 41418)
@@ -1,8 +1,11 @@
- changes:
- rename envvar SOURCE_DATE_EPOCH_TEX_PRIMITIVES to FORCE_SOURCE_DATE;
no changes in functionality.
+
+- bugfixes:
+ - \pdflastmatch more reliable when there was no match
---------------------------------------------------
-pdfTeX 3.14159265-2.6-1.40.17 (TeX Live 2016)
+pdfTeX 3.14159265-2.6-1.40.17 (TeX Live 2016) (May 20, 2016)
- changes:
- if the environment variable SOURCE_DATE_EPOCH is set, use its value for
the PDF CreationDate and ModDate values, and to seed the trailer /ID.
Modified: trunk/Build/source/texk/web2c/pdftexdir/utils.c
===================================================================
--- trunk/Build/source/texk/web2c/pdftexdir/utils.c 2016-06-12 17:01:19 UTC (rev 41417)
+++ trunk/Build/source/texk/web2c/pdftexdir/utils.c 2016-06-12 18:19:07 UTC (rev 41418)
@@ -817,12 +817,16 @@
pdf_printf("/ModDate (%s)\n", start_time_str);
}
+
#define DEFAULT_SUB_MATCH_COUNT 10
static int sub_match_count = DEFAULT_SUB_MATCH_COUNT;
static regmatch_t *pmatch = NULL;
static char *match_string = NULL;
+static int last_match_succeeded = 0;
-void matchstrings(strnumber s, strnumber t, int subcount, boolean icase)
+/* Implements \pdfmatch */
+void
+matchstrings(strnumber s, strnumber t, int subcount, boolean icase)
{
regex_t preg;
int cflags = REG_EXTENDED;
@@ -857,20 +861,31 @@
pmatch = xtalloc(sub_match_count, regmatch_t);
}
ret = regexec(&preg, str, sub_match_count, pmatch, eflags);
+
xfree(match_string);
- match_string = xstrdup(str);
- strpool[poolptr++] = ((ret == 0) ? '1' : '0');
+ match_string = xstrdup(str); /* save searched-in string, used below */
+ last_match_succeeded = ret == 0; /* save whether match succeeded */
+ strpool[poolptr++] = ((ret == 0) ? '1' : '0'); /* in string pool too */
}
regfree(&preg);
}
-void getmatch(int i)
+/* Implements \pdflastmatch */
+
+void
+getmatch(int i)
{
- int size, len = 0; /* to avoid warning about uninitialized use of len */
+ int size;
+ int len = 0; /* avoid spurious uninitialized warning */
- boolean found = i < sub_match_count
- && match_string != NULL && pmatch[i].rm_so >= 0 && i >= 0;
+ boolean found
+ = i >= 0 /* should always be so due to pdftex.web */
+ && i < sub_match_count /* if >subcount, not found by definition */
+ && match_string != NULL /* first call, and just in case */
+ && last_match_succeeded /* if no match, not found */
+ && pmatch[i].rm_so >= 0 /* if no starting position, not found */
+ && pmatch[i].rm_eo >= pmatch[i].rm_so; /* just in case */
if (found) {
len = pmatch[i].rm_eo - pmatch[i].rm_so;
@@ -903,6 +918,7 @@
strpool[poolptr++] = '>';
}
+
/* function strips trailing zeros in string with numbers; */
/* leading zeros are not stripped (as in real life) */
char *stripzeros(char *a)
More information about the tex-live-commits
mailing list