This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] posix: if glob has a trailing slash match directories only.
- From: Paul Eggert <eggert at cs dot ucla dot edu>
- To: Dmitry Goncharov <dgoncharov at users dot sf dot net>, libc-alpha at sourceware dot org
- Date: Wed, 29 Nov 2017 15:01:46 -0800
- Subject: Re: [PATCH] posix: if glob has a trailing slash match directories only.
- Authentication-results: sourceware.org; auth=none
- References: <20171128210857.GC2745@madrid> <a97c9749-5bcd-0292-9eae-bd7c4c59ab09@cs.ucla.edu> <20171129042114.GA2702@madrid> <dec247a8-a079-ccde-89da-f7dd6b572604@cs.ucla.edu> <CAG+Z0CsgP0sMTtaurAF8kXJ0HSqhPMC-BxS36=OB05GNUo9xSQ@mail.gmail.com> <CAG+Z0CsvFWv+JGauq3=PAV8=pcD9YHi8p1k9yTbsdT8iNU9AZw@mail.gmail.com>
On 11/29/2017 01:50 PM, Dmitry Goncharov wrote:
One option is we can decide the patch is compatible and apply it.
It's compatible only if we ignore performance. But I don't think that
would be right: I expect that some callers expect GLOB_ONLYDIR to be
fast (because that's what the Glibc documentation says), and that they
will be disappointed by this performance regression.
If the existing semantics has to be preserved then we can introduce
another flag and use the new flag instead of GLOB_ONLYDIR in
if (pattern[0] && pattern[strlen (pattern) - 1] == '/')
flags |= GLOB_ONLYDIR;
That would be a better approach. Another possibility might be to change
the last assignment to:
flags |= GLOB_ONLYDIR | GLOB_MARK;
and then at the end, filter out all matches that aren't marked with
trailing '/'. This would avoid creating a new GLOB_XXX option and would
probably be easier to implement.