[FFmpeg-devel] [PATCH] Make av_parse_color() support a "Random" color

Stefano Sabatini stefano.sabatini-lala
Thu May 14 00:06:22 CEST 2009


On date Tuesday 2009-05-12 00:09:17 +0100, M?ns Rullg?rd encoded:
> Stefano Sabatini <stefano.sabatini-lala at poste.it> writes:
> 
> > On date Monday 2009-05-11 23:08:22 +0100, M?ns Rullg?rd encoded:
> >> Stefano Sabatini <stefano.sabatini-lala at poste.it> writes:
> >> 
> >> > Also are you saying that there is no safe way to lowercase a string in
> >> > C99?
> >> 
> >> Define lowercase.  As an example, in Turkish the lowercase version of
> >> 'I' is not 'i'.
> >
> > Thanks, that means we should avoid functions fiddling with the
> > locale. New attempt attached.
[...]
> > +/**
> > + * Compares two ASCII strings case-insensitively.
> > + */
> > +static int strcasecmp_ascii(const char *s1, const char *s2)
> > +{
> > +#define ASCII_LC(c) c >= 'A' && c <= 'Z' ? c + 32 : c
> > +    char c1, c2;
> > +    do {
> > +        c1 = *s1++;
> > +        c2 = *s2++;
> > +        c1 = ASCII_LC(c1);
> > +        c2 = ASCII_LC(c2);
> > +    }
> > +    while((c1 == c2) && c1);
> > +
> > +    return (int) c1-c2;
> 
> This assumes the character encoding is ASCII, which may not at all be
> the case.

So we're back to square one, and I'm in short of ideas, so there is no
safe method to match case-insensitively a string in C?

My temptation is to use lowercase anyway, in spite of those languages
mad enough to have a different definition of low/upcase to that of the
English language ;-)...

Regards. 
-- 
FFmpeg = Foolish Frenzy Mortal Programmable Enigmatic Guru



More information about the ffmpeg-devel mailing list