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

2000-06-14

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-06-14 05:30:29 +00:00
parent 00e9a8f0c3
commit abc49e493d
8 changed files with 76 additions and 37 deletions

View file

@ -8,6 +8,33 @@ Wed Jun 14 14:07:38 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
* configure.in: add include <time.h> when daylight checking.
Wed Jun 14 11:36:52 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
* marshal.c (r_object): modified for symbols.
* marshal.c (w_object): ditto.
Wed Jun 14 10:04:58 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* re.c (rb_memcmp): should compare according to ruby_ignorecase.
* string.c (rb_str_cmp): use rb_memcmp.
* string.c (rb_str_index): ditto.
* string.c (rb_str_rindex): ditto.
* string.c (rb_str_each_line): ditto.
Wed 14 Jun 04:58:53 2000 Dave Thomas <dave@thomases.com>
* io.c (rb_io_set_lineno): should have returned VALUE, not
integer.
Wed Jun 14 09:29:42 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* string.c (rb_str_dup): dup should always propagate taintness.
Wed Jun 14 00:50:14 2000 Wakou Aoyama <wakou@fsinet.or.jp>
* lib/cgi.rb: read_multipart(): if no content body then raise EOFError.
@ -50,7 +77,7 @@ Thu Jun 8 14:25:45 2000 Hiroshi Igarashi <iga@ruby-lang.org>
* lib/mkmf.rb: add target `distclean' in Makefile for extlib.
target `clean' doesn't remove Makefile.
Thu Jun 8 13:34:03 2000 Dave Thomas <dave@thomases.com>
Thu Jun 8 13:34:03 2000 Dave Thomas <dave@thomases.com>
* numeric.c: add nan?, infinite?, and finite? to Float

View file

@ -257,6 +257,7 @@ VALUE rb_range_new _((VALUE, VALUE, int));
VALUE rb_range_beg_len _((VALUE, long*, long*, long, int));
VALUE rb_length_by_each _((VALUE));
/* re.c */
int rb_memcmp _((char*,char*,size_t));
VALUE rb_reg_nth_defined _((int, VALUE));
VALUE rb_reg_nth_match _((int, VALUE));
VALUE rb_reg_last_match _((VALUE));

3
io.c
View file

@ -787,7 +787,8 @@ rb_io_set_lineno(io, lineno)
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
return fptr->lineno = NUM2INT(lineno);
fptr->lineno = NUM2INT(lineno);
return lineno;
}
static void

View file

@ -384,7 +384,7 @@ w_object(obj, arg, limit)
rb_raise(rb_eTypeError, "uninitialized struct");
}
for (i=0; i<len; i++) {
w_symbol(FIX2LONG(RARRAY(mem)->ptr[i]), arg);
w_symbol(SYM2ID(RARRAY(mem)->ptr[i]), arg);
w_object(RSTRUCT(obj)->ptr[i], arg, limit);
}
}
@ -826,11 +826,11 @@ r_object(arg)
for (i=0; i<len; i++) {
slot = r_symbol(arg);
if (RARRAY(mem)->ptr[i] != INT2FIX(slot)) {
if (RARRAY(mem)->ptr[i] != ID2SYM(slot)) {
rb_raise(rb_eTypeError, "struct %s not compatible (:%s for :%s)",
rb_class2name(klass),
rb_id2name(slot),
rb_id2name(FIX2INT(RARRAY(mem)->ptr[i])));
rb_id2name(SYM2ID(RARRAY(mem)->ptr[i])));
}
rb_struct_aset(v, INT2FIX(i), r_object(arg));
}

29
re.c
View file

@ -70,21 +70,28 @@ static const char casetable[] = {
#define MIN(a,b) (((a)>(b))?(b):(a))
int
rb_memcmp(p1, p2, len)
char *p1, *p2;
size_t len;
{
int tmp;
if (!ruby_ignorecase) {
return memcmp(p1, p2, len);
}
while (len--) {
if (tmp = casetable[(unsigned)*p1++] - casetable[(unsigned)*p2++])
return tmp;
}
return 0;
}
int
rb_str_cicmp(str1, str2)
VALUE str1, str2;
{
int len, i;
char *p1, *p2;
len = MIN(RSTRING(str1)->len, RSTRING(str2)->len);
p1 = RSTRING(str1)->ptr; p2 = RSTRING(str2)->ptr;
for (i = 0; i < len; i++, p1++, p2++) {
if (casetable[(unsigned)*p1] != casetable[(unsigned)*p2])
return casetable[(unsigned)*p1] - casetable[(unsigned)*p2];
}
return RSTRING(str1)->len - RSTRING(str2)->len;
}
#define REG_CASESTATE FL_USER0

View file

@ -87,6 +87,7 @@ rb_str_new3(str)
str2->len = RSTRING(str)->len;
str2->ptr = RSTRING(str)->ptr;
str2->orig = str;
OBJ_INFECT(str2, str);
return (VALUE)str2;
}
@ -179,24 +180,28 @@ VALUE
rb_str_dup(str)
VALUE str;
{
VALUE shadow;
VALUE str2;
if (TYPE(str) != T_STRING) str = rb_str_to_str(str);
if (OBJ_FROZEN(str)) return rb_str_new3(str);
if (FL_TEST(str, STR_NO_ORIG)) {
VALUE s = rb_str_new(RSTRING(str)->ptr, RSTRING(str)->len);
OBJ_INFECT(s, str);
return s;
str2 = rb_str_new(RSTRING(str)->ptr, RSTRING(str)->len);
OBJ_INFECT(str2, str);
return str2;
}
if (RSTRING(str)->orig) {
str2 = rb_str_new3(RSTRING(str)->orig);
OBJ_INFECT(str2, str);
return str2;
}
if (RSTRING(str)->orig) return rb_str_new3(RSTRING(str)->orig);
shadow = rb_str_new4(str);
str2 = rb_str_new4(str);
{
NEWOBJ(dup, struct RString);
OBJSETUP(dup, rb_cString, T_STRING);
dup->len = RSTRING(shadow)->len;
dup->ptr = RSTRING(shadow)->ptr;
dup->orig = shadow;
dup->len = RSTRING(str2)->len;
dup->ptr = RSTRING(str2)->ptr;
dup->orig = str2;
OBJ_INFECT(dup, str);
return (VALUE)dup;
@ -515,12 +520,8 @@ rb_str_cmp(str1, str2)
long len;
int retval;
if (ruby_ignorecase) {
return rb_str_cicmp(str1, str2);
}
len = lesser(RSTRING(str1)->len, RSTRING(str2)->len);
retval = memcmp(RSTRING(str1)->ptr, RSTRING(str2)->ptr, len);
retval = rb_memcmp(RSTRING(str1)->ptr, RSTRING(str2)->ptr, len);
if (retval == 0) {
if (RSTRING(str1)->len == RSTRING(str2)->len) return 0;
if (RSTRING(str1)->len > RSTRING(str2)->len) return 1;
@ -606,7 +607,7 @@ rb_str_index(str, sub, offset)
if (len == 0) return offset;
e = RSTRING(str)->ptr + RSTRING(str)->len - len + 1;
while (s < e) {
if (*s == *(RSTRING(sub)->ptr) && memcmp(s, p, len) == 0) {
if (rb_memcmp(s, p, len) == 0) {
return (s-(RSTRING(str)->ptr));
}
s++;
@ -706,7 +707,7 @@ rb_str_rindex(argc, argv, str)
t = RSTRING(sub)->ptr;
if (len) {
while (sbeg <= s) {
if (*s == *t && memcmp(s, t, len) == 0) {
if (rb_memcmp(s, t, len) == 0) {
return INT2NUM(s - RSTRING(str)->ptr);
}
s--;
@ -2286,7 +2287,7 @@ rb_str_each_line(argc, argv, str)
}
if (p[-1] == newline &&
(rslen <= 1 ||
memcmp(RSTRING(rs)->ptr, p-rslen, rslen) == 0)) {
rb_memcmp(RSTRING(rs)->ptr, p-rslen, rslen) == 0)) {
line = rb_str_new(s, p - s);
rb_yield(line);
if (RSTRING(str)->ptr != ptr || RSTRING(str)->len != len)
@ -2398,7 +2399,7 @@ rb_str_chomp_bang(argc, argv, str)
if (p[len-1] == newline &&
(rslen <= 1 ||
memcmp(RSTRING(rs)->ptr, p+len-rslen, rslen) == 0)) {
rb_memcmp(RSTRING(rs)->ptr, p+len-rslen, rslen) == 0)) {
rb_str_modify(str);
RSTRING(str)->len -= rslen;
RSTRING(str)->ptr[RSTRING(str)->len] = '\0';

View file

@ -496,12 +496,14 @@ rb_struct_aset(s, idx, val)
i = NUM2LONG(idx);
if (i < 0) i = RSTRUCT(s)->len + i;
if (i < 0)
if (i < 0) {
rb_raise(rb_eIndexError, "offset %d too small for struct(size:%d)",
i, RSTRUCT(s)->len);
if (RSTRUCT(s)->len <= i)
}
if (RSTRUCT(s)->len <= i) {
rb_raise(rb_eIndexError, "offset %d too large for struct(size:%d)",
i, RSTRUCT(s)->len);
}
if (OBJ_FROZEN(s)) rb_error_frozen("Struct");
return RSTRUCT(s)->ptr[i] = val;
}

View file

@ -462,7 +462,7 @@ EXPORTS
rb_range_new
rb_range_beg_len
;re.c
rb_str_cicmp
rb_memcmp
rb_reg_mbclen2
rb_match_busy
rb_reg_adjust_startpos