Blame test/getnr2tb.awk

Packit 575503
#From vp@dmat.uevora.pt Thu Jun 18 09:10 EDT 1998
Packit 575503
#Received: from mescaline.gnu.org (we-refuse-to-spy-on-our-users@mescaline.gnu.org [158.121.106.21]) by cssun.mathcs.emory.edu (8.7.5/8.6.9-940818.01cssun) with ESMTP id JAA23649 for <arnold@mathcs.emory.edu>; Thu, 18 Jun 1998 09:10:54 -0400 (EDT)
Packit 575503
#Received: from khromeleque.dmat.uevora.pt by mescaline.gnu.org (8.8.5/8.6.12GNU) with ESMTP id JAA21732 for <arnold@gnu.ai.mit.edu>; Thu, 18 Jun 1998 09:11:19 -0400
Packit 575503
#Received: from khromeleque.dmat.uevora.pt (vp@localhost [127.0.0.1])
Packit 575503
#	by khromeleque.dmat.uevora.pt (8.8.8/8.8.8/Debian/GNU) with ESMTP id OAA11817
Packit 575503
#	for <arnold@gnu.ai.mit.edu>; Thu, 18 Jun 1998 14:13:57 +0100
Packit 575503
#Message-Id: <199806181313.OAA11817@khromeleque.dmat.uevora.pt>
Packit 575503
#To: arnold@gnu.org
Packit 575503
#Subject: concatenation bug in gawk 3.0.3
Packit 575503
#Date: Thu, 18 Jun 1998 14:13:57 +0200
Packit 575503
#From: Vasco Pedro <vp@dmat.uevora.pt>
Packit 575503
#Content-Type: text
Packit 575503
#Content-Length: 2285
Packit 575503
#Status: RO
Packit 575503
#
Packit 575503
#Hi,
Packit 575503
#
Packit 575503
#The gawk program '{print NR " " 10/NR}' will print:
Packit 575503
#
Packit 575503
#1 10
Packit 575503
#5 5
Packit 575503
#3 3.33333
Packit 575503
#2 2.5
Packit 575503
#2 2
Packit 575503
#1 1.66667
Packit 575503
#
Packit 575503
#instead of the correct:
Packit 575503
#
Packit 575503
#1 10
Packit 575503
#2 5
Packit 575503
#3 3.33333
Packit 575503
#4 2.5
Packit 575503
#5 2
Packit 575503
#6 1.66667
Packit 575503
#
Packit 575503
#You'll notice, on the incorrect output, that the first column is
Packit 575503
#the first digit of the second.
Packit 575503
#
Packit 575503
#I think the problem comes from the way builtin variables are handled.
Packit 575503
#Since the items to be concatenated are processed in reverse order and
Packit 575503
#the return value of tree_eval(``NR'') is a pointer to the value part
Packit 575503
#of `NR_node', the `unref()' of `NR_node' due to its second occurrence
Packit 575503
#will leave a dangling pointer in `strlist'. The reason that it doesn't
Packit 575503
#reuse the freed space with objects of the same type. (Using Electric
Packit 575503
#Fence with EF_PROTECT_FREE set confirms that freed space is being
Packit 575503
#accessed.)
Packit 575503
#
Packit 575503
#The enclosed patch (hack would be a better word to describe it) is
Packit 575503
#all I could come up with. With it installed, things seem to work ok,
Packit 575503
#but I doubt this is the correct way to do it. (If I treated the
Packit 575503
#case for `Node_field_spec' as the I did others, `make check' would
Packit 575503
#fail in several places.)
Packit 575503
#
Packit 575503
#Regards,
Packit 575503
#vasco
Packit 575503
#
Packit 575503
#*** eval.c~	Tue May  6 21:39:55 1997
Packit 575503
#--- eval.c	Thu Jun 18 13:39:25 1998
Packit 575503
#***************
Packit 575503
#*** 685,697 ****
Packit 575503
#  		return func_call(tree->rnode, tree->lnode);
Packit 575503
#  
Packit 575503
#  		/* unary operations */
Packit 575503
#  	case Node_NR:
Packit 575503
#  	case Node_FNR:
Packit 575503
#  	case Node_NF:
Packit 575503
#  	case Node_FIELDWIDTHS:
Packit 575503
#  	case Node_FS:
Packit 575503
#  	case Node_RS:
Packit 575503
#- 	case Node_field_spec:
Packit 575503
#  	case Node_subscript:
Packit 575503
#  	case Node_IGNORECASE:
Packit 575503
#  	case Node_OFS:
Packit 575503
#--- 685,700 ----
Packit 575503
#  		return func_call(tree->rnode, tree->lnode);
Packit 575503
#  
Packit 575503
#  		/* unary operations */
Packit 575503
#+ 	case Node_field_spec:
Packit 575503
#+ 		lhs = get_lhs(tree, (Func_ptr *) NULL);
Packit 575503
#+ 		return *lhs;
Packit 575503
#+ 
Packit 575503
#  	case Node_NR:
Packit 575503
#  	case Node_FNR:
Packit 575503
#  	case Node_NF:
Packit 575503
#  	case Node_FIELDWIDTHS:
Packit 575503
#  	case Node_FS:
Packit 575503
#  	case Node_RS:
Packit 575503
#  	case Node_subscript:
Packit 575503
#  	case Node_IGNORECASE:
Packit 575503
#  	case Node_OFS:
Packit 575503
#***************
Packit 575503
#*** 699,705 ****
Packit 575503
#  	case Node_OFMT:
Packit 575503
#  	case Node_CONVFMT:
Packit 575503
#  		lhs = get_lhs(tree, (Func_ptr *) NULL);
Packit 575503
#! 		return *lhs;
Packit 575503
#  
Packit 575503
#  	case Node_var_array:
Packit 575503
#  		fatal("attempt to use array `%s' in a scalar context",
Packit 575503
#--- 702,710 ----
Packit 575503
#  	case Node_OFMT:
Packit 575503
#  	case Node_CONVFMT:
Packit 575503
#  		lhs = get_lhs(tree, (Func_ptr *) NULL);
Packit 575503
#! 		r = dupnode(*lhs);
Packit 575503
#! 		r->flags |= TEMP;
Packit 575503
#! 		return r;
Packit 575503
#  
Packit 575503
#  	case Node_var_array:
Packit 575503
#  		fatal("attempt to use array `%s' in a scalar context",
Packit 575503
#
Packit 575503
{ print NR " " 10/NR }