This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] posix: if glob has a trailing slash match directories only.


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]