Re: [PATCH v2] git-send-email.perl: Add sub maildomain_sanitize

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

 



Jari Aalto wrote:

>     Jakub Narebski <jnareb@xxxxxxxxx> writes:
>     >   +sub maildomain_sanitize {
>     >   +	local $domain = shift;
>     >   +
>     >   +	#  On Mac, the the domain name is not necessarily in FQDN format
>     >   +	#  Require a period in the string
>     >   +
>     >   +	if ($^O eq 'darwin'  &&  $domain =~ /\.local$/) {
>     >   +		# Nope, pass this one.
>     >   +	} elsif ($domain =~ /\./) {
>     >   +		return $domain;
>     >   +	}
>     >   +}
> 
>     Thanks for 2nd eye. Changed these in above:
> 
>     * Starting brace placement at function start
>     * Placement of else
>     * Maybe: use or "return" (debatable).
> 
>     But not these. Motivation:
> 
>     * The "$_" simplifies usage everywhere in the function. XP: less is more.
>     * The "and" is more readable than "&&". The "and" is also safer
>       due to its lower precedence.

O.K.


Note however that while setting $_ ($ARG with English) simplifies regexp
matching, you have to take care to use

   local $_ = shift;

and not

   my $_ = shift; 

And to use 'local'.

A bit of "difficulty conservation" at work.

[...]
> +sub maildomain_sanitize {
> +	local $_ = shift;
> +
> +	#  On Mac, the the domain name is not necessarily in FQDN format.
> +	#  Require a period in the string.
> +
> +	if ( $^O eq 'darwin'  and  /\.local$/ ) {
> +		# Nope, pass this one.
> +	} elsif ( /\./ ) {
> +		return $_;
> +	}
> +}

-- 
Jakub Narebski
Poland
--
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]