This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
typos and other minor things
[perl5.git] / lib / Net / Netrc.pm
index bbd62ab..02ebc82 100644 (file)
@@ -11,7 +11,7 @@ use strict;
 use FileHandle;
 use vars qw($VERSION);
 
-$VERSION = "2.11"; # $Id: //depot/libnet/Net/Netrc.pm#10 $
+$VERSION = "2.12"; # $Id: //depot/libnet/Net/Netrc.pm#13 $
 
 my %netrc = ();
 
@@ -27,6 +27,7 @@ sub _readrc
  } else {
    # Some OS's don't have `getpwuid', so we default to $ENV{HOME}
    $home = eval { (getpwuid($>))[7] } || $ENV{HOME};
+   $home ||= $ENV{HOMEDRIVE} . ($ENV{HOMEPATH}||'') if defined $ENV{HOMEDRIVE};
    $file = $home . "/.netrc";
  }
 
@@ -75,8 +76,11 @@ sub _readrc
 
      s/^\s*//;
      chomp;
-     push(@tok, $+)
-       while(length && s/^("([^"]*)"|(\S+))\s*//);
+
+     while(length && s/^("((?:[^"]+|\\.)*)"|((?:[^\\\s]+|\\.)*))\s*//) {
+       (my $tok = $+) =~ s/\\(.)/$1/g;
+       push(@tok, $tok);
+     }
 
 TOKEN:
      while(@tok)
@@ -287,6 +291,9 @@ the first entry in the .netrc file for C<MACHINE> will be returned.
 If a matching entry cannot be found, and a default entry exists, then a
 reference to the default entry is returned.
 
+If there is no matching entry found and there is no default defined, or
+no .netrc file is found, then C<undef> is returned.
+
 =back
 
 =head1 METHODS
@@ -328,6 +335,6 @@ it under the same terms as Perl itself.
 
 =for html <hr>
 
-$Id: //depot/libnet/Net/Netrc.pm#10 $
+$Id: //depot/libnet/Net/Netrc.pm#13 $
 
 =cut