mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
858d1cadb2
commit
24b03b32e4
4 changed files with 10 additions and 9 deletions
|
@ -1,4 +1,5 @@
|
||||||
readline.o: readline.c $(HDRS) $(ruby_headers) \
|
readline.o: readline.c $(HDRS) $(ruby_headers) \
|
||||||
|
$(top_srcdir)/internal.h \
|
||||||
$(hdrdir)/ruby/io.h \
|
$(hdrdir)/ruby/io.h \
|
||||||
$(hdrdir)/ruby/encoding.h \
|
$(hdrdir)/ruby/encoding.h \
|
||||||
$(hdrdir)/ruby/oniguruma.h \
|
$(hdrdir)/ruby/oniguruma.h \
|
||||||
|
|
|
@ -105,4 +105,5 @@ unless readline.have_type("rl_hook_func_t*")
|
||||||
$defs << "-Drl_hook_func_t=Function"
|
$defs << "-Drl_hook_func_t=Function"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
$INCFLAGS << " -I$(top_srcdir)"
|
||||||
create_makefile("readline")
|
create_makefile("readline")
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "ruby/ruby.h"
|
#include "ruby/ruby.h"
|
||||||
#include "ruby/io.h"
|
#include "ruby/io.h"
|
||||||
#include "ruby/thread.h"
|
#include "ruby/thread.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <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;
|
char *p, *ptr = rl_line_buffer;
|
||||||
long beg = 0, len = strlen(rl_line_buffer);
|
long beg = 0, len = strlen(rl_line_buffer);
|
||||||
struct RString fakestr;
|
struct RString fakestr;
|
||||||
VALUE str = (VALUE)&fakestr;
|
VALUE str = rb_setup_fake_str(&fakestr, ptr, len, rb_locale_encoding());
|
||||||
|
|
||||||
fakestr.basic.flags = T_STRING | RSTRING_NOEMBED;
|
|
||||||
fakestr.as.heap.ptr = ptr;
|
|
||||||
fakestr.as.heap.len = len;
|
|
||||||
rb_enc_associate(str, rb_locale_encoding());
|
|
||||||
OBJ_FREEZE(str);
|
OBJ_FREEZE(str);
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
beg = NUM2LONG(argv[0]);
|
beg = NUM2LONG(argv[0]);
|
||||||
|
|
|
@ -906,9 +906,6 @@ size_t rb_strftime(char *s, size_t maxsize, const char *format, rb_encoding *enc
|
||||||
void Init_frozen_strings(void);
|
void Init_frozen_strings(void);
|
||||||
VALUE rb_fstring(VALUE);
|
VALUE rb_fstring(VALUE);
|
||||||
VALUE rb_fstring_new(const char *ptr, long len);
|
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_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p);
|
||||||
int rb_str_symname_p(VALUE);
|
int rb_str_symname_p(VALUE);
|
||||||
VALUE rb_str_quote_unprintable(VALUE);
|
VALUE rb_str_quote_unprintable(VALUE);
|
||||||
|
@ -1062,6 +1059,12 @@ VALUE rb_gcd_normal(VALUE self, VALUE other);
|
||||||
VALUE rb_gcd_gmp(VALUE x, VALUE y);
|
VALUE rb_gcd_gmp(VALUE x, VALUE y);
|
||||||
#endif
|
#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 */
|
/* util.c */
|
||||||
extern const signed char ruby_digit36_to_number_table[];
|
extern const signed char ruby_digit36_to_number_table[];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue