[FFmpeg-devel] [PATCH] avutil/avstring: add a "ALL" entry and the possibility to negate matches to av_match_name()
Michael Niedermayer
michael at niedermayer.cc
Sat Feb 13 16:42:55 CET 2016
On Sat, Feb 13, 2016 at 04:39:29PM +0100, Michael Niedermayer wrote:
> On Sat, Feb 13, 2016 at 03:22:52PM +0100, Stefano Sabatini wrote:
> > On date Thursday 2016-02-11 20:49:05 +0100, Michael Niedermayer encoded:
> > > This will extend the whitelist features to allow blacklisting individual protocols and to
> > > explicitly force everything to be enabled.
> > >
> > > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > > ---
> > > libavutil/avstring.c | 15 ++++++++++-----
> > > libavutil/avstring.h | 5 +++++
> > > 2 files changed, 15 insertions(+), 5 deletions(-)
> >
> > Nit: bump micro
>
> done
>
>
> >
> > >
> > > diff --git a/libavutil/avstring.c b/libavutil/avstring.c
> > > index 57fe74d..85fb3e9 100644
> > > --- a/libavutil/avstring.c
> > > +++ b/libavutil/avstring.c
> > > @@ -326,13 +326,18 @@ int av_match_name(const char *name, const char *names)
> > > return 0;
> > >
> > > namelen = strlen(name);
> > > - while ((p = strchr(names, ','))) {
> > > + while (*names) {
> > > + int negate = '-' == *names;
> > > + p = strchr(names, ',');
> > > + if (!p)
> > > + p = names + strlen(names);
> > > + names += negate;
> > > len = FFMAX(p - names, namelen);
> > > - if (!av_strncasecmp(name, names, len))
> > > - return 1;
> > > - names = p + 1;
> > > + if (!av_strncasecmp(name, names, len) || !strncmp("ALL", names, FFMAX(3, p - names)))
> > > + return !negate;
> >
>
> > So we have:
> >
> > av_match_name("foo", "foo") => 1
> > av_match_name("foo", "ALL") => 1
> > av_match_name("foo", "-foo") => 0
> > av_match_name("foo", "ALL,-foo") => 1
> > av_match_name("foo", "-foo,ALL") => 0
> >
> > Is this correct?
>
> yes, thats the intent
btw, a fate test for this would be a good idea, if anyone wants to
write one
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Those who are best at talking, realize last or never when they are wrong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160213/1113a6eb/attachment.sig>
More information about the ffmpeg-devel
mailing list