summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-03-30 06:16:08 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-03-30 06:16:08 +0000
commit2d33d82794559b83131b83528279ce898716c112 (patch)
tree0cf9f625341314a54010e027a9c01305de797c08 /src/common
parent5b5afa7bb6cad66880bbbeee26d0851f25f85d45 (diff)
downloadhercules-2d33d82794559b83131b83528279ce898716c112.tar.gz
hercules-2d33d82794559b83131b83528279ce898716c112.tar.bz2
hercules-2d33d82794559b83131b83528279ce898716c112.tar.xz
hercules-2d33d82794559b83131b83528279ce898716c112.zip
* Added all the missing defines for ctype.h functions and converted all the direct uses to the defines.
Ref: http://www.eathena.ws/board/index.php?showtopic=145235 git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10091 54d463be-8e91-2dee-dedb-b68131a5f0ec
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;
}