Use strcasecmp when available

This commit is contained in:
Kp 2015-01-12 00:26:03 +00:00
parent b6a3735f53
commit 484a2a705d
3 changed files with 17 additions and 0 deletions

View file

@ -856,6 +856,12 @@ help:always wipe certain freed memory
poison = True
if poison:
context.sconf.Define('DXX_HAVE_POISON')
@_custom_test
def check_strcasecmp_present(self,context):
main = '''
return !strcasecmp(argv[0], argv[0] + 1) && !strncasecmp(argv[0] + 1, argv[0], 1);
'''
self.Compile(context, text='#include <cstring>', main=main, msg='for strcasecmp', successflags={'CPPDEFINES' : ['DXX_HAVE_STRCASECMP']})
class LazyObjectConstructor:
def __get_lazy_object(self,srcname,transform_target):

View file

@ -15,10 +15,19 @@
#define snprintf macintosh_snprintf
extern void snprintf(char *out_string, int size, const char * format, ... );
#endif
#ifdef DXX_HAVE_STRCASECMP
#define d_stricmp strcasecmp
static inline int d_strnicmp(const char *s1, const char *s2, size_t n)
{
return strncasecmp(s1, s2, n);
}
#else
__attribute_nonnull()
extern int d_stricmp( const char *s1, const char *s2 );
__attribute_nonnull()
int d_strnicmp(const char *s1, const char *s2, uint_fast32_t n);
#endif
extern void d_strlwr( char *s1 );
extern void d_strupr( char *s1 );
extern void d_strrev( char *s1 );

View file

@ -56,6 +56,7 @@ void snprintf(char *out_string, int size, char * format, ... )
// string compare without regard to case
#ifndef DXX_HAVE_STRCASECMP
int d_stricmp( const char *s1, const char *s2 )
{
for (;; ++s1, ++s2)
@ -82,6 +83,7 @@ int d_strnicmp(const char *s1, const char *s2, uint_fast32_t n)
}
return 0;
}
#endif
void d_strlwr( char *s1 )
{