summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/cbasetypes.h19
-rw-r--r--src/common/core.c2
-rw-r--r--src/common/showmsg.c4
-rw-r--r--src/common/strlib.c4
4 files changed, 21 insertions, 8 deletions
diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h
index 1a1cd22a9..b513b7fa3 100644
--- a/src/common/cbasetypes.h
+++ b/src/common/cbasetypes.h
@@ -297,9 +297,22 @@ typedef char bool;
//////////////////////////////////////////////////////////////////////////
// Has to be unsigned to avoid problems in some systems
-#define TOLOWER(c) ((char)tolower((unsigned char)(c)))
-#define ISSPACE(c) (isspace((unsigned char)(c)))
-#define ISALPHA(c) (isalpha((unsigned char)(c)))
+// Problems arise when these functions expect an argument in the range [0,256[ and are feed a signed char.
+// NOTE: <ctype.h> needs to be included when using these defines
#define ISALNUM(c) (isalnum((unsigned char)(c)))
+#define ISALPHA(c) (isalpha((unsigned char)(c)))
+#define ISCNTRL(c) (iscntrl((unsigned char)(c)))
+#define ISDIGIT(c) (isdigit((unsigned char)(c)))
+#define ISGRAPH(c) (isgraph((unsigned char)(c)))
+#define ISLOWER(c) (islower((unsigned char)(c)))
+#define ISPRINT(c) (isprint((unsigned char)(c)))
+#define ISPUNCT(c) (ispunct((unsigned char)(c)))
+#define ISSPACE(c) (isspace((unsigned char)(c)))
+#define ISUPPER(c) (isupper((unsigned char)(c)))
+#define ISXDIGIT(c) (isxdigit((unsigned char)(c)))
+#define TOASCII(c) (toascii((unsigned char)(c)))
+#define TOLOWER(c) (tolower((unsigned char)(c)))
+#define TOUPPER(c) (toupper((unsigned char)(c)))
+
#endif /* _CBASETYPES_H_ */
diff --git a/src/common/core.c b/src/common/core.c
index 60d25546a..8c57f98ea 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -152,7 +152,7 @@ const char* get_svn_revision(void)
// Check the version
if (fgets(line,sizeof(line),fp))
{
- if(!isdigit(line[0]))
+ if(!ISDIGIT(line[0]))
{
// XML File format
while (fgets(line,sizeof(line),fp))
diff --git a/src/common/showmsg.c b/src/common/showmsg.c
index 9323efa3f..dd8cfb07a 100644
--- a/src/common/showmsg.c
+++ b/src/common/showmsg.c
@@ -242,7 +242,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
q=q+2;
while(1)
{
- if( isdigit((int)((unsigned char)*q)) )
+ if( ISDIGIT(*q) )
{ // add number to number array, only accept 2digits, shift out the rest
// so // \033[123456789m will become \033[89m
numbers[numpoint] = (numbers[numpoint]<<4) | (*q-'0');
@@ -565,7 +565,7 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr)
q=q+2;
while(1)
{
- if( isdigit((int)((unsigned char)*q)) )
+ if( ISDIGIT(*q) )
{
++q;
// and next character
diff --git a/src/common/strlib.c b/src/common/strlib.c
index ee37cb9ae..dd10d655e 100644
--- a/src/common/strlib.c
+++ b/src/common/strlib.c
@@ -150,7 +150,7 @@ const char *stristr(const char *haystack, const char *needle)
}
for ( ; *haystack; ++haystack )
{
- if ( toupper(*haystack) == toupper(*needle) )
+ if ( TOUPPER(*haystack) == TOUPPER(*needle) )
{
/*
* Matched starting char -- loop through remaining chars.
@@ -158,7 +158,7 @@ const char *stristr(const char *haystack, const char *needle)
const char *h, *n;
for ( h = haystack, n = needle; *h && *n; ++h, ++n )
{
- if ( toupper(*h) != toupper(*n) )
+ if ( TOUPPER(*h) != TOUPPER(*n) )
{
break;
}