[前][次][番号順一覧][スレッド一覧]

ruby-changes:35473

From: nobu <ko1@a...>
Date: Fri, 12 Sep 2014 22:11:34 +0900 (JST)
Subject: [ruby-changes:35473] nobu:r47555 (trunk): readline.c: use rb_setup_fake_str

nobu	2014-09-12 22:11:13 +0900 (Fri, 12 Sep 2014)

  New Revision: 47555

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47555

  Log:
    readline.c: use rb_setup_fake_str
    
    * ext/readline/readline.c (readline_s_delete_text): initialize a
      fake string by rb_setup_fake_str().
    
    * internal.h (rb_setup_fake_str): allow extensions to call.

  Modified files:
    trunk/ext/readline/depend
    trunk/ext/readline/extconf.rb
    trunk/ext/readline/readline.c
    trunk/internal.h
Index: ext/readline/depend
===================================================================
--- ext/readline/depend	(revision 47554)
+++ ext/readline/depend	(revision 47555)
@@ -1,4 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ext/readline/depend#L1
 readline.o: readline.c $(HDRS) $(ruby_headers) \
+  $(top_srcdir)/internal.h \
   $(hdrdir)/ruby/io.h \
   $(hdrdir)/ruby/encoding.h \
   $(hdrdir)/ruby/oniguruma.h \
Index: ext/readline/readline.c
===================================================================
--- ext/readline/readline.c	(revision 47554)
+++ ext/readline/readline.c	(revision 47555)
@@ -36,6 +36,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/readline/readline.c#L36
 #include "ruby/ruby.h"
 #include "ruby/io.h"
 #include "ruby/thread.h"
+#include "internal.h"
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -688,12 +689,7 @@ readline_s_delete_text(int argc, VALUE * https://github.com/ruby/ruby/blob/trunk/ext/readline/readline.c#L689
         char *p, *ptr = rl_line_buffer;
         long beg = 0, len = strlen(rl_line_buffer);
         struct RString fakestr;
-        VALUE str = (VALUE)&fakestr;
-
-        fakestr.basic.flags = T_STRING | RSTRING_NOEMBED;
-        fakestr.as.heap.ptr = ptr;
-        fakestr.as.heap.len = len;
-        rb_enc_associate(str, rb_locale_encoding());
+        VALUE str = rb_setup_fake_str(&fakestr, ptr, len, rb_locale_encoding());
         OBJ_FREEZE(str);
         if (argc == 2) {
             beg = NUM2LONG(argv[0]);
Index: ext/readline/extconf.rb
===================================================================
--- ext/readline/extconf.rb	(revision 47554)
+++ ext/readline/extconf.rb	(revision 47555)
@@ -105,4 +105,5 @@ unless readline.have_type("rl_hook_func_ https://github.com/ruby/ruby/blob/trunk/ext/readline/extconf.rb#L105
   $defs << "-Drl_hook_func_t=Function"
 end
 
+$INCFLAGS << " -I$(top_srcdir)"
 create_makefile("readline")
Index: internal.h
===================================================================
--- internal.h	(revision 47554)
+++ internal.h	(revision 47555)
@@ -906,9 +906,6 @@ size_t rb_strftime(char *s, size_t maxsi https://github.com/ruby/ruby/blob/trunk/internal.h#L906
 void Init_frozen_strings(void);
 VALUE rb_fstring(VALUE);
 VALUE rb_fstring_new(const char *ptr, long len);
-#ifdef RUBY_ENCODING_H
-VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb_encoding *enc);
-#endif
 int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p);
 int rb_str_symname_p(VALUE);
 VALUE rb_str_quote_unprintable(VALUE);
@@ -1062,6 +1059,12 @@ VALUE rb_gcd_normal(VALUE self, VALUE ot https://github.com/ruby/ruby/blob/trunk/internal.h#L1059
 VALUE rb_gcd_gmp(VALUE x, VALUE y);
 #endif
 
+/* string.c */
+#ifdef RUBY_ENCODING_H
+/* internal use */
+VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb_encoding *enc);
+#endif
+
 /* util.c */
 extern const signed char ruby_digit36_to_number_table[];
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]