bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

regex: 7 patches syncing from glibc to gnulib


From: Jim Meyering
Subject: regex: 7 patches syncing from glibc to gnulib
Date: Thu, 28 Jan 2010 11:42:57 +0100

Last week or so I merged a bunch of gnulib fixes to glibc and filed BZs.
Uli was quick and has dealt with all of these, occasionally making a
small correction:

      http://sourceware.org/bugzilla/show_bug.cgi?id=11183
      http://sourceware.org/bugzilla/show_bug.cgi?id=11184
      http://sourceware.org/bugzilla/show_bug.cgi?id=11185
      http://sourceware.org/bugzilla/show_bug.cgi?id=11186
      http://sourceware.org/bugzilla/show_bug.cgi?id=11187
      http://sourceware.org/bugzilla/show_bug.cgi?id=11188
      http://sourceware.org/bugzilla/show_bug.cgi?id=11189
      http://sourceware.org/bugzilla/show_bug.cgi?id=11190
      http://sourceware.org/bugzilla/show_bug.cgi?id=11191
      http://sourceware.org/bugzilla/show_bug.cgi?id=11192
      http://sourceware.org/bugzilla/show_bug.cgi?id=11193

Today, I've just pushed a few fixes from glibc into gnulib,
as well as a few white-space-only changes that will make my
subsequent merges a little easier.

I'll continue in this vein in the next week or two.

Feedback welcome.


>From 54b5ce0e1a4f6a4af37f970e45e6e173e5b0a1c6 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 19 Jan 2010 08:47:17 +0100
Subject: [PATCH 1/7] regex_internal.h: define __attribute_warn_unused_result__

* lib/regex_internal.h (__attribute_warn_unused_result__): Define.
---
 ChangeLog            |    3 +++
 lib/regex_internal.h |    8 ++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8b5597f..193d27b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2010-01-28  Jim Meyering  <address@hidden>

+       regex_internal.h: define __attribute_warn_unused_result__
+       * lib/regex_internal.h (__attribute_warn_unused_result__): Define.
+
        maint: add a syntax-check rule to check for vulnerable Makefile.in
        * top/maint.mk (sc_vulnerable_makefile_CVE-2009-4029): New rule.

diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index f5c3125..704d1cc 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -851,4 +851,12 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
 }
 #endif /* RE_ENABLE_I18N */

+#if __GNUC_PREREQ (3,4)
+# undef __attribute_warn_unused_result__
+# define __attribute_warn_unused_result__ \
+   __attribute__ ((__warn_unused_result__))
+#else
+# define __attribute_warn_unused_result__ /* empty */
+#endif
+
 #endif /*  _REGEX_INTERNAL_H */
--
1.7.0.rc0.170.g7207c


>From 419dde7cae3f1c4a0df8a29f5c3361a90201f428 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 19 Jan 2010 09:18:19 +0100
Subject: [PATCH 2/7] regcomp.c: do not ignore internal return values

* lib/regcomp.c: Do not ignore internal return values.
This is from glibc's 2da42bc06566bc89785e580fa1ac89b4c9f2a63c,
but without its white-space changes and spelling fixes.
---
 ChangeLog     |    5 +++++
 lib/regcomp.c |   12 +++++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 193d27b..9434d38 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2010-01-28  Jim Meyering  <address@hidden>

+       regcomp.c: do not ignore internal return values
+       * lib/regcomp.c: Do not ignore internal return values.
+       This is from glibc's 2da42bc06566bc89785e580fa1ac89b4c9f2a63c,
+       but without its white-space changes and spelling fixes.
+
        regex_internal.h: define __attribute_warn_unused_result__
        * lib/regex_internal.h (__attribute_warn_unused_result__): Define.

diff --git a/lib/regcomp.c b/lib/regcomp.c
index ebb696a..fb05da3 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -1021,7 +1021,11 @@ create_initial_state (re_dfa_t *dfa)
            Idx dest_idx = dfa->edests[node_idx].elems[0];
            if (!re_node_set_contains (&init_nodes, dest_idx))
              {
-               re_node_set_merge (&init_nodes, dfa->eclosures + dest_idx);
+               reg_errcode_t err = re_node_set_merge (&init_nodes,
+                                                      dfa->eclosures
+                                                      + dest_idx);
+               if (err != REG_NOERROR)
+                 return err;
                i = 0;
              }
          }
@@ -1446,7 +1450,7 @@ link_nfa_nodes (void *extra, bin_tree_t *node)
     case OP_BACK_REF:
       dfa->nexts[idx] = node->next->node_idx;
       if (node->token.type == OP_BACK_REF)
-       re_node_set_init_1 (dfa->edests + idx, dfa->nexts[idx]);
+       err = re_node_set_init_1 (dfa->edests + idx, dfa->nexts[idx]);
       break;

     default:
@@ -1726,7 +1730,9 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, 
Idx node, bool root)
        else
          eclosure_elem = dfa->eclosures[edest];
        /* Merge the epsilon closure of `edest'.  */
-       re_node_set_merge (&eclosure, &eclosure_elem);
+       err = re_node_set_merge (&eclosure, &eclosure_elem);
+       if (BE (err != REG_NOERROR, 0))
+         return err;
        /* If the epsilon closure of `edest' is incomplete,
           the epsilon closure of this node is also incomplete.  */
        if (dfa->eclosures[edest].nelem == 0)
--
1.7.0.rc0.170.g7207c


>From 6bd173f7ffcd7f02646ad1086035e8ba9cbddcba Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 19 Jan 2010 09:22:30 +0100
Subject: [PATCH 3/7] regcomp.c: sync white-space changes from glibc

* lib/regcomp.c: Merge to accommodate white space
changes from glibc's 2da42bc06566bc89785e580fa1ac89b4c9f2a63c.
---
 ChangeLog     |    4 ++
 lib/regcomp.c |   92 ++++++++++++++++++++++++++++----------------------------
 2 files changed, 50 insertions(+), 46 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9434d38..9024843 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2010-01-28  Jim Meyering  <address@hidden>

+       regcomp.c: sync white-space changes from glibc
+       * lib/regcomp.c: Merge to accommodate white space
+       changes from glibc's 2da42bc06566bc89785e580fa1ac89b4c9f2a63c.
+
        regcomp.c: do not ignore internal return values
        * lib/regcomp.c: Do not ignore internal return values.
        This is from glibc's 2da42bc06566bc89785e580fa1ac89b4c9f2a63c,
diff --git a/lib/regcomp.c b/lib/regcomp.c
index fb05da3..6e87a48 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -636,7 +636,7 @@ free_dfa_content (re_dfa_t *dfa)
            re_dfastate_t *state = entry->array[j];
            free_state (state);
          }
-        re_free (entry->array);
+       re_free (entry->array);
       }
   re_free (dfa->state_table);
 #ifdef RE_ENABLE_I18N
@@ -1094,8 +1094,8 @@ optimize_utf8 (re_dfa_t *dfa)
          }
        break;
       case OP_PERIOD:
-        has_period = true;
-        break;
+       has_period = true;
+       break;
       case OP_BACK_REF:
       case OP_ALT:
       case END_OF_RE:
@@ -1196,7 +1196,7 @@ analyze (regex_t *preg)
     {
       dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len);
       if (BE (dfa->inveclosures == NULL, 0))
-        return REG_ESPACE;
+       return REG_ESPACE;
       ret = calc_inveclosure (dfa);
     }

@@ -1218,16 +1218,16 @@ postorder (bin_tree_t *root, reg_errcode_t (fn (void *, 
bin_tree_t *)),
         if that's the only child).  */
       while (node->left || node->right)
        if (node->left)
-          node = node->left;
-        else
-          node = node->right;
+         node = node->left;
+       else
+         node = node->right;

       do
        {
          reg_errcode_t err = fn (extra, node);
          if (BE (err != REG_NOERROR, 0))
            return err;
-          if (node->parent == NULL)
+         if (node->parent == NULL)
            return REG_NOERROR;
          prev = node;
          node = node->parent;
@@ -1261,7 +1261,7 @@ preorder (bin_tree_t *root, reg_errcode_t (fn (void *, 
bin_tree_t *)),
              prev = node;
              node = node->parent;
              if (!node)
-               return REG_NOERROR;
+               return REG_NOERROR;
            }
          node = node->right;
        }
@@ -1284,13 +1284,13 @@ optimize_subexps (void *extra, bin_tree_t *node)
     }

   else if (node->token.type == SUBEXP
-           && node->left && node->left->token.type == SUBEXP)
+          && node->left && node->left->token.type == SUBEXP)
     {
       Idx other_idx = node->left->token.opr.idx;

       node->left = node->left->left;
       if (node->left)
-        node->left->parent = node;
+       node->left->parent = node;

       dfa->subexp_map[other_idx] = dfa->subexp_map[node->token.opr.idx];
       if (other_idx < BITSET_WORD_BITS)
@@ -1375,9 +1375,9 @@ calc_first (void *extra, bin_tree_t *node)
       node->first = node;
       node->node_idx = re_dfa_add_node (dfa, node->token);
       if (BE (node->node_idx == REG_MISSING, 0))
-        return REG_ESPACE;
+       return REG_ESPACE;
       if (node->token.type == ANCHOR)
-        dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type;
+       dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type;
     }
   return REG_NOERROR;
 }
@@ -1399,7 +1399,7 @@ calc_next (void *extra, bin_tree_t *node)
       if (node->left)
        node->left->next = node->next;
       if (node->right)
-        node->right->next = node->next;
+       node->right->next = node->next;
       break;
     }
   return REG_NOERROR;
@@ -2329,7 +2329,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, 
re_token_t *token,
          && dfa->word_ops_used == 0)
        init_word_char (dfa);
       if (token->opr.ctx_type == WORD_DELIM
-          || token->opr.ctx_type == NOT_WORD_DELIM)
+         || token->opr.ctx_type == NOT_WORD_DELIM)
        {
          bin_tree_t *tree_first, *tree_last;
          if (token->opr.ctx_type == WORD_DELIM)
@@ -2337,13 +2337,13 @@ parse_expression (re_string_t *regexp, regex_t *preg, 
re_token_t *token,
              token->opr.ctx_type = WORD_FIRST;
              tree_first = create_token_tree (dfa, NULL, NULL, token);
              token->opr.ctx_type = WORD_LAST;
-            }
-          else
-            {
+           }
+         else
+           {
              token->opr.ctx_type = INSIDE_WORD;
              tree_first = create_token_tree (dfa, NULL, NULL, token);
              token->opr.ctx_type = INSIDE_NOTWORD;
-            }
+           }
          tree_last = create_token_tree (dfa, NULL, NULL, token);
          tree = create_tree (dfa, tree_first, tree_last, OP_ALT);
          if (BE (tree_first == NULL || tree_last == NULL || tree == NULL, 0))
@@ -2454,7 +2454,7 @@ parse_sub_exp (re_string_t *regexp, regex_t *preg, 
re_token_t *token,
     {
       tree = parse_reg_exp (regexp, preg, token, syntax, nest, err);
       if (BE (*err == REG_NOERROR && token->type != OP_CLOSE_SUBEXP, 0))
-        *err = REG_EPAREN;
+       *err = REG_EPAREN;
       if (BE (*err != REG_NOERROR, 0))
        return NULL;
     }
@@ -2673,9 +2673,9 @@ build_range_exp (bitset_t sbcset, bracket_elem_t 
*start_elem,
        no MBCSET if dfa->mb_cur_max == 1.  */
     if (mbcset)
       {
-        /* Check the space of the arrays.  */
-        if (BE (*range_alloc == mbcset->nranges, 0))
-          {
+       /* Check the space of the arrays.  */
+       if (BE (*range_alloc == mbcset->nranges, 0))
+         {
            /* There is not enough space, need realloc.  */
            wchar_t *new_array_start, *new_array_end;
            Idx new_nranges;
@@ -2685,9 +2685,9 @@ build_range_exp (bitset_t sbcset, bracket_elem_t 
*start_elem,
            /* Use realloc since mbcset->range_starts and mbcset->range_ends
               are NULL if *range_alloc == 0.  */
            new_array_start = re_realloc (mbcset->range_starts, wchar_t,
-                                         new_nranges);
+                                         new_nranges);
            new_array_end = re_realloc (mbcset->range_ends, wchar_t,
-                                       new_nranges);
+                                       new_nranges);

            if (BE (new_array_start == NULL || new_array_end == NULL, 0))
              return REG_ESPACE;
@@ -2695,10 +2695,10 @@ build_range_exp (bitset_t sbcset, bracket_elem_t 
*start_elem,
            mbcset->range_starts = new_array_start;
            mbcset->range_ends = new_array_end;
            *range_alloc = new_nranges;
-          }
+         }

-        mbcset->range_starts[mbcset->nranges] = start_wc;
-        mbcset->range_ends[mbcset->nranges++] = end_wc;
+       mbcset->range_starts[mbcset->nranges] = start_wc;
+       mbcset->range_ends[mbcset->nranges++] = end_wc;
       }

     /* Build the table for single byte characters.  */
@@ -2916,8 +2916,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, 
re_token_t *token,
         build below suffices. */
       if (nrules > 0 || dfa->mb_cur_max > 1)
        {
-          /* Check the space of the arrays.  */
-          if (BE (*range_alloc == mbcset->nranges, 0))
+         /* Check the space of the arrays.  */
+         if (BE (*range_alloc == mbcset->nranges, 0))
            {
              /* There is not enough space, need realloc.  */
              uint32_t *new_array_start;
@@ -2929,18 +2929,18 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, 
re_token_t *token,
              new_array_start = re_realloc (mbcset->range_starts, uint32_t,
                                            new_nranges);
              new_array_end = re_realloc (mbcset->range_ends, uint32_t,
-                                         new_nranges);
+                                         new_nranges);

              if (BE (new_array_start == NULL || new_array_end == NULL, 0))
-               return REG_ESPACE;
+               return REG_ESPACE;

              mbcset->range_starts = new_array_start;
              mbcset->range_ends = new_array_end;
              *range_alloc = new_nranges;
            }

-          mbcset->range_starts[mbcset->nranges] = start_collseq;
-          mbcset->range_ends[mbcset->nranges++] = end_collseq;
+         mbcset->range_starts[mbcset->nranges] = start_collseq;
+         mbcset->range_ends[mbcset->nranges++] = end_collseq;
        }

       /* Build the table for single byte characters.  */
@@ -3274,17 +3274,17 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, 
re_token_t *token,
         of having both SIMPLE_BRACKET and COMPLEX_BRACKET.  */
       if (sbc_idx < BITSET_WORDS)
        {
-          /* Build a tree for simple bracket.  */
-          br_token.type = SIMPLE_BRACKET;
-          br_token.opr.sbcset = sbcset;
-          work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
-          if (BE (work_tree == NULL, 0))
-            goto parse_bracket_exp_espace;
+         /* Build a tree for simple bracket.  */
+         br_token.type = SIMPLE_BRACKET;
+         br_token.opr.sbcset = sbcset;
+         work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
+         if (BE (work_tree == NULL, 0))
+           goto parse_bracket_exp_espace;

-          /* Then join them by ALT node.  */
-          work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT);
-          if (BE (work_tree == NULL, 0))
-            goto parse_bracket_exp_espace;
+         /* Then join them by ALT node.  */
+         work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT);
+         if (BE (work_tree == NULL, 0))
+           goto parse_bracket_exp_espace;
        }
       else
        {
@@ -3303,7 +3303,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, 
re_token_t *token,
       br_token.opr.sbcset = sbcset;
       work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
       if (BE (work_tree == NULL, 0))
-        goto parse_bracket_exp_espace;
+       goto parse_bracket_exp_espace;
     }
   return work_tree;

@@ -3858,7 +3858,7 @@ duplicate_tree (const bin_tree_t *root, re_dfa_t *dfa)
              node = node->parent;
              dup_node = dup_node->parent;
              if (!node)
-               return dup_root;
+               return dup_root;
            }
          node = node->right;
          p_new = &dup_node->right;
--
1.7.0.rc0.170.g7207c


>From d835285804942758507f63816504731aea8c9b60 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 19 Jan 2010 09:23:51 +0100
Subject: [PATCH 4/7] regcomp.c: spelling and merge-artifact from glibc

* lib/regcomp.c: Merge remainder of glibc's
2da42bc06566bc89785e580fa1ac89b4c9f2a63c.
---
 ChangeLog     |    4 ++++
 lib/regcomp.c |    7 +++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9024843..2a60680 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2010-01-28  Jim Meyering  <address@hidden>

+       regcomp.c: spelling and merge-artifact from glibc
+       * lib/regcomp.c: Merge remainder of glibc's
+       2da42bc06566bc89785e580fa1ac89b4c9f2a63c.
+
        regcomp.c: sync white-space changes from glibc
        * lib/regcomp.c: Merge to accommodate white space
        changes from glibc's 2da42bc06566bc89785e580fa1ac89b4c9f2a63c.
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 6e87a48..c653511 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -1682,10 +1682,9 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, 
Idx node, bool root)
 {
   reg_errcode_t err;
   Idx i;
-  bool incomplete;
-  bool ok;
   re_node_set eclosure;
-  incomplete = false;
+  bool ok;
+  bool incomplete = false;
   err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1);
   if (BE (err != REG_NOERROR, 0))
     return err;
@@ -1742,7 +1741,7 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, 
Idx node, bool root)
          }
       }

-  /* Epsilon closures include itself.  */
+  /* An epsilon closure includes itself.  */
   ok = re_node_set_insert (&eclosure, node);
   if (BE (! ok, 0))
     return REG_ESPACE;
--
1.7.0.rc0.170.g7207c


>From 0f6dd806d5fd7c45d9366cd35c793958b14dd75b Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 19 Jan 2010 13:44:26 +0100
Subject: [PATCH 5/7] regex: add many uses of __attribute_warn_unused_result__

* lib/regex_internal.c: Use __attribute_warn_unused_result__.
* lib/regexec.c: Likewise.
Extracted from a messy glibc commit.
---
 ChangeLog            |    5 +++++
 lib/regex_internal.c |   37 +++++++++++++++++++------------------
 lib/regexec.c        |   46 +++++++++++++++++++++++++---------------------
 3 files changed, 49 insertions(+), 39 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2a60680..942e866 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2010-01-28  Jim Meyering  <address@hidden>

+       regex: add many uses of __attribute_warn_unused_result__
+       * lib/regex_internal.c: Use __attribute_warn_unused_result__.
+       * lib/regexec.c: Likewise.
+       Extracted from a messy glibc commit.
+
        regcomp.c: spelling and merge-artifact from glibc
        * lib/regcomp.c: Merge remainder of glibc's
        2da42bc06566bc89785e580fa1ac89b4c9f2a63c.
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index e3afa58..967d7f5 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -36,7 +36,7 @@ static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
    re_string_reconstruct before using the object.  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len,
                    RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa)
 {
@@ -64,7 +64,7 @@ re_string_allocate (re_string_t *pstr, const char *str, Idx 
len, Idx init_len,
 /* This function allocate the buffers, and initialize them.  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 re_string_construct (re_string_t *pstr, const char *str, Idx len,
                     RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa)
 {
@@ -127,7 +127,7 @@ re_string_construct (re_string_t *pstr, const char *str, 
Idx len,
 /* Helper functions for re_string_allocate, and re_string_construct.  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
 {
 #ifdef RE_ENABLE_I18N
@@ -267,7 +267,7 @@ build_wcs_buffer (re_string_t *pstr)
    but for REG_ICASE.  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 build_wcs_upper_buffer (re_string_t *pstr)
 {
   mbstate_t prev_st;
@@ -569,7 +569,7 @@ re_string_translate_buffer (re_string_t *pstr)
    convert to upper case in case of REG_ICASE, apply translation.  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
 {
   Idx offset;
@@ -964,7 +964,7 @@ re_string_context_at (const re_string_t *input, Idx idx, 
int eflags)
 /* Functions for set operation.  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 re_node_set_alloc (re_node_set *set, Idx size)
 {
   set->alloc = size;
@@ -976,7 +976,7 @@ re_node_set_alloc (re_node_set *set, Idx size)
 }

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 re_node_set_init_1 (re_node_set *set, Idx elem)
 {
   set->alloc = 1;
@@ -992,7 +992,7 @@ re_node_set_init_1 (re_node_set *set, Idx elem)
 }

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2)
 {
   set->alloc = 2;
@@ -1022,7 +1022,7 @@ re_node_set_init_2 (re_node_set *set, Idx elem1, Idx 
elem2)
 }

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
 {
   dest->nelem = src->nelem;
@@ -1047,7 +1047,7 @@ re_node_set_init_copy (re_node_set *dest, const 
re_node_set *src)
    Note: We assume dest->elems is NULL, when dest->alloc is 0.  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
                           const re_node_set *src2)
 {
@@ -1138,7 +1138,7 @@ re_node_set_add_intersect (re_node_set *dest, const 
re_node_set *src1,
    DEST. Return value indicate the error code or REG_NOERROR if succeeded.  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
                        const re_node_set *src2)
 {
@@ -1191,7 +1191,7 @@ re_node_set_init_union (re_node_set *dest, const 
re_node_set *src1,
    DEST. Return value indicate the error code or REG_NOERROR if succeeded.  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 re_node_set_merge (re_node_set *dest, const re_node_set *src)
 {
   Idx is, id, sbase, delta;
@@ -1275,7 +1275,7 @@ re_node_set_merge (re_node_set *dest, const re_node_set 
*src)
    Return true if successful.  */

 static bool
-internal_function
+internal_function __attribute_warn_unused_result__
 re_node_set_insert (re_node_set *set, Idx elem)
 {
   Idx idx;
@@ -1327,7 +1327,7 @@ re_node_set_insert (re_node_set *set, Idx elem)
    Return true if successful.  */

 static bool
-internal_function
+internal_function __attribute_warn_unused_result__
 re_node_set_insert_last (re_node_set *set, Idx elem)
 {
   /* Realloc if we need.  */
@@ -1473,7 +1473,7 @@ calc_state_hash (const re_node_set *nodes, unsigned int 
context)
           optimization.  */

 static re_dfastate_t *
-internal_function
+internal_function __attribute_warn_unused_result__
 re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
                  const re_node_set *nodes)
 {
@@ -1521,7 +1521,7 @@ re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
           optimization.  */

 static re_dfastate_t *
-internal_function
+internal_function __attribute_warn_unused_result__
 re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
                          const re_node_set *nodes, unsigned int context)
 {
@@ -1562,6 +1562,7 @@ re_acquire_state_context (reg_errcode_t *err, const 
re_dfa_t *dfa,
    indicates the error code if failed.  */

 static reg_errcode_t
+__attribute_warn_unused_result__
 register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
                re_hashval_t hash)
 {
@@ -1616,7 +1617,7 @@ free_state (re_dfastate_t *state)
    Return the new state if succeeded, otherwise return NULL.  */

 static re_dfastate_t *
-internal_function
+internal_function __attribute_warn_unused_result__
 create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
                    re_hashval_t hash)
 {
@@ -1666,7 +1667,7 @@ create_ci_newstate (const re_dfa_t *dfa, const 
re_node_set *nodes,
    Return the new state if succeeded, otherwise return NULL.  */

 static re_dfastate_t *
-internal_function
+internal_function __attribute_warn_unused_result__
 create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
                    unsigned int context, re_hashval_t hash)
 {
diff --git a/lib/regexec.c b/lib/regexec.c
index 05979b1..598e456 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -637,7 +637,7 @@ re_exec (s)
    (0 <= LAST_START && LAST_START <= LENGTH)  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 re_search_internal (const regex_t *preg,
                    const char *string, Idx length,
                    Idx start, Idx last_start, Idx stop,
@@ -972,7 +972,7 @@ re_search_internal (const regex_t *preg,
 }

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 prune_impossible_nodes (re_match_context_t *mctx)
 {
   const re_dfa_t *const dfa = mctx->dfa;
@@ -1110,7 +1110,7 @@ acquire_init_state_context (reg_errcode_t *err, const 
re_match_context_t *mctx,
    index of the buffer.  */

 static Idx
-internal_function
+internal_function __attribute_warn_unused_result__
 check_matching (re_match_context_t *mctx, bool fl_longest_match,
                Idx *p_match_first)
 {
@@ -1385,7 +1385,7 @@ proceed_next_node (const re_match_context_t *mctx, Idx 
nregs, regmatch_t *regs,
 }

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node,
                 Idx nregs, regmatch_t *regs, re_node_set *eps_via_nodes)
 {
@@ -1432,7 +1432,7 @@ pop_fail_stack (struct re_fail_stack_t *fs, Idx *pidx, 
Idx nregs,
    pmatch[i].rm_so == pmatch[i].rm_eo == -1 for 0 < i < nmatch.  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
          regmatch_t *pmatch, bool fl_backtrack)
 {
@@ -1686,7 +1686,7 @@ sift_states_backward (const re_match_context_t *mctx, 
re_sift_context_t *sctx)
 }

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
                     Idx str_idx, re_node_set *cur_dest)
 {
@@ -1848,7 +1848,7 @@ update_cur_sifted_state (const re_match_context_t *mctx,
 }

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes,
                       const re_node_set *candidates)
 {
@@ -1863,10 +1863,14 @@ add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set 
*dest_nodes,
     {
       err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem);
       if (BE (err != REG_NOERROR, 0))
-        return REG_ESPACE;
+       return REG_ESPACE;
       for (i = 0; i < dest_nodes->nelem; i++)
-        re_node_set_merge (&state->inveclosure,
-                          dfa->inveclosures + dest_nodes->elems[i]);
+       {
+         err = re_node_set_merge (&state->inveclosure,
+                                  dfa->inveclosures + dest_nodes->elems[i]);
+         if (BE (err != REG_NOERROR, 0))
+           return REG_ESPACE;
+       }
     }
   return re_node_set_add_intersect (dest_nodes, candidates,
                                    &state->inveclosure);
@@ -2158,7 +2162,7 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set 
*dest_nodes,
 }

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
                   Idx str_idx, const re_node_set *candidates)
 {
@@ -2288,7 +2292,7 @@ sift_states_iter_mb (const re_match_context_t *mctx, 
re_sift_context_t *sctx,
    update the destination of STATE_LOG.  */

 static re_dfastate_t *
-internal_function
+internal_function __attribute_warn_unused_result__
 transit_state (reg_errcode_t *err, re_match_context_t *mctx,
               re_dfastate_t *state)
 {
@@ -2714,7 +2718,7 @@ transit_state_bkref (re_match_context_t *mctx, const 
re_node_set *nodes)
    delay these checking for prune_impossible_nodes().  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
 {
   const re_dfa_t *const dfa = mctx->dfa;
@@ -2915,7 +2919,7 @@ find_subexp_node (const re_dfa_t *dfa, const re_node_set 
*nodes,
    Return REG_NOERROR if it can arrive, or REG_NOMATCH otherwise.  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
               Idx top_str, Idx last_node, Idx last_str, int type)
 {
@@ -3077,7 +3081,7 @@ check_arrival (re_match_context_t *mctx, state_array_t 
*path, Idx top_node,
         Can't we unify them?  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
                              re_node_set *cur_nodes, re_node_set *next_nodes)
 {
@@ -3211,7 +3215,7 @@ check_arrival_expand_ecl (const re_dfa_t *dfa, 
re_node_set *cur_nodes,
    problematic append it to DST_NODES.  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
                              Idx target, Idx ex_subexp, int type)
 {
@@ -3256,7 +3260,7 @@ check_arrival_expand_ecl_sub (const re_dfa_t *dfa, 
re_node_set *dst_nodes,
    in MCTX->BKREF_ENTS.  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
                    Idx cur_str, Idx subexp_num, int type)
 {
@@ -4128,7 +4132,7 @@ check_node_accept (const re_match_context_t *mctx, const 
re_token_t *node,
 /* Extend the buffers, if the buffers have run out.  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 extend_buffers (re_match_context_t *mctx)
 {
   reg_errcode_t ret;
@@ -4191,7 +4195,7 @@ extend_buffers (re_match_context_t *mctx)
 /* Initialize MCTX.  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 match_ctx_init (re_match_context_t *mctx, int eflags, Idx n)
 {
   mctx->eflags = eflags;
@@ -4271,7 +4275,7 @@ match_ctx_free (re_match_context_t *mctx)
 */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from,
                     Idx to)
 {
@@ -4343,7 +4347,7 @@ search_cur_bkref_entry (const re_match_context_t *mctx, 
Idx str_idx)
    at STR_IDX.  */

 static reg_errcode_t
-internal_function
+internal_function __attribute_warn_unused_result__
 match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx)
 {
 #ifdef DEBUG
--
1.7.0.rc0.170.g7207c


>From 7247132e085fbab2d1823288aed34f6ff156b7e0 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 19 Jan 2010 15:04:37 +0100
Subject: [PATCH 6/7] regex: sync more white-space changes from libc

* lib/regex_internal.c: White-space only changes.
* lib/regexec.c: Likewise.
---
 ChangeLog            |    4 ++
 lib/regex_internal.c |   56 ++++++++++++++--------------
 lib/regexec.c        |  102 +++++++++++++++++++++++++-------------------------
 3 files changed, 83 insertions(+), 79 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 942e866..20b6ae2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2010-01-28  Jim Meyering  <address@hidden>

+       regex: sync more white-space changes from libc
+       * lib/regex_internal.c: White-space only changes.
+       * lib/regexec.c: Likewise.
+
        regex: add many uses of __attribute_warn_unused_result__
        * lib/regex_internal.c: Use __attribute_warn_unused_result__.
        * lib/regexec.c: Likewise.
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index 967d7f5..a116106 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -430,8 +430,8 @@ build_wcs_upper_buffer (re_string_t *pstr)
                    src_idx += mbclen;
                    continue;
                  }
-                else
-                  memcpy (pstr->mbs + byte_idx, p, mbclen);
+               else
+                 memcpy (pstr->mbs + byte_idx, p, mbclen);
              }
            else
              memcpy (pstr->mbs + byte_idx, p, mbclen);
@@ -1062,7 +1062,7 @@ re_node_set_add_intersect (re_node_set *dest, const 
re_node_set *src1,
       Idx new_alloc = src1->nelem + src2->nelem + dest->alloc;
       Idx *new_elems = re_realloc (dest->elems, Idx, new_alloc);
       if (BE (new_elems == NULL, 0))
-        return REG_ESPACE;
+       return REG_ESPACE;
       dest->elems = new_elems;
       dest->alloc = new_alloc;
     }
@@ -1112,20 +1112,20 @@ re_node_set_add_intersect (re_node_set *dest, const 
re_node_set *src1,
   if (delta > 0 && REG_VALID_INDEX (id))
     for (;;)
       {
-        if (dest->elems[is] > dest->elems[id])
-          {
-            /* Copy from the top.  */
-            dest->elems[id + delta--] = dest->elems[is--];
-            if (delta == 0)
-              break;
-          }
-        else
-          {
-            /* Slide from the bottom.  */
-            dest->elems[id + delta] = dest->elems[id];
-            if (! REG_VALID_INDEX (--id))
-              break;
-          }
+       if (dest->elems[is] > dest->elems[id])
+         {
+           /* Copy from the top.  */
+           dest->elems[id + delta--] = dest->elems[is--];
+           if (delta == 0)
+             break;
+         }
+       else
+         {
+           /* Slide from the bottom.  */
+           dest->elems[id + delta] = dest->elems[id];
+           if (! REG_VALID_INDEX (--id))
+             break;
+         }
       }

   /* Copy remaining SRC elements.  */
@@ -1221,11 +1221,11 @@ re_node_set_merge (re_node_set *dest, const re_node_set 
*src)
        REG_VALID_INDEX (is) && REG_VALID_INDEX (id); )
     {
       if (dest->elems[id] == src->elems[is])
-        is--, id--;
+       is--, id--;
       else if (dest->elems[id] < src->elems[is])
-        dest->elems[--sbase] = src->elems[is--];
+       dest->elems[--sbase] = src->elems[is--];
       else /* if (dest->elems[id] > src->elems[is]) */
-        --id;
+       --id;
     }

   if (REG_VALID_INDEX (is))
@@ -1247,21 +1247,21 @@ re_node_set_merge (re_node_set *dest, const re_node_set 
*src)
   for (;;)
     {
       if (dest->elems[is] > dest->elems[id])
-        {
+       {
          /* Copy from the top.  */
-          dest->elems[id + delta--] = dest->elems[is--];
+         dest->elems[id + delta--] = dest->elems[is--];
          if (delta == 0)
            break;
        }
       else
-        {
-          /* Slide from the bottom.  */
-          dest->elems[id + delta] = dest->elems[id];
+       {
+         /* Slide from the bottom.  */
+         dest->elems[id + delta] = dest->elems[id];
          if (! REG_VALID_INDEX (--id))
            {
              /* Copy remaining SRC elements.  */
              memcpy (dest->elems, dest->elems + sbase,
-                     delta * sizeof (Idx));
+                     delta * sizeof (Idx));
              break;
            }
        }
@@ -1308,12 +1308,12 @@ re_node_set_insert (re_node_set *set, Idx elem)
     {
       idx = 0;
       for (idx = set->nelem; idx > 0; idx--)
-        set->elems[idx] = set->elems[idx - 1];
+       set->elems[idx] = set->elems[idx - 1];
     }
   else
     {
       for (idx = set->nelem; set->elems[idx - 1] > elem; idx--)
-        set->elems[idx] = set->elems[idx - 1];
+       set->elems[idx] = set->elems[idx - 1];
     }

   /* Insert the new element.  */
diff --git a/lib/regexec.c b/lib/regexec.c
index 598e456..ea07643 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -833,10 +833,10 @@ re_search_internal (const regex_t *preg,
                break;
              match_first += incr;
              if (match_first < left_lim || match_first > right_lim)
-               {
-                 err = REG_NOMATCH;
-                 goto free_return;
-               }
+               {
+                 err = REG_NOMATCH;
+                 goto free_return;
+               }
            }
          break;
        }
@@ -953,14 +953,14 @@ re_search_internal (const regex_t *preg,
        }

       if (dfa->subexp_map)
-        for (reg_idx = 0; reg_idx + 1 < nmatch; reg_idx++)
-          if (dfa->subexp_map[reg_idx] != reg_idx)
-            {
-              pmatch[reg_idx + 1].rm_so
-                = pmatch[dfa->subexp_map[reg_idx] + 1].rm_so;
-              pmatch[reg_idx + 1].rm_eo
-                = pmatch[dfa->subexp_map[reg_idx] + 1].rm_eo;
-            }
+       for (reg_idx = 0; reg_idx + 1 < nmatch; reg_idx++)
+         if (dfa->subexp_map[reg_idx] != reg_idx)
+           {
+             pmatch[reg_idx + 1].rm_so
+               = pmatch[dfa->subexp_map[reg_idx] + 1].rm_so;
+             pmatch[reg_idx + 1].rm_eo
+               = pmatch[dfa->subexp_map[reg_idx] + 1].rm_eo;
+           }
     }

  free_return:
@@ -1149,7 +1149,7 @@ check_matching (re_match_context_t *mctx, bool 
fl_longest_match,
            {
              err = transit_state_bkref (mctx, &cur_state->nodes);
              if (BE (err != REG_NOERROR, 0))
-               return err;
+               return err;
            }
        }
     }
@@ -1176,16 +1176,16 @@ check_matching (re_match_context_t *mctx, bool 
fl_longest_match,
       Idx next_char_idx = re_string_cur_idx (&mctx->input) + 1;

       if (BE (next_char_idx >= mctx->input.bufs_len, 0)
-          || (BE (next_char_idx >= mctx->input.valid_len, 0)
-              && mctx->input.valid_len < mctx->input.len))
-        {
-          err = extend_buffers (mctx);
-          if (BE (err != REG_NOERROR, 0))
+         || (BE (next_char_idx >= mctx->input.valid_len, 0)
+             && mctx->input.valid_len < mctx->input.len))
+       {
+         err = extend_buffers (mctx);
+         if (BE (err != REG_NOERROR, 0))
            {
              assert (err == REG_ESPACE);
              return REG_ERROR;
            }
-        }
+       }

       cur_state = transit_state (&err, mctx, cur_state);
       if (mctx->state_log != NULL)
@@ -1309,17 +1309,17 @@ proceed_next_node (const re_match_context_t *mctx, Idx 
nregs, regmatch_t *regs,
           if (dest_node == REG_MISSING)
            dest_node = candidate;

-          else
+         else
            {
              /* In order to avoid infinite loop like "(a*)*", return the second
-                epsilon-transition if the first was already considered.  */
+                epsilon-transition if the first was already considered.  */
              if (re_node_set_contains (eps_via_nodes, dest_node))
-               return candidate;
+               return candidate;

              /* Otherwise, push the second epsilon-transition on the fail 
stack.  */
              else if (fs != NULL
                       && push_fail_stack (fs, *pidx, candidate, nregs, regs,
-                                          eps_via_nodes))
+                                          eps_via_nodes))
                return REG_ERROR;

              /* We know we are going to exit.  */
@@ -1667,7 +1667,7 @@ sift_states_backward (const re_match_context_t *mctx, 
re_sift_context_t *sctx)
       if (mctx->state_log[str_idx])
        {
          err = build_sifted_states (mctx, sctx, str_idx, &cur_dest);
-          if (BE (err != REG_NOERROR, 0))
+         if (BE (err != REG_NOERROR, 0))
            goto free_return;
        }

@@ -1982,7 +1982,7 @@ check_dst_limits_calc_pos_1 (const re_match_context_t 
*mctx, int boundaries,
            {
              struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx;
              do
-               {
+               {
                  Idx dst;
                  int cpos;

@@ -2004,9 +2004,9 @@ check_dst_limits_calc_pos_1 (const re_match_context_t 
*mctx, int boundaries,
                  if (dst == from_node)
                    {
                      if (boundaries & 1)
-                       return -1;
+                       return -1;
                      else /* if (boundaries & 2) */
-                       return 0;
+                       return 0;
                    }

                  cpos =
@@ -2020,7 +2020,7 @@ check_dst_limits_calc_pos_1 (const re_match_context_t 
*mctx, int boundaries,
                  if (subexp_idx < BITSET_WORD_BITS)
                    ent->eps_reachable_subexps_map
                      &= ~((bitset_word_t) 1 << subexp_idx);
-               }
+               }
              while (ent++->more);
            }
          break;
@@ -2245,7 +2245,7 @@ sift_states_bkref (const re_match_context_t *mctx, 
re_sift_context_t *sctx,
          re_node_set_remove (&local_sctx.limits, enabled_idx);

          /* mctx->bkref_ents may have changed, reload the pointer.  */
-          entry = mctx->bkref_ents + enabled_idx;
+         entry = mctx->bkref_ents + enabled_idx;
        }
       while (enabled_idx++, entry++->more);
     }
@@ -2326,7 +2326,7 @@ transit_state (reg_errcode_t *err, re_match_context_t 
*mctx,

       trtable = state->word_trtable;
       if (BE (trtable != NULL, 1))
-        {
+       {
          unsigned int context;
          context
            = re_string_context_at (&mctx->input,
@@ -2372,21 +2372,21 @@ merge_state_with_log (reg_errcode_t *err, 
re_match_context_t *mctx,
       unsigned int context;
       re_node_set next_nodes, *log_nodes, *table_nodes = NULL;
       /* If (state_log[cur_idx] != 0), it implies that cur_idx is
-         the destination of a multibyte char/collating element/
-         back reference.  Then the next state is the union set of
-         these destinations and the results of the transition table.  */
+        the destination of a multibyte char/collating element/
+        back reference.  Then the next state is the union set of
+        these destinations and the results of the transition table.  */
       pstate = mctx->state_log[cur_idx];
       log_nodes = pstate->entrance_nodes;
       if (next_state != NULL)
-        {
-          table_nodes = next_state->entrance_nodes;
-          *err = re_node_set_init_union (&next_nodes, table_nodes,
+       {
+         table_nodes = next_state->entrance_nodes;
+         *err = re_node_set_init_union (&next_nodes, table_nodes,
                                             log_nodes);
-          if (BE (*err != REG_NOERROR, 0))
+         if (BE (*err != REG_NOERROR, 0))
            return NULL;
-        }
+       }
       else
-        next_nodes = *log_nodes;
+       next_nodes = *log_nodes;
       /* Note: We already add the nodes of the initial state,
         then we don't need to add them here.  */

@@ -2394,12 +2394,12 @@ merge_state_with_log (reg_errcode_t *err, 
re_match_context_t *mctx,
                                      re_string_cur_idx (&mctx->input) - 1,
                                      mctx->eflags);
       next_state = mctx->state_log[cur_idx]
-        = re_acquire_state_context (err, dfa, &next_nodes, context);
+       = re_acquire_state_context (err, dfa, &next_nodes, context);
       /* We don't need to check errors here, since the return value of
-         this function is next_state and ERR is already set.  */
+        this function is next_state and ERR is already set.  */

       if (table_nodes != NULL)
-        re_node_set_free (&next_nodes);
+       re_node_set_free (&next_nodes);
     }

   if (BE (dfa->nbackref, 0) && next_state != NULL)
@@ -2440,9 +2440,9 @@ find_recover_state (reg_errcode_t *err, 
re_match_context_t *mctx)

       do
        {
-          if (++cur_str_idx > max)
-            return NULL;
-          re_string_skip_bytes (&mctx->input, 1);
+         if (++cur_str_idx > max)
+           return NULL;
+         re_string_skip_bytes (&mctx->input, 1);
        }
       while (mctx->state_log[cur_str_idx] == NULL);

@@ -2550,7 +2550,7 @@ transit_state_mb (re_match_context_t *mctx, re_dfastate_t 
*pstate)
       re_dfastate_t *dest_state;

       if (!dfa->nodes[cur_node_idx].accept_mb)
-        continue;
+       continue;

       if (dfa->nodes[cur_node_idx].constraint)
        {
@@ -2731,7 +2731,7 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx 
bkref_str_idx)
       const struct re_backref_cache_entry *entry
        = mctx->bkref_ents + cache_idx;
       do
-        if (entry->node == bkref_node)
+       if (entry->node == bkref_node)
          return REG_NOERROR; /* We already checked it.  */
       while (entry++->more);
     }
@@ -3479,7 +3479,7 @@ out_free:
                                                        CONTEXT_NEWLINE);
          if (BE (dest_states_nl[i] == NULL && err != REG_NOERROR, 0))
            goto out_free;
-       }
+       }
       else
        {
          dest_states_word[i] = dest_states[i];
@@ -3626,7 +3626,7 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const 
re_dfastate_t *state,
        }
 #ifdef RE_ENABLE_I18N
       else if (type == OP_UTF8_PERIOD)
-        {
+       {
          if (ASCII_CHARS % BITSET_WORD_BITS == 0)
            memset (accepts, -1, ASCII_CHARS / CHAR_BIT);
          else
@@ -3635,7 +3635,7 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const 
re_dfastate_t *state,
            bitset_clear (accepts, '\n');
          if (dfa->syntax & RE_DOT_NOT_NULL)
            bitset_clear (accepts, '\0');
-        }
+       }
 #endif
       else
        continue;
@@ -3840,7 +3840,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx 
node_idx,
   if (node->type == OP_PERIOD)
     {
       if (char_len <= 1)
-        return 0;
+       return 0;
       /* FIXME: I don't think this if is needed, as both '\n'
         and '\0' are char_len == 1.  */
       /* '.' accepts any one character except the following two cases.  */
--
1.7.0.rc0.170.g7207c


>From 70ee45de0f1ca64fa8bc7a3b37713b3a00f1e645 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 19 Jan 2010 15:13:16 +0100
Subject: [PATCH 7/7] regex: do not ignore memory allocation failure

* lib/regex_internal.c (create_cd_newstate): Detect
re_node_set_init_copy failure.   Extracted from glibc commit
2da42bc06566bc89785e580fa1ac89b4c9f2a63c.
---
 ChangeLog            |    5 +++++
 lib/regex_internal.c |    4 +++-
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 20b6ae2..c3cb300 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2010-01-28  Jim Meyering  <address@hidden>

+       regex: do not ignore memory allocation failure
+       * lib/regex_internal.c (create_cd_newstate): Detect
+       re_node_set_init_copy failure.   Extracted from glibc commit
+       2da42bc06566bc89785e580fa1ac89b4c9f2a63c.
+
        regex: sync more white-space changes from libc
        * lib/regex_internal.c: White-space only changes.
        * lib/regexec.c: Likewise.
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index a116106..378b767 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -1716,7 +1716,9 @@ create_cd_newstate (const re_dfa_t *dfa, const 
re_node_set *nodes,
                  free_state (newstate);
                  return NULL;
                }
-             re_node_set_init_copy (newstate->entrance_nodes, nodes);
+             if (re_node_set_init_copy (newstate->entrance_nodes, nodes)
+                 != REG_NOERROR)
+               return NULL;
              nctx_nodes = 0;
              newstate->has_constraint = 1;
            }
--
1.7.0.rc0.170.g7207c




reply via email to

[Prev in Thread] Current Thread [Next in Thread]