summaryrefslogtreecommitdiff
path: root/ext/nkf/nkf.c
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
commit25c50cd193d89ad0737219142bab191f12b8abe8 (patch)
treea14ada29405880c7f56c615067b6600815f54334 /ext/nkf/nkf.c
parent22f249ebd7a142faacdf5edd7e196bd2149feae5 (diff)
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@10809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/nkf/nkf.c')
-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 723fa55b03..8a4bcfce64 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);