From 7af33b90b644e810827f79e6d680963f3c6e6baa Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sun, 3 Sep 2017 16:46:34 -0700 Subject: [PATCH] SCP: Fix internal ctype routines make consistent with standard routines. --- scp.c | 36 ++++++++++++++++++------------------ scp.h | 26 ++++++++++++++------------ 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/scp.c b/scp.c index 2a2d2a3c..41aa2f94 100644 --- a/scp.c +++ b/scp.c @@ -7991,54 +7991,54 @@ while ((--tptr >= cptr) && sim_isspace (*tptr)) return cptr; } -int sim_isspace (char c) +int sim_isspace (int c) { -return (c & 0x80) ? 0 : isspace (c); +return ((c > 0) && (c < 128)) ? 0 : isspace (c); } -int sim_islower (char c) +int sim_islower (int c) { -return (c & 0x80) ? 0 : islower (c); +return (c >= 'a') && (c <= 'z'); } -int sim_isupper (char c) +int sim_isupper (int c) { -return (c & 0x80) ? 0 : isupper (c); +return (c >= 'A') && (c <= 'Z'); } -int sim_toupper (char c) +int sim_toupper (int c) { return ((c >= 'a') && (c <= 'z')) ? ((c - 'a') + 'A') : c; } -int sim_tolower (char c) +int sim_tolower (int c) { return ((c >= 'A') && (c <= 'Z')) ? ((c - 'A') + 'a') : c; } -int sim_isalpha (char c) +int sim_isalpha (int c) { -return (c & 0x80) ? 0 : isalpha (c); +return ((c > 0) && (c < 128)) ? 0 : isalpha (c); } -int sim_isprint (char c) +int sim_isprint (int c) { -return (c & 0x80) ? 0 : isprint (c); +return ((c > 0) && (c < 128)) ? 0 : isprint (c); } -int sim_isdigit (char c) +int sim_isdigit (int c) { -return (c & 0x80) ? 0 : isdigit (c); +return ((c > 0) && (c < 128)) ? 0 : isdigit (c); } -int sim_isgraph (char c) +int sim_isgraph (int c) { -return (c & 0x80) ? 0 : isgraph (c); +return ((c > 0) && (c < 128)) ? 0 : isgraph (c); } -int sim_isalnum (char c) +int sim_isalnum (int c) { -return (c & 0x80) ? 0 : isalnum (c); +return ((c > 0) && (c < 128)) ? 0 : isalnum (c); } /* strncasecmp() is not available on all platforms */ diff --git a/scp.h b/scp.h index 2a1145c1..69108428 100644 --- a/scp.h +++ b/scp.h @@ -149,21 +149,23 @@ const char *sim_uname (UNIT *dptr); const char *sim_set_uname (UNIT *uptr, const char *uname); t_stat get_yn (const char *ques, t_stat deflt); char *sim_trim_endspc (char *cptr); -int sim_isspace (char c); -int sim_islower (char c); -int sim_isalpha (char c); -int sim_isprint (char c); -int sim_isdigit (char c); -int sim_isgraph (char c); -int sim_isalnum (char c); -int sim_toupper (char c); -int sim_tolower (char c); -#ifndef toupper +int sim_isspace (int c); +int sim_islower (int c); +int sim_isalpha (int c); +int sim_isprint (int c); +int sim_isdigit (int c); +int sim_isgraph (int c); +int sim_isalnum (int c); +int sim_toupper (int c); +int sim_tolower (int c); +#ifdef toupper +#undef toupper +#endif #define toupper(chr) sim_toupper(chr) +#ifdef tolower +#undef tolower #endif -#ifndef tolower #define tolower(chr) sim_tolower(chr) -#endif int sim_strncasecmp (const char *string1, const char *string2, size_t len); int sim_strcasecmp (const char *string1, const char *string2); size_t sim_strlcat (char *dst, const char *src, size_t size);