stricmp function for Norcroft library
Dave Higton (281) 668 posts |
I hadn’t realised until a few minutes ago that stricmp is not included in the ANSI string library. At least, I assume that’s the case, because K&R lists strcmp but not stricmp (or strcmpi). However, it’s widely implemented (gcc for example), and it’s very useful. Does anyone share my view that it should be included in Norcroft’s libraries? |
John-Mark Bell (94) 36 posts |
There’s an implementation in the unix compatibility library, unixlib, in TCPIPLibs. This is not to be confused with the far richer UnixLib shipped with GCCSDK. Simply include unixlib.h in your sources, add unixlib to your link line, and then use strcasecmp. |
Dave Higton (281) 668 posts |
OK, thanks, John-Mark, that worked. stricmp, strcmpi, strcasecmp. Clearly not standardised :-) |
Ben Avison (25) 445 posts |
You’ll notice that the ANSI part of the shared C library is actually a very strict implementation of the ANSI C standards, and stricmp is not part of the ANSI standards. While you could start adding arbitrary extra functions to it, there’s always the question of where you draw the line. Remembering that the shared C library goes in ROM on machines which have limited ROM space, it makes sense to keep it as small as possible. All the RISC_OSLib stuff is only there because it’s shared between multiple ROM apps – Edit etc. – and therefore represents a ROM space saving. |