From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: Fix 'dirname' and 'basename' on MS-Windows Date: Wed, 09 Jul 2014 16:22:02 +0200 Message-ID: <87mwcizk6t.fsf@gnu.org> References: <83simj3fji.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1404995997 6606 80.91.229.3 (10 Jul 2014 12:39:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 10 Jul 2014 12:39:57 +0000 (UTC) Cc: guile-devel@gnu.org To: Eli Zaretskii Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Jul 10 14:39:50 2014 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X5Ddd-0005cL-U2 for guile-devel@m.gmane.org; Thu, 10 Jul 2014 14:39:50 +0200 Original-Received: from localhost ([::1]:60590 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4slU-0006GM-GY for guile-devel@m.gmane.org; Wed, 09 Jul 2014 10:22:32 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4slF-0006G1-SQ for guile-devel@gnu.org; Wed, 09 Jul 2014 10:22:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4slA-0003jG-6X for guile-devel@gnu.org; Wed, 09 Jul 2014 10:22:17 -0400 Original-Received: from hera.aquilenet.fr ([2a01:474::1]:39704) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4sl2-0003hx-EK; Wed, 09 Jul 2014 10:22:04 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 152653106; Wed, 9 Jul 2014 16:22:03 +0200 (CEST) Original-Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WnAIkKU8sl4r; Wed, 9 Jul 2014 16:22:02 +0200 (CEST) Original-Received: from pluto (pluto.bordeaux.inria.fr [193.50.110.57]) by hera.aquilenet.fr (Postfix) with ESMTPSA id D079630E3; Wed, 9 Jul 2014 16:22:02 +0200 (CEST) X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 21 Messidor an 222 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu In-Reply-To: <83simj3fji.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 02 Jul 2014 19:13:05 +0300") User-Agent: Gnus/5.130009 (Ma Gnus v0.9) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:474::1 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:17299 Archived-At: Eli Zaretskii 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 =3D=3D 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") =3D> "." > (basename "_foo" "_foo") =3D> "." > > Also, isn't the following result wrong as well? > > (basename "/") =3D> "/" > > I think all of these should return the empty string, "". (I think I forgot about this message, sorry.) It seems that Gnulib=E2=80=99s dirname-lgpl and basename-lgpl modules do wh= at you want. Could you confirm? If that=E2=80=99s the case, I=E2=80=99ll import them. If you want to commit Window-specific tests, that=E2=80=99s even better. Thanks, Ludo=E2=80=99.