[FFmpeg-devel] [PATCH 2/4] Make strmatch() return 1 only if the string compared against the prefix does not contain other characters which may belong to an identifier.

Michael Niedermayer michaelni
Sun Oct 31 11:28:02 CET 2010


On Sun, Oct 31, 2010 at 01:30:56AM +0200, Stefano Sabatini wrote:
> This allows to distinguish for example to have different constants
> with the same prefix (e.g. "foo" and "foobar").
> ---
>  libavutil/eval.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/libavutil/eval.c b/libavutil/eval.c
> index 6e03498..27c1b6d 100644
> --- a/libavutil/eval.c
> +++ b/libavutil/eval.c
> @@ -103,13 +103,15 @@ double av_strtod(const char *numstr, char **tail)
>      return d;
>  }
>  
> +#define IDENTIFIER_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789"
> +
>  static int strmatch(const char *s, const char *prefix)
>  {
>      int i;
>      for (i=0; prefix[i]; i++) {
>          if (prefix[i] != s[i]) return 0;
>      }
> -    return 1;
> +    return !strspn(s+i, IDENTIFIER_CHARS);

check the char ranges directly please, this is just slow


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you really think that XML is the answer, then you definitly missunderstood
the question -- Attila Kinali
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101031/60bac64d/attachment.pgp>



More information about the ffmpeg-devel mailing list