automake-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Automake-commit] [SCM] GNU Automake branch, master, updated. v1.11-2114


From: Stefano Lattarini
Subject: [Automake-commit] [SCM] GNU Automake branch, master, updated. v1.11-2114-g2d671e1
Date: Wed, 28 Mar 2012 23:06:12 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Automake".

http://git.sv.gnu.org/gitweb/?p=automake.git;a=commitdiff;h=2d671e11c8574d86c47211cc1bfe680ec8d91957

The branch, master has been updated
       via  2d671e11c8574d86c47211cc1bfe680ec8d91957 (commit)
      from  84bf694bcba198d700a3214a0f1be7e24a6c8755 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2d671e11c8574d86c47211cc1bfe680ec8d91957
Author: Stefano Lattarini <address@hidden>
Date:   Thu Mar 29 00:31:47 2012 +0200

    perl refactor: use modern semantics of 'open'
    
    * 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>

-----------------------------------------------------------------------

Summary of changes:
 lib/Automake/FileUtils.pm |   33 +++------------------------------
 lib/Automake/XFile.pm     |   13 +++++++++----
 2 files changed, 12 insertions(+), 34 deletions(-)

diff --git a/lib/Automake/FileUtils.pm b/lib/Automake/FileUtils.pm
index 17d8a49..fc2347b 100644
--- a/lib/Automake/FileUtils.pm
+++ b/lib/Automake/FileUtils.pm
@@ -45,40 +45,13 @@ use Automake::ChannelDefs;
 use vars qw (@ISA @EXPORT);
 
 @ISA = qw (Exporter);
address@hidden = qw (&open_quote &contents
address@hidden = qw (&contents
              &find_file &mtime
              &update_file &up_to_date_p
              &xsystem &xsystem_hint &xqx
              &dir_has_case_matching_file &reset_dir_cache
              &set_dir_cache_file);
 
-
-=item C<open_quote ($file_name)>
-
-Quote C<$file_name> for open.
-
-=cut
-
-# $FILE_NAME
-# open_quote ($FILE_NAME)
-# -----------------------
-# If the string $S is a well-behaved file name, simply return it.
-# If it starts with white space, prepend './', if it ends with
-# white space, add '\0'.  Return the new string.
-sub open_quote($)
-{
-  my ($s) = @_;
-  if ($s =~ m/^\s/)
-    {
-      $s = "./$s";
-    }
-  if ($s =~ m/\s$/)
-    {
-      $s = "$s\0";
-    }
-  return $s;
-}
-
 =item C<find_file ($file_name, @include)>
 
 Return the first path for a C<$file_name> in the C<include>s.
@@ -168,7 +141,7 @@ sub update_file ($$;$)
 
   if ($to eq '-')
     {
-      my $in = new IO::File ("< " . open_quote ($from));
+      my $in = new IO::File $from, "<";
       my $out = new IO::File (">-");
       while ($_ = $in->getline)
        {
@@ -360,7 +333,7 @@ sub contents ($)
   my ($file) = @_;
   verb "reading $file";
   local $/;                    # Turn on slurp-mode.
-  my $f = new Automake::XFile "< " . open_quote ($file);
+  my $f = new Automake::XFile $file, "<";
   my $contents = $f->getline;
   $f->close;
   return $contents;
diff --git a/lib/Automake/XFile.pm b/lib/Automake/XFile.pm
index 82edb23..177dad9 100644
--- a/lib/Automake/XFile.pm
+++ b/lib/Automake/XFile.pm
@@ -31,13 +31,13 @@ Automake::XFile - supply object methods for filehandles 
with error handling
     use Automake::XFile;
 
     $fh = new Automake::XFile;
-    $fh->open ("< file");
+    $fh->open ("file", "<");
     # No need to check $FH: we died if open failed.
     print <$fh>;
     $fh->close;
     # No need to check the return value of close: we died if it failed.
 
-    $fh = new Automake::XFile "> file";
+    $fh = new Automake::XFile "file", ">";
     # No need to check $FH: we died if new failed.
     print $fh "bar\n";
     $fh->close;
@@ -130,7 +130,7 @@ Die if opening fails.  Store the name of the file.  Use 
binmode for writing.
 sub open
 {
   my $fh = shift;
-  my ($file) = @_;
+  my ($file, $mode) = @_;
 
   # WARNING: Gross hack: $FH is a typeglob: use its hash slot to store
   # the 'name' of the file we are opening.  See the example with
@@ -147,7 +147,12 @@ sub open
   # (This circumvents a bug in at least Cygwin bash where the shell
   # parsing fails on lines ending with the continuation character '\'
   # and CRLF).
-  binmode $fh if $file =~ /^\s*>/;
+  # Correctly recognize usages like:
+  #  - open ($file, "w")
+  #  - open ($file, "+<")
+  #  - open (" >$file")
+  binmode $fh
+    if (defined $mode && $mode =~ /^[+>wa]/ or $file =~ /^\s*>/);
 }
 
 =item C<$fh-E<gt>close>


hooks/post-receive
-- 
GNU Automake



reply via email to

[Prev in Thread] Current Thread [Next in Thread]