summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-12 13:11:13 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-12 13:11:13 +0000
commit24b03b32e4295adc8fced6bb9ab8f881dd24b113 (patch)
treeae572e6f2930062e036f9b0ff31fbe7f42df503f /ext
parent858d1cadb244056cbf9dfc84825e792f535aa93e (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/readline/depend1
-rw-r--r--ext/readline/extconf.rb1
-rw-r--r--ext/readline/readline.c8
3 files changed, 4 insertions, 6 deletions
diff --git a/ext/readline/depend b/ext/readline/depend
index ef0414d9b23..5780d8d42a3 100644
--- a/ext/readline/depend
+++ b/ext/readline/depend
@@ -1,4 +1,5 @@
readline.o: readline.c $(HDRS) $(ruby_headers) \
+ $(top_srcdir)/internal.h \
$(hdrdir)/ruby/io.h \
$(hdrdir)/ruby/encoding.h \
$(hdrdir)/ruby/oniguruma.h \
diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb
index 3317e2fe837..c79370bf4cd 100644
--- a/ext/readline/extconf.rb
+++ b/ext/readline/extconf.rb
@@ -105,4 +105,5 @@ unless readline.have_type("rl_hook_func_t*")
$defs << "-Drl_hook_func_t=Function"
end
+$INCFLAGS << " -I$(top_srcdir)"
create_makefile("readline")
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index da3b10939c9..5ceaaf780b4 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -36,6 +36,7 @@
#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 *argv, VALUE self)
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]);