ruby-changes:38926
From: nobu <ko1@a...>
Date: Wed, 24 Jun 2015 12:47:30 +0900 (JST)
Subject: [ruby-changes:38926] nobu:r51007 (trunk): intern.h: rb_strlen_lit
nobu 2015-06-24 12:47:10 +0900 (Wed, 24 Jun 2015) New Revision: 51007 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51007 Log: intern.h: rb_strlen_lit * include/ruby/intern.h (rb_strlen_lit): new macro to get the length of a string literal, borrowed from mruby/mruby@e4afd53. Modified files: trunk/ChangeLog trunk/include/ruby/intern.h Index: include/ruby/intern.h =================================================================== --- include/ruby/intern.h (revision 51006) +++ include/ruby/intern.h (revision 51007) @@ -877,10 +877,15 @@ VALUE rb_sym_all_symbols(void); https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L877 #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, ...); Index: ChangeLog =================================================================== --- ChangeLog (revision 51006) +++ ChangeLog (revision 51007) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Jun 24 12:47:05 2015 Nobuyoshi Nakada <nobu@r...> + + * 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 <hsbt@r...> * re.c: Update documentation for Regexp class. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/