bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] An Issue About --re-interval And --traditional


From: Aharon Robbins
Subject: Re: [bug-gawk] An Issue About --re-interval And --traditional
Date: Sun, 20 Jan 2013 20:46:21 +0200
User-agent: Heirloom mailx 12.5 6/20/10

Hello.

This is indeed a bug.

> Date: Fri, 18 Jan 2013 17:45:48 +0800
> From: Yan Lei <address@hidden>
> To: address@hidden
> Subject: [bug-gawk] An Issue About --re-interval And --traditional
>
> Hi,
>
>      I got some problem when using gawk with options --re-interval and
> --traditional.
>      As it is said on the gawk manpage, if --re-interval or -r is provided,
> interval expressions in regular expression will be allowed, even if
> --traditional or -c is provided. But when I tried the following command,
> it did not run as expected:
>      echo -e "aabbbc\naaabcc" | gawk --traditional -r '/b{2,}/'
>      My expected output was aabbbc, but acturally, I got nothing. So please
> kindly tell me if it was due to my command or the gawk itself.
>      My environment is:
>          Machine: x86_64
>          OS: linux-gnu
>          Compiler: gcc
>          uname output: Linux RHEL7U0Alpha2-Intel64 3.3.0-0.20.el7.x86_64 #1
>                        SMP Mon Jul 9 16:28:22 EDT 2012 x86_64 x86_64 x86_64 
> GNU/Linux
>          Machine Type: x86_64-redhat-linux-gnu
>
>      Thanks a lot!
>
> Best Regards.
> Yan

Here is the fix. I will shortly push it into the git repo in both the
stable and master branches.

Arnold
------------------------------------------------------------
diff --git a/re.c b/re.c
index 9be46d9..711b53e 100644
--- a/re.c
+++ b/re.c
@@ -27,6 +27,7 @@
 
 static reg_syntax_t syn;
 static void check_bracket_exp(char *s, size_t len);
+const char *regexflags2str(int flags);
 
 /* make_regexp --- generate compiled regular expressions */
 
@@ -394,7 +395,7 @@ resetup()
         * variable remains for use with --traditional.
         */
        if (do_intervals)
-               syn |= RE_INTERVALS | RE_INVALID_INTERVAL_ORD;
+               syn |= RE_INTERVALS | RE_INVALID_INTERVAL_ORD | RE_NO_BK_BRACES;
 
        (void) re_set_syntax(syn);
        dfasyntax(syn, FALSE, '\n');
@@ -609,3 +610,40 @@ again:
 done:
        s[length] = save;
 }
+
+/* regexflags2str --- make regex flags printable */
+
+const char *
+regexflags2str(int flags)
+{
+       static const struct flagtab regextab[] = {
+               { RE_BACKSLASH_ESCAPE_IN_LISTS, "RE_BACKSLASH_ESCAPE_IN_LISTS" 
},
+               { RE_BK_PLUS_QM,                "RE_BK_PLUS_QM" },
+               { RE_CHAR_CLASSES,              "RE_CHAR_CLASSES" },
+               { RE_CONTEXT_INDEP_ANCHORS,     "RE_CONTEXT_INDEP_ANCHORS" },
+               { RE_CONTEXT_INDEP_OPS,         "RE_CONTEXT_INDEP_OPS" },
+               { RE_CONTEXT_INVALID_OPS,       "RE_CONTEXT_INVALID_OPS" },
+               { RE_DOT_NEWLINE,               "RE_DOT_NEWLINE" },
+               { RE_DOT_NOT_NULL,              "RE_DOT_NOT_NULL" },
+               { RE_HAT_LISTS_NOT_NEWLINE,     "RE_HAT_LISTS_NOT_NEWLINE" },
+               { RE_INTERVALS,                 "RE_INTERVALS" },
+               { RE_LIMITED_OPS,               "RE_LIMITED_OPS" },
+               { RE_NEWLINE_ALT,               "RE_NEWLINE_ALT" },
+               { RE_NO_BK_BRACES,              "RE_NO_BK_BRACES" },
+               { RE_NO_BK_PARENS,              "RE_NO_BK_PARENS" },
+               { RE_NO_BK_REFS,                "RE_NO_BK_REFS" },
+               { RE_NO_BK_VBAR,                "RE_NO_BK_VBAR" },
+               { RE_NO_EMPTY_RANGES,           "RE_NO_EMPTY_RANGES" },
+               { RE_UNMATCHED_RIGHT_PAREN_ORD, "RE_UNMATCHED_RIGHT_PAREN_ORD" 
},
+               { RE_NO_POSIX_BACKTRACKING,     "RE_NO_POSIX_BACKTRACKING" },
+               { RE_NO_GNU_OPS,                "RE_NO_GNU_OPS" },
+               { RE_DEBUG,                     "RE_DEBUG" },
+               { RE_INVALID_INTERVAL_ORD,      "RE_INVALID_INTERVAL_ORD" },
+               { RE_ICASE,                     "RE_ICASE" },
+               { RE_CARET_ANCHORS_HERE,        "RE_CARET_ANCHORS_HERE" },
+               { RE_CONTEXT_INVALID_DUP,       "RE_CONTEXT_INVALID_DUP" },
+               { 0,                            NULL }
+       };
+
+       return genflags2str(flags, regextab);
+}



reply via email to

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