mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* regex.c (NUM_FAILURE_ITEMS): was confusing NUM_REG_ITEMS and
NUM_NONREG_ITEMS, which have happened to be same value. * class.c (rb_class_new): subclass check moved to this function. * class.c (rb_class_boot): check less version of rb_class_new(). * eval.c (proc_invoke): should preserve iter status for embedded frame in the block. * file.c (rb_file_s_expand_path): may overrun buffer on stack. * string.c (rb_str_insert): forgot to call rb_str_modify(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c068201c50
commit
f35971afdf
11 changed files with 71 additions and 24 deletions
28
ChangeLog
28
ChangeLog
|
@ -1,3 +1,8 @@
|
|||
Tue Jul 17 11:22:01 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* regex.c (NUM_FAILURE_ITEMS): was confusing NUM_REG_ITEMS and
|
||||
NUM_NONREG_ITEMS, which have happened to be same value.
|
||||
|
||||
Tue Jul 17 11:08:34 2001 Usaku Nakamura <usa@osb.att.ne.jp>
|
||||
|
||||
* ext/extmk.rb.in: modify RM macro because command.com/cmd.exe don't
|
||||
|
@ -5,10 +10,29 @@ Tue Jul 17 11:08:34 2001 Usaku Nakamura <usa@osb.att.ne.jp>
|
|||
|
||||
* lib/mkmf.rb: ditto.
|
||||
|
||||
Tue Jul 17 01:38:15 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* class.c (rb_class_new): subclass check moved to this function.
|
||||
|
||||
* class.c (rb_class_boot): check less version of rb_class_new().
|
||||
|
||||
Man Jul 16 13:21:30 2001 Usaku Nakamura <usa@osb.att.ne.jp>
|
||||
|
||||
* file.c (file_load_ok): fix typo.
|
||||
|
||||
Mon Jul 16 12:58:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (proc_invoke): should preserve iter status for embedded
|
||||
frame in the block.
|
||||
|
||||
Mon Jul 16 00:04:39 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* file.c (rb_file_s_expand_path): may overrun buffer on stack.
|
||||
|
||||
Sun Jul 15 01:38:28 2001 Guy Decoux <decoux@moulon.inra.fr>
|
||||
|
||||
* string.c (rb_str_insert): forgot to call rb_str_modify().
|
||||
|
||||
Sat Jul 14 12:26:30 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
|
||||
|
||||
* ext/digest/*/extconf.rb: fix so that they build from any
|
||||
|
@ -73,8 +97,8 @@ Sat Jul 7 17:45:35 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
|||
|
||||
Fri Jul 6 18:01:10 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* object.c (rb_obj_dup): should free generic_ivar if original owns
|
||||
them.
|
||||
* object.c (rb_obj_dup): copies (actually does not free)
|
||||
generic_ivar on dupif original owns them.
|
||||
|
||||
Fri Jul 6 02:15:06 2001 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
|
|
18
class.c
18
class.c
|
@ -19,7 +19,7 @@
|
|||
extern st_table *rb_class_tbl;
|
||||
|
||||
VALUE
|
||||
rb_class_new(super)
|
||||
rb_class_boot(super)
|
||||
VALUE super;
|
||||
{
|
||||
NEWOBJ(klass, struct RClass);
|
||||
|
@ -33,6 +33,20 @@ rb_class_new(super)
|
|||
return (VALUE)klass;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_class_new(super)
|
||||
VALUE super;
|
||||
{
|
||||
Check_Type(super, T_CLASS);
|
||||
if (super == rb_cClass) {
|
||||
rb_raise(rb_eTypeError, "can't make subclass of Class");
|
||||
}
|
||||
if (FL_TEST(super, FL_SINGLETON)) {
|
||||
rb_raise(rb_eTypeError, "can't make subclass of virtual class");
|
||||
}
|
||||
return rb_class_boot(super);
|
||||
}
|
||||
|
||||
static int
|
||||
clone_method(mid, body, tbl)
|
||||
ID mid;
|
||||
|
@ -78,7 +92,7 @@ VALUE
|
|||
rb_singleton_class_new(super)
|
||||
VALUE super;
|
||||
{
|
||||
VALUE klass = rb_class_new(super);
|
||||
VALUE klass = rb_class_boot(super);
|
||||
|
||||
FL_SET(klass, FL_SINGLETON);
|
||||
return klass;
|
||||
|
|
9
eval.c
9
eval.c
|
@ -3590,7 +3590,8 @@ rb_jump_tag(tag)
|
|||
int
|
||||
rb_block_given_p()
|
||||
{
|
||||
if (ruby_frame->iter) return Qtrue;
|
||||
if (ruby_frame->iter && ruby_block)
|
||||
return Qtrue;
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
|
@ -3603,7 +3604,8 @@ rb_iterator_p()
|
|||
static VALUE
|
||||
rb_f_block_given_p()
|
||||
{
|
||||
if (ruby_frame->prev && ruby_frame->prev->iter) return Qtrue;
|
||||
if (ruby_frame->prev && ruby_frame->prev->iter && ruby_block)
|
||||
return Qtrue;
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
|
@ -3622,7 +3624,7 @@ rb_yield_0(val, self, klass, pcall)
|
|||
int state;
|
||||
static unsigned serial = 1;
|
||||
|
||||
if (!(rb_block_given_p() || rb_f_block_given_p()) || !ruby_block) {
|
||||
if (!(rb_block_given_p() || rb_f_block_given_p())) {
|
||||
rb_raise(rb_eLocalJumpError, "yield called out of block");
|
||||
}
|
||||
|
||||
|
@ -6409,7 +6411,6 @@ proc_invoke(proc, args, pcall)
|
|||
old_block = ruby_block;
|
||||
_block = *data;
|
||||
ruby_block = &_block;
|
||||
ruby_block->frame.iter = ITER_NOT;
|
||||
|
||||
PUSH_ITER(ITER_CUR);
|
||||
ruby_frame->iter = ITER_CUR;
|
||||
|
|
|
@ -82,6 +82,7 @@ rb_nkf_kconv(obj, opt, src)
|
|||
kanji_convert(NULL);
|
||||
RSTRING(dst)->ptr[output_ctr] = '\0';
|
||||
RSTRING(dst)->len = output_ctr;
|
||||
OBJ_INFECT(dst, src);
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
|
|
@ -770,6 +770,8 @@ ruby_connect(fd, sockaddr, len, socks)
|
|||
errno = 0;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_FCNTL
|
||||
|
|
17
file.c
17
file.c
|
@ -1304,6 +1304,7 @@ rb_file_s_expand_path(argc, argv)
|
|||
VALUE fname, dname;
|
||||
char *s, *p;
|
||||
char buf[MAXPATHLEN+2];
|
||||
char *bend = buf + sizeof(buf) - 2;
|
||||
int tainted;
|
||||
|
||||
rb_scan_args(argc, argv, "11", &fname, &dname);
|
||||
|
@ -1318,6 +1319,7 @@ rb_file_s_expand_path(argc, argv)
|
|||
if (!dir) {
|
||||
rb_raise(rb_eArgError, "couldn't find HOME environment -- expanding `%s'", s);
|
||||
}
|
||||
if (strlen(dir) > MAXPATHLEN) goto toolong;
|
||||
strcpy(buf, dir);
|
||||
p = &buf[strlen(buf)];
|
||||
s++;
|
||||
|
@ -1330,6 +1332,7 @@ rb_file_s_expand_path(argc, argv)
|
|||
#endif
|
||||
while (*s && !isdirsep(*s)) {
|
||||
*p++ = *s++;
|
||||
if (p >= bend) goto toolong;
|
||||
}
|
||||
*p = '\0';
|
||||
#ifdef HAVE_PWD_H
|
||||
|
@ -1338,6 +1341,7 @@ rb_file_s_expand_path(argc, argv)
|
|||
endpwent();
|
||||
rb_raise(rb_eArgError, "user %s doesn't exist", buf);
|
||||
}
|
||||
if (strlen(pwPtr->pw_dir) > MAXPATHLEN) goto toolong;
|
||||
strcpy(buf, pwPtr->pw_dir);
|
||||
p = &buf[strlen(buf)];
|
||||
endpwent();
|
||||
|
@ -1349,6 +1353,7 @@ rb_file_s_expand_path(argc, argv)
|
|||
else if (ISALPHA(s[0]) && s[1] == ':' && isdirsep(s[2])) {
|
||||
while (*s && !isdirsep(*s)) {
|
||||
*p++ = *s++;
|
||||
if (p >= bend) goto toolong;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1356,6 +1361,7 @@ rb_file_s_expand_path(argc, argv)
|
|||
if (!NIL_P(dname)) {
|
||||
dname = rb_file_s_expand_path(1, &dname);
|
||||
if (OBJ_TAINTED(dname)) tainted = 1;
|
||||
if (strlen(RSTRING(dname)->ptr) > MAXPATHLEN) goto toolong;
|
||||
strcpy(buf, RSTRING(dname)->ptr);
|
||||
}
|
||||
else {
|
||||
|
@ -1372,6 +1378,7 @@ rb_file_s_expand_path(argc, argv)
|
|||
else {
|
||||
while (*s && isdirsep(*s)) {
|
||||
*p++ = '/';
|
||||
if (p >= bend) goto toolong;
|
||||
s++;
|
||||
}
|
||||
if (p > buf && *s) p--;
|
||||
|
@ -1391,7 +1398,10 @@ rb_file_s_expand_path(argc, argv)
|
|||
}
|
||||
else {
|
||||
*++p = '.';
|
||||
do *++p = '.'; while (*++s == '.');
|
||||
do {
|
||||
*++p = '.';
|
||||
if (p >= bend) goto toolong;
|
||||
} while (*++s == '.');
|
||||
--s;
|
||||
}
|
||||
break;
|
||||
|
@ -1413,6 +1423,7 @@ rb_file_s_expand_path(argc, argv)
|
|||
if (!isdirsep(*p)) *++p = '/'; break;
|
||||
default:
|
||||
*++p = *s;
|
||||
if (p >= bend) goto toolong;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1423,6 +1434,10 @@ rb_file_s_expand_path(argc, argv)
|
|||
fname = rb_str_new2(buf);
|
||||
if (tainted) OBJ_TAINT(fname);
|
||||
return fname;
|
||||
|
||||
toolong:
|
||||
rb_raise(rb_eArgError, "argument too long (size=%d)", RSTRING(fname)->len);
|
||||
return Qnil; /* not reached */
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
1
intern.h
1
intern.h
|
@ -79,6 +79,7 @@ VALUE rb_big_xor _((VALUE, VALUE));
|
|||
VALUE rb_big_lshift _((VALUE, VALUE));
|
||||
VALUE rb_big_rand _((VALUE, double));
|
||||
/* class.c */
|
||||
VALUE rb_class_boot _((VALUE));
|
||||
VALUE rb_class_new _((VALUE));
|
||||
VALUE rb_mod_clone _((VALUE));
|
||||
VALUE rb_mod_dup _((VALUE));
|
||||
|
|
14
object.c
14
object.c
|
@ -655,10 +655,6 @@ rb_class_s_new(argc, argv)
|
|||
if (rb_scan_args(argc, argv, "01", &super) == 0) {
|
||||
super = rb_cObject;
|
||||
}
|
||||
Check_Type(super, T_CLASS);
|
||||
if (FL_TEST(super, FL_SINGLETON)) {
|
||||
rb_raise(rb_eTypeError, "can't make subclass of virtual class");
|
||||
}
|
||||
klass = rb_class_new(super);
|
||||
/* make metaclass */
|
||||
RBASIC(klass)->klass = rb_singleton_class_new(RBASIC(super)->klass);
|
||||
|
@ -669,13 +665,6 @@ rb_class_s_new(argc, argv)
|
|||
return klass;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_class_s_inherited()
|
||||
{
|
||||
rb_raise(rb_eTypeError, "can't make subclass of Class");
|
||||
return Qnil; /* dummy */
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_class_superclass(klass)
|
||||
VALUE klass;
|
||||
|
@ -1096,7 +1085,7 @@ boot_defclass(name, super)
|
|||
VALUE super;
|
||||
{
|
||||
extern st_table *rb_class_tbl;
|
||||
VALUE obj = rb_class_new(super);
|
||||
VALUE obj = rb_class_boot(super);
|
||||
ID id = rb_intern(name);
|
||||
|
||||
rb_name_class(obj, id);
|
||||
|
@ -1271,7 +1260,6 @@ Init_Object()
|
|||
rb_define_singleton_method(rb_cClass, "new", rb_class_s_new, -1);
|
||||
rb_undef_method(rb_cClass, "extend_object");
|
||||
rb_undef_method(rb_cClass, "append_features");
|
||||
rb_define_singleton_method(rb_cClass, "inherited", rb_class_s_inherited, 1);
|
||||
|
||||
rb_cData = rb_define_class("Data", rb_cObject);
|
||||
rb_undef_method(CLASS_OF(rb_cData), "new");
|
||||
|
|
2
regex.c
2
regex.c
|
@ -3373,7 +3373,7 @@ re_search(bufp, string, size, startpos, range, regs)
|
|||
#define MAX_NUM_FAILURE_ITEMS (num_regs * NUM_REG_ITEMS + NUM_NONREG_ITEMS)
|
||||
|
||||
/* We push this many things on the stack whenever we fail. */
|
||||
#define NUM_FAILURE_ITEMS (last_used_reg * NUM_REG_ITEMS + NUM_REG_ITEMS + 1)
|
||||
#define NUM_FAILURE_ITEMS (last_used_reg * NUM_REG_ITEMS + NUM_NONREG_ITEMS + 1)
|
||||
|
||||
/* This pushes counter information for succeed_n and jump_n */
|
||||
#define PUSH_FAILURE_COUNT(ptr) \
|
||||
|
|
1
string.c
1
string.c
|
@ -1208,6 +1208,7 @@ rb_str_insert(str, idx, str2)
|
|||
{
|
||||
long pos = NUM2LONG(idx);
|
||||
|
||||
rb_str_modify(str);
|
||||
if (pos == -1) {
|
||||
pos = RSTRING(str)->len;
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ VALUE
|
|||
rb_mod_name(mod)
|
||||
VALUE mod;
|
||||
{
|
||||
VALUE path = classname(rb_obj_type(mod));
|
||||
VALUE path = classname(rb_class_real(mod));
|
||||
|
||||
if (path) return rb_str_dup(path);
|
||||
return rb_str_new(0,0);
|
||||
|
|
Loading…
Add table
Reference in a new issue