On Thursday, September 15, 2016 4:16:44 PM CEST Matthew White wrote: > On Thu, 15 Sep 2016 09:11:31 +0200 > > Giuseppe Scrivano <gscriv...@gnu.org> wrote: > > Hi Matthew, > > > > Matthew White <mehw.is...@inventati.org> writes: > > >> > Function amended to modify *name in place. > > >> > > > >> > Followed Tim's suggestions for Patch 09/25 about different > > >> > environments compatibility, the function now uses last_component() > > >> > to detect the basename: > > >> > http://lists.gnu.org/archive/html/bug-wget/2016-09/msg00083.html > > >> > > > >> > NOTES: if *name is NULL and ref is like 'dir/C:D:file', the result > > >> > will be 'C:D:file'; is it advisable to remove the drive letters > > >> > 'C:D:' and return only 'file'? > > >> > > > >> > /* > > >> > > > >> > Replace/remove the basename of a file name. > > >> > > > >> > The file name is permanently modified. > > >> > > > >> > Always set NAME to a string, even an empty one. > > >> > > > >> > Use REF's basename as replacement. If REF is NULL or if it doesn't > > >> > provide a valid basename candidate, then remove NAME's basename. > > >> > > > >> > */ > > >> > void > > >> > replace_metalink_basename (char **name, char *ref) > > >> > { > > >> > > >> is it something we could do using only dirname and basename? What you > > >> need here is "dirname(name) + basename(ref)"? > > > > > > You asked to avoid superfluous memory allocations, right? > > > > yes, and that is still my idea. I was just wondering if the cost of > > these extra memory allocations was worth. Is it enough to use > > last_component() to get it working on Windows? > > Extra memory allocations shouldn't be a concern any longer, they are removed > in the amended function definition previously posted: > http://lists.gnu.org/archive/html/bug-wget/2016-09/msg00094.html > > About base_name() and last_component() multi-environment compatibility: > * lib/basename.c (base_name): Call last_component() to find the basename, > allocate the basename (prefix with './' if required) * lib/basename-lgpl.c > (last_component): Use the macros FILE_SYSTEM_PREFIX_LEN and ISSLASH to > isolate the basename * lib/dosname.h: Define the macros > FILE_SYSTEM_PREFIX_LEN and ISSLASH to work on different system environments > > Forgive this copy and paste, but my question about > replace_metalink_basename() is "if *name is NULL and ref is like > 'dir/C:D:file', the result will be 'C:D:file'; is it advisable to remove > the drive letters 'C:D:' and return only 'file'?".
Yes, if you use the result as file name to any file/system calls. > PS: I'm currently working to create a common python class for the Metalink > tests (testenv), see Patch 01/25 :thumbs up: Regards, Tim
signature.asc
Description: This is a digitally signed message part.