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

[augeas-devel] augeas: master - * src/fa.c (re_cset_as_string): turn '[^\n]' into '.'



Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=a4fc2ddc76d200c456f65f2af96092ee203c62e6
Commit:        a4fc2ddc76d200c456f65f2af96092ee203c62e6
Parent:        aab887dbbb48a3d8feb1b2ae7af01abc321c5e23
Author:        David Lutterkort <lutter redhat com>
AuthorDate:    Thu Mar 12 16:59:04 2009 -0700
Committer:     David Lutterkort <lutter redhat com>
CommitterDate: Thu Mar 12 16:59:04 2009 -0700

* src/fa.c (re_cset_as_string): turn '[^\n]' into '.'

---
 src/fa.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/fa.c b/src/fa.c
index 9bb8876..9fce844 100644
--- a/src/fa.c
+++ b/src/fa.c
@@ -2846,6 +2846,7 @@ static char *re_cset_as_string(const struct re *re) {
 
     static const char *const empty_set = "[]";
     static const char *const total_set = "(.|\n)";
+    static const char *const not_newline = ".";
 
     char *result = NULL, *s;
     int from, to, negate;
@@ -2868,6 +2869,15 @@ static char *re_cset_as_string(const struct re *re) {
             /* Special case: the set matches every character */
             return strdup(total_set);
         }
+        if (from == '\n') {
+            for (from += 1;
+                 from <= UCHAR_MAX && bitset_get(re->cset, from);
+                 from += 1);
+            if (from > UCHAR_MAX) {
+                /* Special case: the set matches everything but '\n' */
+                return strdup(not_newline);
+            }
+        }
     }
 
     /* See if ']' and '-' will be explicitly included in the character set



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