summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog28
-rw-r--r--class.c18
-rw-r--r--eval.c9
-rw-r--r--ext/nkf/nkf.c1
-rw-r--r--ext/socket/socket.c2
-rw-r--r--file.c17
-rw-r--r--intern.h1
-rw-r--r--object.c14
-rw-r--r--regex.c2
-rw-r--r--string.c1
-rw-r--r--variable.c2
11 files changed, 71 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index 4765be10daa..0bf0b3460fe 100644
--- a/ChangeLog
+++ b/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>
diff --git a/class.c b/class.c
index 6f6c5d2b856..1c3391a5d47 100644
--- a/class.c
+++ b/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;
diff --git a/eval.c b/eval.c
index af3791059e3..95cf12d18a7 100644
--- a/eval.c
+++ b/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;
diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c
index 58daad11ab7..50723467cd4 100644
--- a/ext/nkf/nkf.c
+++ b/ext/nkf/nkf.c
@@ -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;
}
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index f0ed09bd981..b909a433a73 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -770,6 +770,8 @@ ruby_connect(fd, sockaddr, len, socks)
errno = 0;
break;
#endif
+ default:
+ break;
}
}
#ifdef HAVE_FCNTL
diff --git a/file.c b/file.c
index 327db537414..d79897fc927 100644
--- a/file.c
+++ b/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
diff --git a/intern.h b/intern.h
index 9f2793c9e83..46caaa091ea 100644
--- a/intern.h
+++ b/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));
diff --git a/object.c b/object.c
index e34bb23b1b5..66d369e1e98 100644
--- a/object.c
+++ b/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);
@@ -670,13 +666,6 @@ rb_class_s_new(argc, argv)
}
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");
diff --git a/regex.c b/regex.c
index df174328cb7..b2e25fcf678 100644
--- a/regex.c
+++ b/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) \
diff --git a/string.c b/string.c
index 9982e561b7d..7d7eb5c7699 100644
--- a/string.c
+++ b/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;
}
diff --git a/variable.c b/variable.c
index 79a11b76fee..79e02b910c7 100644
--- a/variable.c
+++ b/variable.c
@@ -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);