[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A small gawk --profile bug
From: |
Aharon Robbins |
Subject: |
Re: A small gawk --profile bug |
Date: |
Thu, 21 Jan 2010 23:28:37 +0200 |
Greetings. Re this:
> Date: Thu, 21 Jan 2010 19:51:41 +0100
> From: Hermann Peifer <address@hidden>
> To: address@hidden
> Subject: A small gawk --profile bug
>
> Hi Arnold,
>
> I just made a small test with the switch/case feature and saw that gawk
> --profile prints the default case twice. I guess this is a small bug.
>
> (I was using Juergen's xgawk, which is based on gawk version 3.1.6)
>
> Hermann
>
>
> $ cat casetest.awk
> {
> switch ($1) {
> case 1000:
> print "XL"
> break
>
> case 100:
> print "L"
> break
>
> case 10:
> print "M"
> break
>
> default:
> print "S"
> }
> }
>
> $ cat awkprof.out
> # gawk profile, created Thu Jan 21 19:45:21 2010
>
> # Rule(s)
>
> {
> switch ($1) {
> case 1000:
> print "XL"
> break
> case 100:
> print "L"
> break
> case 10:
> print "M"
> break
> default:
> print "S"
> default:
> print "S"
> }
> }
It is indeed a bug. Thank you for reporting it. The patch is below, and it
will be in the CVS shortly.
Arnold
---------------------------------------------------------------------
Thu Jan 21 23:24:56 2010 Arnold D. Robbins <address@hidden>
* profile.c (pprint): Separate out code for Node_switch_body and only
print the lnode; avoids printing the default case twice. Thanks to
Hermann Peifer <address@hidden> for reporting the bug.
Index: profile.c
===================================================================
RCS file: /d/mongo/cvsrep/gawk-stable/profile.c,v
retrieving revision 1.13
diff -u -r1.13 profile.c
--- profile.c 11 Aug 2009 18:23:09 -0000 1.13
+++ profile.c 21 Jan 2010 21:02:42 -0000
@@ -268,6 +268,9 @@
break;
case Node_switch_body:
+ pprint(tree->lnode);
+ break;
+
case Node_case_list:
pprint(tree->lnode);
pprint(tree->rnode);