summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-22 05:55:22 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-22 05:55:22 +0000
commit4a3f2a7bc5de8e0b3c1cb18a689d21a66e289f70 (patch)
tree33189b96b21739d89c86c21209f21672200331f7 /ext
parent1d38a821eaad46cd649a911b38a7d3540d6df8a9 (diff)
* string.c (rb_external_str_new_with_enc): no implicit strlen call.
[ruby-dev:36854] * string.c (rb_external_str_new_cstr): new function to create string from external NUL terminated C string. * string.c (rb_locale_str_new_cstr): ditto. * ext/readline/readline.c: now use rb_locale_str_new_cstr(). * test/sdbm/test_sdbm.rb (TestSDBM#test_delete_with_block): deleted key to the block may be a copy of specified key. * test/dbm/test_dbm.rb (TestDBM#test_delete_with_block): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/readline/readline.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 6cc720f504..5e30aa3046 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -246,7 +246,7 @@ readline_readline(int argc, VALUE *argv, VALUE self)
add_history(buff);
}
if (buff) {
- result = rb_locale_str_new(buff, strlen(buff));
+ result = rb_locale_str_new_cstr(buff);
}
else
result = Qnil;
@@ -385,7 +385,7 @@ readline_attempted_completion_function(const char *text, int start, int end)
rl_attempted_completion_over = 1;
#endif
case_fold = RTEST(rb_attr_get(mReadline, completion_case_fold));
- ary = rb_funcall(proc, rb_intern("call"), 1, rb_locale_str_new(text, strlen(text)));
+ ary = rb_funcall(proc, rb_intern("call"), 1, rb_locale_str_new_cstr(text));
if (TYPE(ary) != T_ARRAY)
ary = rb_Array(ary);
matches = RARRAY_LEN(ary);
@@ -608,7 +608,7 @@ readline_s_get_completion_append_character(VALUE self)
if (rl_completion_append_character == '\0')
return Qnil;
- str = rb_str_new("", 1);
+ str = rb_str_new(0, 1);
RSTRING_PTR(str)[0] = rl_completion_append_character;
return str;
#else
@@ -673,7 +673,7 @@ readline_s_get_basic_word_break_characters(VALUE self, VALUE str)
rb_secure(4);
if (rl_basic_word_break_characters == NULL)
return Qnil;
- return rb_locale_str_new(rl_basic_word_break_characters, 0);
+ return rb_locale_str_new_cstr(rl_basic_word_break_characters);
#else
rb_notimplement();
return Qnil; /* not reached */
@@ -736,7 +736,7 @@ readline_s_get_completer_word_break_characters(VALUE self, VALUE str)
rb_secure(4);
if (rl_completer_word_break_characters == NULL)
return Qnil;
- return rb_locale_str_new(rl_completer_word_break_characters, 0);
+ return rb_locale_str_new_cstr(rl_completer_word_break_characters);
#else
rb_notimplement();
return Qnil; /* not reached */
@@ -797,7 +797,7 @@ readline_s_get_basic_quote_characters(VALUE self, VALUE str)
rb_secure(4);
if (rl_basic_quote_characters == NULL)
return Qnil;
- return rb_locale_str_new(rl_basic_quote_characters, 0);
+ return rb_locale_str_new_cstr(rl_basic_quote_characters);
#else
rb_notimplement();
return Qnil; /* not reached */
@@ -861,7 +861,7 @@ readline_s_get_completer_quote_characters(VALUE self, VALUE str)
rb_secure(4);
if (rl_completer_quote_characters == NULL)
return Qnil;
- return rb_locale_str_new(rl_completer_quote_characters, 0);
+ return rb_locale_str_new_cstr(rl_completer_quote_characters);
#else
rb_notimplement();
return Qnil; /* not reached */
@@ -923,7 +923,7 @@ readline_s_get_filename_quote_characters(VALUE self, VALUE str)
rb_secure(4);
if (rl_filename_quote_characters == NULL)
return Qnil;
- return rb_locale_str_new(rl_filename_quote_characters, 0);
+ return rb_locale_str_new_cstr(rl_filename_quote_characters);
#else
rb_notimplement();
return Qnil; /* not reached */
@@ -933,7 +933,7 @@ readline_s_get_filename_quote_characters(VALUE self, VALUE str)
static VALUE
hist_to_s(VALUE self)
{
- return rb_str_new2("HISTORY");
+ return rb_str_new_cstr("HISTORY");
}
static int
@@ -965,7 +965,7 @@ hist_get(VALUE self, VALUE index)
if (entry == NULL) {
rb_raise(rb_eIndexError, "invalid index");
}
- return rb_locale_str_new(entry->line, 0);
+ return rb_locale_str_new_cstr(entry->line);
}
static VALUE
@@ -1027,7 +1027,7 @@ rb_remove_history(int index)
rb_secure(4);
entry = remove_history(index);
if (entry) {
- val = rb_locale_str_new(entry->line, 0);
+ val = rb_locale_str_new_cstr(entry->line);
free((void *) entry->line);
free(entry);
return val;
@@ -1074,7 +1074,7 @@ hist_each(VALUE self)
entry = history_get(history_get_offset_func(i));
if (entry == NULL)
break;
- rb_yield(rb_locale_str_new(entry->line, 0));
+ rb_yield(rb_locale_str_new_cstr(entry->line));
}
return self;
}
@@ -1133,7 +1133,7 @@ filename_completion_proc_call(VALUE self, VALUE str)
if (matches) {
result = rb_ary_new();
for (i = 0; matches[i]; i++) {
- rb_ary_push(result, rb_locale_str_new(matches[i], 0));
+ rb_ary_push(result, rb_locale_str_new_cstr(matches[i]));
free(matches[i]);
}
free(matches);
@@ -1158,7 +1158,7 @@ username_completion_proc_call(VALUE self, VALUE str)
if (matches) {
result = rb_ary_new();
for (i = 0; matches[i]; i++) {
- rb_ary_push(result, rb_locale_str_new(matches[i], 0));
+ rb_ary_push(result, rb_locale_str_new_cstr(matches[i]));
free(matches[i]);
}
free(matches);
@@ -1275,7 +1275,7 @@ Init_readline()
rb_define_const(mReadline, "USERNAME_COMPLETION_PROC", ucomp);
history_get_offset_func = history_get_offset_history_base;
#if defined HAVE_RL_LIBRARY_VERSION
- version = rb_str_new2(rl_library_version);
+ version = rb_str_new_cstr(rl_library_version);
#if defined HAVE_CLEAR_HISTORY || defined HAVE_REMOVE_HISTORY
if (strncmp(rl_library_version, EDIT_LINE_LIBRARY_VERSION,
strlen(EDIT_LINE_LIBRARY_VERSION)) == 0) {
@@ -1295,7 +1295,7 @@ Init_readline()
}
#endif
#else
- version = rb_str_new2("2.0 or prior version");
+ version = rb_str_new_cstr("2.0 or prior version");
#endif
/* Version string of GNU Readline or libedit. */
rb_define_const(mReadline, "VERSION", version);