summaryrefslogtreecommitdiffstats
path: root/ext/nkf
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-31 10:30:33 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-31 10:30:33 +0000
commita1fd7d2ae86fd7627d74f216c187954a9ac3824a (patch)
treea14ada29405880c7f56c615067b6600815f54334 /ext/nkf
parent4ae021c31c797c0951d8c3bb2263890c4f073369 (diff)
downloadruby-a1fd7d2ae86fd7627d74f216c187954a9ac3824a.tar.gz
ruby-a1fd7d2ae86fd7627d74f216c187954a9ac3824a.tar.xz
ruby-a1fd7d2ae86fd7627d74f216c187954a9ac3824a.zip
* ruby.h (struct RString): embed small strings.
(RSTRING_LEN): defined for accessing string members. (RSTRING_PTR): ditto. * string.c: use RSTRING_LEN and RSTRING_PTR. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@10809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/nkf')
-rw-r--r--ext/nkf/nkf.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c
index 723fa55b0..8a4bcfce6 100644
--- a/ext/nkf/nkf.c
+++ b/ext/nkf/nkf.c
@@ -62,7 +62,7 @@ rb_nkf_putchar(unsigned int c)
o_len += incsize;
rb_str_resize(result, o_len);
incsize *= 2;
- output = RSTRING(result)->ptr;
+ output = RSTRING_PTR(result);
}
output[output_ctr++] = c;
@@ -147,30 +147,29 @@ rb_nkf_kconv(VALUE obj, VALUE opt, VALUE src)
reinit();
StringValue(opt);
- opt_ptr = RSTRING(opt)->ptr;
- opt_end = opt_ptr + RSTRING(opt)->len;
+ opt_ptr = RSTRING_PTR(opt);
+ opt_end = opt_ptr + RSTRING_LEN(opt);
nkf_split_options(opt_ptr);
incsize = INCSIZE;
input_ctr = 0;
StringValue(src);
- input = RSTRING(src)->ptr;
- i_len = RSTRING(src)->len;
+ input = RSTRING_PTR(src);
+ i_len = RSTRING_LEN(src);
result = rb_str_new(0, i_len*3 + 10);
v = result;
output_ctr = 0;
- output = RSTRING(result)->ptr;
- o_len = RSTRING(result)->len;
+ output = RSTRING_PTR(result);
+ o_len = RSTRING_LEN(result);
*output = '\0';
if(x0201_f == WISH_TRUE)
x0201_f = ((!iso2022jp_f)? TRUE : NO_X0201);
kanji_convert(NULL);
- RSTRING(result)->ptr[output_ctr] = '\0';
- RSTRING(result)->len = output_ctr;
+ rb_str_set_len(result, output_ctr);
OBJ_INFECT(result, src);
return result;
@@ -209,8 +208,8 @@ rb_nkf_guess1(VALUE obj, VALUE src)
int sequence_counter = 0;
StringValue(src);
- p = RSTRING(src)->ptr;
- pend = p + RSTRING(src)->len;
+ p = RSTRING_PTR(src);
+ pend = p + RSTRING_LEN(src);
if (p == pend) return INT2FIX(_UNKNOWN);
#define INCR do {\
@@ -323,8 +322,8 @@ rb_nkf_guess2(VALUE obj, VALUE src)
input_ctr = 0;
StringValue(src);
- input = RSTRING(src)->ptr;
- i_len = RSTRING(src)->len;
+ input = RSTRING_PTR(src);
+ i_len = RSTRING_LEN(src);
if(x0201_f == WISH_TRUE)
x0201_f = ((!iso2022jp_f)? TRUE : NO_X0201);