summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-31 11:24:44 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-31 11:24:44 +0000
commitc1c7a3ca0f8483754f5b234739b027dd0a0e1b33 (patch)
treeedc5c2dd23e5782b76695b8e22b5f67a4fbdbadf /util.c
parent77c9830d3048f56c5ac3addfbed82d4d58a75303 (diff)
downloadruby-c1c7a3ca0f8483754f5b234739b027dd0a0e1b33.tar.gz
ruby-c1c7a3ca0f8483754f5b234739b027dd0a0e1b33.tar.xz
ruby-c1c7a3ca0f8483754f5b234739b027dd0a0e1b33.zip
* 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
Diffstat (limited to 'util.c')
-rw-r--r--util.c14
1 files changed, 7 insertions, 7 deletions
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)