summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-18 23:48:49 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-18 23:48:49 +0000
commite54022001d84d1fa9fa07ecf9faddc7aba40a432 (patch)
tree05b7cb29e01dca8cc48c81eb6f9fcb783f2975a2 /string.c
parente1c72381c574a948ea6b1b959f3e89052350c25d (diff)
* indent and tabify
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c94
1 files changed, 47 insertions, 47 deletions
diff --git a/string.c b/string.c
index 75e828e..4849907 100644
--- a/string.c
+++ b/string.c
@@ -438,7 +438,7 @@ rb_str_format(str, arg)
MEMCPY(argv+1, RARRAY(arg)->ptr, VALUE, RARRAY(arg)->len);
return rb_f_sprintf(RARRAY(arg)->len+1, argv);
}
-
+
argv = ALLOCA_N(VALUE, 2);
argv[0] = str;
argv[1] = arg;
@@ -627,7 +627,7 @@ rb_str_resize(str, len)
if (len < 0) {
rb_raise(rb_eArgError, "negative string size (or size too big)");
}
-
+
if (len != RSTRING(str)->len) {
rb_str_modify(str);
if (RSTRING(str)->len < len || RSTRING(str)->len - len > 1024) {
@@ -1169,7 +1169,7 @@ rb_str_rindex_m(argc, argv, str)
if (rb_scan_args(argc, argv, "11", &sub, &position) == 2) {
pos = NUM2LONG(position);
- if (pos < 0) {
+ if (pos < 0) {
pos += RSTRING(str)->len;
if (pos < 0) {
if (TYPE(sub) == T_REGEXP) {
@@ -1177,7 +1177,7 @@ rb_str_rindex_m(argc, argv, str)
}
return Qnil;
}
- }
+ }
if (pos > RSTRING(str)->len) pos = RSTRING(str)->len;
}
else {
@@ -1355,8 +1355,8 @@ rb_str_succ(orig)
sbeg = RSTRING(str)->ptr; s = sbeg + RSTRING(str)->len - 1;
c = '\001';
while (sbeg <= s) {
- if ((*s += 1) != 0) break;
- s--;
+ if ((*s += 1) != 0) break;
+ s--;
}
}
if (s < sbeg) {
@@ -1455,7 +1455,7 @@ rb_str_subpat(str, re, nth)
}
return Qnil;
}
-
+
static VALUE
rb_str_aref(str, indx)
VALUE str;
@@ -2017,7 +2017,7 @@ str_gsub(argc, argv, str, bang)
}
pat = get_pat(argv[0], 1);
- offset=0; n=0;
+ offset=0; n=0;
beg = rb_reg_search(pat, str, 0, 0);
if (beg < 0) {
if (bang) return Qnil; /* no match, no substitution */
@@ -2054,7 +2054,7 @@ str_gsub(argc, argv, str, bang)
bp += len;
memcpy(bp, RSTRING(val)->ptr, RSTRING(val)->len);
bp += RSTRING(val)->len;
- offset = END(0);
+ offset = END(0);
if (BEG(0) == END(0)) {
/*
* Always consume at least one character of the input string
@@ -2586,7 +2586,7 @@ rb_str_dump(str)
case '"': case '\\':
case '\n': case '\r':
case '\t': case '\f': case '#':
- case '\013': case '\007': case '\033':
+ case '\013': case '\007': case '\033':
len += 2;
break;
@@ -3487,7 +3487,7 @@ rb_str_split_m(argc, argv, str)
if (!RSTRING(str)->ptr) {
rb_ary_push(result, rb_str_new("", 0));
break;
- }
+ }
else if (last_null == 1) {
rb_ary_push(result, rb_str_substr(str, beg, mbclen2(RSTRING(str)->ptr[beg],spat)));
beg = start;
@@ -3651,7 +3651,7 @@ rb_str_each_line(argc, argv, str)
}
if (s != pend) {
- if (p > pend) p = pend;
+ if (p > pend) p = pend;
line = rb_str_new5(str, s, p - s);
OBJ_INFECT(line, str);
rb_yield(line);
@@ -4208,7 +4208,7 @@ rb_str_scan(str, pat)
rb_backref_set(match);
return ary;
}
-
+
while (!NIL_P(result = scan_once(str, pat, &start))) {
match = rb_backref_get();
rb_match_busy(match);
@@ -4436,45 +4436,45 @@ rb_str_justify(argc, argv, str, jflag)
if (RSTRING(pad)->len > 0) {
f = RSTRING(pad)->ptr;
flen = RSTRING(pad)->len;
- }
+ }
}
p = RSTRING(res)->ptr;
if (jflag != 'l') {
- n = width - RSTRING(str)->len;
- pend = p + ((jflag == 'r') ? n : n/2);
- if (flen <= 1) {
- while (p < pend) {
- *p++ = *f;
- }
- }
- else {
- char *q = f;
- while (p + flen <= pend) {
- memcpy(p,f,flen);
- p += flen;
- }
- while (p < pend) {
- *p++ = *q++;
- }
- }
+ n = width - RSTRING(str)->len;
+ pend = p + ((jflag == 'r') ? n : n/2);
+ if (flen <= 1) {
+ while (p < pend) {
+ *p++ = *f;
+ }
+ }
+ else {
+ char *q = f;
+ while (p + flen <= pend) {
+ memcpy(p,f,flen);
+ p += flen;
+ }
+ while (p < pend) {
+ *p++ = *q++;
+ }
+ }
}
memcpy(p, RSTRING(str)->ptr, RSTRING(str)->len);
if (jflag != 'r') {
- p += RSTRING(str)->len; pend = RSTRING(res)->ptr + width;
- if (flen <= 1) {
- while (p < pend) {
- *p++ = *f;
- }
- }
- else {
- while (p + flen <= pend) {
- memcpy(p,f,flen);
- p += flen;
- }
- while (p < pend) {
- *p++ = *f++;
- }
- }
+ p += RSTRING(str)->len; pend = RSTRING(res)->ptr + width;
+ if (flen <= 1) {
+ while (p < pend) {
+ *p++ = *f;
+ }
+ }
+ else {
+ while (p + flen <= pend) {
+ memcpy(p,f,flen);
+ p += flen;
+ }
+ while (p < pend) {
+ *p++ = *f++;
+ }
+ }
}
OBJ_INFECT(res, str);
if (flen > 0) OBJ_INFECT(res, pad);
@@ -4581,7 +4581,7 @@ Init_String()
rb_include_module(rb_cString, rb_mEnumerable);
rb_define_alloc_func(rb_cString, str_alloc);
rb_define_method(rb_cString, "initialize", rb_str_init, -1);
- rb_define_method(rb_cString, "initialize_copy", rb_str_replace, 1);
+ rb_define_method(rb_cString, "initialize_copy", rb_str_replace, 1);
rb_define_method(rb_cString, "<=>", rb_str_cmp_m, 1);
rb_define_method(rb_cString, "==", rb_str_equal, 1);
rb_define_method(rb_cString, "eql?", rb_str_eql, 1);