This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 11/13] introduce relative_filename and use it
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 27 Aug 2013 14:44:30 +0100
- Subject: Re: [PATCH 11/13] introduce relative_filename and use it
- Authentication-results: sourceware.org; auth=none
- References: <1377290210-483-1-git-send-email-tromey at redhat dot com> <1377290210-483-12-git-send-email-tromey at redhat dot com>
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