> * lib/Automake/XFile.pm: Update comments and POD documentation to > suggest a more idiomatic/modern usage. > (open): Be more robust in detecting whether the created file handle > is being opened for writing. > * lib/Automake/FileUtils.pm (update_file, contents): Call the > 'Automake::XFile' and 'File::IO' constructors with two arguments > rather than one; this change obsoletes ... > (open_quote): ... this subroutine, which has thus been removed. > (@EXPORT): Drop '&open_quote'. > > Signed-off-by: Stefano Lattarini <address@hidden> > --- > lib/Automake/FileUtils.pm | 33 +++------------------------------ > lib/Automake/XFile.pm | 13 +++++++++---- > 2 files changed, 12 insertions(+), 34 deletions(-) > > Change tested with perl 5.10.1 and perl 5.6.0. No regression in the > testsuite. Patch already pushed to master. Help! I can't release autoconf 2.69 until I figure out how to work around this patch. After updating to the latest shared files, as well as applying this patch, I'm now stuck with output going to a literal file named '-' instead of going to stdout. I suspect that the conversion to the 2-arg form is mishandling our idiom of '-' as standard in/out. From 6ee479858ab4a4c4054d6ee334adae4e38295e52 Mon Sep 17 00:00:00 2001 From: Eric Blake <eblake@xxxxxxxxxx> Date: Tue, 24 Apr 2012 16:06:03 -0600 Subject: [PATCH] bin: replace older perl open_quote workaround with modern idiom Now that we require more modern perl, we might as well use it. See https://lists.gnu.org/archive/html/automake-patches/2012-03/msg00111.html for an example of how using 2-argument open makes life nicer. * bin/autoheader.in: Use two-arg open, not open_quote. * bin/autom4te.in: Likewise. * bin/autoscan.in: Likewise. * bin/autoupdate.in: Likewise. * bin/ifnames.in: Likewise. Signed-off-by: Eric Blake <eblake@xxxxxxxxxx> --- bin/autoheader.in | 12 ++++++------ bin/autom4te.in | 17 +++++++++-------- bin/autoscan.in | 12 ++++++------ bin/autoupdate.in | 16 ++++++++-------- bin/ifnames.in | 2 +- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/bin/autoheader.in b/bin/autoheader.in index d81a313..f51382f 100644 --- a/bin/autoheader.in +++ b/bin/autoheader.in @@ -201,7 +201,7 @@ $config_h_in ||= "$config_h.in"; # only the name of the macro. %symbol = map { s/\(.*//; $_ => 1 } keys %symbol; -my $out = new Autom4te::XFile ("> " . open_quote ("$tmp/config.hin")); +my $out = new Autom4te::XFile "$tmp/config.hin", ">"; # Don't write "do not edit" -- it will get copied into the # config.h, which it's ok to edit. @@ -210,7 +210,7 @@ print $out "/* $config_h_in. Generated from $ARGV[0] by autoheader. */\n"; # Dump the top. if ($config_h_top) { - my $in = new Autom4te::XFile ("< " . open_quote ($config_h_top)); + my $in = new Autom4te::XFile $config_h_top, "<"; while ($_ = $in->getline) { print $out $_; @@ -220,7 +220,7 @@ if ($config_h_top) # Dump `acconfig.h', except for its bottom portion. if ($acconfig_h) { - my $in = new Autom4te::XFile ("< " . open_quote ($acconfig_h)); + my $in = new Autom4te::XFile $acconfig_h, "<"; while ($_ = $in->getline) { last if /\@BOTTOM\@/; @@ -238,7 +238,7 @@ foreach (sort keys %verbatim) # Dump bottom portion of `acconfig.h'. if ($acconfig_h) { - my $in = new Autom4te::XFile ("< " . open_quote ($acconfig_h)); + my $in = new Autom4te::XFile $acconfig_h, "<"; my $dump = 0; while ($_ = $in->getline) { @@ -250,7 +250,7 @@ if ($acconfig_h) # Dump the bottom. if ($config_h_bot) { - my $in = new Autom4te::XFile ("< " . open_quote ($config_h_bot)); + my $in = new Autom4te::XFile $config_h_bot, "<"; while ($_ = $in->getline) { print $out $_; @@ -261,7 +261,7 @@ $out->close; # Check that all the symbols have a template. { - my $in = new Autom4te::XFile ("< " . open_quote ("$tmp/config.hin")); + my $in = new Autom4te::XFile "$tmp/config.hin", "<"; my $suggest_ac_define = 1; while ($_ = $in->getline) { diff --git a/bin/autom4te.in b/bin/autom4te.in index 11773c9..c2424c9 100644 --- a/bin/autom4te.in +++ b/bin/autom4te.in @@ -258,7 +258,7 @@ sub load_configuration ($) my ($file) = @_; use Text::ParseWords; - my $cfg = new Autom4te::XFile ("< " . open_quote ($file)); + my $cfg = new Autom4te::XFile $file, "<"; my $lang; while ($_ = $cfg->getline) { @@ -527,7 +527,8 @@ sub handle_output ($$) handle_traces ($req, "$tmp/patterns", ('m4_pattern_forbid' => 'forbid:$1:$2', 'm4_pattern_allow' => 'allow:$1')); - my @patterns = new Autom4te::XFile ("< " . open_quote ("$tmp/patterns"))->getlines; + my $pattern_file = new Autom4te::XFile "$tmp/patterns", "<"; + my @patterns = $pattern_file->getlines; chomp @patterns; my %forbidden = map { /^forbid:([^:]+):.+$/ => /^forbid:[^:]+:(.+)$/ } @patterns; @@ -554,7 +555,7 @@ sub handle_output ($$) } fatal "cannot create $output: $!" unless $out; - my $in = new Autom4te::XFile ("< " . open_quote ($ocache . $req->id)); + my $in = new Autom4te::XFile $ocache . $req->id, "<"; my %prohibited; my $res; @@ -599,7 +600,7 @@ sub handle_output ($$) if ($ARGV[$#ARGV] ne '-') { my $prohibited = '\b(' . join ('|', keys %prohibited) . ')\b'; - my $file = new Autom4te::XFile ("< " . open_quote ($ARGV[$#ARGV])); + my $file = new Autom4te::XFile $ARGV[$#ARGV], "<"; while ($_ = $file->getline) { @@ -717,7 +718,7 @@ sub handle_traces ($$%) verb "formatting traces for `$output': " . join (', ', sort keys %trace); # Processing the traces. - my $trace_m4 = new Autom4te::XFile ("> " . open_quote ("$tmp/traces.m4")); + my $trace_m4 = new Autom4te::XFile "$tmp/traces.m4", ">"; $_ = <<'EOF'; divert(-1) @@ -818,7 +819,7 @@ EOF # # Pay attention that the file name might include colons, if under DOS # for instance, so we don't use `[^:]+'. - my $traces = new Autom4te::XFile ("< " . open_quote ($tcache . $req->id)); + my $traces = new Autom4te::XFile $tcache . $req->id, "<"; while ($_ = $traces->getline) { # Trace with arguments, as the example above. We don't try @@ -834,7 +835,7 @@ EOF $trace_m4->close; my $in = new Autom4te::XFile ("$m4 " . shell_quote ("$tmp/traces.m4") . " |"); - my $out = new Autom4te::XFile ("> " . open_quote ($output)); + my $out = new Autom4te::XFile $output, ">"; # This is dubious: should we really transform the quadrigraphs in # traces? It might break balanced [ ] etc. in the output. The @@ -896,7 +897,7 @@ sub up_to_date ($) handle_traces ($req, "$tmp/dependencies", ('include' => '$1', 'm4_include' => '$1')); - my $deps = new Autom4te::XFile ("< " . open_quote ("$tmp/dependencies")); + my $deps = new Autom4te::XFile "$tmp/dependencies", "<"; while ($_ = $deps->getline) { chomp; diff --git a/bin/autoscan.in b/bin/autoscan.in index a67c48d..8aad720 100644 --- a/bin/autoscan.in +++ b/bin/autoscan.in @@ -169,7 +169,7 @@ sub init_tables () # instead of duplicating the code in lots of configure.ac files. my $file = find_file ("autoscan/autoscan.list", reverse (@prepend_include), @include); - my $table = new Autom4te::XFile "< " . open_quote ($file); + my $table = new Autom4te::XFile $file, "<"; my $tables_are_consistent = 1; while ($_ = $table->getline) @@ -244,7 +244,7 @@ sub scan_c_file ($) # Nonzero if in a multiline comment. my $in_comment = 0; - my $file = new Autom4te::XFile "< " . open_quote ($file_name); + my $file = new Autom4te::XFile $file_name, "<"; while ($_ = $file->getline) { @@ -310,7 +310,7 @@ sub scan_makefile ($) my ($file_name) = @_; push @makefiles, $File::Find::name; - my $file = new Autom4te::XFile "< " . open_quote ($file_name); + my $file = new Autom4te::XFile $file_name, "<"; while ($_ = $file->getline) { @@ -352,7 +352,7 @@ sub scan_sh_file ($) my ($file_name) = @_; push @shfiles, $File::Find::name; - my $file = new Autom4te::XFile "< " . open_quote ($file_name); + my $file = new Autom4te::XFile $file_name, "<"; while ($_ = $file->getline) { @@ -521,7 +521,7 @@ sub output ($) my $configure_scan = shift; my %unique_makefiles; - my $file = new Autom4te::XFile "> " . open_quote ($configure_scan); + my $file = new Autom4te::XFile $configure_scan, ">"; print $file ("# -*- Autoconf -*-\n" . @@ -639,7 +639,7 @@ sub check_configure_ac ($) ## -------------- ## parse_args; -$log = new Autom4te::XFile "> " . open_quote ("$me.log"); +$log = new Autom4te::XFile "$me.log", ">"; $autoconf .= " --debug" if $debug; $autoconf .= " --verbose" if $verbose; diff --git a/bin/autoupdate.in b/bin/autoupdate.in index 9737d49..ff56759 100644 --- a/bin/autoupdate.in +++ b/bin/autoupdate.in @@ -130,7 +130,7 @@ sub handle_autoconf_macros () { # Get the builtins. xsystem ("echo dumpdef | $m4 2>" . shell_quote ("$tmp/m4.defs") . " >/dev/null"); - my $m4_defs = new Autom4te::XFile "< " . open_quote ("$tmp/m4.defs"); + my $m4_defs = new Autom4te::XFile "$tmp/m4.defs", "<"; while ($_ = $m4_defs->getline) { $m4_builtins{$1} = 1 @@ -186,9 +186,9 @@ sub handle_autoconf_macros () # ac.m4 -- autoquoting definitions of the AC macros (M4sugar excluded). # unac.m4 -- undefine the AC macros. - my $ac_m4 = new Autom4te::XFile "> " . open_quote ("$tmp/ac.m4"); + my $ac_m4 = new Autom4te::XFile "$tmp/ac.m4", ">"; print $ac_m4 "# ac.m4 -- autoquoting definitions of the AC macros.\n"; - my $unac_m4 = new Autom4te::XFile "> " . open_quote ("$tmp/unac.m4"); + my $unac_m4 = new Autom4te::XFile "$tmp/unac.m4", ">"; print $unac_m4 "# unac.m4 -- undefine the AC macros.\n"; foreach (sort keys %ac_macros) { @@ -199,11 +199,11 @@ sub handle_autoconf_macros () # m4save.m4 -- save the m4 builtins. # unm4.m4 -- disable the m4 builtins. # m4.m4 -- enable the m4 builtins. - my $m4save_m4 = new Autom4te::XFile "> " . open_quote ("$tmp/m4save.m4"); + my $m4save_m4 = new Autom4te::XFile "$tmp/m4save.m4", ">"; print $m4save_m4 "# m4save.m4 -- save the m4 builtins.\n"; - my $unm4_m4 = new Autom4te::XFile "> " . open_quote ("$tmp/unm4.m4"); + my $unm4_m4 = new Autom4te::XFile "$tmp/unm4.m4", ">"; print $unm4_m4 "# unm4.m4 -- disable the m4 builtins.\n"; - my $m4_m4 = new Autom4te::XFile "> " . open_quote ("$tmp/m4.m4"); + my $m4_m4 = new Autom4te::XFile "$tmp/m4.m4", ">"; print $m4_m4 "# m4.m4 -- enable the m4 builtins.\n"; foreach (sort keys %m4_builtins) { @@ -381,9 +381,9 @@ EOF $input_m4 =~ s/\$file/$file/g; # prepared input -- input, but reenables the quote before each AU macro. - open INPUT_M4, "> " . open_quote ("$tmp/input.m4") + open INPUT_M4, "$tmp/input.m4", ">" or error "cannot open: $!"; - open FILE, "< " . open_quote ($file) + open FILE, $file, "<" or error "cannot open: $!"; print INPUT_M4 "$input_m4"; while (<FILE>) diff --git a/bin/ifnames.in b/bin/ifnames.in index ba2cd05..51cec64 100644 --- a/bin/ifnames.in +++ b/bin/ifnames.in @@ -96,7 +96,7 @@ my %occurrence; sub scan_file ($) { my ($file_name) = @_; - my $file = new Autom4te::XFile ("< " . open_quote ($file_name)); + my $file = new Autom4te::XFile $file_name, "<"; while ($_ = $file->getline) { # Continuation lines. -- 1.7.7.6 -- Eric Blake eblake@xxxxxxxxxx +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Autoconf mailing list Autoconf@xxxxxxx https://lists.gnu.org/mailman/listinfo/autoconf