aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ruby/encoding.h16
-rw-r--r--include/ruby/ruby.h32
-rw-r--r--include/ruby/st.h2
3 files changed, 36 insertions, 14 deletions
diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h
index 89f3ec36b8..e10d893fb1 100644
--- a/include/ruby/encoding.h
+++ b/include/ruby/encoding.h
@@ -136,4 +136,20 @@ VALUE rb_enc_default_external(void);
void rb_enc_set_default_external(VALUE encoding);
VALUE rb_locale_charmap(VALUE klass);
+#define rb_isascii(c) ONIGENC_IS_CODE_ASCII(c)
+#define rb_isalnum(c) ONIGENC_IS_CODE_ALNUM(ONIG_ENCODING_ASCII, c)
+#define rb_isalpha(c) ONIGENC_IS_CODE_ALPHA(ONIG_ENCODING_ASCII, c)
+#define rb_isblank(c) ONIGENC_IS_CODE_BLANK(ONIG_ENCODING_ASCII, c)
+#define rb_iscntrl(c) ONIGENC_IS_CODE_CNTRL(ONIG_ENCODING_ASCII, c)
+#define rb_isdigit(c) ONIGENC_IS_CODE_DIGIT(ONIG_ENCODING_ASCII, c)
+#define rb_isgraph(c) ONIGENC_IS_CODE_GRAPH(ONIG_ENCODING_ASCII, c)
+#define rb_islower(c) ONIGENC_IS_CODE_LOWER(ONIG_ENCODING_ASCII, c)
+#define rb_isprint(c) ONIGENC_IS_CODE_PRINT(ONIG_ENCODING_ASCII, c)
+#define rb_ispunct(c) ONIGENC_IS_CODE_PUNCT(ONIG_ENCODING_ASCII, c)
+#define rb_isspace(c) ONIGENC_IS_CODE_SPACE(ONIG_ENCODING_ASCII, c)
+#define rb_isupper(c) ONIGENC_IS_CODE_UPPER(ONIG_ENCODING_ASCII, c)
+#define rb_isxdigit(c) ONIGENC_IS_CODE_XDIGIT(ONIG_ENCODING_ASCII, c)
+#define rb_tolower(c) rb_enc_tolower(c, ONIG_ENCODING_ASCII)
+#define rb_toupper(c) rb_enc_toupper(c, ONIG_ENCODING_ASCII)
+
#endif /* RUBY_ENCODING_H */
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 90402afeec..8ce623dfe3 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -63,20 +63,6 @@ extern "C" {
#include "defines.h"
-/* need to include <ctype.h> to use these macros */
-#ifndef ISPRINT
-#define ISASCII(c) isascii((int)(unsigned char)(c))
-#undef ISPRINT
-#define ISPRINT(c) (ISASCII(c) && isprint((int)(unsigned char)(c)))
-#define ISSPACE(c) (ISASCII(c) && isspace((int)(unsigned char)(c)))
-#define ISUPPER(c) (ISASCII(c) && isupper((int)(unsigned char)(c)))
-#define ISLOWER(c) (ISASCII(c) && islower((int)(unsigned char)(c)))
-#define ISALNUM(c) (ISASCII(c) && isalnum((int)(unsigned char)(c)))
-#define ISALPHA(c) (ISASCII(c) && isalpha((int)(unsigned char)(c)))
-#define ISDIGIT(c) (ISASCII(c) && isdigit((int)(unsigned char)(c)))
-#define ISXDIGIT(c) (ISASCII(c) && isxdigit((int)(unsigned char)(c)))
-#endif
-
#if defined(HAVE_ALLOCA_H)
#include <alloca.h>
#else
@@ -982,4 +968,22 @@ int rb_remove_event_hook(rb_event_hook_func_t func);
} /* extern "C" { */
#endif
+#include "encoding.h"
+#ifndef ISPRINT
+#define ISASCII(c) rb_isascii((int)(unsigned char)(c))
+#undef ISPRINT
+#define ISPRINT(c) (ISASCII(c) && rb_isprint((int)(unsigned char)(c)))
+#define ISSPACE(c) (ISASCII(c) && rb_isspace((int)(unsigned char)(c)))
+#define ISUPPER(c) (ISASCII(c) && rb_isupper((int)(unsigned char)(c)))
+#define ISLOWER(c) (ISASCII(c) && rb_islower((int)(unsigned char)(c)))
+#define ISALNUM(c) (ISASCII(c) && rb_isalnum((int)(unsigned char)(c)))
+#define ISALPHA(c) (ISASCII(c) && rb_isalpha((int)(unsigned char)(c)))
+#define ISDIGIT(c) (ISASCII(c) && rb_isdigit((int)(unsigned char)(c)))
+#define ISXDIGIT(c) (ISASCII(c) && rb_isxdigit((int)(unsigned char)(c)))
+#endif
+#define TOUPPER(c) (rb_toupper((int)(unsigned char)(c)))
+#define TOLOWER(c) (rb_tolower((int)(unsigned char)(c)))
+#define STRCASECMP(s1, s2) (st_strcasecmp(s1, s2))
+#define STRNCASECMP(s1, s2, n) (st_strncasecmp(s1, s2, n))
+
#endif /* RUBY_H */
diff --git a/include/ruby/st.h b/include/ruby/st.h
index 4adf48fde4..199d67e411 100644
--- a/include/ruby/st.h
+++ b/include/ruby/st.h
@@ -87,6 +87,8 @@ void st_clear(st_table *);
st_table *st_copy(st_table *);
int st_numcmp(st_data_t, st_data_t);
int st_numhash(st_data_t);
+int st_strcasecmp(const char *s1, const char *s2);
+int st_strncasecmp(const char *s1, const char *s2, size_t n);
#if defined(__cplusplus)
#if 0