Eli Zaretskii <e...@gnu.org> skribis: > These 2 functions don't deal correctly with Windows file names with > drive letters and with UNCs. The patch below fixes that. > > Incidentally, isn't the line in scm_basename marked below wrong? > > if (i == end) > { > if (len > 0 && is_file_name_separator (scm_c_string_ref (filename, 0))) > return scm_c_substring (filename, 0, 1); > else > return scm_dot_string; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > } > else > return scm_c_substring (filename, i+1, end+1); > > It is responsible for the following strange results: > > (basename ".foo" ".foo") => "." > (basename "_foo" "_foo") => "." > > Also, isn't the following result wrong as well? > > (basename "/") => "/" > > I think all of these should return the empty string, "".
(I think I forgot about this message, sorry.) It seems that Gnulib’s dirname-lgpl and basename-lgpl modules do what you want. Could you confirm? If that’s the case, I’ll import them. If you want to commit Window-specific tests, that’s even better. Thanks, Ludo’.