aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2019-10-11 18:23:47 -0700
committerPaul Eggert2019-10-11 18:24:19 -0700
commit4b60e0722d0a79751f345bd470d07db0d635aa28 (patch)
tree9ebcaa21ec5f08c0caafc7190daf34ed047f8e1f
parentf9d8babe6a28b19c781778c361e45b93f7a01f17 (diff)
downloademacs-4b60e0722d0a79751f345bd470d07db0d635aa28.tar.gz
emacs-4b60e0722d0a79751f345bd470d07db0d635aa28.zip
Update from Gnulib
This incorporates: 2019-10-11 Simplify and regularize regex use of ‘assert’ 2019-10-09 regex: omit debug assignment when not debugging 2019-10-09 regex: tell compiler there’s at most 256 arcs out 2019-10-09 regex: simplify by assuming C99 2019-10-09 regex: avoid copying of uninitialized storage 2019-09-29 fbufmode: Fix compilation error on glibc >= 2.28 systems 2019-09-28 Update comments that refer to POSIX 2019-09-23 Update URLs and associated text * doc/misc/texinfo.tex, lib/open.c, lib/regcomp.c: * lib/regex_internal.c, lib/regex_internal.h, lib/regexec.c: * lib/stdio-impl.h: Copy from Gnulib.
-rw-r--r--doc/misc/texinfo.tex13
-rw-r--r--lib/open.c16
-rw-r--r--lib/regcomp.c35
-rw-r--r--lib/regex_internal.c13
-rw-r--r--lib/regex_internal.h30
-rw-r--r--lib/regexec.c83
-rw-r--r--lib/stdio-impl.h13
7 files changed, 78 insertions, 125 deletions
diff --git a/doc/misc/texinfo.tex b/doc/misc/texinfo.tex
index df43c1e26ed..1ea515b2ae4 100644
--- a/doc/misc/texinfo.tex
+++ b/doc/misc/texinfo.tex
@@ -3,7 +3,7 @@
3% Load plain if necessary, i.e., if running under initex. 3% Load plain if necessary, i.e., if running under initex.
4\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi 4\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
5% 5%
6\def\texinfoversion{2019-09-20.22} 6\def\texinfoversion{2019-09-24.13}
7% 7%
8% Copyright 1985, 1986, 1988, 1990-2019 Free Software Foundation, Inc. 8% Copyright 1985, 1986, 1988, 1990-2019 Free Software Foundation, Inc.
9% 9%
@@ -3099,11 +3099,16 @@ end
3099\def\wordbefore{before} 3099\def\wordbefore{before}
3100\def\wordnone{none} 3100\def\wordnone{none}
3101 3101
3102% Allow a ragged right output to aid breaking long URL's. Putting stretch in 3102% Allow a ragged right output to aid breaking long URL's. There can
3103% between characters of the URL doesn't look good. 3103% be a break at the \allowbreak with no extra glue (if the existing stretch in
3104% the line is sufficent), a break at the \penalty100 with extra glue added
3105% at the end of the line, or no break at all here.
3106% Changing the value of the penalty and/or the amount of stretch affects how
3107% preferrable one choice is over the other.
3104\def\urefallowbreak{% 3108\def\urefallowbreak{%
3105 \hskip 0pt plus 4 em\relax
3106 \allowbreak 3109 \allowbreak
3110 \hskip 0pt plus 4 em\relax
3111 \penalty100
3107 \hskip 0pt plus -4 em\relax 3112 \hskip 0pt plus -4 em\relax
3108} 3113}
3109 3114
diff --git a/lib/open.c b/lib/open.c
index 4572ebf6cd2..0c2742bbda6 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -92,9 +92,13 @@ open (const char *filename, int flags, ...)
92#endif 92#endif
93 93
94#if OPEN_TRAILING_SLASH_BUG 94#if OPEN_TRAILING_SLASH_BUG
95 /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR 95 /* Fail if one of O_CREAT, O_WRONLY, O_RDWR is specified and the filename
96 is specified, then fail. 96 ends in a slash, as POSIX says such a filename must name a directory
97 Rationale: POSIX <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html> 97 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>:
98 "A pathname that contains at least one non-<slash> character and that
99 ends with one or more trailing <slash> characters shall not be resolved
100 successfully unless the last pathname component before the trailing
101 <slash> characters names an existing directory"
98 If the named file already exists as a directory, then 102 If the named file already exists as a directory, then
99 - if O_CREAT is specified, open() must fail because of the semantics 103 - if O_CREAT is specified, open() must fail because of the semantics
100 of O_CREAT, 104 of O_CREAT,
@@ -164,6 +168,12 @@ open (const char *filename, int flags, ...)
164#if OPEN_TRAILING_SLASH_BUG 168#if OPEN_TRAILING_SLASH_BUG
165 /* If the filename ends in a slash and fd does not refer to a directory, 169 /* If the filename ends in a slash and fd does not refer to a directory,
166 then fail. 170 then fail.
171 Rationale: POSIX says such a filename must name a directory
172 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>:
173 "A pathname that contains at least one non-<slash> character and that
174 ends with one or more trailing <slash> characters shall not be resolved
175 successfully unless the last pathname component before the trailing
176 <slash> characters names an existing directory"
167 If the named file without the slash is not a directory, open() must fail 177 If the named file without the slash is not a directory, open() must fail
168 with ENOTDIR. */ 178 with ENOTDIR. */
169 if (fd >= 0) 179 if (fd >= 0)
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 892139a02af..ad6f931a5c3 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -1436,7 +1436,7 @@ link_nfa_nodes (void *extra, bin_tree_t *node)
1436 break; 1436 break;
1437 1437
1438 case END_OF_RE: 1438 case END_OF_RE:
1439 assert (node->next == NULL); 1439 DEBUG_ASSERT (node->next == NULL);
1440 break; 1440 break;
1441 1441
1442 case OP_DUP_ASTERISK: 1442 case OP_DUP_ASTERISK:
@@ -1452,8 +1452,8 @@ link_nfa_nodes (void *extra, bin_tree_t *node)
1452 right = node->right->first->node_idx; 1452 right = node->right->first->node_idx;
1453 else 1453 else
1454 right = node->next->node_idx; 1454 right = node->next->node_idx;
1455 assert (left > -1); 1455 DEBUG_ASSERT (left > -1);
1456 assert (right > -1); 1456 DEBUG_ASSERT (right > -1);
1457 err = re_node_set_init_2 (dfa->edests + idx, left, right); 1457 err = re_node_set_init_2 (dfa->edests + idx, left, right);
1458 } 1458 }
1459 break; 1459 break;
@@ -1471,7 +1471,7 @@ link_nfa_nodes (void *extra, bin_tree_t *node)
1471 break; 1471 break;
1472 1472
1473 default: 1473 default:
1474 assert (!IS_EPSILON_NODE (node->token.type)); 1474 DEBUG_ASSERT (!IS_EPSILON_NODE (node->token.type));
1475 dfa->nexts[idx] = node->next->node_idx; 1475 dfa->nexts[idx] = node->next->node_idx;
1476 break; 1476 break;
1477 } 1477 }
@@ -1653,9 +1653,7 @@ calc_eclosure (re_dfa_t *dfa)
1653{ 1653{
1654 Idx node_idx; 1654 Idx node_idx;
1655 bool incomplete; 1655 bool incomplete;
1656#ifdef DEBUG 1656 DEBUG_ASSERT (dfa->nodes_len > 0);
1657 assert (dfa->nodes_len > 0);
1658#endif
1659 incomplete = false; 1657 incomplete = false;
1660 /* For each nodes, calculate epsilon closure. */ 1658 /* For each nodes, calculate epsilon closure. */
1661 for (node_idx = 0; ; ++node_idx) 1659 for (node_idx = 0; ; ++node_idx)
@@ -1670,9 +1668,7 @@ calc_eclosure (re_dfa_t *dfa)
1670 node_idx = 0; 1668 node_idx = 0;
1671 } 1669 }
1672 1670
1673#ifdef DEBUG 1671 DEBUG_ASSERT (dfa->eclosures[node_idx].nelem != -1);
1674 assert (dfa->eclosures[node_idx].nelem != -1);
1675#endif
1676 1672
1677 /* If we have already calculated, skip it. */ 1673 /* If we have already calculated, skip it. */
1678 if (dfa->eclosures[node_idx].nelem != 0) 1674 if (dfa->eclosures[node_idx].nelem != 0)
@@ -2442,9 +2438,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2442 2438
2443 default: 2439 default:
2444 /* Must not happen? */ 2440 /* Must not happen? */
2445#ifdef DEBUG 2441 DEBUG_ASSERT (false);
2446 assert (0);
2447#endif
2448 return NULL; 2442 return NULL;
2449 } 2443 }
2450 fetch_token (token, regexp, syntax); 2444 fetch_token (token, regexp, syntax);
@@ -3306,7 +3300,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3306 goto parse_bracket_exp_free_return; 3300 goto parse_bracket_exp_free_return;
3307 break; 3301 break;
3308 default: 3302 default:
3309 assert (0); 3303 DEBUG_ASSERT (false);
3310 break; 3304 break;
3311 } 3305 }
3312 } 3306 }
@@ -3662,7 +3656,6 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3662 Idx alloc = 0; 3656 Idx alloc = 0;
3663#endif /* not RE_ENABLE_I18N */ 3657#endif /* not RE_ENABLE_I18N */
3664 reg_errcode_t ret; 3658 reg_errcode_t ret;
3665 re_token_t br_token;
3666 bin_tree_t *tree; 3659 bin_tree_t *tree;
3667 3660
3668 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); 3661 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
@@ -3713,11 +3706,7 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3713#endif 3706#endif
3714 3707
3715 /* Build a tree for simple bracket. */ 3708 /* Build a tree for simple bracket. */
3716#if defined GCC_LINT || defined lint 3709 re_token_t br_token = { .type = SIMPLE_BRACKET, .opr.sbcset = sbcset };
3717 memset (&br_token, 0, sizeof br_token);
3718#endif
3719 br_token.type = SIMPLE_BRACKET;
3720 br_token.opr.sbcset = sbcset;
3721 tree = create_token_tree (dfa, NULL, NULL, &br_token); 3710 tree = create_token_tree (dfa, NULL, NULL, &br_token);
3722 if (__glibc_unlikely (tree == NULL)) 3711 if (__glibc_unlikely (tree == NULL))
3723 goto build_word_op_espace; 3712 goto build_word_op_espace;
@@ -3808,11 +3797,7 @@ static bin_tree_t *
3808create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, 3797create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
3809 re_token_type_t type) 3798 re_token_type_t type)
3810{ 3799{
3811 re_token_t t; 3800 re_token_t t = { .type = type };
3812#if defined GCC_LINT || defined lint
3813 memset (&t, 0, sizeof t);
3814#endif
3815 t.type = type;
3816 return create_token_tree (dfa, left, right, &t); 3801 return create_token_tree (dfa, left, right, &t);
3817} 3802}
3818 3803
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index 0092cc2a468..4ade0df0b47 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -212,7 +212,7 @@ build_wcs_buffer (re_string_t *pstr)
212{ 212{
213#ifdef _LIBC 213#ifdef _LIBC
214 unsigned char buf[MB_LEN_MAX]; 214 unsigned char buf[MB_LEN_MAX];
215 assert (MB_LEN_MAX >= pstr->mb_cur_max); 215 DEBUG_ASSERT (MB_LEN_MAX >= pstr->mb_cur_max);
216#else 216#else
217 unsigned char buf[64]; 217 unsigned char buf[64];
218#endif 218#endif
@@ -285,7 +285,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
285 size_t mbclen; 285 size_t mbclen;
286#ifdef _LIBC 286#ifdef _LIBC
287 char buf[MB_LEN_MAX]; 287 char buf[MB_LEN_MAX];
288 assert (MB_LEN_MAX >= pstr->mb_cur_max); 288 DEBUG_ASSERT (pstr->mb_cur_max <= MB_LEN_MAX);
289#else 289#else
290 char buf[64]; 290 char buf[64];
291#endif 291#endif
@@ -685,9 +685,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
685 pstr->valid_len - offset); 685 pstr->valid_len - offset);
686 pstr->valid_len -= offset; 686 pstr->valid_len -= offset;
687 pstr->valid_raw_len -= offset; 687 pstr->valid_raw_len -= offset;
688#if defined DEBUG && DEBUG 688 DEBUG_ASSERT (pstr->valid_len > 0);
689 assert (pstr->valid_len > 0);
690#endif
691 } 689 }
692 } 690 }
693 else 691 else
@@ -941,10 +939,7 @@ re_string_context_at (const re_string_t *input, Idx idx, int eflags)
941 Idx wc_idx = idx; 939 Idx wc_idx = idx;
942 while(input->wcs[wc_idx] == WEOF) 940 while(input->wcs[wc_idx] == WEOF)
943 { 941 {
944#if defined DEBUG && DEBUG 942 DEBUG_ASSERT (wc_idx >= 0);
945 /* It must not happen. */
946 assert (wc_idx >= 0);
947#endif
948 --wc_idx; 943 --wc_idx;
949 if (wc_idx < 0) 944 if (wc_idx < 0)
950 return input->tip_context; 945 return input->tip_context;
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index a3aedda8915..ccac8f13133 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -20,7 +20,6 @@
20#ifndef _REGEX_INTERNAL_H 20#ifndef _REGEX_INTERNAL_H
21#define _REGEX_INTERNAL_H 1 21#define _REGEX_INTERNAL_H 1
22 22
23#include <assert.h>
24#include <ctype.h> 23#include <ctype.h>
25#include <stdio.h> 24#include <stdio.h>
26#include <stdlib.h> 25#include <stdlib.h>
@@ -34,6 +33,14 @@
34#include <stdint.h> 33#include <stdint.h>
35 34
36#include <intprops.h> 35#include <intprops.h>
36#include <verify.h>
37
38#if defined DEBUG && DEBUG != 0
39# include <assert.h>
40# define DEBUG_ASSERT(x) assert (x)
41#else
42# define DEBUG_ASSERT(x) assume (x)
43#endif
37 44
38#ifdef _LIBC 45#ifdef _LIBC
39# include <libc-lock.h> 46# include <libc-lock.h>
@@ -44,22 +51,7 @@
44# define lock_unlock(lock) __libc_lock_unlock (lock) 51# define lock_unlock(lock) __libc_lock_unlock (lock)
45#elif defined GNULIB_LOCK && !defined USE_UNLOCKED_IO 52#elif defined GNULIB_LOCK && !defined USE_UNLOCKED_IO
46# include "glthread/lock.h" 53# include "glthread/lock.h"
47 /* Use gl_lock_define if empty macro arguments are known to work. 54# define lock_define(name) gl_lock_define (, name)
48 Otherwise, fall back on less-portable substitutes. */
49# if ((defined __GNUC__ && !defined __STRICT_ANSI__) \
50 || (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__))
51# define lock_define(name) gl_lock_define (, name)
52# elif USE_POSIX_THREADS
53# define lock_define(name) pthread_mutex_t name;
54# elif USE_PTH_THREADS
55# define lock_define(name) pth_mutex_t name;
56# elif USE_SOLARIS_THREADS
57# define lock_define(name) mutex_t name;
58# elif USE_WINDOWS_THREADS
59# define lock_define(name) gl_lock_t name;
60# else
61# define lock_define(name)
62# endif
63# define lock_init(lock) glthread_lock_init (&(lock)) 55# define lock_init(lock) glthread_lock_init (&(lock))
64# define lock_fini(lock) glthread_lock_destroy (&(lock)) 56# define lock_fini(lock) glthread_lock_destroy (&(lock))
65# define lock_lock(lock) glthread_lock_lock (&(lock)) 57# define lock_lock(lock) glthread_lock_lock (&(lock))
@@ -618,11 +610,7 @@ typedef struct
618{ 610{
619 /* The string object corresponding to the input string. */ 611 /* The string object corresponding to the input string. */
620 re_string_t input; 612 re_string_t input;
621#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
622 const re_dfa_t *const dfa; 613 const re_dfa_t *const dfa;
623#else
624 const re_dfa_t *dfa;
625#endif
626 /* EFLAGS of the argument of regexec. */ 614 /* EFLAGS of the argument of regexec. */
627 int eflags; 615 int eflags;
628 /* Where the matching ends. */ 616 /* Where the matching ends. */
diff --git a/lib/regexec.c b/lib/regexec.c
index f464869fb03..c5dc6220b2d 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -443,7 +443,7 @@ re_search_stub (struct re_pattern_buffer *bufp, const char *string, Idx length,
443 { 443 {
444 if (ret_len) 444 if (ret_len)
445 { 445 {
446 assert (pmatch[0].rm_so == start); 446 DEBUG_ASSERT (pmatch[0].rm_so == start);
447 rval = pmatch[0].rm_eo - start; 447 rval = pmatch[0].rm_eo - start;
448 } 448 }
449 else 449 else
@@ -502,9 +502,9 @@ re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
502 } 502 }
503 else 503 else
504 { 504 {
505 assert (regs_allocated == REGS_FIXED); 505 DEBUG_ASSERT (regs_allocated == REGS_FIXED);
506 /* This function may not be called with REGS_FIXED and nregs too big. */ 506 /* This function may not be called with REGS_FIXED and nregs too big. */
507 assert (regs->num_regs >= nregs); 507 DEBUG_ASSERT (nregs <= regs->num_regs);
508 rval = REGS_FIXED; 508 rval = REGS_FIXED;
509 } 509 }
510 510
@@ -597,21 +597,12 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
597 Idx extra_nmatch; 597 Idx extra_nmatch;
598 bool sb; 598 bool sb;
599 int ch; 599 int ch;
600#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
601 re_match_context_t mctx = { .dfa = dfa }; 600 re_match_context_t mctx = { .dfa = dfa };
602#else
603 re_match_context_t mctx;
604#endif
605 char *fastmap = ((preg->fastmap != NULL && preg->fastmap_accurate 601 char *fastmap = ((preg->fastmap != NULL && preg->fastmap_accurate
606 && start != last_start && !preg->can_be_null) 602 && start != last_start && !preg->can_be_null)
607 ? preg->fastmap : NULL); 603 ? preg->fastmap : NULL);
608 RE_TRANSLATE_TYPE t = preg->translate; 604 RE_TRANSLATE_TYPE t = preg->translate;
609 605
610#if !(defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
611 memset (&mctx, '\0', sizeof (re_match_context_t));
612 mctx.dfa = dfa;
613#endif
614
615 extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub + 1) : 0; 606 extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub + 1) : 0;
616 nmatch -= extra_nmatch; 607 nmatch -= extra_nmatch;
617 608
@@ -622,10 +613,8 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
622 || dfa->init_state_begbuf == NULL)) 613 || dfa->init_state_begbuf == NULL))
623 return REG_NOMATCH; 614 return REG_NOMATCH;
624 615
625#ifdef DEBUG
626 /* We assume front-end functions already check them. */ 616 /* We assume front-end functions already check them. */
627 assert (0 <= last_start && last_start <= length); 617 DEBUG_ASSERT (0 <= last_start && last_start <= length);
628#endif
629 618
630 /* If initial states with non-begbuf contexts have no elements, 619 /* If initial states with non-begbuf contexts have no elements,
631 the regex must be anchored. If preg->newline_anchor is set, 620 the regex must be anchored. If preg->newline_anchor is set,
@@ -677,8 +666,6 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
677 goto free_return; 666 goto free_return;
678 } 667 }
679 } 668 }
680 else
681 mctx.state_log = NULL;
682 669
683 match_first = start; 670 match_first = start;
684 mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF 671 mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
@@ -838,10 +825,8 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
838 match_ctx_clean (&mctx); 825 match_ctx_clean (&mctx);
839 } 826 }
840 827
841#ifdef DEBUG 828 DEBUG_ASSERT (match_last != -1);
842 assert (match_last != -1); 829 DEBUG_ASSERT (err == REG_NOERROR);
843 assert (err == REG_NOERROR);
844#endif
845 830
846 /* Set pmatch[] if we need. */ 831 /* Set pmatch[] if we need. */
847 if (nmatch > 0) 832 if (nmatch > 0)
@@ -886,7 +871,7 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
886 : mctx.input.offsets[pmatch[reg_idx].rm_eo]); 871 : mctx.input.offsets[pmatch[reg_idx].rm_eo]);
887 } 872 }
888#else 873#else
889 assert (mctx.input.offsets_needed == 0); 874 DEBUG_ASSERT (mctx.input.offsets_needed == 0);
890#endif 875#endif
891 pmatch[reg_idx].rm_so += match_first; 876 pmatch[reg_idx].rm_so += match_first;
892 pmatch[reg_idx].rm_eo += match_first; 877 pmatch[reg_idx].rm_eo += match_first;
@@ -926,9 +911,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
926 re_dfastate_t **sifted_states; 911 re_dfastate_t **sifted_states;
927 re_dfastate_t **lim_states = NULL; 912 re_dfastate_t **lim_states = NULL;
928 re_sift_context_t sctx; 913 re_sift_context_t sctx;
929#ifdef DEBUG 914 DEBUG_ASSERT (mctx->state_log != NULL);
930 assert (mctx->state_log != NULL);
931#endif
932 match_last = mctx->match_last; 915 match_last = mctx->match_last;
933 halt_node = mctx->last_node; 916 halt_node = mctx->last_node;
934 917
@@ -1074,7 +1057,7 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1074 /* An initial state must not be NULL (invalid). */ 1057 /* An initial state must not be NULL (invalid). */
1075 if (__glibc_unlikely (cur_state == NULL)) 1058 if (__glibc_unlikely (cur_state == NULL))
1076 { 1059 {
1077 assert (err == REG_ESPACE); 1060 DEBUG_ASSERT (err == REG_ESPACE);
1078 return -2; 1061 return -2;
1079 } 1062 }
1080 1063
@@ -1129,7 +1112,7 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1129 err = extend_buffers (mctx, next_char_idx + 1); 1112 err = extend_buffers (mctx, next_char_idx + 1);
1130 if (__glibc_unlikely (err != REG_NOERROR)) 1113 if (__glibc_unlikely (err != REG_NOERROR))
1131 { 1114 {
1132 assert (err == REG_ESPACE); 1115 DEBUG_ASSERT (err == REG_ESPACE);
1133 return -2; 1116 return -2;
1134 } 1117 }
1135 } 1118 }
@@ -1212,9 +1195,7 @@ check_halt_state_context (const re_match_context_t *mctx,
1212{ 1195{
1213 Idx i; 1196 Idx i;
1214 unsigned int context; 1197 unsigned int context;
1215#ifdef DEBUG 1198 DEBUG_ASSERT (state->halt);
1216 assert (state->halt);
1217#endif
1218 context = re_string_context_at (&mctx->input, idx, mctx->eflags); 1199 context = re_string_context_at (&mctx->input, idx, mctx->eflags);
1219 for (i = 0; i < state->nodes.nelem; ++i) 1200 for (i = 0; i < state->nodes.nelem; ++i)
1220 if (check_halt_node_context (mctx->dfa, state->nodes.elems[i], context)) 1201 if (check_halt_node_context (mctx->dfa, state->nodes.elems[i], context))
@@ -1362,7 +1343,7 @@ pop_fail_stack (struct re_fail_stack_t *fs, Idx *pidx, Idx nregs,
1362 regmatch_t *regs, re_node_set *eps_via_nodes) 1343 regmatch_t *regs, re_node_set *eps_via_nodes)
1363{ 1344{
1364 Idx num = --fs->num; 1345 Idx num = --fs->num;
1365 assert (num >= 0); 1346 DEBUG_ASSERT (num >= 0);
1366 *pidx = fs->stack[num].idx; 1347 *pidx = fs->stack[num].idx;
1367 memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs); 1348 memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs);
1368 re_node_set_free (eps_via_nodes); 1349 re_node_set_free (eps_via_nodes);
@@ -1389,10 +1370,8 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
1389 regmatch_t *prev_idx_match; 1370 regmatch_t *prev_idx_match;
1390 bool prev_idx_match_malloced = false; 1371 bool prev_idx_match_malloced = false;
1391 1372
1392#ifdef DEBUG 1373 DEBUG_ASSERT (nmatch > 1);
1393 assert (nmatch > 1); 1374 DEBUG_ASSERT (mctx->state_log != NULL);
1394 assert (mctx->state_log != NULL);
1395#endif
1396 if (fl_backtrack) 1375 if (fl_backtrack)
1397 { 1376 {
1398 fs = &fs_body; 1377 fs = &fs_body;
@@ -1578,9 +1557,7 @@ sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
1578 Idx str_idx = sctx->last_str_idx; 1557 Idx str_idx = sctx->last_str_idx;
1579 re_node_set cur_dest; 1558 re_node_set cur_dest;
1580 1559
1581#ifdef DEBUG 1560 DEBUG_ASSERT (mctx->state_log != NULL && mctx->state_log[str_idx] != NULL);
1582 assert (mctx->state_log != NULL && mctx->state_log[str_idx] != NULL);
1583#endif
1584 1561
1585 /* Build sifted state_log[str_idx]. It has the nodes which can epsilon 1562 /* Build sifted state_log[str_idx]. It has the nodes which can epsilon
1586 transit to the last_node and the last_node itself. */ 1563 transit to the last_node and the last_node itself. */
@@ -1648,11 +1625,8 @@ build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
1648 Idx prev_node = cur_src->elems[i]; 1625 Idx prev_node = cur_src->elems[i];
1649 int naccepted = 0; 1626 int naccepted = 0;
1650 bool ok; 1627 bool ok;
1628 DEBUG_ASSERT (!IS_EPSILON_NODE (dfa->nodes[prev_node].type));
1651 1629
1652#ifdef DEBUG
1653 re_token_type_t type = dfa->nodes[prev_node].type;
1654 assert (!IS_EPSILON_NODE (type));
1655#endif
1656#ifdef RE_ENABLE_I18N 1630#ifdef RE_ENABLE_I18N
1657 /* If the node may accept "multi byte". */ 1631 /* If the node may accept "multi byte". */
1658 if (dfa->nodes[prev_node].accept_mb) 1632 if (dfa->nodes[prev_node].accept_mb)
@@ -2505,9 +2479,7 @@ transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
2505 err = clean_state_log_if_needed (mctx, dest_idx); 2479 err = clean_state_log_if_needed (mctx, dest_idx);
2506 if (__glibc_unlikely (err != REG_NOERROR)) 2480 if (__glibc_unlikely (err != REG_NOERROR))
2507 return err; 2481 return err;
2508#ifdef DEBUG 2482 DEBUG_ASSERT (dfa->nexts[cur_node_idx] != -1);
2509 assert (dfa->nexts[cur_node_idx] != -1);
2510#endif
2511 new_nodes = dfa->eclosures + dfa->nexts[cur_node_idx]; 2483 new_nodes = dfa->eclosures + dfa->nexts[cur_node_idx];
2512 2484
2513 dest_state = mctx->state_log[dest_idx]; 2485 dest_state = mctx->state_log[dest_idx];
@@ -2571,9 +2543,7 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2571 2543
2572 /* And add the epsilon closures (which is 'new_dest_nodes') of 2544 /* And add the epsilon closures (which is 'new_dest_nodes') of
2573 the backreference to appropriate state_log. */ 2545 the backreference to appropriate state_log. */
2574#ifdef DEBUG 2546 DEBUG_ASSERT (dfa->nexts[node_idx] != -1);
2575 assert (dfa->nexts[node_idx] != -1);
2576#endif
2577 for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx) 2547 for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx)
2578 { 2548 {
2579 Idx subexp_len; 2549 Idx subexp_len;
@@ -3032,10 +3002,8 @@ check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
3032 { 3002 {
3033 int naccepted = 0; 3003 int naccepted = 0;
3034 Idx cur_node = cur_nodes->elems[cur_idx]; 3004 Idx cur_node = cur_nodes->elems[cur_idx];
3035#ifdef DEBUG 3005 DEBUG_ASSERT (!IS_EPSILON_NODE (dfa->nodes[cur_node].type));
3036 re_token_type_t type = dfa->nodes[cur_node].type; 3006
3037 assert (!IS_EPSILON_NODE (type));
3038#endif
3039#ifdef RE_ENABLE_I18N 3007#ifdef RE_ENABLE_I18N
3040 /* If the node may accept "multi byte". */ 3008 /* If the node may accept "multi byte". */
3041 if (dfa->nodes[cur_node].accept_mb) 3009 if (dfa->nodes[cur_node].accept_mb)
@@ -3103,9 +3071,7 @@ check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
3103 reg_errcode_t err; 3071 reg_errcode_t err;
3104 Idx idx, outside_node; 3072 Idx idx, outside_node;
3105 re_node_set new_nodes; 3073 re_node_set new_nodes;
3106#ifdef DEBUG 3074 DEBUG_ASSERT (cur_nodes->nelem);
3107 assert (cur_nodes->nelem);
3108#endif
3109 err = re_node_set_alloc (&new_nodes, cur_nodes->nelem); 3075 err = re_node_set_alloc (&new_nodes, cur_nodes->nelem);
3110 if (__glibc_unlikely (err != REG_NOERROR)) 3076 if (__glibc_unlikely (err != REG_NOERROR))
3111 return err; 3077 return err;
@@ -3695,6 +3661,7 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3695 bitset_empty (accepts); 3661 bitset_empty (accepts);
3696 } 3662 }
3697 } 3663 }
3664 assume (ndests <= SBC_MAX);
3698 return ndests; 3665 return ndests;
3699 error_return: 3666 error_return:
3700 for (j = 0; j < ndests; ++j) 3667 for (j = 0; j < ndests; ++j)
@@ -4272,10 +4239,8 @@ static reg_errcode_t
4272__attribute_warn_unused_result__ 4239__attribute_warn_unused_result__
4273match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx) 4240match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx)
4274{ 4241{
4275#ifdef DEBUG 4242 DEBUG_ASSERT (mctx->sub_tops != NULL);
4276 assert (mctx->sub_tops != NULL); 4243 DEBUG_ASSERT (mctx->asub_tops > 0);
4277 assert (mctx->asub_tops > 0);
4278#endif
4279 if (__glibc_unlikely (mctx->nsub_tops == mctx->asub_tops)) 4244 if (__glibc_unlikely (mctx->nsub_tops == mctx->asub_tops))
4280 { 4245 {
4281 Idx new_asub_tops = mctx->asub_tops * 2; 4246 Idx new_asub_tops = mctx->asub_tops * 2;
diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h
index 4260468b612..d49625780bb 100644
--- a/lib/stdio-impl.h
+++ b/lib/stdio-impl.h
@@ -18,11 +18,16 @@
18 the same implementation of stdio extension API, except that some fields 18 the same implementation of stdio extension API, except that some fields
19 have different naming conventions, or their access requires some casts. */ 19 have different naming conventions, or their access requires some casts. */
20 20
21/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this 21/* Glibc 2.28 made _IO_UNBUFFERED and _IO_IN_BACKUP private. For now, work
22 problem by defining it ourselves. FIXME: Do not rely on glibc 22 around this problem by defining them ourselves. FIXME: Do not rely on glibc
23 internals. */ 23 internals. */
24#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN 24#if defined _IO_EOF_SEEN
25# define _IO_IN_BACKUP 0x100 25# if !defined _IO_UNBUFFERED
26# define _IO_UNBUFFERED 0x2
27# endif
28# if !defined _IO_IN_BACKUP
29# define _IO_IN_BACKUP 0x100
30# endif
26#endif 31#endif
27 32
28/* BSD stdio derived implementations. */ 33/* BSD stdio derived implementations. */