diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-09-22 14:21:11 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-09-22 14:21:11 +0100 |
commit | 1028dc3c3b25bebb0a1a079d1d384b6dccc2958b (patch) | |
tree | 8178d856f6d06c1e3d97c6481a7a202efdcbc6a6 /embed.pl | |
parent | 916e4025cf76677d80d3543dcfe683347234c30b (diff) | |
download | perl-1028dc3c3b25bebb0a1a079d1d384b6dccc2958b.tar.gz |
In embed.pl, refactor walk_table to simplify its arguments.
No need to pass in leader and have it default to do_not_edit ($filename),
as the only time the leader is needed is for the case of explicit open file
by name. Use undef instead of '/dev/null' to signal that no output is desired.
Diffstat (limited to 'embed.pl')
-rwxr-xr-x | embed.pl | 25 |
1 files changed, 12 insertions, 13 deletions
@@ -124,23 +124,22 @@ while (<IN>) { # walk table providing an array of components in each line to # subroutine, printing the result sub walk_table (&@) { - my ($function, $filename, $leader, $trailer) = @_; - defined $leader or $leader = do_not_edit ($filename); + my ($function, $filename, $trailer) = @_; my $F; if (ref $filename) { # filehandle $F = $filename; } - else { - # safer_unlink $filename if $filename ne '/dev/null'; + elsif (defined $filename) { $F = safer_open("$filename-new"); + print $F do_not_edit ($filename); } - print $F $leader if $leader; foreach (@embed) { my @outs = &{$function}(@$_); - print $F @outs; # $function->(@args) is not 5.003 + # $function->(@args) is not 5.003 + print $F @outs if $F; } print $F $trailer if $trailer; - unless (ref $filename) { + if (defined $filename && !ref $filename) { safer_close($F); rename_if_different("$filename-new", $filename); } @@ -156,7 +155,7 @@ sub munge_c_files () { if (@_ > 1) { $functions->{$_[2]} = \@_ if $_[@_-1] =~ /\.\.\./; } - } '/dev/null', '', ''; + }; local $^I = '.bak'; while (<>) { s{(\b(\w+)[ \t]*\([ \t]*(?!aTHX))} @@ -322,9 +321,9 @@ sub write_protos { } } -walk_table(\&write_protos, "proto.h", undef, "/* ex: set ro: */\n"); +walk_table(\&write_protos, "proto.h", "/* ex: set ro: */\n"); warn "$unflagged_pointers pointer arguments to clean up\n" if $unflagged_pointers; -walk_table(\&write_global_sym, "global.sym", undef, "# ex: set ro:\n"); +walk_table(\&write_global_sym, "global.sym", "# ex: set ro:\n"); # XXX others that may need adding # warnhook @@ -487,7 +486,7 @@ walk_table { # Remember the new state. $ifdef_state = $new_ifdef_state; $ret; -} $em, ""; +} $em; if ($ifdef_state) { print $em "#endif\n"; @@ -565,7 +564,7 @@ walk_table { # Remember the new state. $ifdef_state = $new_ifdef_state; $ret; -} $em, ""; +} $em; if ($ifdef_state) { print $em "#endif\n"; @@ -624,7 +623,7 @@ walk_table { my $t = (length $ret) >> 3; $ret .= "\t" x ($t < 5 ? 5 - $t : 1); "$ret$func($alist)\n"; -} $em, ""; +} $em; print $em <<'END'; |