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

Måns Rullgård mans
Thu May 14 00:54:20 CEST 2009


Stefano Sabatini <stefano.sabatini-lala at poste.it> writes:

> 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?

Use the standard functions and let people who set funny locales get
what they deserve.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list