From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 1A24DBC6B for ; Wed, 5 Sep 2007 14:10:08 +0200 (CEST) Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.234]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l85CA6w7023718 for ; Wed, 5 Sep 2007 14:10:07 +0200 Received: by wr-out-0506.google.com with SMTP id l58so967625wrl for ; Wed, 05 Sep 2007 05:10:06 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=NVMKtpKvTgfyFSi/MVHoAckB7Q7TycQdIUEnaOiTqJsFx/cmS5YZlg2OI5FtTKVq52mgkIEJjmH6bT/ZPPCVVGU7elzymOIFS8z3nnXwTj0MIlWgXRvZbOjWkOw00NaWe/9nTrJzIBYUsn9RrnxHG3uvDxjC+puZNecCC5oTONY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=am8EYBou8QbX1OqCzn4uHT3DKAVMhn9VoYj1oiNnNv7SKeFFaOlF86WlDS8iWSxxW0gWBHkG2ZWJ1Me6Vf0TJ4deHcwgcovkqXfpkAwd8aiQGNd88YKpHePA96wf33s0rmPKhpcvG8q0hMQsf1mwUv3DURlgM+7PnMsCtopJFlE= Received: by 10.90.105.19 with SMTP id d19mr624859agc.1188994206319; Wed, 05 Sep 2007 05:10:06 -0700 (PDT) Received: by 10.90.72.5 with HTTP; Wed, 5 Sep 2007 05:10:06 -0700 (PDT) Message-ID: <95513600709050510v4be7f21dpd3a9df75fb8c4bce@mail.gmail.com> Date: Wed, 5 Sep 2007 14:10:06 +0200 From: "Olivier Andrieu" Sender: oandrieu@gmail.com To: "Richard Jones" Subject: Re: [Caml-list] Bug in Filename.basename? Cc: caml-list@inria.fr In-Reply-To: <20070905104127.GB24323@furbychan.cocan.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20070905184538.88ada4e8.mle+ocaml@mega-nerd.com> <20070905104127.GB24323@furbychan.cocan.org> X-Google-Sender-Auth: 827ac75e24b7fc7f X-Miltered: at concorde with ID 46DE9C9E.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; andrieu:01 oandrieu:01 bug:01 basename:01 bug:01 basename:01 val:01 val:01 ocaml:01 opengroup:01 onlinepubs:01 wrote:01 wrote:01 caml-list:01 functions:01 On 9/5/07, Richard Jones wrote: > On Wed, Sep 05, 2007 at 06:45:38PM +1000, Erik de Castro Lopo wrote: > > Hi all, > > > > I think I have found a bug in the above function. > > Objective Caml version 3.10.0 > > > > # let x = Filename.basename "a/b/c" ;; > > val x : string = "c" > > # let x = Filename.basename "a/b/c/" ;; > > val x : string = "." > > > > The first result is fine, but second result is definitely not what > > one would reasonably expect. > > > > For instance, the basename program in Linux gives: > > > > > basename a/b/c/ > > c > > I think the OCaml one is what I'd reasonably expect actually. > > The GNU documentation for basename says: > > `basename' removes any leading directory components from NAME. > > and a/b/c/ are leading directory components. POSIX has a precise definition of its basename() function: http://www.opengroup.org/onlinepubs/009695399/functions/basename.html and it indeed says that trailing / are to be removed. -- Olivier