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

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

Re: Bug in gawk 3.1.2 and 3.1.3


From: Aharon Robbins
Subject: Re: Bug in gawk 3.1.2 and 3.1.3
Date: Wed, 29 Oct 2003 18:39:47 +0200

Greetings. Re this:

> From: wb <address@hidden>
> To: address@hidden
> Subject: Bug in gawk 3.1.2 and 3.1.3
> Date: Thu, 23 Oct 2003 15:03:18 -0500
>
> I have experienced a bug in gawk 3.1.2 and 3.1.3.
>
> I am using Mandrake 9.2 Linux distribution.  I upgraded gawk to rev 
> 3.1.3, and have the same problem.
>
> Recreate the bug with the following script:
>
> #------------cut here-----------
> #!/bin/sh
>
> gawk-3.1.2 '  BEGIN   {IGNORECASE=1}
>               {       # Kill control characters
>               gsub(/[[:cntrl:]]+/, "")
>               }
>       ' <<<'slkdjlsjdf'
>
> exit
> #------------cut here------
>
> The output is:
>
> #------------cut here------
>
> gawk-3.1.2: cmd. line:3: (FILENAME=- FNR=1) fatal error: internal error
> /home/wb/bin/tmp2.sh: line 10:  1026 Aborted                 gawk-3.1.2 
> '       BEGIN   {IGNORECASE=1}
>                 {       # Kill control characters
>                 gsub(/[[:cntrl:]]+/, "")
>                 }
>         ' <<< 'slkdjlsjdf'
> #------------cut here------
>
> If you change IGNORECASE=1  to IGNORECASE=0, it will not fail in that 
> way.  This worked in version 3.1.1.
>
> Thanks a lot for looking into this.
>
>                                               -- Wayne Bergeron

Using LC_ALL=en_US I have reproduced this in 3.1.3.  It does not fail
in my development version.  Below is a diff of the 3.1.3 regex code and
my current regex code.  I believe that the first part of the patch is
what fixes the problem.  In any case, I verified that applying the whole
patch to the 3.1.3 distribution fixes the problem.

Enjoy,

Arnold
----------------------------------------------------
--- ../gawk-3.1.3/regcomp.c     2003-03-11 11:42:51.000000000 +0200
+++ regcomp.c   2003-08-11 18:24:56.000000000 +0300
@@ -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);
--- ../gawk-3.1.3/regex.h       2003-02-25 11:58:52.000000000 +0200
+++ regex.h     2003-09-08 19:04:41.000000000 +0300
@@ -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
--- ../gawk-3.1.3/regexec.c     2003-02-28 10:57:02.000000000 +0200
+++ regexec.c   2003-09-08 19:04:41.000000000 +0300
@@ -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]