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

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

Re: Another small awk profile bug


From: Aharon Robbins
Subject: Re: Another small awk profile bug
Date: Tue, 17 Aug 2010 23:31:37 +0300
User-agent: Heirloom mailx 12.4 7/29/08

Hi Hermann.

> Date: Sat, 14 Aug 2010 17:28:18 +0200
> From: Hermann Peifer <address@hidden>
> To: address@hidden
> Subject: Another small awk profile bug
>
> Hi Arnold,
>
> The gawk profile has an additional backslash in the pattern, which 
> changes the regex somewhat. I am not sure if this is worth fixing, but I 
> thought I should report it anyway.
>
> Regards, Hermann

You're right, it's a bug. And of course it's worth fixing. Patch below.

THANKS for the bug report.

Arnold
-------------------------------------------
Tue Aug 17 23:27:43 2010  Arnold D. Robbins  <address@hidden>

        * profile.c (pp_string_fp): Use different sets of escape characters
        if printing a string or a regex, based on delimiter. Thanks to
        Hermann Peifer <address@hidden> for the bug report.

Index: profile.c
===================================================================
RCS file: /d/mongo/cvsrep/gawk-stable/profile.c,v
retrieving revision 1.16
diff -u -r1.16 profile.c
--- profile.c   2 Feb 2010 18:32:55 -0000       1.16
+++ profile.c   17 Aug 2010 20:26:59 -0000
@@ -1225,14 +1225,28 @@
 void
 pp_string_fp(FILE *fp, const char *in_str, size_t len, int delim, int 
breaklines)
 {
-       static char escapes[] = "\b\f\n\r\t\v\\";
-       static char printables[] = "bfnrtv\\";
+       static char str_escapes[] = "\b\f\n\r\t\v\\";
+       static char str_printables[] = "bfnrtv\\";
+       static char re_escapes[] = "\b\f\n\r\t\v";
+       static char re_printables[] = "bfnrtv";
+       char *escapes;
+       char *printables;
        char *cp;
        int i;
        int count;
 #define BREAKPOINT     70 /* arbitrary */
        const unsigned char *str = (const unsigned char *) in_str;
 
+       assert(delim == '"' || delim == '/');
+
+       if (delim == '/') {
+               escapes = re_escapes;
+               printables = re_printables;
+       } else {
+               escapes = str_escapes;
+               printables = str_printables;
+       }
+
        fprintf(fp, "%c", delim);
        for (count = 0; len > 0; len--, str++) {
                if (++count >= BREAKPOINT && breaklines) {



reply via email to

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