[prev in list] [next in list] [prev in thread] [next in thread]
List: git
Subject: [PATCH 5/9] send-email: refactor sendmail aliases parser
From: Eric Sunshine <sunshine () sunshineco ! com>
Date: 2015-05-31 22:29:27
Message-ID: 1433111371-19573-6-git-send-email-sunshine () sunshineco ! com
[Download RAW message or body]
The sendmail aliases parser inlined into %parse_alias is already
uncomfortably large and is expected to grow as additional functionality
is implemented, so extract it to improve manageability.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
git-send-email.perl | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 1380e6e..76bb499 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -487,6 +487,29 @@ sub split_addrs {
}
my %aliases;
+
+sub parse_sendmail_alias {
+ local $_ = shift;
+ if (/"/) {
+ print STDERR "warning: sendmail alias with quotes is not supported: $_\n";
+ } elsif (/^\s|\\$/) {
+ print STDERR "warning: sendmail continuation line is not supported: $_\n";
+ } elsif (/^(\S+?)\s*:\s*(.+)$/) {
+ my ($alias, $addr) = ($1, $2);
+ $aliases{$alias} = [ split_addrs($addr) ];
+ } else {
+ print STDERR "warning: sendmail line is not recognized: $_\n";
+ }
+}
+
+sub parse_sendmail_aliases {
+ my $fh = shift;
+ while (<$fh>) {
+ if (/^\s*(?:#.*)?$/) { next; }
+ parse_sendmail_alias($_);
+ }
+}
+
my %parse_alias = (
# multiline formats can be supported in the future
mutt => sub { my $fh = shift; while (<$fh>) {
@@ -515,20 +538,7 @@ my %parse_alias = (
$aliases{$alias} = [ split_addrs($addr) ];
}
} },
-
- sendmail => sub { my $fh = shift; while (<$fh>) {
- if (/^\s*(?:#.*)?$/) {
- } elsif (/"/) {
- print STDERR "warning: sendmail alias with quotes is not supported: $_\n";
- } elsif (/^\s|\\$/) {
- print STDERR "warning: sendmail continuation line is not supported: $_\n";
- } elsif (/^(\S+?)\s*:\s*(.+)$/) {
- my ($alias, $addr) = ($1, $2);
- $aliases{$alias} = [ split_addrs($addr) ];
- } else {
- print STDERR "warning: sendmail line is not recognized: $_\n";
- }}},
-
+ sendmail => \&parse_sendmail_aliases,
gnus => sub { my $fh = shift; while (<$fh>) {
if (/\(define-mail-alias\s+"(\S+?)"\s+"(\S+?)"\)/) {
$aliases{$1} = [ $2 ];
--
2.4.2.538.g5f4350e
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic