New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Ticket #29410 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

gawk @3.1.8: add --enable-switch

Reported by: axkibe@… Owned by: mschamschula@…
Priority: Normal Milestone:
Component: ports Version: 1.9.2
Keywords: haspatch Cc: ryandesign@…
Port: gawk

Description (last modified by macsforever2000@…) (diff)

--enable-switch is not enabled for gawks macport build. It is necessary to work with scripts that have a switch statement in them. Both Linux and Windows version I tested have this enabled by default, so people just assume it to be widely avaiable.

Please enable it by default.

Simple patch makes it work:

--- release/ports/lang/gawk/Portfile.orig	2011-05-09 17:26:34.000000000 +0200
+++ release/ports/lang/gawk/Portfile	2011-05-09 17:58:10.000000000 +0200
@@ -27,8 +27,10 @@
                         port:gettext
 
 configure.args          --with-libiconv-prefix=${prefix} \
+                        --enable-switch \
                         ac_cv_libsigsegv=no
 
 test.run                yes
 test.target             check

Change History

comment:1 Changed 2 years ago by macsforever2000@…

  • Owner changed from macports-tickets@… to mschamschula@…
  • Description modified (diff)
  • Port set to gawk

It would be more helpful to attach the patch to the ticket rather than pasting the text inline in the description.

comment:2 in reply to: ↑ description Changed 2 years ago by ryandesign@…

  • Cc ryandesign@… added
  • Keywords haspatch added
  • Type changed from defect to enhancement
  • Summary changed from gawk @3.1.8 --enable-switch not enabled. to gawk @3.1.8: add --enable-switch

Replying to axkibe@…:

--enable-switch [...] is necessary to work with scripts that have a switch statement in them.

I am not familiar with this option. Can you please provide a test case -- a script I can run through gawk that will fail now but will succeed with your changes?

comment:3 follow-up: ↓ 4 Changed 2 years ago by axkibe@…

Any script that has a switch statement in it.

E.g. Run this with:

$ gawk -f switch.awk -v time="year"

See also http://www.gnu.org/software/gawk/manual/html_node/Switch-Statement.html

BEGIN { 
	IGNORECASE = 1
	switch(time) {
		case "year":
			timeformat = "%Y"
			break
		case "month":
			timeformat = "%Y-%b"
			break
		case "day":
			timeformat = "%Y-%b-%d"
			break
		case "hour":
			timeformat = "%Y-%b-%d %H"
			break
		case "minute":
			timeformat = "%Y-%b-%d %H:%M"
			break
		default:
			print "missing timeformat"
			exit
	}
			
	print timeformat
	exit
}

comment:4 in reply to: ↑ 3 Changed 2 years ago by ryandesign@…

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in r79954 by updating the port to version 4.0.0. Switch support is now always on. From the NEWS file:

10. switch / case is now enabled by default. There's no longer a need
    for a configure-time option.
Note: See TracTickets for help on using tickets.