From: Junio C Hamano Date: Thu, 27 Oct 2016 22:03:35 +0000 (-0700) Subject: Merge branch 'svn-wt' of git://bogomips.org/git-svn X-Git-Tag: v2.11.0-rc0~15 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/251641b771c3b8d3ccf1f1cccd71e2c779eae41d?hp=-c Merge branch 'svn-wt' of git://bogomips.org/git-svn * 'svn-wt' of git://bogomips.org/git-svn: git-svn: "git worktree" awareness git-svn: reduce scope of input record separator change --- 251641b771c3b8d3ccf1f1cccd71e2c779eae41d diff --combined perl/Git.pm index 864123fe8e,d2c5a8d238..b2732822af --- a/perl/Git.pm +++ b/perl/Git.pm @@@ -59,7 -59,7 +59,7 @@@ require Exporter command_bidi_pipe command_close_bidi_pipe version exec_path html_path hash_object git_cmd_try remote_refs prompt - get_tz_offset + get_tz_offset get_record credential credential_read credential_write temp_acquire temp_is_locked temp_release temp_reset temp_path); @@@ -538,6 -538,20 +538,20 @@@ sub get_tz_offset return sprintf("%s%02d%02d", $sign, (gmtime(abs($t - $gm)))[2,1]); } + =item get_record ( FILEHANDLE, INPUT_RECORD_SEPARATOR ) + + Read one record from FILEHANDLE delimited by INPUT_RECORD_SEPARATOR, + removing any trailing INPUT_RECORD_SEPARATOR. + + =cut + + sub get_record { + my ($fh, $rs) = @_; + local $/ = $rs; + my $rec = <$fh>; + chomp $rec if defined $rs; + $rec; + } =item prompt ( PROMPT , ISPASSWORD ) @@@ -871,8 -885,6 +885,8 @@@ Return an array of mailboxes extracted =cut +# Very close to Mail::Address's parser, but we still have minor +# differences in some cases (see t9000 for examples). sub parse_mailboxes { my $re_comment = qr/\((?:[^)]*)\)/; my $re_quote = qr/"(?:[^\"\\]|\\.)*"/; @@@ -881,7 -893,6 +895,7 @@@ # divide the string in tokens of the above form my $re_token = qr/(?:$re_quote|$re_word|$re_comment|\S)/; my @tokens = map { $_ =~ /\s*($re_token)\s*/g } @_; + my $end_of_addr_seen = 0; # add a delimiter to simplify treatment for the last mailbox push @tokens, ","; @@@ -891,10 -902,10 +905,10 @@@ if ($token =~ /^[,;]$/) { # if buffer still contains undeterminated strings # append it at the end of @address or @phrase - if (@address) { - push @address, @buffer; - } else { + if ($end_of_addr_seen) { push @phrase, @buffer; + } else { + push @address, @buffer; } my $str_phrase = join ' ', @phrase; @@@ -918,16 -929,16 +932,16 @@@ push @addr_list, $str_mailbox if ($str_mailbox); @phrase = @address = @comment = @buffer = (); + $end_of_addr_seen = 0; } elsif ($token =~ /^\(/) { push @comment, $token; } elsif ($token eq "<") { push @phrase, (splice @address), (splice @buffer); } elsif ($token eq ">") { + $end_of_addr_seen = 1; push @address, (splice @buffer); - } elsif ($token eq "@") { + } elsif ($token eq "@" && !$end_of_addr_seen) { push @address, (splice @buffer), "@"; - } elsif ($token eq ".") { - push @address, (splice @buffer), "."; } else { push @buffer, $token; }