зеркало из https://github.com/github/ruby.git
* intern.h, re.c (rb_memsearch): returns long.
* string.c (rb_str_index): should return offset position. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
b89cbf192b
Коммит
34033db665
|
@ -1,3 +1,9 @@
|
|||
Fri Feb 07 15:35:21 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||
|
||||
* intern.h, re.c (rb_memsearch): returns long.
|
||||
|
||||
* string.c (rb_str_index): should return offset position.
|
||||
|
||||
Fri Feb 07 15:30:15 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||
|
||||
* eval.c (proc_invoke): should propagate self to super
|
||||
|
|
2
intern.h
2
intern.h
|
@ -330,7 +330,7 @@ VALUE rb_length_by_each _((VALUE));
|
|||
/* re.c */
|
||||
int rb_memcmp _((char*,char*,long));
|
||||
int rb_memcicmp _((char*,char*,long));
|
||||
int rb_memsearch _((char*,long,char*,long));
|
||||
long rb_memsearch _((char*,long,char*,long));
|
||||
VALUE rb_reg_nth_defined _((int, VALUE));
|
||||
VALUE rb_reg_nth_match _((int, VALUE));
|
||||
VALUE rb_reg_last_match _((VALUE));
|
||||
|
|
2
re.c
2
re.c
|
@ -96,7 +96,7 @@ rb_memcmp(p1, p2, len)
|
|||
return rb_memcicmp(p1, p2, len);
|
||||
}
|
||||
|
||||
int
|
||||
long
|
||||
rb_memsearch(x0, m, y0, n)
|
||||
char *x0, *y0;
|
||||
long m, n;
|
||||
|
|
6
string.c
6
string.c
|
@ -839,14 +839,18 @@ rb_str_index(str, sub, offset)
|
|||
VALUE str, sub;
|
||||
long offset;
|
||||
{
|
||||
long pos;
|
||||
|
||||
if (offset < 0) {
|
||||
offset += RSTRING(str)->len;
|
||||
if (offset < 0) return -1;
|
||||
}
|
||||
if (RSTRING(str)->len - offset < RSTRING(sub)->len) return -1;
|
||||
if (RSTRING(sub)->len == 0) return offset;
|
||||
return rb_memsearch(RSTRING(sub)->ptr, RSTRING(sub)->len,
|
||||
pos = rb_memsearch(RSTRING(sub)->ptr, RSTRING(sub)->len,
|
||||
RSTRING(str)->ptr+offset, RSTRING(str)->len-offset);
|
||||
if (pos < 0) return pos;
|
||||
return pos + offset;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
Загрузка…
Ссылка в новой задаче