Re: [PATCH v4 4/4] t0060: verify that basename() and dirname() work as expected
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 13, 2016, 18:53 UTC
- Message-ID
- <alpine.DEB.2.20.1601131953010.2964@virtualbox>
- In-Reply-To
- <xmqqh9ihpfav.fsf@gitster.mtv.corp.google.com>
Hi Junio,
On Wed, 13 Jan 2016, Junio C Hamano wrote:
Show 26 quoted lines
> Ramsay Jones <ramsay@ramsayjones.plus.com> writes: > > > This particular section documents what is almost certainly a bug > > in the cygwin basename() and also documents my choice of 'fix'. (ie. > > in my implementation I chose to return '/' for '//', which is one of > > the possible options that POSIX allows.) > > ... > > POSIX says, in part [1]: > > > > If the string pointed to by path consists entirely of the '/' > > character, basename() shall return a pointer to the string "/". If > > the string pointed to by path is exactly "//", it is > > implementation-defined whether '/' or "//" is returned. > > > > [1] > > http://pubs.opengroup.org/onlinepubs/9699919799/functions/basename.html > > > > So we should expect other systems to differ, even if they support POSIX. (and maybe > > not just this test case.) > > Doesn't that mean the test shouldn't be insisting on the output > being one that you arbitrarily pick? It feels to me that it is > wrong to say "We require // to become / unless we know we are on > such and such systems". Instead, shouldn't it be doing "We feed // > to the function. Either / or // is acceptable; any other value is a > bug"?
I guess that is the best solution of all. I'll try to modify test-path-utils.c accordingly tomorrow.
Ciao, Dscho