Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Oliver Bandel <oliver@first.in-berlin.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Bug in Filename.basename?
Date: Wed,  5 Sep 2007 13:25:26 +0200	[thread overview]
Message-ID: <1188991526.46de922610e05@webmail.in-berlin.de> (raw)
In-Reply-To: <20070905211013.b53cf46b.mle+ocaml@mega-nerd.com>

Zitat von Erik de Castro Lopo <mle+ocaml@mega-nerd.com>:

> Richard Jones wrote:
>
> > 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.
>
> The word "leading" in the above is at best, ambiguous.
>
> Regardless of what the documentation says, the behaviour of Ocaml's
> basename function is different from the basename program (from the
> GNU coreutils package) on my Linux system.
[...]

But possibly it's not different to other basename-implementations.

Do you think *your* current basename should be the way, all other people
should go, when implementing a function that has the same name and a similar
functionality?
What, if your basename-implemantation is buggy? Should all
other people rewrite a buggy thing?



>
> Since I suspect that the basename function is meant to emulate the
> basename program I see the Ocaml function's behaviour as a bug. I
> would however discount this if the behaviour of basename on some
> other commonly used system (eg *BSD) matched the Ocaml behaviour.
>
> However, here is a comparison chart of what I have tested so far:
>
>                                  "a/b/c"     "a/b/c/"
>     Linux basename                 "c"         "c"
>     Mac OSX basename               "c"         "c"
>     Ocaml Filename.basename        "c"         "."
[...]

It doesn't matter.

It even doesn't matter that Filename.basename might be correct,
when loohing at the basename-documentation.

You (both) have to look in the OCaml-documentation,
if you think it might be buggy.

When you look there, you find this:
======================================================================
val basename : string -> string

Split a file name into directory name / base file name. concat (dirname name)
(basename name) returns a file name which is equivalent to name. Moreover,
after setting the current directory to dirname name (with Sys.chdir),
references to basename name (which is a relative file name) designate the same
file as name before the call to Sys.chdir.

The result is not specified if the argument is not a valid file name (for
example, under Unix if there is a NUL character in the string).

======================================================================

Looking at that documentation, I can't see no bug in the implementation.


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?
And if you then drive in the wrong direction, who do you will blame for that?


Ciao,
   Oliver


  reply	other threads:[~2007-09-05 11:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-05  8:45 Erik de Castro Lopo
2007-09-05 10:41 ` [Caml-list] " Richard Jones
2007-09-05 11:10   ` Erik de Castro Lopo
2007-09-05 11:25     ` Oliver Bandel [this message]
2007-09-05 12:00       ` Erik de Castro Lopo
2007-09-05 13:06         ` Markus E L
2007-09-05 20:39         ` Oliver Bandel
2007-09-05 21:03           ` Oliver Bandel
2007-09-06  4:52           ` skaller
2007-09-06  7:09             ` Christophe Raffalli
2007-09-06  9:51             ` Oliver Bandel
2007-09-06  9:32           ` Markus E L
2007-09-06 10:00             ` Oliver Bandel
2007-09-05 12:15       ` Mattias Engdegård
2007-09-05 20:54         ` Oliver Bandel
2007-09-05 12:37     ` Brian Hurt
2007-09-05 13:06     ` Markus E L
2007-09-05 12:10   ` Olivier Andrieu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1188991526.46de922610e05@webmail.in-berlin.de \
    --to=oliver@first.in-berlin.de \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox