This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 11/13] introduce relative_filename and use it


On 08/23/2013 09:36 PM, Tom Tromey wrote:
> +# ROOT and FULL are file names.  Returns the relative path from ROOT
> +# to FULL.  Note that FULL must be in a subdirectory of ROOT.

Would it be a good idea to "error" out on mistakes here?

> +    return [eval file join [lrange [file split $full] $len end]]


> +# For example, given ROOT = /usr/bin and FULL = /usr/bin/ls, this
> +# will return "ls".
> +
> +proc relative_filename {root full} {
> +    set len [llength [file split $root]]
> +    return [eval file join [lrange [file split $full] $len end]]
> +}

I think we'd just have to make sure full[1..len] equals root.

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]