[MPlayer-dev-eng] [patch] stricmp
Frédéric Marchal
fmarchal at perso.be
Mon Jan 19 09:06:51 CET 2015
On Sunday 18 January 2015 19:03:03, Reimar Döffinger wrote :
> On Thu, Jan 15, 2015 at 06:40:37PM +0100, Ingo Brückl wrote:
> > Reimar Döffinger wrote on Wed, 14 Jan 2015 21:19:44 +0100:
> > >>Stephen Sheldon wrote on Tue, 13 Jan 2015 10:45:38 -0800:
> > >> Something has changed in Cygwin, and it no longer has a definition
> > >> for "stricmp".
> > >
> > > To be honest I agree with Nicolas here: I see no reason to use stricmp
> > > even the whole rest of the code base uses strcasecmp for the same
> > > effect, especially not if it involves ugly ifdefs...
> >
> > I had in mind people maybe using a more Windows-like compiler that would
> > only have stricmp (which is the Windows standard, AFAIK) but seemingly
> > we are only supporting Cygwin, MinGW and Wine, so this consideration
> > seems irrelevant.
>
> I don't see the connection either way.
> All other code uses strcasecmp, what is the point if you can compile
> the GUI code with such a compiler but none of all the other code?
> The only question I see is what is better code:
> 1) Code with several hundred uses of strcasecmp and one stricmp
> 2) Code which only uses strcasecmp
> 3) Code which only uses stricmp
>
> And I think 2 is the only sensible choice (besides using av_strcasecmp
> which might have other advantages), supporting compilers without
> it is still possible without issue by e.g. using a macro or helper
> in osdep/ that implements strcasecmp via stricmp.
> Btw. anyone else find the name choice "stricmp" funny?
> I just thought it ironic that they chose the only ascii letter "i"
> that is going to cause issues when people use it (
> stricmp/strcasecmp("i", "I") says they do not match for Turkish locales
> in case you didn't know).
Back at the time I programmed with Borland Turbo C, stricmp was the only
supported variant.
Likewise, National Instrument Labwindows/CVI only supports stricmp.
You need not to care about those two compilers. The former doesn't exist any
more and the latter is largely too crappy to compile anything but code
designed for it. Nobody sound of mind would port mplayer to either compiler
:-)
I think stricmp was introduced by Borland for its Turbo C compiler (maybe
strcasecmp didn't exist at the time or the name was judged too long). As that
compiler was the reference around 1990, Microsoft used the same API for its C
compiler. Others followed in suit except in the Unix world where strcasecmp
was the only supported function.
In any case, don't use the non-ANSI stricmp function.
If you ever encounter a compiler that only support stricmp, use a code like
this:
#if defined(_CVI_)
#define strcasecmp stricmp
#define strncasecmp strnicmp
#endif
Frederic
More information about the MPlayer-dev-eng
mailing list