From eacd26c25d4c0f9cd32d5789d729d19023841d45 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Sun, 21 Aug 2011 15:47:56 +0200 Subject: [PATCH] In embed.pl, refactor the handling of varargs *_nocontext wrappers. This is what commit 125218eb5a6d12e7 should have been. :-) --- regen/embed.pl | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/regen/embed.pl b/regen/embed.pl index 681c99c..53dcd2c 100755 --- a/regen/embed.pl +++ b/regen/embed.pl @@ -54,7 +54,6 @@ sub open_print_header { open IN, "embed.fnc" or die $!; my @embed; -my (%has_va, %has_nocontext); while () { chomp; @@ -71,11 +70,6 @@ while () { } else { @args = split /\s*\|\s*/, $_; - my $func = $args[2]; - if ($func) { - ++$has_va{$func} if $args[-1] =~ /\.\.\./; - ++$has_nocontext{$1} if $func =~ /(.*)_nocontext/; - } } if (@args == 1 && $args[0] !~ /^#\s*(?:if|ifdef|ifndef|else|endif)/) { die "Illegal line $. '$args[0]' in embed.fnc"; @@ -524,6 +518,21 @@ walk_table { "$ret$func($alist)\n"; } $em; +my @nocontext; +{ + my (%has_va, %has_nocontext); + foreach (@embed) { + next unless @$_ > 1; + ++$has_va{$_->[2]} if $_->[-1] =~ /\.\.\./; + ++$has_nocontext{$1} if $_->[2] =~ /(.*)_nocontext/; + } + + @nocontext = sort grep { + $has_nocontext{$_} + && !/printf/ # Not clear to me why these are skipped but they are. + } keys %has_va; +} + print $em <<'END'; /* varargs functions can't be handled with CPP macros. :-( @@ -534,9 +543,7 @@ print $em <<'END'; #if defined(PERL_IMPLICIT_CONTEXT) && !defined(PERL_NO_SHORT_NAMES) END -foreach (sort keys %has_va) { - next unless $has_nocontext{$_}; - next if /printf/; # Not clear to me why these are skipped but they are. +foreach (@nocontext) { print $em hide($_, "Perl_${_}_nocontext", " "); } @@ -549,9 +556,7 @@ print $em <<'END'; /* undefined symbols, point them back at the usual ones */ END -foreach (sort keys %has_va) { - next unless $has_nocontext{$_}; - next if /printf/; # Not clear to me why these are skipped but they are. +foreach (@nocontext) { print $em hide("Perl_${_}_nocontext", "Perl_$_", " "); } -- 2.7.4