1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* indent and tabify

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2004-10-19 00:03:01 +00:00
parent 39324f819f
commit 9bd744a092

View file

@ -1169,7 +1169,7 @@ rb_str_rindex_m(argc, argv, str)
if (rb_scan_args(argc, argv, "11", &sub, &position) == 2) { if (rb_scan_args(argc, argv, "11", &sub, &position) == 2) {
pos = NUM2LONG(position); pos = NUM2LONG(position);
if (pos < 0) { if (pos < 0) {
pos += RSTRING(str)->len; pos += RSTRING(str)->len;
if (pos < 0) { if (pos < 0) {
if (TYPE(sub) == T_REGEXP) { if (TYPE(sub) == T_REGEXP) {
@ -1177,7 +1177,7 @@ rb_str_rindex_m(argc, argv, str)
} }
return Qnil; return Qnil;
} }
} }
if (pos > RSTRING(str)->len) pos = RSTRING(str)->len; if (pos > RSTRING(str)->len) pos = RSTRING(str)->len;
} }
else { else {
@ -1365,8 +1365,8 @@ rb_str_succ(orig)
sbeg = RSTRING(str)->ptr; s = sbeg + RSTRING(str)->len - 1; sbeg = RSTRING(str)->ptr; s = sbeg + RSTRING(str)->len - 1;
c = '\001'; c = '\001';
while (sbeg <= s) { while (sbeg <= s) {
if ((*s += 1) != 0) break; if ((*s += 1) != 0) break;
s--; s--;
} }
} }
if (s < sbeg) { if (s < sbeg) {
@ -3523,7 +3523,7 @@ rb_str_split_m(argc, argv, str)
if (!RSTRING(str)->ptr) { if (!RSTRING(str)->ptr) {
rb_ary_push(result, rb_str_new("", 0)); rb_ary_push(result, rb_str_new("", 0));
break; break;
} }
else if (last_null == 1) { else if (last_null == 1) {
rb_ary_push(result, rb_str_substr(str, beg, mbclen2(RSTRING(str)->ptr[beg],spat))); rb_ary_push(result, rb_str_substr(str, beg, mbclen2(RSTRING(str)->ptr[beg],spat)));
beg = start; beg = start;
@ -3687,7 +3687,7 @@ rb_str_each_line(argc, argv, str)
} }
if (s != pend) { if (s != pend) {
if (p > pend) p = pend; if (p > pend) p = pend;
line = rb_str_new5(str, s, p - s); line = rb_str_new5(str, s, p - s);
OBJ_INFECT(line, str); OBJ_INFECT(line, str);
rb_yield(line); rb_yield(line);
@ -4473,41 +4473,41 @@ rb_str_justify(argc, argv, str, jflag)
} }
p = RSTRING(res)->ptr; p = RSTRING(res)->ptr;
if (jflag != 'l') { if (jflag != 'l') {
n = width - RSTRING(str)->len; n = width - RSTRING(str)->len;
pend = p + ((jflag == 'r') ? n : n/2); pend = p + ((jflag == 'r') ? n : n/2);
if (flen <= 1) { if (flen <= 1) {
while (p < pend) { while (p < pend) {
*p++ = *f; *p++ = *f;
} }
} }
else { else {
char *q = f; char *q = f;
while (p + flen <= pend) { while (p + flen <= pend) {
memcpy(p,f,flen); memcpy(p,f,flen);
p += flen; p += flen;
} }
while (p < pend) { while (p < pend) {
*p++ = *q++; *p++ = *q++;
} }
} }
} }
memcpy(p, RSTRING(str)->ptr, RSTRING(str)->len); memcpy(p, RSTRING(str)->ptr, RSTRING(str)->len);
if (jflag != 'r') { if (jflag != 'r') {
p += RSTRING(str)->len; pend = RSTRING(res)->ptr + width; p += RSTRING(str)->len; pend = RSTRING(res)->ptr + width;
if (flen <= 1) { if (flen <= 1) {
while (p < pend) { while (p < pend) {
*p++ = *f; *p++ = *f;
} }
} }
else { else {
while (p + flen <= pend) { while (p + flen <= pend) {
memcpy(p,f,flen); memcpy(p,f,flen);
p += flen; p += flen;
} }
while (p < pend) { while (p < pend) {
*p++ = *f++; *p++ = *f++;
} }
} }
} }
OBJ_INFECT(res, str); OBJ_INFECT(res, str);
if (flen > 0) OBJ_INFECT(res, pad); if (flen > 0) OBJ_INFECT(res, pad);