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=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 80250BC6B for ; Wed, 5 Sep 2007 22:39:35 +0200 (CEST) Received: from einhorn.in-berlin.de (einhorn.in-berlin.de [192.109.42.8]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l85KdXQr018863 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Wed, 5 Sep 2007 22:39:35 +0200 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: Received: from einhorn.in-berlin.de (localhost [127.0.0.1]) by einhorn.in-berlin.de (8.13.6/8.13.6/Debian-1) with ESMTP id l85KdT55021251 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 5 Sep 2007 22:39:31 +0200 Received: (from www-data@localhost) by einhorn.in-berlin.de (8.13.6/8.13.6/Submit) id l85KdR8a021230 for caml-list@inria.fr; Wed, 5 Sep 2007 22:39:27 +0200 X-Authentication-Warning: einhorn.in-berlin.de: www-data set sender to oliver@first.in-berlin.de using -f Received: from dslb-088-073-068-051.pools.arcor-ip.net (dslb-088-073-068-051.pools.arcor-ip.net [88.73.68.51]) by webmail.in-berlin.de (IMP) with HTTP for ; Wed, 5 Sep 2007 22:39:26 +0200 Message-ID: <1189024766.46df13fed404a@webmail.in-berlin.de> Date: Wed, 5 Sep 2007 22:39:26 +0200 From: Oliver Bandel To: caml-list@inria.fr Subject: Re: [Caml-list] Bug in Filename.basename? References: <20070905184538.88ada4e8.mle+ocaml@mega-nerd.com> <20070905104127.GB24323@furbychan.cocan.org> <20070905211013.b53cf46b.mle+ocaml@mega-nerd.com> <1188991526.46de922610e05@webmail.in-berlin.de> <20070905220031.5995251d.mle+ocaml@mega-nerd.com> In-Reply-To: <20070905220031.5995251d.mle+ocaml@mega-nerd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.6 X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 X-Miltered: at concorde with ID 46DF1405.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bandel:01 in-berlin:01 bug:01 basename:01 ocaml:01 bandel:01 bug:01 ocaml:01 ocaml's:01 basename:01 opengroup:01 onlinepubs:01 implements:01 opengroup:01 onlinepubs:01 Zitat von Erik de Castro Lopo : > Oliver Bandel wrote: > > > But possibly it's not different to other basename-implementations. > > Which is exactly what I said later in my email. [...] No, you showed two examples. Did you tested other systems/implementations also? Even if all results are the same, it doesn't matter, because you compare things that can't be compared. Switch on your mental type checking ;-) > > > Looking at that documentation, I can't see no bug in the implementation. > > Your documentation documents the Ocaml function. Yes, and you asked for the behaviour of the OCaml function, so I did read the right documentation. You preassumed, that OCaml's Filename.basename has to implement a basename-function that you want, but this is nonsense. > > > When you want to know how your car's GPS-navigation system works, > > do you look in the documentation of your video-camera or vacuum-cleaner? > > We are not talking about GPS systems or video cameras or vacuum cleaners, > but if you want we can continue; [...] it seems, that you want to cintinue this. But it's better to stop it. > I would be complaining if I was sold > a video camera that didn't record video but did suck a lot of air. You better should open your eyes and see that a video camera is not a car. And that you looked into the wrong manual. > > The function is called basename just like the IEEE Std 1003.1 standard > function specified by The Open Group: > > http://www.opengroup.org/onlinepubs/000095399/functions/basename.html [...] This is a C-function. Filename.basename has the same name, and does a similar thing, but it's an OCaml-function that implements a behaviour that is described in the OCaml-manual. If you want the behaviour of http://www.opengroup.org/onlinepubs/000095399/functions/basename.html then use it. But you have to program in C for that. BTW: In your examples you used shells, not C. This again is wrong, when you compare it with C. It's more likely to assume that a shell (which shells did you use? different shells might also bring different results) is intended to offer the behaviour of the C-functions, than to assume that OCaml re-implements the shell-behaviour. > > In the examples section of that document they give these examples: > > Input String Output String > "/usr/lib" "lib" > "/usr/" "usr" [...] ================================================ # Filename.basename "/usr/lib";; - : string = "lib" # Filename.basename "/usr/";; - : string = "." # Filename.dirname "/usr/lib";; - : string = "/usr" # Filename.dirname "/usr/";; - : string = "/usr" # ================================================ "/usr/" is a directory. So, Filename.dirname should give "usr". The behaviour of OCaml's Filename.concat (Filename.dirname) (Filename.basename) makes sense to me. IMHO it should be done the way OCaml does it. And the documentation and the Implementation do not differ. So, this is fine. If you mean a directory, append "/", if it is a file, not use a "/" at the end. So, the OCaml-behaviour IMHO makes sense wonderfully. Ciao, Oliver