From 216e2af04b838e3312c38eeb7b50834742b16865 Mon Sep 17 00:00:00 2001 From: ugen Date: Fri, 3 Feb 1995 15:16:03 +0000 Subject: Fix to h2ph "undefined function" bug i reported today earlier..tested and works OK.. ( To those who want to experience bug try running aub with old version of socket.ph and with new one or just any perl script "requiring " or ) --- gnu/usr.bin/perl/x2p/h2ph | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'gnu/usr.bin/perl') diff --git a/gnu/usr.bin/perl/x2p/h2ph b/gnu/usr.bin/perl/x2p/h2ph index 26c4ec4..143791f 100755 --- a/gnu/usr.bin/perl/x2p/h2ph +++ b/gnu/usr.bin/perl/x2p/h2ph @@ -68,7 +68,7 @@ foreach $file (@ARGV) { $args = "local($args) = \@_;\n$t "; } s/^\s+//; - do expr(); + do expr(0); $new =~ s/(["\\])/\\$1/g; if ($t ne '') { $new =~ s/(['\\])/\\$1/g; @@ -82,7 +82,7 @@ foreach $file (@ARGV) { } else { s/^\s+//; - do expr(); + do expr(0); $new = 1 if $new eq ''; if ($t ne '') { $new =~ s/(['\\])/\\$1/g; @@ -109,14 +109,14 @@ foreach $file (@ARGV) { } elsif (s/^if\s+//) { $new = ''; - do expr(); - print OUT $t,"if ($new) {\n"; + do expr(1); + print OUT $t,"if ( $new) {\n"; $tab += 4; $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); } elsif (s/^elif\s+//) { $new = ''; - do expr(); + do expr(1); $tab -= 4; $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); print OUT $t,"}\n${t}elsif ($new) {\n"; @@ -141,6 +141,7 @@ foreach $file (@ARGV) { } sub expr { +$hd=0; while ($_ ne '') { s/^(\s+)// && do {$new .= ' '; next;}; s/^(0x[0-9a-fA-F]+)// && do {$new .= $1; next;}; @@ -176,6 +177,7 @@ sub expr { } elsif ($id eq 'defined') { $new .= 'defined'; + $hd=1; } elsif (/^\(/) { s/^\((\w),/("$1",/ if $id =~ /^_IO[WR]*$/i; # cheat @@ -184,6 +186,7 @@ sub expr { elsif ($isatype{$id}) { if ($new =~ /{\s*$/) { $new .= "'$id'"; + $hd=0; } elsif ($new =~ /\(\s*$/ && /^[\s*]*\)/) { $new =~ s/\(\s*$//; @@ -194,7 +197,12 @@ sub expr { } } else { - $new .= ' &' . $id; + if ($hd == 0) { + $new .= 'defined &' . $id . ' && &' . $id; + } else { + $new .= ' &' . $id; + } + $hd=0; } next; }; -- cgit v1.1