rb_strlen_lit: support wide string literals

This commit is contained in:
Nobuyoshi Nakada 2024-11-10 22:52:17 +09:00
parent 2f88a9258d
commit bce1bd1dc1
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
Notes: git 2024-11-10 14:27:40 +00:00
2 changed files with 2 additions and 2 deletions

View File

@ -1689,7 +1689,7 @@ rbimpl_exc_new_cstr(VALUE exc, const char *str)
* @return An integer constant expression that represents `str`'s length,
* in bytes, not including the terminating NUL character.
*/
#define rb_strlen_lit(str) (sizeof(str "") - 1)
#define rb_strlen_lit(str) ((sizeof(str "") / sizeof(str ""[0])) - 1)
/**
* Identical to rb_str_new_static(), except it cannot take string variables.

View File

@ -23,7 +23,7 @@
# define FALSE 0
#endif
#define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
#define rb_strlen_lit(str) (sizeof(str "") - 1)
#define rb_strlen_lit(str) ((sizeof(str "") / sizeof(str ""[0])) - 1)
#undef FIXNUM_MAX
#define FIXNUM_MAX (LONG_MAX / 2)