Use of internal StrCmpIns function in stead of runtime stricmp/strcasecmp.
* Because of incompatible implementations of string comparison functions on different platforms (uppercase vs lowercase compares) it is better to have an scl specific StrCmpIns function. This fixes issues creating and validating complex structures in stepfile.cc.
This commit is contained in:
1 parent
14926414c3
commit
c316f21fe6
2 files changed
+10
-11
No files matched your search
@@ -96,6 +96,15 @@ const char * StrToConstant( const char * word, std::string & s ) {
|
||||
return const_cast<char *>( s.c_str() );
|
||||
}
|
||||
|
||||
int StrCmpIns( const char * str1, const char * str2 ) {
|
||||
char c1, c2;
|
||||
while ((c1 = tolower(*str1)) == (c2 = tolower(*str2)) && c1 != '\0') {
|
||||
str1++;
|
||||
str2++;
|
||||
}
|
||||
return c1 - c2;
|
||||
}
|
||||
|
||||
/**************************************************************//**
|
||||
** \fn PrettyTmpName (char * oldname)
|
||||
** \returns a new capitalized name in a static buffer
|
||||
|
||||
+1
-11
@@ -21,23 +21,13 @@
|
||||
#include <string.h>
|
||||
#include <errordesc.h>
|
||||
|
||||
|
||||
//StrCmpIns - case-insensitive string compare. Original fct (replaced Sep 2011)
|
||||
//called PrettyTmpName(). Not doing so may affect sort order but that shouldn't hurt
|
||||
#if defined(__MSVC__)
|
||||
#define StrCmpIns(a,b) _stricmp(a,b)
|
||||
#elif defined(__BORLAND__)
|
||||
#define StrCmpIns(a,b) stricmp(a,b)
|
||||
#else
|
||||
#define StrCmpIns(a,b) strcasecmp(a,b)
|
||||
#endif
|
||||
|
||||
SCL_UTILS_EXPORT char ToLower( const char c );
|
||||
SCL_UTILS_EXPORT char ToUpper( const char c );
|
||||
SCL_UTILS_EXPORT char * StrToLower( const char *, char * );
|
||||
SCL_UTILS_EXPORT const char * StrToLower( const char * word, std::string & s );
|
||||
SCL_UTILS_EXPORT const char * StrToUpper( const char * word, std::string & s );
|
||||
SCL_UTILS_EXPORT const char * StrToConstant( const char * word, std::string & s );
|
||||
SCL_UTILS_EXPORT int StrCmpIns( const char *str1, const char *str2 );
|
||||
SCL_UTILS_EXPORT const char * PrettyTmpName( const char * oldname );
|
||||
SCL_UTILS_EXPORT char * PrettyNewName( const char * oldname );
|
||||
SCL_UTILS_EXPORT char * EntityClassName( char * oldname );
|
||||
|
||||
Reference in new issue
Block a user