This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC][BZ #10278] glob() gives inconsistent results with trailing "/"
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: OndÅej BÃlka <neleai at seznam dot cz>
- Cc: eblake at redhat dot com, libc-alpha at sourceware dot org
- Date: Thu, 03 Oct 2013 04:49:40 -0400
- Subject: Re: [RFC][BZ #10278] glob() gives inconsistent results with trailing "/"
- Authentication-results: sourceware.org; auth=none
- References: <20131003075937 dot GA22576 at domone dot podge>
On 10/03/2013 03:59 AM, OndÅej BÃlka wrote:
> Hi,
>
> For this bug https://sourceware.org/bugzilla/show_bug.cgi?id=10278 there
> is a simple fix when we have DIRENT_H defined.
>
> For cross platform solution we would need surround this by ifdefs when
> separator is not slash and handling case of no dirent.
>
> Comments?
Sounds correct.
We should add a regression test for this.
> diff --git a/posix/glob.c b/posix/glob.c
> index 4c7dce5..ab5b4cb 100644
> --- a/posix/glob.c
> +++ b/posix/glob.c
> @@ -276,6 +276,9 @@ glob (pattern, flags, errfunc, pglob)
> return -1;
> }
>
Add a comment specifying why we do this.
> + if (pattern[0] && pattern[strlen (pattern) - 1] == '/')
> + flags |= GLOB_ONLYDIR;
> +
> if (!(flags & GLOB_DOOFFS))
> /* Have to do this so `globfree' knows where to start freeing. It
> also makes all the code that uses gl_offs simpler. */
>
Cheers,
Carlos.