# New Ticket Created by [EMAIL PROTECTED] # Please include the string: [perl #36770] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=36770 >
This patch changes build_tools/ops2c.pl 1. to use Pod::Usage. perldoc comment becomes usage. 2. to check parameters strictly. A routine to check if trans parameter is one of (C | CGoto | CGP | CSwitch | CPrederef) is added.
--- build_tools/ops2c.pl.orig 2005-08-02 04:05:13.000000000 +0900 +++ build_tools/ops2c.pl 2005-08-03 06:01:55.000000000 +0900 @@ -108,6 +108,7 @@ use strict; use lib 'lib'; +use Pod::Usage; use Getopt::Long; use Parrot::OpsFile; @@ -123,27 +124,32 @@ # # Look at the command line options # +sub Usage { + pod2usage(-exitval => 1, -verbose => 0, -output => \*STDERR); +} -# TODO: Use Pod::Usage my ( $nolines_flag, $help_flag, $dynamic_flag, $core_flag ); GetOptions( "no-lines" => \$nolines_flag, "help" => \$help_flag, "dynamic|d" => \$dynamic_flag, "core" => \$core_flag, - ); - -sub Usage { - print STDERR <<_EOF_; -usage: $0 trans [--help] [--no-lines] [--dynamic] [--core | input.ops [input2.ops ...]] - trans := C | CGoto | CGP | CSwitch | CPrederef -_EOF_ - exit 1; -} + ) || Usage(); Usage() if $help_flag; Usage() unless @ARGV; -my $trans_class = "Parrot::OpTrans::" . shift @ARGV; +my $class_name = shift @ARGV; +my @classes = ("C", "CGoto", "CGP", "CSwitch", "CPrederef"); +my $trans_class = ""; +foreach my $class (@classes) { + if ($class_name eq $class) { + $trans_class = "Parrot::OpTrans::" . $class_name; + last; + } +} +if ($trans_class eq "") { + Usage(); +} eval "require $trans_class";