summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorTodd Rinaldo <toddr@cpan.org>2010-09-01 11:05:26 -0500
committerFlorian Ragwitz <rafl@debian.org>2010-09-01 18:22:52 +0200
commitf178b03ba25ce69b2031fa5b9fabbb5c69482ad2 (patch)
tree1ce511ef4618ee5c2f275082628a4989b6e19876 /utils
parentc9a84c8bfeae3aee63d5def31bab0d11877f5dee (diff)
downloadperl-f178b03ba25ce69b2031fa5b9fabbb5c69482ad2.tar.gz
RT 74404 - h2ph using deprecated goto
It looks like h2ph makes copious use of global variables. As a result, I can commit this evil for a minimal patch. No code was changed moving it into the sub other than passing $proto, which is the only non-global used (but not modified). I tried a 5.12.0 build with this patch and it seems to be passing tests. There is a lib/h2ph.t file but I don't know what it tests exactly.
Diffstat (limited to 'utils')
-rw-r--r--utils/h2ph.PL42
1 files changed, 24 insertions, 18 deletions
diff --git a/utils/h2ph.PL b/utils/h2ph.PL
index 1255807a4c..2228e1bf91 100644
--- a/utils/h2ph.PL
+++ b/utils/h2ph.PL
@@ -147,23 +147,7 @@ while (defined (my $file = next_file())) {
s/^\s+//;
expr();
$new =~ s/(["\\])/\\$1/g; #"]);
- EMIT:
- $new = reindent($new);
- $args = reindent($args);
- if ($t ne '') {
- $new =~ s/(['\\])/\\$1/g; #']);
- if ($opt_h) {
- print OUT $t,
- "eval \"\\n#line $eval_index $outfile\\n\" . 'sub $name $proto\{\n$t ${args}eval q($new);\n$t}' unless defined(\&$name);\n";
- $eval_index++;
- } else {
- print OUT $t,
- "eval 'sub $name $proto\{\n$t ${args}eval q($new);\n$t}' unless defined(\&$name);\n";
- }
- } else {
- print OUT "unless(defined(\&$name)) {\n sub $name $proto\{\n\t${args}eval q($new);\n }\n}\n";
- }
- %curargs = ();
+ EMIT($proto);
} else {
s/^\s+//;
expr();
@@ -380,7 +364,7 @@ while (defined (my $file = next_file())) {
$new =~ s/&$_\b/\$$_/g for @local_variables;
$new =~ s/(["\\])/\\$1/g; #"]);
# now that's almost like a macro (we hope)
- goto EMIT;
+ EMIT($proto);
}
}
$Is_converted{$file} = 1;
@@ -400,6 +384,28 @@ if ($opt_e && (scalar(keys %bad_file) > 0)) {
exit $Exit;
+sub EMIT {
+ my $proto = shift;
+
+ $new = reindent($new);
+ $args = reindent($args);
+ if ($t ne '') {
+ $new =~ s/(['\\])/\\$1/g; #']);
+ if ($opt_h) {
+ print OUT $t,
+ "eval \"\\n#line $eval_index $outfile\\n\" . 'sub $name $proto\{\n$t ${args}eval q($new);\n$t}' unless defined(\&$name);\n";
+ $eval_index++;
+ } else {
+ print OUT $t,
+ "eval 'sub $name $proto\{\n$t ${args}eval q($new);\n$t}' unless defined(\&$name);\n";
+ }
+ } else {
+ print OUT "unless(defined(\&$name)) {\n sub $name $proto\{\n\t${args}eval q($new);\n }\n}\n";
+ }
+ %curargs = ();
+ return;
+}
+
sub expr {
if (/\b__asm__\b/) { # freak out
$new = '"(assembly code)"';