This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v2 11/17] introduce relative_filename and use it
- From: Tom Tromey <tromey at redhat dot com>
- To: Doug Evans <dje at google dot com>
- Cc: gdb-patches <gdb-patches at sourceware dot org>
- Date: Mon, 28 Oct 2013 14:10:28 -0600
- Subject: Re: [PATCH v2 11/17] introduce relative_filename and use it
- Authentication-results: sourceware.org; auth=none
- References: <1382129374-18344-1-git-send-email-tromey at redhat dot com> <1382129374-18344-12-git-send-email-tromey at redhat dot com> <CADPb22SD_=0YSaq6L8Scrkzpc1G+t8wjjs1QVhxzQeeR7ebCaA at mail dot gmail dot com>
>>>>> "Doug" == Doug Evans <dje@google.com> writes:
Doug> There's also string compare -length.
Doug> Or maybe for some incremental robustness, do the file splits first and
Doug> then compare that?
Ok, I replaced it with this implementation.
Let me know what you think.
proc relative_filename {root full} {
set root_split [file split $root]
set full_split [file split $full]
set len [llength $root_split]
if {[eval file join $root_split]
!= [eval file join [lrange $full_split 0 [expr {$len - 1}]]]} {
error "$full not a subdir of $root"
}
return [eval file join [lrange $full_split $len end]]
}
Tom