summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-31 10:47:44 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-31 10:47:44 +0000
commit54af80844fbcf132f85e9275673eaa66b72da996 (patch)
tree4509d254ff81222c7b4db1b34cbcc377c2311e54 /ruby.c
parent25c50cd193d89ad0737219142bab191f12b8abe8 (diff)
downloadbundler-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 'ruby.c')
-rw-r--r--ruby.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/ruby.c b/ruby.c
index 1fa10e1f00..4ce58abaab 100644
--- a/ruby.c
+++ b/ruby.c
@@ -217,7 +217,7 @@ ruby_incpush(const char *path)
static VALUE
expand_include_path(VALUE path)
{
- char *p = RSTRING(path)->ptr;
+ char *p = RSTRING_PTR(path);
if (!p) return path;
if (*p == '.' && p[1] == '/') return path;
return rb_file_expand_path(path, Qnil);
@@ -883,10 +883,10 @@ load_file(const char *fname, int script)
xflag = Qfalse;
while (!NIL_P(line = rb_io_gets(f))) {
line_start++;
- if (RSTRING(line)->len > 2
- && RSTRING(line)->ptr[0] == '#'
- && RSTRING(line)->ptr[1] == '!') {
- if ((p = strstr(RSTRING(line)->ptr, "ruby")) != 0) {
+ if (RSTRING_LEN(line) > 2
+ && RSTRING_PTR(line)[0] == '#'
+ && RSTRING_PTR(line)[1] == '!') {
+ if ((p = strstr(RSTRING_PTR(line), "ruby")) != 0) {
goto start_read;
}
}
@@ -901,13 +901,13 @@ load_file(const char *fname, int script)
line = rb_io_gets(f);
if (NIL_P(line)) return;
- if ((p = strstr(RSTRING(line)->ptr, "ruby")) == 0) {
+ if ((p = strstr(RSTRING_PTR(line), "ruby")) == 0) {
/* not ruby script, kick the program */
char **argv;
char *path;
- char *pend = RSTRING(line)->ptr + RSTRING(line)->len;
+ char *pend = RSTRING_PTR(line) + RSTRING_LEN(line);
- p = RSTRING(line)->ptr; /* skip `#!' */
+ p = RSTRING_PTR(line); /* skip `#!' */
if (pend[-1] == '\n') pend--; /* chomp line */
if (pend[-1] == '\r') pend--;
*pend = '\0';
@@ -935,9 +935,9 @@ load_file(const char *fname, int script)
start_read:
p += 4;
- RSTRING(line)->ptr[RSTRING(line)->len-1] = '\0';
- if (RSTRING(line)->ptr[RSTRING(line)->len-2] == '\r')
- RSTRING(line)->ptr[RSTRING(line)->len-2] = '\0';
+ RSTRING_PTR(line)[RSTRING_LEN(line)-1] = '\0';
+ if (RSTRING_PTR(line)[RSTRING_LEN(line)-2] == '\r')
+ RSTRING_PTR(line)[RSTRING_LEN(line)-2] = '\0';
if ((p = strstr(p, " -")) != 0) {
p++; /* skip space before `-' */
while (*p == '-') {
@@ -1032,14 +1032,14 @@ set_arg0(VALUE val, ID id)
if (origargv == 0) rb_raise(rb_eRuntimeError, "$0 not initialized");
StringValue(val);
- s = RSTRING(val)->ptr;
- i = RSTRING(val)->len;
+ s = RSTRING_PTR(val);
+ i = RSTRING_LEN(val);
#if defined(PSTAT_SETCMD)
if (i >= PST_CLEN) {
union pstun j;
j.pst_command = s;
i = PST_CLEN;
- RSTRING(val)->len = i;
+ RSTRING_LEN(val) = i;
*(s + i) = '\0';
pstat(PSTAT_SETCMD, j, PST_CLEN, 0, 0);
}