diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-08-31 10:47:44 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-08-31 10:47:44 +0000 |
commit | 54af80844fbcf132f85e9275673eaa66b72da996 (patch) | |
tree | 4509d254ff81222c7b4db1b34cbcc377c2311e54 /time.c | |
parent | 25c50cd193d89ad0737219142bab191f12b8abe8 (diff) | |
download | ruby-54af80844fbcf132f85e9275673eaa66b72da996.tar.gz |
* 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@10810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r-- | time.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -326,14 +326,14 @@ time_arg(int argc, VALUE *argv, struct tm *tm, time_t *usec) if (!NIL_P(s)) { tm->tm_mon = -1; for (i=0; i<12; i++) { - if (RSTRING(s)->len == 3 && - strcasecmp(months[i], RSTRING(v[1])->ptr) == 0) { + if (RSTRING_LEN(s) == 3 && + strcasecmp(months[i], RSTRING_PTR(v[1])) == 0) { tm->tm_mon = i; break; } } if (tm->tm_mon == -1) { - char c = RSTRING(s)->ptr[0]; + char c = RSTRING_PTR(s)[0]; if ('0' <= c && c <= '9') { tm->tm_mon = obj2long(s)-1; @@ -1873,8 +1873,8 @@ time_strftime(VALUE time, VALUE format) } StringValue(format); format = rb_str_new4(format); - fmt = RSTRING(format)->ptr; - len = RSTRING(format)->len; + fmt = RSTRING_PTR(format); + len = RSTRING_LEN(format); if (len == 0) { rb_warning("strftime called with empty format string"); } @@ -1897,7 +1897,7 @@ time_strftime(VALUE time, VALUE format) return str; } else { - len = rb_strftime(&buf, RSTRING(format)->ptr, &tobj->tm); + len = rb_strftime(&buf, RSTRING_PTR(format), &tobj->tm); } str = rb_str_new(buf, len); if (buf != buffer) free(buf); @@ -1997,8 +1997,8 @@ time_mload(VALUE time, VALUE str) time_modify(time); StringValue(str); - buf = (unsigned char *)RSTRING(str)->ptr; - if (RSTRING(str)->len != 8) { + buf = (unsigned char *)RSTRING_PTR(str); + if (RSTRING_LEN(str) != 8) { rb_raise(rb_eTypeError, "marshaled time format differ"); } |