diff options
Diffstat (limited to 'include/ruby/internal/encoding/ctype.h')
-rw-r--r-- | include/ruby/internal/encoding/ctype.h | 83 |
1 files changed, 72 insertions, 11 deletions
diff --git a/include/ruby/internal/encoding/ctype.h b/include/ruby/internal/encoding/ctype.h index e0b95f93b2..422e2b9c2d 100644 --- a/include/ruby/internal/encoding/ctype.h +++ b/include/ruby/internal/encoding/ctype.h @@ -39,7 +39,14 @@ RBIMPL_SYMBOL_EXPORT_BEGIN() * @retval 0 It isn't. * @retval otherwise It is. */ -#define rb_enc_is_newline(p,end,enc) ONIGENC_IS_MBC_NEWLINE((enc),(UChar*)(p),(UChar*)(end)) +static inline bool +rb_enc_is_newline(const char *p, const char *e, const rb_encoding *enc) +{ + OnigUChar *up = RBIMPL_CAST((OnigUChar *)p); + OnigUChar *ue = RBIMPL_CAST((OnigUChar *)e); + + return ONIGENC_IS_MBC_NEWLINE(enc, up, ue); +} /** * Queries if the passed code point is of passed character type in the passed @@ -52,7 +59,11 @@ RBIMPL_SYMBOL_EXPORT_BEGIN() * @retval 1 `c` is of `t` in `enc`. * @retval 0 Otherwise. */ -#define rb_enc_isctype(c,t,enc) ONIGENC_IS_CODE_CTYPE((enc),(c),(t)) +static inline bool +rb_enc_isctype(OnigCodePoint c, OnigCtype t, const rb_encoding *enc) +{ + return ONIGENC_IS_CODE_CTYPE(enc, c, t); +} /** * Identical to rb_isascii(), except it additionally takes an encoding. @@ -67,7 +78,11 @@ RBIMPL_SYMBOL_EXPORT_BEGIN() * `enc` is ignored. This is at least an intentional implementation detail * (not a bug). But there could be rooms for future extensions. */ -#define rb_enc_isascii(c,enc) ONIGENC_IS_CODE_ASCII(c) +static inline bool +rb_enc_isascii(OnigCodePoint c, const rb_encoding *enc) +{ + return ONIGENC_IS_CODE_ASCII(c); +} /** * Identical to rb_isalpha(), except it additionally takes an encoding. @@ -77,7 +92,11 @@ RBIMPL_SYMBOL_EXPORT_BEGIN() * @retval 1 `enc` classifies `c` as "ALPHA". * @retval 0 Otherwise. */ -#define rb_enc_isalpha(c,enc) ONIGENC_IS_CODE_ALPHA((enc),(c)) +static inline bool +rb_enc_isalpha(OnigCodePoint c, const rb_encoding *enc) +{ + return ONIGENC_IS_CODE_ALPHA(enc, c); +} /** * Identical to rb_islower(), except it additionally takes an encoding. @@ -87,7 +106,11 @@ RBIMPL_SYMBOL_EXPORT_BEGIN() * @retval 1 `enc` classifies `c` as "LOWER". * @retval 0 Otherwise. */ -#define rb_enc_islower(c,enc) ONIGENC_IS_CODE_LOWER((enc),(c)) +static inline bool +rb_enc_islower(OnigCodePoint c, const rb_encoding *enc) +{ + return ONIGENC_IS_CODE_LOWER(enc, c); +} /** * Identical to rb_isupper(), except it additionally takes an encoding. @@ -97,7 +120,11 @@ RBIMPL_SYMBOL_EXPORT_BEGIN() * @retval 1 `enc` classifies `c` as "UPPER". * @retval 0 Otherwise. */ -#define rb_enc_isupper(c,enc) ONIGENC_IS_CODE_UPPER((enc),(c)) +static inline bool +rb_enc_isupper(OnigCodePoint c, const rb_encoding *enc) +{ + return ONIGENC_IS_CODE_UPPER(enc, c); +} /** * Identical to rb_ispunct(), except it additionally takes an encoding. @@ -107,7 +134,11 @@ RBIMPL_SYMBOL_EXPORT_BEGIN() * @retval 1 `enc` classifies `c` as "PUNCT". * @retval 0 Otherwise. */ -#define rb_enc_ispunct(c,enc) ONIGENC_IS_CODE_PUNCT((enc),(c)) +static inline bool +rb_enc_ispunct(OnigCodePoint c, const rb_encoding *enc) +{ + return ONIGENC_IS_CODE_PUNCT(enc, c); +} /** * Identical to rb_isalnum(), except it additionally takes an encoding. @@ -117,7 +148,11 @@ RBIMPL_SYMBOL_EXPORT_BEGIN() * @retval 1 `enc` classifies `c` as "ANUM". * @retval 0 Otherwise. */ -#define rb_enc_isalnum(c,enc) ONIGENC_IS_CODE_ALNUM((enc),(c)) +static inline bool +rb_enc_isalnum(OnigCodePoint c, const rb_encoding *enc) +{ + return ONIGENC_IS_CODE_ALNUM(enc, c); +} /** * Identical to rb_isprint(), except it additionally takes an encoding. @@ -127,7 +162,11 @@ RBIMPL_SYMBOL_EXPORT_BEGIN() * @retval 1 `enc` classifies `c` as "PRINT". * @retval 0 Otherwise. */ -#define rb_enc_isprint(c,enc) ONIGENC_IS_CODE_PRINT((enc),(c)) +static inline bool +rb_enc_isprint(OnigCodePoint c, const rb_encoding *enc) +{ + return ONIGENC_IS_CODE_PRINT(enc, c); +} /** * Identical to rb_isspace(), except it additionally takes an encoding. @@ -137,7 +176,11 @@ RBIMPL_SYMBOL_EXPORT_BEGIN() * @retval 1 `enc` classifies `c` as "PRINT". * @retval 0 Otherwise. */ -#define rb_enc_isspace(c,enc) ONIGENC_IS_CODE_SPACE((enc),(c)) +static inline bool +rb_enc_isspace(OnigCodePoint c, const rb_encoding *enc) +{ + return ONIGENC_IS_CODE_SPACE(enc, c); +} /** * Identical to rb_isdigit(), except it additionally takes an encoding. @@ -147,7 +190,11 @@ RBIMPL_SYMBOL_EXPORT_BEGIN() * @retval 1 `enc` classifies `c` as "DIGIT". * @retval 0 Otherwise. */ -#define rb_enc_isdigit(c,enc) ONIGENC_IS_CODE_DIGIT((enc),(c)) +static inline bool +rb_enc_isdigit(OnigCodePoint c, const rb_encoding *enc) +{ + return ONIGENC_IS_CODE_DIGIT(enc, c); +} RBIMPL_ATTR_CONST() /** @@ -179,4 +226,18 @@ int rb_enc_tolower(int c, rb_encoding *enc); RBIMPL_SYMBOL_EXPORT_END() +/** @cond INTERNAL_MACRO */ +#define rb_enc_is_newline rb_enc_is_newline +#define rb_enc_isalnum rb_enc_isalnum +#define rb_enc_isalpha rb_enc_isalpha +#define rb_enc_isascii rb_enc_isascii +#define rb_enc_isctype rb_enc_isctype +#define rb_enc_isdigit rb_enc_isdigit +#define rb_enc_islower rb_enc_islower +#define rb_enc_isprint rb_enc_isprint +#define rb_enc_ispunct rb_enc_ispunct +#define rb_enc_isspace rb_enc_isspace +#define rb_enc_isupper rb_enc_isupper +/** @endcond */ + #endif /* RUBY_INTERNAL_ENCODING_CTYPE_H */ |