diff options
author | Karl Berry <karl@freefriends.org> | 2016-06-12 18:19:07 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-06-12 18:19:07 +0000 |
commit | a9e05811d1d1a04b467aac0678e8f3fdbb2c7ab1 (patch) | |
tree | 527cc09267bac1be29b1facc621eaf1135d2b6de /Build/source | |
parent | 54cf03cb1282a86ff0001946e1d47622bb4f9587 (diff) |
\pdflastmatch: more checks if no preceding match, from pdftex r759
git-svn-id: svn://tug.org/texlive/trunk@41418 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r-- | Build/source/texk/web2c/lib/ChangeLog | 4 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/ChangeLog | 14 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/NEWS | 5 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/utils.c | 30 |
4 files changed, 45 insertions, 8 deletions
diff --git a/Build/source/texk/web2c/lib/ChangeLog b/Build/source/texk/web2c/lib/ChangeLog index 37931ded8fb..729d5974740 100644 --- a/Build/source/texk/web2c/lib/ChangeLog +++ b/Build/source/texk/web2c/lib/ChangeLog @@ -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@tug.org> + + * TeX Live 2016 release. + 2016-05-06 Akira Kakuto <kakuto@fuk.kinidai.ac.jp> * texmfmp.c: Avoid crash for too large a value of SOURCE_DATE_EPOCH. diff --git a/Build/source/texk/web2c/pdftexdir/ChangeLog b/Build/source/texk/web2c/pdftexdir/ChangeLog index bdc4f56dbff..05f7aa7ede1 100644 --- a/Build/source/texk/web2c/pdftexdir/ChangeLog +++ b/Build/source/texk/web2c/pdftexdir/ChangeLog @@ -1,3 +1,17 @@ +2016-06-12 Karl Berry <karl@freefriends.org> + and Akira Kakuto <kakuto@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@tug.org> + + * TeX Live 2016 release. + 2016-04-06 Karl Berry <karl@tug.org> * pdftexextra.h (COPYRIGHT_HOLDER): don't specifically mention peb diff --git a/Build/source/texk/web2c/pdftexdir/NEWS b/Build/source/texk/web2c/pdftexdir/NEWS index 5e035092352..e35738463ef 100644 --- a/Build/source/texk/web2c/pdftexdir/NEWS +++ b/Build/source/texk/web2c/pdftexdir/NEWS @@ -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. diff --git a/Build/source/texk/web2c/pdftexdir/utils.c b/Build/source/texk/web2c/pdftexdir/utils.c index 88b8f09e11c..67ff8e9db46 100644 --- a/Build/source/texk/web2c/pdftexdir/utils.c +++ b/Build/source/texk/web2c/pdftexdir/utils.c @@ -817,12 +817,16 @@ void printmoddate(void) 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 @@ void matchstrings(strnumber s, strnumber t, int subcount, boolean icase) 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 @@ void getmatch(int i) strpool[poolptr++] = '>'; } + /* function strips trailing zeros in string with numbers; */ /* leading zeros are not stripped (as in real life) */ char *stripzeros(char *a) |