mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Glauber Costa <glommer@cloudius-systems.com>
To: musl@lists.openwall.com
Subject: Re: [PATCH] implement glibc's glob_pattern_p
Date: Tue, 22 Jul 2014 02:44:10 +0400	[thread overview]
Message-ID: <CAD-J=za-Lpw7cfFgGSfpo60r8mq_TS6Qa_dw_mo53b+hTyxN3Q@mail.gmail.com> (raw)
In-Reply-To: <20140721143323.GP17402@brightrain.aerifal.cx>

[-- Attachment #1: Type: text/plain, Size: 1642 bytes --]

On Mon, Jul 21, 2014 at 6:33 PM, Rich Felker <dalias@libc.org> wrote:

> On Thu, Jul 17, 2014 at 01:12:55PM +0400, Glauber Costa wrote:
> > Currently, glob is implemented but glob_pattern_p is not. This function
> > can trivially be implemented with existing glob machinery, since all it
> > does is to tell whether or not the string contains special symbols. This
> > is basically the same logic as is_literal, but with inverted return
> value.
> >
> > The value of the "quote" parameter should also be inverted, since the man
> > page states that when the quote parameter is *non*-zero, then backslashes
> > are ignored. is_literal ignores them when useesc is *zero*.
>
> Upon reviewing this patch, I'm not sure if it's correct. It wrote this
> code (glob.c) roughly 10 years ago and barely touched it since, but
> from what I can tell, the existing is_literal looks like a premature
> optimization to avoid calling fnmatch when it's not necessary than an
> accurate predicate. In other words, it's designed to reliably return 0
> if the string is a glob, but there are also cases where it returns 0
> when the string is not a "glob pattern" but not purely a literal
> either (e.g. anything containing backslash when useesc is nonzero,
> since such strings cannot be processed with strcmp and need fnmatch).
>
> My leaning would be to remove this "optimization" from glob.c entirely
> (it shouldn't be needed if fnmatch is efficient) and move the code to
> a separate file for glob_pattern_p, but then we need to make sure it
> gets things right with no false positives or false negatives.
>
> Hi

I will come back to this soon, then.

Cya

[-- Attachment #2: Type: text/html, Size: 2205 bytes --]

      reply	other threads:[~2014-07-21 22:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-17  9:12 Glauber Costa
2014-07-19 20:11 ` Rich Felker
2014-07-19 23:17   ` Glauber Costa
2014-07-19 23:45     ` Rich Felker
2014-07-20 20:01       ` Thomas Petazzoni
2014-07-21 10:19         ` Glauber Costa
2014-07-20 20:36 ` Szabolcs Nagy
2014-07-21 10:29   ` Glauber Costa
2014-07-21 14:11     ` Rich Felker
2014-07-21 23:45       ` John Spencer
2014-07-21 14:33 ` Rich Felker
2014-07-21 22:44   ` Glauber Costa [this message]

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='CAD-J=za-Lpw7cfFgGSfpo60r8mq_TS6Qa_dw_mo53b+hTyxN3Q@mail.gmail.com' \
    --to=glommer@cloudius-systems.com \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).