Switch to safe ctype.h wrappers
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/a6bfd289 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/a6bfd289 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/a6bfd289 Branch: refs/heads/master Commit: a6bfd289edd6dba8cd73aed9b655fd56ae52b20b Parents: fb28c3c Author: Nick Wellnhofer <wellnho...@aevum.de> Authored: Wed Apr 6 13:24:36 2016 +0200 Committer: Nick Wellnhofer <wellnho...@aevum.de> Committed: Wed Apr 6 13:24:36 2016 +0200 ---------------------------------------------------------------------- compiler/src/CFCCHtml.c | 1 - compiler/src/CFCCallable.c | 1 - compiler/src/CFCClass.c | 13 ++++++------- compiler/src/CFCDocuComment.c | 20 ++++++++++++-------- compiler/src/CFCFile.c | 5 ++--- compiler/src/CFCFileSpec.c | 1 - compiler/src/CFCFunction.c | 5 +++-- compiler/src/CFCGo.c | 1 - compiler/src/CFCGoFunc.c | 3 +-- compiler/src/CFCGoMethod.c | 1 - compiler/src/CFCGoTypeMap.c | 13 ++++++------- compiler/src/CFCHierarchy.c | 1 - compiler/src/CFCMethod.c | 7 +++---- compiler/src/CFCParcel.c | 11 +++++------ compiler/src/CFCPerl.c | 8 ++++---- compiler/src/CFCPerlClass.c | 2 +- compiler/src/CFCPerlMethod.c | 3 +-- compiler/src/CFCPerlPod.c | 13 ++++++------- compiler/src/CFCPyClass.c | 3 +-- compiler/src/CFCPyMethod.c | 5 ++--- compiler/src/CFCPython.c | 5 ++--- compiler/src/CFCRuby.c | 8 ++++---- compiler/src/CFCSymbol.c | 5 ++--- compiler/src/CFCType.c | 13 ++++++------- compiler/src/CFCUri.c | 5 ++--- compiler/src/CFCUtil.c | 4 ++-- compiler/src/CFCVersion.c | 5 ++--- 27 files changed, 73 insertions(+), 89 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCCHtml.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCCHtml.c b/compiler/src/CFCCHtml.c index a054cb8..222f5fd 100644 --- a/compiler/src/CFCCHtml.c +++ b/compiler/src/CFCCHtml.c @@ -14,7 +14,6 @@ * limitations under the License. */ -#include <ctype.h> #include <stdlib.h> #include <stddef.h> #include <string.h> http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCCallable.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCCallable.c b/compiler/src/CFCCallable.c index ccb3931..8071761 100644 --- a/compiler/src/CFCCallable.c +++ b/compiler/src/CFCCallable.c @@ -15,7 +15,6 @@ */ #include <string.h> -#include <ctype.h> #ifndef true #define true 1 http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCClass.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCClass.c b/compiler/src/CFCClass.c index 77e0158..319b1ae 100644 --- a/compiler/src/CFCClass.c +++ b/compiler/src/CFCClass.c @@ -16,7 +16,6 @@ #include <stdio.h> #include <string.h> -#include <ctype.h> #ifndef true #define true 1 @@ -139,22 +138,22 @@ CFCClass_validate_class_name(const char *class_name) { for (;;substring++) { if (*substring == 0) { return false; } else if (*substring == ':') { return false; } - else if (islower(*substring)) { break; } + else if (CFCUtil_islower(*substring)) { break; } } // Must be UpperCamelCase, separated by "::". const char *ptr = class_name; - if (!isupper(*ptr)) { return false; } + if (!CFCUtil_isupper(*ptr)) { return false; } while (*ptr != 0) { if (*ptr == 0) { break; } else if (*ptr == ':') { ptr++; if (*ptr != ':') { return false; } ptr++; - if (!isupper(*ptr)) { return false; } + if (!CFCUtil_isupper(*ptr)) { return false; } ptr++; } - else if (!isalnum(*ptr)) { return false; } + else if (!CFCUtil_isalnum(*ptr)) { return false; } else { ptr++; } } @@ -178,7 +177,7 @@ S_validate_nickname(const char *nickname) { if (strlen(nickname)) { return true; } else { break; } } - else if (!isupper(*ptr)) { break; } + else if (!CFCUtil_isupper(*ptr)) { break; } } // Same as one component of a class name. @@ -274,7 +273,7 @@ CFCClass_do_create(CFCClass *self, struct CFCParcel *parcel, char *short_class_var = (char*)MALLOCATE(struct_sym_len + 1); size_t i; for (i = 0; i < struct_sym_len; i++) { - short_class_var[i] = (char)toupper(struct_sym[i]); + short_class_var[i] = CFCUtil_toupper(struct_sym[i]); } short_class_var[struct_sym_len] = '\0'; self->short_class_var = short_class_var; http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCDocuComment.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCDocuComment.c b/compiler/src/CFCDocuComment.c index 2bcc495..26eb059 100644 --- a/compiler/src/CFCDocuComment.c +++ b/compiler/src/CFCDocuComment.c @@ -14,7 +14,6 @@ * limitations under the License. */ -#include <ctype.h> #include <string.h> #include <cmark.h> @@ -50,7 +49,7 @@ S_strip(char *comment) { // Capture text minus beginning "/**", ending "*/", and left border. size_t i = 3; size_t max = len - 2; - while ((isspace(comment[i]) || comment[i] == '*') && i < max) { + while ((CFCUtil_isspace(comment[i]) || comment[i] == '*') && i < max) { i++; } size_t j = 0; @@ -58,7 +57,10 @@ S_strip(char *comment) { while (comment[i] == '\n' && i < max) { scratch[j++] = comment[i]; i++; - while (isspace(comment[i]) && comment[i] != '\n' && i < max) { + while (CFCUtil_isspace(comment[i]) + && comment[i] != '\n' + && i < max + ) { i++; } if (comment[i] == '*') { i++; } @@ -104,7 +106,7 @@ CFCDocuComment_parse(const char *raw_text) { } while (ptr < limit) { if (*ptr == '.' - && ((ptr == limit - 1) || isspace(*(ptr + 1))) + && ((ptr == limit - 1) || CFCUtil_isspace(*(ptr + 1))) ) { ptr++; size_t brief_len = (size_t)(ptr - text); @@ -130,19 +132,21 @@ CFCDocuComment_parse(const char *raw_text) { while (candidate) { // Extract param name. char *ptr = candidate + sizeof("@param") - 1; - if (!isspace(*ptr) || ptr > text_limit) { + if (!CFCUtil_isspace(*ptr) || ptr > text_limit) { CFCUtil_die("Malformed @param directive in '%s'", raw_text); } - while (isspace(*ptr) && ptr < text_limit) { ptr++; } + while (CFCUtil_isspace(*ptr) && ptr < text_limit) { ptr++; } char *param_name = ptr; - while ((isalnum(*ptr) || *ptr == '_') && ptr < text_limit) { ptr++; } + while ((CFCUtil_isalnum(*ptr) || *ptr == '_') && ptr < text_limit) { + ptr++; + } size_t param_name_len = (size_t)(ptr - param_name); if (!param_name_len) { CFCUtil_die("Malformed @param directive in '%s'", raw_text); } // Extract param description. - while (isspace(*ptr) && ptr < text_limit) { ptr++; } + while (CFCUtil_isspace(*ptr) && ptr < text_limit) { ptr++; } char *param_doc = ptr; while (ptr < text_limit && (*ptr != '@' http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCFile.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCFile.c b/compiler/src/CFCFile.c index 1e03a3e..d8620f2 100644 --- a/compiler/src/CFCFile.c +++ b/compiler/src/CFCFile.c @@ -18,7 +18,6 @@ #include <string.h> #include <stdio.h> -#include <ctype.h> #ifndef true #define true 1 @@ -80,8 +79,8 @@ CFCFile_init(CFCFile *self, CFCParcel *parcel, CFCFileSpec *spec) { if (c == CHY_DIR_SEP_CHAR) { self->guard_name[j++] = '_'; } - else if (isalnum(c)) { - self->guard_name[j++] = (char)toupper(c); + else if (CFCUtil_isalnum(c)) { + self->guard_name[j++] = CFCUtil_toupper(c); } } self->guard_name[j] = '\0'; http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCFileSpec.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCFileSpec.c b/compiler/src/CFCFileSpec.c index 90e3b76..4523f20 100644 --- a/compiler/src/CFCFileSpec.c +++ b/compiler/src/CFCFileSpec.c @@ -18,7 +18,6 @@ #include <string.h> #include <stdio.h> -#include <ctype.h> #ifndef true #define true 1 http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCFunction.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCFunction.c b/compiler/src/CFCFunction.c index bbfc88c..d739007 100644 --- a/compiler/src/CFCFunction.c +++ b/compiler/src/CFCFunction.c @@ -15,7 +15,6 @@ */ #include <string.h> -#include <ctype.h> #ifndef true #define true 1 @@ -58,7 +57,9 @@ S_validate_function_name(const char *name) { if (!len) { return false; } for (size_t i = 0; i < len; i++) { char c = name[i]; - if (!islower(c) && !isdigit(c) && c != '_') { return false; } + if (!CFCUtil_islower(c) && !CFCUtil_isdigit(c) && c != '_') { + return false; + } } return true; } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCGo.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCGo.c b/compiler/src/CFCGo.c index c263bfd..56c43bf 100644 --- a/compiler/src/CFCGo.c +++ b/compiler/src/CFCGo.c @@ -19,7 +19,6 @@ #include <string.h> #include <stdio.h> #include <stdlib.h> -#include <ctype.h> #define CFC_NEED_BASE_STRUCT_DEF #include "CFCBase.h" http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCGoFunc.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCGoFunc.c b/compiler/src/CFCGoFunc.c index 8607d8f..7abf90f 100644 --- a/compiler/src/CFCGoFunc.c +++ b/compiler/src/CFCGoFunc.c @@ -17,7 +17,6 @@ #include <string.h> #include <stdio.h> -#include <ctype.h> #include "charmony.h" @@ -49,7 +48,7 @@ char* CFCGoFunc_go_meth_name(const char *orig, int is_public) { char *go_name = CFCUtil_strdup(orig); if (!is_public) { - go_name[0] = (char)tolower(go_name[0]); + go_name[0] = CFCUtil_tolower(go_name[0]); } for (size_t i = 1, j = 1, max = strlen(go_name) + 1; i < max; i++) { if (go_name[i] != '_') { http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCGoMethod.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCGoMethod.c b/compiler/src/CFCGoMethod.c index 7de4f09..241e4da 100644 --- a/compiler/src/CFCGoMethod.c +++ b/compiler/src/CFCGoMethod.c @@ -17,7 +17,6 @@ #include <string.h> #include <stdio.h> -#include <ctype.h> #define CFC_NEED_BASE_STRUCT_DEF #include "CFCBase.h" http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCGoTypeMap.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCGoTypeMap.c b/compiler/src/CFCGoTypeMap.c index ad91817..197051f 100644 --- a/compiler/src/CFCGoTypeMap.c +++ b/compiler/src/CFCGoTypeMap.c @@ -16,7 +16,6 @@ #include <string.h> #include <stdio.h> -#include <ctype.h> #include <stdlib.h> #include "CFCGoTypeMap.h" @@ -113,7 +112,7 @@ CFCGoTypeMap_go_type_name(CFCType *type, CFCParcel *current_parcel) { const char *specifier = CFCType_get_specifier(type); size_t prefix_len = 0; for (size_t max = strlen(specifier); prefix_len < max; prefix_len++) { - if (isupper(specifier[prefix_len])) { + if (CFCUtil_isupper(specifier[prefix_len])) { break; } } @@ -153,7 +152,7 @@ CFCGoTypeMap_go_type_name(CFCType *type, CFCParcel *current_parcel) { } char *result = CFCUtil_sprintf("%s.%s", package_name, struct_sym); for (int i = 0; result[i] != '.'; i++) { - result[i] = (char)tolower(result[i]); + result[i] = CFCUtil_tolower(result[i]); } return result; } @@ -184,7 +183,7 @@ CFCGoTypeMap_go_short_package(CFCParcel *parcel) { // parcel names. char *go_short_package = CFCUtil_strdup(parcel_frag); for (int i = 0; go_short_package[i] != '\0'; i++) { - go_short_package[i] = (char)tolower(go_short_package[i]); + go_short_package[i] = CFCUtil_tolower(go_short_package[i]); } return go_short_package; } @@ -206,8 +205,8 @@ CFCGoTypeMap_go_meth_receiever(const char *struct_name, // Find the first letter of the type and lowercase it. for (size_t i = 0, max = strlen(struct_name); i < max; i++) { - if (isupper(struct_name[i])) { - buf[0] = (char)tolower(struct_name[i]); + if (CFCUtil_isupper(struct_name[i])) { + buf[0] = CFCUtil_tolower(struct_name[i]); buf[1] = '\0'; break; } @@ -265,7 +264,7 @@ CFCGoTypeMap_go_arg_name(CFCParamList *param_list, size_t tick, char *buf, continue; } else if (last_was_underscore) { - buf[dest_tick] = (char)toupper(orig[i]); + buf[dest_tick] = CFCUtil_toupper(orig[i]); } else { buf[dest_tick] = orig[i]; http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCHierarchy.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCHierarchy.c b/compiler/src/CFCHierarchy.c index 57d3bfc..5b1e636 100644 --- a/compiler/src/CFCHierarchy.c +++ b/compiler/src/CFCHierarchy.c @@ -21,7 +21,6 @@ #include <string.h> #include <errno.h> #include <sys/stat.h> -#include <ctype.h> #ifndef true #define true 1 http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCMethod.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCMethod.c b/compiler/src/CFCMethod.c index 8a142d1..a8585fb 100644 --- a/compiler/src/CFCMethod.c +++ b/compiler/src/CFCMethod.c @@ -15,7 +15,6 @@ */ #include <string.h> -#include <ctype.h> #include <stdio.h> #define CFC_NEED_CALLABLE_STRUCT_DEF @@ -66,15 +65,15 @@ S_validate_meth_name(const char *meth_name) { int need_upper = true; int need_letter = true; for (;; meth_name++) { - if (need_upper && !isupper(*meth_name)) { return false; } - if (need_letter && !isalpha(*meth_name)) { return false; } + if (need_upper && !CFCUtil_isupper(*meth_name)) { return false; } + if (need_letter && !CFCUtil_isalpha(*meth_name)) { return false; } need_upper = false; need_letter = false; // We've reached NULL-termination without problems, so succeed. if (!*meth_name) { return true; } - if (!isalnum(*meth_name)) { + if (!CFCUtil_isalnum(*meth_name)) { if (*meth_name != '_') { return false; } need_upper = true; } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCParcel.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCParcel.c b/compiler/src/CFCParcel.c index cbfd2a5..5379d63 100644 --- a/compiler/src/CFCParcel.c +++ b/compiler/src/CFCParcel.c @@ -14,7 +14,6 @@ * limitations under the License. */ -#include <ctype.h> #include <string.h> #include <stdlib.h> @@ -143,7 +142,7 @@ static int S_validate_name_or_nickname(const char *orig) { const char *ptr = orig; for (; *ptr != 0; ptr++) { - if (!isalpha(*ptr)) { return false; } + if (!CFCUtil_isalpha(*ptr)) { return false; } } return true; } @@ -209,8 +208,8 @@ CFCParcel_init(CFCParcel *self, const char *name, const char *nickname, self->Prefix[nickname_len] = '\0'; } for (size_t i = 0; i < amount; i++) { - self->prefix[i] = (char)tolower(self->Prefix[i]); - self->PREFIX[i] = (char)toupper(self->Prefix[i]); + self->prefix[i] = CFCUtil_tolower(self->Prefix[i]); + self->PREFIX[i] = CFCUtil_toupper(self->Prefix[i]); } self->prefix[prefix_len] = '\0'; self->Prefix[prefix_len] = '\0'; @@ -221,7 +220,7 @@ CFCParcel_init(CFCParcel *self, const char *name, const char *nickname, self->privacy_sym = (char*)MALLOCATE(privacy_sym_len + 1); memcpy(self->privacy_sym, "CFP_", 4); for (size_t i = 0; i < nickname_len; i++) { - self->privacy_sym[i+4] = (char)toupper(self->nickname[i]); + self->privacy_sym[i+4] = CFCUtil_toupper(self->nickname[i]); } self->privacy_sym[privacy_sym_len] = '\0'; @@ -805,7 +804,7 @@ S_parse_json_null(const char **json) { static void S_skip_whitespace(const char **json) { - while (isspace(json[0][0])) { *json = *json + 1; } + while (CFCUtil_isspace(json[0][0])) { *json = *json + 1; } } static void http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCPerl.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCPerl.c b/compiler/src/CFCPerl.c index ccd548b..34bd0cb 100644 --- a/compiler/src/CFCPerl.c +++ b/compiler/src/CFCPerl.c @@ -18,7 +18,7 @@ #include <string.h> #include <stdio.h> -#include <ctype.h> + #define CFC_NEED_BASE_STRUCT_DEF #include "CFCBase.h" #include "CFCPerl.h" @@ -108,7 +108,7 @@ CFCPerl_init(CFCPerl *self, CFCHierarchy *hierarchy, const char *lib_dir, // Derive the name of the bootstrap function. self->boot_func = CFCUtil_sprintf("cfish_%s_bootstrap", boot_class); for (int i = 0; self->boot_func[i] != 0; i++) { - if (!isalnum(self->boot_func[i])) { + if (!CFCUtil_isalnum(self->boot_func[i])) { self->boot_func[i] = '_'; } } @@ -279,8 +279,8 @@ S_write_boot_h(CFCPerl *self) { char *guard = CFCUtil_sprintf("%s_BOOT", self->boot_class); S_replace_double_colons(guard, '_'); for (char *ptr = guard; *ptr != '\0'; ptr++) { - if (isalpha(*ptr)) { - *ptr = (char)toupper(*ptr); + if (CFCUtil_isalpha(*ptr)) { + *ptr = CFCUtil_toupper(*ptr); } } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCPerlClass.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCPerlClass.c b/compiler/src/CFCPerlClass.c index cb26d4d..30dc1d6 100644 --- a/compiler/src/CFCPerlClass.c +++ b/compiler/src/CFCPerlClass.c @@ -15,9 +15,9 @@ */ #include <string.h> -#include <ctype.h> #include <stdlib.h> #include <stdio.h> + #define CFC_NEED_BASE_STRUCT_DEF #include "CFCBase.h" #include "CFCPerlClass.h" http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCPerlMethod.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCPerlMethod.c b/compiler/src/CFCPerlMethod.c index f614896..313176d 100644 --- a/compiler/src/CFCPerlMethod.c +++ b/compiler/src/CFCPerlMethod.c @@ -16,7 +16,6 @@ #include <string.h> #include <stdio.h> -#include <ctype.h> #define CFC_NEED_PERLSUB_STRUCT_DEF 1 #include "CFCPerlSub.h" @@ -133,7 +132,7 @@ CFCPerlMethod_perl_name(CFCMethod *method) { const char *name = CFCMethod_get_name(method); char *perl_name = CFCUtil_strdup(name); for (size_t i = 0; perl_name[i] != '\0'; i++) { - perl_name[i] = (char)tolower(perl_name[i]); + perl_name[i] = CFCUtil_tolower(perl_name[i]); } return perl_name; http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCPerlPod.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCPerlPod.c b/compiler/src/CFCPerlPod.c index 09be538..63105da 100644 --- a/compiler/src/CFCPerlPod.c +++ b/compiler/src/CFCPerlPod.c @@ -17,7 +17,6 @@ #include "charmony.h" #include <string.h> -#include <ctype.h> #include <cmark.h> @@ -533,7 +532,7 @@ S_perl_var_name(CFCType *type, int is_ctor_retval) { } else { // Skip parcel prefix. - if (islower(*specifier)) { + if (CFCUtil_islower(*specifier)) { for (specifier++; *specifier; specifier++) { if (*specifier == '_') { specifier++; @@ -570,21 +569,21 @@ S_camel_to_lower(const char *camel) { size_t alloc = 1; for (size_t i = 1; camel[i]; i++) { - if (isupper(camel[i]) && islower(camel[i+1])) { + if (CFCUtil_isupper(camel[i]) && CFCUtil_islower(camel[i+1])) { alloc += 1; } alloc += 1; } char *lower = (char*)MALLOCATE(alloc + 1); - lower[0] = (char)tolower(camel[0]); + lower[0] = CFCUtil_tolower(camel[0]); size_t j = 1; for (size_t i = 1; camel[i]; i++) { // Only insert underscore if next char is lowercase. - if (isupper(camel[i]) && islower(camel[i+1])) { + if (CFCUtil_isupper(camel[i]) && CFCUtil_islower(camel[i+1])) { lower[j++] = '_'; } - lower[j++] = (char)tolower(camel[i]); + lower[j++] = CFCUtil_tolower(camel[i]); } lower[j] = '\0'; @@ -948,7 +947,7 @@ S_convert_link(cmark_node *link, CFCClass *doc_class, int header_level) { char *perl_name = CFCUtil_strdup(name); for (size_t i = 0; perl_name[i] != '\0'; ++i) { - perl_name[i] = (char)tolower(perl_name[i]); + perl_name[i] = CFCUtil_tolower(perl_name[i]); } // The Perl POD only contains sections for novel methods. Link http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCPyClass.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCPyClass.c b/compiler/src/CFCPyClass.c index 1e80ebb..7e59715 100644 --- a/compiler/src/CFCPyClass.c +++ b/compiler/src/CFCPyClass.c @@ -15,7 +15,6 @@ */ #include <string.h> -#include <ctype.h> #include <stdlib.h> #define CFC_NEED_BASE_STRUCT_DEF 1 @@ -204,7 +203,7 @@ S_pytype_struct_def(CFCPyClass *self) { char *pymod_name = CFCUtil_strdup(parcel_name); // TODO: Stop lowercasing when parcels are restricted to lowercase. for (int i = 0; pymod_name[i] != '\0'; i++) { - pymod_name[i] = (char)tolower(pymod_name[i]); + pymod_name[i] = CFCUtil_tolower(pymod_name[i]); } const char *struct_sym = CFCClass_get_struct_sym(klass); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCPyMethod.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCPyMethod.c b/compiler/src/CFCPyMethod.c index 168bfb8..ec29846 100644 --- a/compiler/src/CFCPyMethod.c +++ b/compiler/src/CFCPyMethod.c @@ -15,7 +15,6 @@ */ #include <string.h> -#include <ctype.h> #include "CFCPyMethod.h" #include "CFCPyTypeMap.h" @@ -277,7 +276,7 @@ S_build_pymeth_invocation(CFCMethod *method) { CFCUtil_die("Unexpectedly long type name: %s", ret_type_str); } for (size_t i = 0, max = strlen(ret_type_str) + 1; i < max; i++) { - type_upcase[i] = (char)toupper(ret_type_str[i]); + type_upcase[i] = CFCUtil_toupper(ret_type_str[i]); } const char pattern[] = " %s cfcb_RESULT = CALL_PYMETH_%s((PyObject*)self, \"%s\", cfcb_ARGS);"; @@ -646,7 +645,7 @@ CFCPyMethod_pymethoddef(CFCMethod *method, CFCClass *invoker) { char *meth_sym = CFCMethod_full_method_sym(method, invoker); char *micro_sym = CFCUtil_strdup(CFCSymbol_get_name((CFCSymbol*)method)); for (int i = 0; micro_sym[i] != 0; i++) { - micro_sym[i] = (char)tolower(micro_sym[i]); + micro_sym[i] = CFCUtil_tolower(micro_sym[i]); } char pattern[] = http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCPython.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCPython.c b/compiler/src/CFCPython.c index 0dff7e2..f81cfd4 100644 --- a/compiler/src/CFCPython.c +++ b/compiler/src/CFCPython.c @@ -19,7 +19,6 @@ #include <string.h> #include <stdio.h> #include <stdlib.h> -#include <ctype.h> #define CFC_NEED_BASE_STRUCT_DEF #include "CFCBase.h" @@ -447,7 +446,7 @@ S_write_module_file(CFCPython *self, CFCParcel *parcel, const char *dest) { char *pymod_name = CFCUtil_strdup(parcel_name); // TODO: Stop lowercasing when parcels are restricted to lowercase. for (int i = 0; pymod_name[i] != '\0'; i++) { - pymod_name[i] = (char)tolower(pymod_name[i]); + pymod_name[i] = CFCUtil_tolower(pymod_name[i]); } const char *last_dot = strrchr(pymod_name, '.'); const char *last_component = last_dot != NULL @@ -455,7 +454,7 @@ S_write_module_file(CFCPython *self, CFCParcel *parcel, const char *dest) { : pymod_name; char *helper_mod_name = CFCUtil_sprintf("%s._%s", pymod_name, last_component); for (int i = 0; helper_mod_name[i] != '\0'; i++) { - helper_mod_name[i] = (char)tolower(helper_mod_name[i]); + helper_mod_name[i] = CFCUtil_tolower(helper_mod_name[i]); } CFCClass **ordered = CFCHierarchy_ordered_classes(self->hierarchy); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCRuby.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCRuby.c b/compiler/src/CFCRuby.c index 0e2c146..bf25b68 100644 --- a/compiler/src/CFCRuby.c +++ b/compiler/src/CFCRuby.c @@ -18,7 +18,7 @@ #include <string.h> #include <stdio.h> -#include <ctype.h> + #define CFC_NEED_BASE_STRUCT_DEF #include "CFCBase.h" #include "CFCClass.h" @@ -89,7 +89,7 @@ CFCRuby_init(CFCRuby *self, CFCParcel *parcel, CFCHierarchy *hierarchy, self->boot_func = CFCUtil_sprintf("%s%s_bootstrap", prefix, boot_class); for (int i = 0; self->boot_func[i] != 0; i++) { - if (!isalnum(self->boot_func[i])) { + if (!CFCUtil_isalnum(self->boot_func[i])) { self->boot_func[i] = '_'; } } @@ -134,8 +134,8 @@ S_write_boot_h(CFCRuby *self) { "_BOOT", NULL); S_replace_double_colons(guard, '_'); for (char *ptr = guard; *ptr != '\0'; ptr++) { - if (isalpha(*ptr)) { - *ptr = (char)toupper(*ptr); + if (CFCUtil_isalpha(*ptr)) { + *ptr = CFCUtil_toupper(*ptr); } } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCSymbol.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCSymbol.c b/compiler/src/CFCSymbol.c index 2dd7ddc..ab37b4e 100644 --- a/compiler/src/CFCSymbol.c +++ b/compiler/src/CFCSymbol.c @@ -15,7 +15,6 @@ */ #include <string.h> -#include <ctype.h> #ifndef true #define true 1 @@ -56,9 +55,9 @@ S_validate_exposure(const char *exposure) { static int S_validate_identifier(const char *identifier) { const char *ptr = identifier; - if (!isalpha(*ptr) && *ptr != '_') { return false; } + if (!CFCUtil_isalpha(*ptr) && *ptr != '_') { return false; } for (; *ptr != 0; ptr++) { - if (!isalnum(*ptr) && *ptr != '_') { return false; } + if (!CFCUtil_isalnum(*ptr) && *ptr != '_') { return false; } } return true; } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCType.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCType.c b/compiler/src/CFCType.c index a45c174..5dd3136 100644 --- a/compiler/src/CFCType.c +++ b/compiler/src/CFCType.c @@ -16,7 +16,6 @@ #include <string.h> #include <stdio.h> -#include <ctype.h> #include "charmony.h" @@ -221,12 +220,12 @@ CFCType_new_object(int flags, CFCParcel *parcel, const char *specifier, S_check_flags(flags, acceptable_flags, "Object"); // Validate specifier. - if (!isalpha(*specifier)) { + if (!CFCUtil_isalpha(*specifier)) { CFCUtil_die("Invalid specifier: '%s'", specifier); } const char *small_specifier = specifier; - while (!isupper(*small_specifier)) { - if (!isalnum(*small_specifier) && *small_specifier != '_') { + while (!CFCUtil_isupper(*small_specifier)) { + if (!CFCUtil_isalnum(*small_specifier) && *small_specifier != '_') { CFCUtil_die("Invalid specifier: '%s'", specifier); } small_specifier++; @@ -276,7 +275,7 @@ CFCType* CFCType_new_arbitrary(CFCParcel *parcel, const char *specifier) { // Validate specifier. for (size_t i = 0, max = strlen(specifier); i < max; i++) { - if (!isalnum(specifier[i]) && specifier[i] != '_') { + if (!CFCUtil_isalnum(specifier[i]) && specifier[i] != '_') { CFCUtil_die("Illegal specifier: '%s'", specifier); } } @@ -295,7 +294,7 @@ CFCType_resolve(CFCType *self) { } char *specifier = self->specifier; - if (isupper(specifier[0])) { + if (CFCUtil_isupper(specifier[0])) { CFCParcel *parcel = CFCParcel_lookup_struct_sym(self->parcel, specifier); if (!parcel) { @@ -384,7 +383,7 @@ CFCType_get_class_var(CFCType *self) { if (!self->class_var) { self->class_var = CFCUtil_strdup(self->specifier); for (int i = 0; self->class_var[i] != 0; i++) { - self->class_var[i] = (char)toupper(self->class_var[i]); + self->class_var[i] = CFCUtil_toupper(self->class_var[i]); } } return self->class_var; http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCUri.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCUri.c b/compiler/src/CFCUri.c index 7ac8a7e..c16c43e 100644 --- a/compiler/src/CFCUri.c +++ b/compiler/src/CFCUri.c @@ -14,7 +14,6 @@ * limitations under the License. */ -#include <ctype.h> #include <stdlib.h> #include <string.h> @@ -110,7 +109,7 @@ S_parse(CFCUri *self) { char *iter = buf; const char *component = S_next_component(&iter); - if (islower(component[0])) { + if (CFCUtil_islower(component[0])) { // Parcel parcel = component; component = S_next_component(&iter); @@ -179,7 +178,7 @@ S_resolve(CFCUri *self, const char *parcel, const char *struct_sym, CFCBase_incref((CFCBase*)klass); if (callable) { - if (islower(callable[0])) { + if (CFCUtil_islower(callable[0])) { CFCFunction *function = CFCClass_function(klass, callable); if (!function) { http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCUtil.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCUtil.c b/compiler/src/CFCUtil.c index 83c30e2..c5444fd 100644 --- a/compiler/src/CFCUtil.c +++ b/compiler/src/CFCUtil.c @@ -130,13 +130,13 @@ CFCUtil_trim_whitespace(char *text) { // Find start. char *ptr = text; - while (*ptr != '\0' && isspace(*ptr)) { ptr++; } + while (*ptr != '\0' && CFCUtil_isspace(*ptr)) { ptr++; } // Find end. size_t orig_len = strlen(text); char *limit = text + orig_len; for (; limit > text; limit--) { - if (!isspace(*(limit - 1))) { break; } + if (!CFCUtil_isspace(*(limit - 1))) { break; } } // Modify string in place and NULL-terminate. http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a6bfd289/compiler/src/CFCVersion.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCVersion.c b/compiler/src/CFCVersion.c index 97727a8..74d3c39 100644 --- a/compiler/src/CFCVersion.c +++ b/compiler/src/CFCVersion.c @@ -15,7 +15,6 @@ */ #include <string.h> -#include <ctype.h> #ifndef true #define true 1 @@ -49,7 +48,7 @@ CFCVersion_new(const char *vstring) { CFCVersion* CFCVersion_init(CFCVersion *self, const char *vstring) { CFCUTIL_NULL_CHECK(vstring); - if (*vstring != 'v' || !isdigit(vstring[1])) { + if (*vstring != 'v' || !CFCUtil_isdigit(vstring[1])) { CFCBase_decref((CFCBase*)self); CFCUtil_die("Bad version string: '%s'", vstring); } @@ -59,7 +58,7 @@ CFCVersion_init(CFCVersion *self, const char *vstring) { self->num_numbers = 0; self->numbers = (uint32_t*)CALLOCATE(1, sizeof(uint32_t)); while (1) { - if (isdigit(*vstring)) { + if (CFCUtil_isdigit(*vstring)) { int digit = *vstring - '0'; num = num * 10 + (uint32_t)digit; }