bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: A bug with regex ?


From: Aharon Robbins
Subject: Re: A bug with regex ?
Date: Mon, 5 Jan 2004 16:46:49 +0200

Greetings.  Re this:

> Date: Mon, 5 Jan 2004 16:19:26 +0300 (MSK)
> From: "Alexander A. Kelner" <address@hidden>
> To: address@hidden
> Subject: A bug with regex ?
>
> Hi!
>
> I have Slackware Linux 9.1 with preinstalled AWK 3.1.3
>
> AWK dies at some conditions (look attached tgz) when I use my
> native locale settings and regexp expression in FS=...
>
> Short investigations show: in my environment AWK's death depends
> neither of Linux version nor of AWK's "configure" options, but
> does depend of AWK version. So AWK 3.1.1 is a last version
> which works properly.
>
> AWK's epithaph:
> ===============================================================
> ~/awk-death> ./Run-me
>
> awk: file.awk:2: fatal error: internal error
> ./Run-me: line 18: 4928 Aborted $AWK -f file.awk < file.txt
>
> ===============================================================
>
> Thank you for AWK. It's the best program I know :-)
>
> ---
> Alexander A. Kelner
> Bryansk Telephone & Telegraph
> phone +7 0832 722708

Here is the fix. I verified that it worked against your test case.  Enjoy.

Arnold
----------------------------------------------
diff -ur gawk-3.1.3/awk.h gawk-3.1.3-patched/awk.h
--- gawk-3.1.3/awk.h    2003-06-29 15:52:40.000000000 +0300
+++ gawk-3.1.3-patched/awk.h    2004-01-05 16:42:04.000000000 +0200
@@ -211,7 +211,6 @@
 #include "unsupported/atari/redirect.h"
 #endif
 
-#define RE_TRANSLATE_TYPE const char *
 #define        GNU_REGEX
 #ifdef GNU_REGEX
 #include "regex.h"
diff -ur gawk-3.1.3/regcomp.c gawk-3.1.3-patched/regcomp.c
--- gawk-3.1.3/regcomp.c        2003-03-11 11:42:51.000000000 +0200
+++ gawk-3.1.3-patched/regcomp.c        2004-01-05 16:35:03.000000000 +0200
@@ -2407,8 +2407,8 @@
                ? __btowc (start_ch) : start_elem->opr.wch);
     end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM)
              ? __btowc (end_ch) : end_elem->opr.wch);
-    cmp_buf[0] = start_wc;
-    cmp_buf[4] = end_wc;
+    cmp_buf[0] = start_wc != WEOF ? start_wc : start_ch;
+    cmp_buf[4] = end_wc != WEOF ? end_wc : end_ch;
     if (wcscoll (cmp_buf, cmp_buf + 4) > 0)
       return REG_ERANGE;
 
@@ -2965,7 +2965,10 @@
 #endif /* RE_ENABLE_I18N */
                                      start_elem.opr.name, syntax);
               if (BE (ret != REG_NOERROR, 0))
-               goto parse_bracket_exp_espace;
+              {
+                *err = ret;
+                goto parse_bracket_exp_free_return;
+              }
              break;
            default:
              assert (0);
diff -ur gawk-3.1.3/regex.h gawk-3.1.3-patched/regex.h
--- gawk-3.1.3/regex.h  2003-02-25 11:58:52.000000000 +0200
+++ gawk-3.1.3-patched/regex.h  2004-01-05 16:42:18.000000000 +0200
@@ -327,7 +327,7 @@
    private to the regex routines.  */
 
 #ifndef RE_TRANSLATE_TYPE
-# define RE_TRANSLATE_TYPE char *
+# define RE_TRANSLATE_TYPE unsigned char *
 #endif
 
 struct re_pattern_buffer
diff -ur gawk-3.1.3/regexec.c gawk-3.1.3-patched/regexec.c
--- gawk-3.1.3/regexec.c        2003-02-28 10:57:02.000000000 +0200
+++ gawk-3.1.3-patched/regexec.c        2004-01-05 16:43:32.000000000 +0200
@@ -657,8 +657,8 @@
        {
          if (BE (fast_translate, 1))
            {
-             unsigned RE_TRANSLATE_TYPE t
-               = (unsigned RE_TRANSLATE_TYPE) preg->translate;
+             RE_TRANSLATE_TYPE t
+               = (RE_TRANSLATE_TYPE) preg->translate;
              if (BE (range >= 0, 1))
                {
                  if (BE (t != NULL, 0))




reply via email to

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