summaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-20 22:48:49 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-20 22:48:49 +0000
commit836f85804eb490375f97b3bf81c8455cddd3010a (patch)
tree4126da7c1a4054faffe2a4defe43dbe312576c71 /string.c
parent022792c4956b7d84d578cada84a90aad47862541 (diff)
downloadruby-836f85804eb490375f97b3bf81c8455cddd3010a.tar.gz
ruby-836f85804eb490375f97b3bf81c8455cddd3010a.tar.xz
ruby-836f85804eb490375f97b3bf81c8455cddd3010a.zip
* string.c (rb_usascii_str_new): use rb_str_new.
* string.c (rb_enc_str_new): ditto. * string.c (rb_usascii_str_new2): use rb_str_new2. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/string.c b/string.c
index 2f20d3dc8..eb41c0db1 100644
--- a/string.c
+++ b/string.c
@@ -385,8 +385,7 @@ rb_str_new(const char *ptr, long len)
VALUE
rb_usascii_str_new(const char *ptr, long len)
{
- VALUE str = str_new(rb_cString, ptr, len);
-
+ VALUE str = rb_str_new(ptr, len);
ENCODING_CODERANGE_SET(str, rb_usascii_encindex(), ENC_CODERANGE_7BIT);
return str;
}
@@ -394,8 +393,7 @@ rb_usascii_str_new(const char *ptr, long len)
VALUE
rb_enc_str_new(const char *ptr, long len, rb_encoding *enc)
{
- VALUE str = str_new(rb_cString, ptr, len);
-
+ VALUE str = rb_str_new(ptr, len);
rb_enc_associate(str, enc);
return str;
}
@@ -412,10 +410,9 @@ rb_str_new2(const char *ptr)
VALUE
rb_usascii_str_new2(const char *ptr)
{
- if (!ptr) {
- rb_raise(rb_eArgError, "NULL pointer given");
- }
- return rb_usascii_str_new(ptr, strlen(ptr));
+ VALUE str = rb_str_new2(ptr);
+ ENCODING_CODERANGE_SET(str, rb_usascii_encindex(), ENC_CODERANGE_7BIT);
+ return str;
}
VALUE