|
Ruby 3.4.7p58 (2025-10-08 revision 7a5688e2a27668e48f8d6ff4af5b2208b98a2f5e)
|
Our own, locale independent, character handling routines. More...
#include "ruby/internal/config.h"#include "ruby/internal/attr/artificial.h"#include "ruby/internal/attr/const.h"#include "ruby/internal/attr/constexpr.h"#include "ruby/internal/attr/nonnull.h"#include "ruby/internal/dllexport.h"

Go to the source code of this file.
Macros | |
| #define | ISASCII rb_isascii |
Old character classification macros | |
What is this ISPRINT business? Well, according to our VCS and some internet surfing, it appears that the initial intent of these macros were to mimic codes appear in common in several GNU projects. As far as @shyouhei detects they seem to originate GNU regex (that standalone one rather than Gnulib or Glibc), and at least date back to 1995. Let me lawfully quote from a GNU coreutils commit https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=49803907f5dbd7646184a8912c9db9b09dcd0f22
So the intent was to reroute old problematic systems that no longer exist. At the same time the problems described above no longer hurt us, because we decided to completely avoid using system-provided isupper etc. to reinvent the wheel. These macros are entirely legacy; please ignore them. But let me also put stress that GNU people are wise; they use those macros only inside of their own implementations and never let them be public. On the other hand ruby has thoughtlessly publicised them to 3rd party libraries since its beginning, which is a very bad idea. These macros are too easy to get conflicted with definitions elsewhere. New programs should stick to the rb_ prefixed names.
*/ define ISASCII /**< @old{rb_isascii} | |
| #define | ISPRINT rb_isprint |
| @old{rb_isprint} | |
| #define | ISGRAPH rb_isgraph |
| @old{rb_isgraph} | |
| #define | ISSPACE rb_isspace |
| @old{rb_isspace} | |
| #define | ISUPPER rb_isupper |
| @old{rb_isupper} | |
| #define | ISLOWER rb_islower |
| @old{rb_islower} | |
| #define | ISALNUM rb_isalnum |
| @old{rb_isalnum} | |
| #define | ISALPHA rb_isalpha |
| @old{rb_isalpha} | |
| #define | ISDIGIT rb_isdigit |
| @old{rb_isdigit} | |
| #define | ISXDIGIT rb_isxdigit |
| @old{rb_isxdigit} | |
| #define | ISBLANK rb_isblank |
| @old{rb_isblank} | |
| #define | ISCNTRL rb_iscntrl |
| @old{rb_iscntrl} | |
| #define | ISPUNCT rb_ispunct |
| @old{rb_ispunct} | |
| #define | TOUPPER rb_toupper |
| @old{rb_toupper} | |
| #define | TOLOWER rb_tolower |
| @old{rb_tolower} | |
| #define | STRCASECMP st_locale_insensitive_strcasecmp |
| @old{st_locale_insensitive_strcasecmp} | |
| #define | STRNCASECMP st_locale_insensitive_strncasecmp |
| @old{st_locale_insensitive_strncasecmp} | |
| #define | STRTOUL ruby_strtoul |
| @old{ruby_strtoul} | |
Functions | |
locale insensitive functions | |
| int | st_locale_insensitive_strcasecmp (const char *s1, const char *s2) |
| Our own locale-insensitive version of strcasecmp(3). | |
| int | st_locale_insensitive_strncasecmp (const char *s1, const char *s2, size_t n) |
| Our own locale-insensitive version of strcnasecmp(3). | |
| unsigned long | ruby_strtoul (const char *str, char **endptr, int base) |
| Our own locale-insensitive version of strtoul(3). | |
| static int | rb_isascii (int c) |
| Our own locale-insensitive version of isascii(3). | |
| static int | rb_isupper (int c) |
| Our own locale-insensitive version of isupper(3). | |
| static int | rb_islower (int c) |
| Our own locale-insensitive version of islower(3). | |
| static int | rb_isalpha (int c) |
| Our own locale-insensitive version of isalpha(3). | |
| static int | rb_isdigit (int c) |
| Our own locale-insensitive version of isdigit(3). | |
| static int | rb_isalnum (int c) |
| Our own locale-insensitive version of isalnum(3). | |
| static int | rb_isxdigit (int c) |
| Our own locale-insensitive version of isxdigit(3). | |
| static int | rb_isblank (int c) |
| Our own locale-insensitive version of isblank(3). | |
| static int | rb_isspace (int c) |
| Our own locale-insensitive version of isspace(3). | |
| static int | rb_iscntrl (int c) |
| Our own locale-insensitive version of iscntrl(3). | |
| static int | rb_isprint (int c) |
| Identical to rb_isgraph(), except it also returns true for ' '. | |
| static int | rb_ispunct (int c) |
| Our own locale-insensitive version of ispunct(3). | |
| static int | rb_isgraph (int c) |
| Our own locale-insensitive version of isgraph(3). | |
| static int | rb_tolower (int c) |
| Our own locale-insensitive version of tolower(3). | |
| static int | rb_toupper (int c) |
| Our own locale-insensitive version of toupper(3). | |
Our own, locale independent, character handling routines.
Definition in file ctype.h.
| #define ISALNUM rb_isalnum |
| #define ISALPHA rb_isalpha |
| #define ISBLANK rb_isblank |
| #define ISCNTRL rb_iscntrl |
| #define ISDIGIT rb_isdigit |
| #define ISGRAPH rb_isgraph |
| #define ISLOWER rb_islower |
| #define ISPRINT rb_isprint |
@old{rb_isprint}
Definition at line 86 of file ctype.h.
Referenced by rb_str_dump(), and rb_str_inspect().
| #define ISPUNCT rb_ispunct |
| #define ISSPACE rb_isspace |
@old{rb_isspace}
Definition at line 88 of file ctype.h.
Referenced by rb_memory_view_parse_item_format(), ruby_each_words(), and ruby_strtoul().
| #define ISUPPER rb_isupper |
| #define ISXDIGIT rb_isxdigit |
| #define STRCASECMP st_locale_insensitive_strcasecmp |
| #define STRNCASECMP st_locale_insensitive_strncasecmp |
@old{st_locale_insensitive_strncasecmp}
Definition at line 103 of file ctype.h.
Referenced by ruby_init_loadpath().
| #define STRTOUL ruby_strtoul |
| #define TOLOWER rb_tolower |
| #define TOUPPER rb_toupper |
|
inlinestatic |
Our own locale-insensitive version of isalnum(3).
| [in] | c | Byte in question to query. |
| true | c is listed in either IEEE 1003.1 section 7.3.1.1 "upper", "lower", or "digit". |
| false | Anything else. |
Definition at line 326 of file ctype.h.
Referenced by rb_isalnum(), and rb_ispunct().
|
inlinestatic |
Our own locale-insensitive version of isalpha(3).
| [in] | c | Byte in question to query. |
| true | c is listed in either IEEE 1003.1 section 7.3.1.1 "upper" or "lower". |
| false | Anything else. |
Definition at line 279 of file ctype.h.
Referenced by rb_isalnum(), and rb_isalpha().
|
inlinestatic |
Our own locale-insensitive version of isascii(3).
| [in] | c | Byte in question to query. |
| false | c is out of range of ASCII character set. |
| true | Yes it is. |
Definition at line 209 of file ctype.h.
Referenced by rb_isascii().
|
inlinestatic |
Our own locale-insensitive version of isblank(3).
| [in] | c | Byte in question to query. |
| true | c is listed in IEEE 1003.1 section 7.3.1.1 "blank". |
| false | Anything else. |
Definition at line 372 of file ctype.h.
Referenced by rb_isblank().
|
inlinestatic |
Our own locale-insensitive version of iscntrl(3).
| [in] | c | Byte in question to query. |
| true | c is listed in IEEE 1003.1 section 7.3.1.1 "cntrl". |
| false | Anything else. |
Definition at line 418 of file ctype.h.
Referenced by rb_iscntrl().
|
inlinestatic |
Our own locale-insensitive version of isdigit(3).
| [in] | c | Byte in question to query. |
| true | c is listed in IEEE 1003.1 section 7.3.1.1 "digit". |
| false | Anything else. |
Definition at line 302 of file ctype.h.
Referenced by rb_isalnum(), rb_isdigit(), and rb_isxdigit().
|
inlinestatic |
Our own locale-insensitive version of isgraph(3).
| [in] | c | Byte in question to query. |
| true | c is listed in either IEEE 1003.1 section 7.3.1.1 "upper", "lower", "digit", or "punct". |
| false | Anything else. |
Definition at line 489 of file ctype.h.
Referenced by rb_isgraph().
|
inlinestatic |
Our own locale-insensitive version of islower(3).
| [in] | c | Byte in question to query. |
| true | c is listed in IEEE 1003.1 section 7.3.1.1 "lower". |
| false | Anything else. |
Definition at line 255 of file ctype.h.
Referenced by rb_isalpha(), rb_islower(), and rb_toupper().
|
inlinestatic |
Identical to rb_isgraph(), except it also returns true for ' '.
| [in] | c | Byte in question to query. |
| true | c is listed in either IEEE 1003.1 section 7.3.1.1 "upper", "lower", "digit", "punct", or a ' '. |
| false | Anything else. |
Definition at line 442 of file ctype.h.
Referenced by rb_isprint().
|
inlinestatic |
Our own locale-insensitive version of ispunct(3).
| [in] | c | Byte in question to query. |
| true | c is listed in IEEE 1003.1 section 7.3.1.1 "punct". |
| false | Anything else. |
Definition at line 465 of file ctype.h.
Referenced by rb_ispunct().
|
inlinestatic |
Our own locale-insensitive version of isspace(3).
| [in] | c | Byte in question to query. |
| true | c is listed in IEEE 1003.1 section 7.3.1.1 "space". |
| false | Anything else. |
Definition at line 395 of file ctype.h.
Referenced by rb_isspace().
|
inlinestatic |
Our own locale-insensitive version of isupper(3).
| [in] | c | Byte in question to query. |
| true | c is listed in IEEE 1003.1 section 7.3.1.1 "upper". |
| false | Anything else. |
Definition at line 232 of file ctype.h.
Referenced by rb_isalpha(), rb_isupper(), and rb_tolower().
|
inlinestatic |
Our own locale-insensitive version of isxdigit(3).
| [in] | c | Byte in question to query. |
| true | c is listed in IEEE 1003.1 section 7.3.1.1 "xdigit". |
| false | Anything else. |
Definition at line 349 of file ctype.h.
Referenced by rb_isxdigit().
|
inlinestatic |
Our own locale-insensitive version of tolower(3).
| [in] | c | Byte in question to convert. |
| c | The byte is not listed in in IEEE 1003.1 section 7.3.1.1 "upper". |
| otherwise | Byte converted using the map defined in IEEE 1003.1 section 7.3.1 "tolower". |
Definition at line 514 of file ctype.h.
Referenced by rb_tolower().
|
inlinestatic |
Our own locale-insensitive version of toupper(3).
| [in] | c | Byte in question to convert. |
| c | The byte is not listed in in IEEE 1003.1 section 7.3.1.1 "lower". |
| otherwise | Byte converted using the map defined in IEEE 1003.1 section 7.3.1 "toupper". |
Definition at line 539 of file ctype.h.
Referenced by rb_toupper().
| unsigned long ruby_strtoul | ( | const char * | str, |
| char ** | endptr, | ||
| int | base ) |
Our own locale-insensitive version of strtoul(3).
The conversion is done as if the current locale is set to the "C" locale, no matter actual runtime locale settings.
| [in] | str | String of digits, optionally preceded with whitespaces (ignored) and optionally + or - sign. |
| [out] | endptr | NULL, or an arbitrary pointer (overwritten on return). |
| [in] | base | 2 to 36 inclusive for each base, or special case 0 to detect the base from the contents of the string. |
Definition at line 138 of file util.c.
Referenced by ruby_strtoul().
| int st_locale_insensitive_strcasecmp | ( | const char * | s1, |
| const char * | s2 ) |
Our own locale-insensitive version of strcasecmp(3).
The "case" here always means that of the POSIX Locale. It doesn't depend on runtime locale settings.
| [in] | s1 | Comparison LHS. |
| [in] | s2 | Comparison RHS. |
| -1 | s1 is "less" than s2. |
| 0 | Both strings converted into lowercase would be identical. |
| 1 | s1 is "greater" than s2. |
| int st_locale_insensitive_strncasecmp | ( | const char * | s1, |
| const char * | s2, | ||
| size_t | n ) |
Our own locale-insensitive version of strcnasecmp(3).
The "case" here always means that of the POSIX Locale. It doesn't depend on runtime locale settings.
| [in] | s1 | Comparison LHS. |
| [in] | s2 | Comparison RHS. |
| [in] | n | Comparison shall stop after first n bytes are scanned. |
| -1 | s1 is "less" than s2. |
| 0 | Both strings converted into lowercase would be identical. |
| 1 | s1 is "greater" than s2. |