aboutsummaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2021-06-30 21:46:50 +0300
committerArnold D. Robbins <arnold@skeeve.com>2021-06-30 21:46:50 +0300
commitb3bfdb152de59cab66ee428a42bc2a7f6f97b636 (patch)
treec2fb49b170362f23736b1e720c7de9b512c0368c /support
parentb00eb107c4f72189c6a49823550413177e6bbb60 (diff)
downloadegawk-b3bfdb152de59cab66ee428a42bc2a7f6f97b636.tar.gz
egawk-b3bfdb152de59cab66ee428a42bc2a7f6f97b636.tar.bz2
egawk-b3bfdb152de59cab66ee428a42bc2a7f6f97b636.zip
Update support files from GNULIB.
Diffstat (limited to 'support')
-rw-r--r--support/ChangeLog5
-rw-r--r--support/dfa.c42
-rw-r--r--support/dynarray.h24
-rw-r--r--support/libc-config.h5
-rw-r--r--support/regexec.c12
-rw-r--r--support/verify.h14
6 files changed, 59 insertions, 43 deletions
diff --git a/support/ChangeLog b/support/ChangeLog
index f7a52b02..8baacf3c 100644
--- a/support/ChangeLog
+++ b/support/ChangeLog
@@ -1,3 +1,8 @@
+2021-06-30 Arnold D. Robbins <arnold@skeeve.com>
+
+ * dfa.c, dynarray.h, libc-config.h, regexec.c,
+ verify.h: Update from GNULIB. Sigh.
+
2021-05-10 Arnold D. Robbins <arnold@skeeve.com>
* support/dynarray_at_failure.c, support/dynarray_resize_clear.c:
diff --git a/support/dfa.c b/support/dfa.c
index 33de2fb8..7e05a78d 100644
--- a/support/dfa.c
+++ b/support/dfa.c
@@ -617,14 +617,14 @@ static void regexp (struct dfa *dfa);
* PWC points to wint_t, not to wchar_t.
* The last arg is a dfa *D instead of merely a multibyte conversion
state D->mbs.
- * N must be at least 1.
+ * N is idx_t not size_t, and must be at least 1.
* S[N - 1] must be a sentinel byte.
* Shift encodings are not supported.
* The return value is always in the range 1..N.
* D->mbs is always valid afterwards.
* *PWC is always set to something. */
static int
-mbs_to_wchar (wint_t *pwc, char const *s, size_t n, struct dfa *d)
+mbs_to_wchar (wint_t *pwc, char const *s, idx_t n, struct dfa *d)
{
unsigned char uc = s[0];
wint_t wc = d->localeinfo.sbctowc[uc];
@@ -1531,8 +1531,8 @@ addtok_mb (struct dfa *dfa, token t, char mbprop)
dfa->tokens = xpalloc (dfa->tokens, &dfa->talloc, 1, -1,
sizeof *dfa->tokens);
if (dfa->localeinfo.multibyte)
- dfa->multibyte_prop = xnrealloc (dfa->multibyte_prop, dfa->talloc,
- sizeof *dfa->multibyte_prop);
+ dfa->multibyte_prop = xreallocarray (dfa->multibyte_prop, dfa->talloc,
+ sizeof *dfa->multibyte_prop);
}
if (dfa->localeinfo.multibyte)
dfa->multibyte_prop[dfa->tindex] = mbprop;
@@ -2165,7 +2165,7 @@ state_index (struct dfa *d, position_set const *s, int context)
for (i = 0; i < s->nelem; ++i)
{
- size_t ind = s->elems[i].index;
+ idx_t ind = s->elems[i].index;
hash ^= ind + s->elems[i].constraint;
}
@@ -2488,7 +2488,7 @@ reorder_tokens (struct dfa *d)
static void
dfaoptimize (struct dfa *d)
{
- char *flags = xzalloc (d->tindex);
+ char *flags = xizalloc (d->tindex);
for (idx_t i = 0; i < d->tindex; i++)
{
@@ -2511,7 +2511,7 @@ dfaoptimize (struct dfa *d)
position_set *merged = &merged0;
alloc_position_set (merged, d->nleaves);
- d->constraints = xcalloc (d->tindex, sizeof *d->constraints);
+ d->constraints = xicalloc (d->tindex, sizeof *d->constraints);
for (idx_t i = 0; i < d->tindex; i++)
if (flags[i] & OPT_QUEUED)
@@ -2614,9 +2614,9 @@ dfaanalyze (struct dfa *d, bool searchflag)
d->searchflag = searchflag;
alloc_position_set (&merged, d->nleaves);
- d->follows = xcalloc (tindex, sizeof *d->follows);
+ d->follows = xicalloc (tindex, sizeof *d->follows);
position_set *backward
- = d->epsilon ? xcalloc (tindex, sizeof *backward) : NULL;
+ = d->epsilon ? xicalloc (tindex, sizeof *backward) : NULL;
for (idx_t i = 0; i < tindex; i++)
{
@@ -2799,7 +2799,7 @@ dfaanalyze (struct dfa *d, bool searchflag)
append (pos, &tmp);
- d->separates = xcalloc (tindex, sizeof *d->separates);
+ d->separates = xicalloc (tindex, sizeof *d->separates);
for (idx_t i = 0; i < tindex; i++)
{
@@ -2850,13 +2850,13 @@ realloc_trans_if_necessary (struct dfa *d)
realtrans[0] = realtrans[1] = NULL;
d->trans = realtrans + 2;
idx_t newalloc = d->tralloc = newalloc1 - 2;
- d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
- d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
- d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);
+ d->fails = xreallocarray (d->fails, newalloc, sizeof *d->fails);
+ d->success = xreallocarray (d->success, newalloc, sizeof *d->success);
+ d->newlines = xreallocarray (d->newlines, newalloc, sizeof *d->newlines);
if (d->localeinfo.multibyte)
{
realtrans = d->mb_trans ? d->mb_trans - 2 : NULL;
- realtrans = xnrealloc (realtrans, newalloc1, sizeof *realtrans);
+ realtrans = xreallocarray (realtrans, newalloc1, sizeof *realtrans);
if (oldalloc == 0)
realtrans[0] = realtrans[1] = NULL;
d->mb_trans = realtrans + 2;
@@ -3900,7 +3900,7 @@ icatalloc (char *old, char const *new)
if (newsize == 0)
return old;
idx_t oldsize = strlen (old);
- char *result = xrealloc (old, oldsize + newsize + 1);
+ char *result = xirealloc (old, oldsize + newsize + 1);
memcpy (result + oldsize, new, newsize + 1);
return result;
}
@@ -3915,7 +3915,7 @@ freelist (char **cpp)
static char **
enlist (char **cpp, char *new, idx_t len)
{
- new = memcpy (xmalloc (len + 1), new, len);
+ new = memcpy (ximalloc (len + 1), new, len);
new[len] = '\0';
/* Is there already something in the list that's new (or longer)? */
idx_t i;
@@ -3938,7 +3938,7 @@ enlist (char **cpp, char *new, idx_t len)
cpp[i] = NULL;
}
/* Add the new string. */
- cpp = xnrealloc (cpp, i + 2, sizeof *cpp);
+ cpp = xreallocarray (cpp, i + 2, sizeof *cpp);
cpp[i] = new;
cpp[i + 1] = NULL;
return cpp;
@@ -4016,9 +4016,9 @@ allocmust (must *mp, idx_t size)
{
must *new_mp = xmalloc (sizeof *new_mp);
new_mp->in = xzalloc (sizeof *new_mp->in);
- new_mp->left = xzalloc (size);
- new_mp->right = xzalloc (size);
- new_mp->is = xzalloc (size);
+ new_mp->left = xizalloc (size);
+ new_mp->right = xizalloc (size);
+ new_mp->is = xizalloc (size);
new_mp->begline = false;
new_mp->endline = false;
new_mp->prev = mp;
@@ -4169,7 +4169,7 @@ dfamust (struct dfa const *d)
{
idx_t lrlen = strlen (lmp->right);
idx_t rllen = strlen (rmp->left);
- char *tp = xmalloc (lrlen + rllen);
+ char *tp = ximalloc (lrlen + rllen);
memcpy (tp, lmp->right, lrlen);
memcpy (tp + lrlen, rmp->left, rllen);
lmp->in = enlist (lmp->in, tp, lrlen + rllen);
diff --git a/support/dynarray.h b/support/dynarray.h
index ba2bc2ed..76ca2294 100644
--- a/support/dynarray.h
+++ b/support/dynarray.h
@@ -1,17 +1,17 @@
/* Type-safe arrays which grow dynamically.
Copyright 2021 Free Software Foundation, Inc.
- 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 3 of the License, or
- (at your option) any later version.
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
+ This file 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.
+ GNU Lesser General Public License for more details.
- You should have received a copy of the GNU General Public License
+ You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert and Bruno Haible, 2021. */
@@ -259,18 +259,22 @@ static DYNARRAY_ELEMENT *
#if defined DYNARRAY_STRUCT || defined DYNARRAY_ELEMENT || defined DYNARRAY_PREFIX
-# include <libc-config.h>
+# ifndef _GL_LIKELY
+/* Rely on __builtin_expect, as provided by the module 'builtin-expect'. */
+# define _GL_LIKELY(cond) __builtin_expect ((cond), 1)
+# define _GL_UNLIKELY(cond) __builtin_expect ((cond), 0)
+# endif
/* Define auxiliary structs and declare auxiliary functions, common to all
instantiations of dynarray. */
-# include <malloc/dynarray.h>
+# include <malloc/dynarray.gl.h>
/* Define the instantiation, specified through
DYNARRAY_STRUCT
DYNARRAY_ELEMENT
DYNARRAY_PREFIX
etc. */
-# include <malloc/dynarray-skeleton.c>
+# include <malloc/dynarray-skeleton.gl.h>
#else
diff --git a/support/libc-config.h b/support/libc-config.h
index fabca2fa..f68749fc 100644
--- a/support/libc-config.h
+++ b/support/libc-config.h
@@ -28,7 +28,10 @@
When compiled as part of glibc this is a no-op; when compiled as
part of Gnulib this includes Gnulib's <config.h> and defines macros
- that glibc library code would normally assume. */
+ that glibc library code would normally assume.
+
+ Note: This header file MUST NOT be included by public header files
+ of Gnulib. */
#include <config.h>
diff --git a/support/regexec.c b/support/regexec.c
index 6309deac..5e4eb497 100644
--- a/support/regexec.c
+++ b/support/regexec.c
@@ -1220,9 +1220,13 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
{
re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes;
re_node_set *edests = &dfa->edests[node];
- bool ok = re_node_set_insert (eps_via_nodes, node);
- if (__glibc_unlikely (! ok))
- return -2;
+
+ if (! re_node_set_contains (eps_via_nodes, node))
+ {
+ bool ok = re_node_set_insert (eps_via_nodes, node);
+ if (__glibc_unlikely (! ok))
+ return -2;
+ }
/* Pick a valid destination, or return -1 if none is found. */
Idx dest_node = -1;
@@ -1414,7 +1418,7 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch);
if ((idx == pmatch[0].rm_eo && cur_node == mctx->last_node)
- || re_node_set_contains (&eps_via_nodes, cur_node))
+ || (fs && re_node_set_contains (&eps_via_nodes, cur_node)))
{
Idx reg_idx;
cur_node = -1;
diff --git a/support/verify.h b/support/verify.h
index 65514c34..3485a7e6 100644
--- a/support/verify.h
+++ b/support/verify.h
@@ -2,17 +2,17 @@
Copyright (C) 2005-2006, 2009-2021 Free Software Foundation, Inc.
- 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 3 of the License, or
- (at your option) any later version.
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
+ This file 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.
+ GNU Lesser General Public License for more details.
- You should have received a copy of the GNU General Public License
+ You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */