[PATCH/RFC v2 5/5] send-email: refactor address list process

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

 



Simplify code by creating a function to transform list of email lists
(comma separated, with aliases ...)  into a simple list of valid email
addresses.

Signed-off-by: Remi Lespinet <remi.lespinet@xxxxxxxxxxxxxxxxxxxxxxx>
---
 I'm not sure about the name of the function...

 git-send-email.perl | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 4bc489d..ea03308 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -794,15 +794,9 @@ sub expand_one_alias {
 	return $aliases{$alias} ? expand_aliases(@{$aliases{$alias}}) : $alias;
 }
 
-@initial_to = split_at_commas(@initial_to);
-@initial_to = expand_aliases(@initial_to);
-@initial_to = validate_address_list(sanitize_address_list(@initial_to));
+@initial_to = process_address_list(@initial_to);
-@initial_cc = split_at_commas(@initial_cc);
-@initial_cc = expand_aliases(@initial_cc);
-@initial_cc = validate_address_list(sanitize_address_list(@initial_cc));
+@initial_cc = process_address_list(@initial_cc);
-@bcclist = split_at_commas(@bcclist);
-@bcclist = expand_aliases(@bcclist);
-@bcclist = validate_address_list(sanitize_address_list(@bcclist));
+@bcclist = process_address_list(@bcclist);
 
 if ($thread && !defined $initial_reply_to && $prompting) {
 	$initial_reply_to = ask(
@@ -1019,6 +1013,14 @@ sub split_at_commas {
 	return (map { split /\s*,\s*/, $_ } @_);
 }
 
+sub process_address_list {
+    my @addr_list = split_at_commas(@_);
+    @addr_list = expand_aliases(@addr_list);
+    @addr_list = sanitize_address_list(@addr_list);
+    @addr_list = validate_address_list(@addr_list);
+    return @addr_list;
+}
+
 # Returns the local Fully Qualified Domain Name (FQDN) if available.
 #
 # Tightly configured MTAa require that a caller sends a real DNS
@@ -1528,12 +1530,8 @@ foreach my $t (@files) {
 		($confirm =~ /^(?:auto|compose)$/ && $compose && $message_num == 1));
 	$needs_confirm = "inform" if ($needs_confirm && $confirm_unconfigured && @cc);
 
-	@to = split_at_commas(@to);
-	@to = expand_aliases(@to);
-	@to = validate_address_list(sanitize_address_list(@to));
+	@to = process_address_list(@to);
-	@cc = split_at_commas(@cc);
-	@cc = expand_aliases(@cc);
-	@cc = validate_address_list(sanitize_address_list(@cc));
+	@cc = process_address_list(@cc);
 
 	@to = (@initial_to, @to);
 	@cc = (@initial_cc, @cc);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]