From c1c7a3ca0f8483754f5b234739b027dd0a0e1b33 Mon Sep 17 00:00:00 2001 From: usa Date: Thu, 31 Aug 2006 11:24:44 +0000 Subject: * file.c (test_identical, rb_file_s_truncate): use RSTRING_PTR and RSTRING_STR. * io.c (pipe_open, rb_io_reopen): ditto. * process.c (proc_spawn_n, rb_spawn): ditto. * util.c (ruby_add_suffix): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@10811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- util.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'util.c') diff --git a/util.c b/util.c index 3f85c5b13..6c16aaed4 100644 --- a/util.c +++ b/util.c @@ -156,26 +156,26 @@ ruby_add_suffix(VALUE str, const char *suffix) long slen; char buf[1024]; - if (RSTRING(str)->len > 1000) + if (RSTRING_LEN(str) > 1000) rb_fatal("Cannot do inplace edit on long filename (%ld characters)", - RSTRING(str)->len); + RSTRING_LEN(str)); #if defined(DJGPP) || defined(__CYGWIN32__) || defined(_WIN32) /* Style 0 */ - slen = RSTRING(str)->len; + slen = RSTRING_LEN(str); rb_str_cat(str, suffix, extlen); #if defined(DJGPP) if (_USE_LFN) return; #else - if (valid_filename(RSTRING(str)->ptr)) return; + if (valid_filename(RSTRING_PTR(str))) return; #endif /* Fooey, style 0 failed. Fix str before continuing. */ - RSTRING(str)->ptr[RSTRING(str)->len = slen] = '\0'; + rb_str_resize(str, slen); #endif slen = extlen; - t = buf; baselen = 0; s = RSTRING(str)->ptr; + t = buf; baselen = 0; s = RSTRING_PTR(str); while ((*t = *s) && *s != '.') { baselen++; if (*s == '\\' || *s == '/') baselen = 0; @@ -213,7 +213,7 @@ fallback: (void)memcpy(p, strEQ(ext, suffix1) ? suffix2 : suffix1, 5); } rb_str_resize(str, strlen(buf)); - memcpy(RSTRING(str)->ptr, buf, RSTRING(str)->len); + memcpy(RSTRING_PTR(str), buf, RSTRING_LEN(str)); } #if defined(__CYGWIN32__) || defined(_WIN32) -- cgit