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 [email protected] +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
