diff --git a/ChangeLog b/ChangeLog index ae27ddd3d2..276ea0187b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Jun 24 12:47:05 2015 Nobuyoshi Nakada + + * include/ruby/intern.h (rb_strlen_lit): new macro to get the + length of a string literal, borrowed from mruby/mruby@e4afd53. + Wed Jun 24 12:21:16 2015 SHIBATA Hiroshi * re.c: Update documentation for Regexp class. diff --git a/include/ruby/intern.h b/include/ruby/intern.h index 9e26c8b4f3..56865f3109 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -877,10 +877,15 @@ VALUE rb_sym_all_symbols(void); #define rb_str_buf_cat rb_str_cat #define rb_str_buf_cat2 rb_str_cat_cstr #define rb_str_cat2 rb_str_cat_cstr -#define rb_str_new_literal(str) rb_str_new_static((str), sizeof(str)-1) -#define rb_usascii_str_new_literal(str) rb_usascii_str_new_static((str), sizeof(str)-1) -#define rb_utf8_str_new_literal(str) rb_utf8_str_new_static((str), sizeof(str)-1) -#define rb_enc_str_new_literal(str, enc) rb_enc_str_new_static((str), sizeof(str)-1, (enc)) +#define rb_strlen_lit(str) (sizeof(str "") - 1) +#define rb_str_new_lit(str) rb_str_new_static((str), rb_strlen_lit(str)) +#define rb_usascii_str_new_lit(str) rb_usascii_str_new_static((str), rb_strlen_lit(str)) +#define rb_utf8_str_new_lit(str) rb_utf8_str_new_static((str), rb_strlen_lit(str)) +#define rb_enc_str_new_lit(str, enc) rb_enc_str_new_static((str), rb_strlen_lit(str), (enc)) +#define rb_str_new_literal(str) rb_str_new_lit(str) +#define rb_usascii_str_new_literal(str) rb_usascii_str_new_lit(str) +#define rb_utf8_str_new_literal(str) rb_utf8_str_new_lit(str) +#define rb_enc_str_new_literal(str, enc) rb_enc_str_new_lit(str, enc) /* struct.c */ VALUE rb_struct_new(VALUE, ...);