coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH 4/6] realpath: let --relative-to default to --relative-base


From: Eric Blake
Subject: Re: [PATCH 4/6] realpath: let --relative-to default to --relative-base
Date: Wed, 14 Mar 2012 15:43:56 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1

On 03/14/2012 03:38 PM, Pádraig Brady wrote:
> On 03/14/2012 08:38 PM, Eric Blake wrote:
>> Most of the time, if someone wants to filter which paths are
>> relative while leaving all others absolute, they also want to
>> to the filtering based on the same --relative-to directory.

s/to/do/ before this gets applied


> I wonder is it worth short circuiting some later code
> when relative_to == relative_base, like:
> 
> diff --git a/src/realpath.c b/src/realpath.c
> index 7834c62..c3f5809 100644
> --- a/src/realpath.c
> +++ b/src/realpath.c
> @@ -183,7 +183,8 @@ relpath (const char *can_fname)
>        if (can_relative_base)
>          {
>            if (!path_prefix (can_relative_base, can_fname)
> -              || !path_prefix (can_relative_base, can_relative_to))
> +              || ((can_relative_base != can_relative_to)
> +                  && !path_prefix (can_relative_base, can_relative_to)))

Indeed, that would save some string operations on a (potentially long)
name through multiple command line arguments.  I'll squash this in if
you like the series.

-- 
Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]