Skip to content

Commit bce1bd1

Browse files
committed
rb_strlen_lit: support wide string literals
1 parent 2f88a92 commit bce1bd1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

include/ruby/internal/intern/string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,7 @@ rbimpl_exc_new_cstr(VALUE exc, const char *str)
16891689
* @return An integer constant expression that represents `str`'s length,
16901690
* in bytes, not including the terminating NUL character.
16911691
*/
1692-
#define rb_strlen_lit(str) (sizeof(str "") - 1)
1692+
#define rb_strlen_lit(str) ((sizeof(str "") / sizeof(str ""[0])) - 1)
16931693

16941694
/**
16951695
* Identical to rb_str_new_static(), except it cannot take string variables.

universal_parser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# define FALSE 0
2424
#endif
2525
#define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
26-
#define rb_strlen_lit(str) (sizeof(str "") - 1)
26+
#define rb_strlen_lit(str) ((sizeof(str "") / sizeof(str ""[0])) - 1)
2727
#undef FIXNUM_MAX
2828
#define FIXNUM_MAX (LONG_MAX / 2)
2929

0 commit comments

Comments
 (0)