summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-12-04 07:39:32 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-12-04 07:39:32 +0000
commita526e3fe0251880978baee867f72d59de4b3e84e (patch)
treef47e9ce8f0c67d0fde2a89046f60ebd0afc5d3dc
parent96f82b243fce324b33e71357564a15b51f6aa949 (diff)
* object.c (copy_object): copy finalizers as well if any.
* gc.c (rb_gc_copy_finalizer): new function to copy finalizers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--.cvsignore2
-rw-r--r--ChangeLog6
-rw-r--r--gc.c16
-rw-r--r--intern.h1
-rw-r--r--object.c1
-rw-r--r--pack.c27
6 files changed, 41 insertions, 12 deletions
diff --git a/.cvsignore b/.cvsignore
index 6036a2c..2332ee6 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -11,7 +11,7 @@ ChangeLog.pre1_1
Makefile
README.fat-patch
README.v6
-a.rb
+README.atheos
archive
autom4te*.cache
automake
diff --git a/ChangeLog b/ChangeLog
index ed6c397..14f6be7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Dec 4 16:37:11 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (copy_object): copy finalizers as well if any.
+
+ * gc.c (rb_gc_copy_finalizer): new function to copy finalizers.
+
Tue Dec 3 01:13:41 2002 Tanaka Akira <akr@m17n.org>
* lib/pp.rb (PP.singleline_pp): new method.
diff --git a/gc.c b/gc.c
index 3f8c4f9..f925e55 100644
--- a/gc.c
+++ b/gc.c
@@ -1475,6 +1475,22 @@ define_final(argc, argv, os)
return proc;
}
+void
+rb_gc_copy_finalizer(dest, obj)
+ VALUE dest, obj;
+{
+ VALUE table;
+
+ if (!finalizer_table) return;
+ if (!FL_TEST(obj, FL_FINALIZE)) return;
+ if (FL_TEST(dest, FL_FINALIZE)) {
+ rb_warn("copy_finalizer: descarding old finalizers");
+ }
+ if (st_lookup(finalizer_table, obj, &table)) {
+ st_insert(finalizer_table, dest, table);
+ }
+}
+
static VALUE
run_single_final(args)
VALUE *args;
diff --git a/intern.h b/intern.h
index aa0d9e4..f7838d6 100644
--- a/intern.h
+++ b/intern.h
@@ -220,6 +220,7 @@ void rb_gc_mark_maybe _((VALUE));
void rb_gc_mark _((VALUE));
void rb_gc_force_recycle _((VALUE));
void rb_gc _((void));
+void rb_gc_copy_finalizer _((VALUE,VALUE));
void rb_gc_call_finalizer_at_exit _((void));
VALUE rb_gc_enable _((void));
VALUE rb_gc_disable _((void));
diff --git a/object.c b/object.c
index 80d2d65..06c748a 100644
--- a/object.c
+++ b/object.c
@@ -119,6 +119,7 @@ copy_object(dest, obj)
if (FL_TEST(obj, FL_EXIVAR)) {
rb_copy_generic_ivar(dest, obj);
}
+ rb_gc_copy_finalizer(dest, obj);
switch (TYPE(obj)) {
case T_OBJECT:
case T_CLASS:
diff --git a/pack.c b/pack.c
index d482465..74ef708 100644
--- a/pack.c
+++ b/pack.c
@@ -1850,6 +1850,16 @@ uv_to_utf8(buf, uv)
#endif
}
+static const long utf8_limits[] = {
+ 0x0, /* 1 */
+ 0x80, /* 2 */
+ 0x800, /* 3 */
+ 0x1000, /* 4 */
+ 0x200000, /* 5 */
+ 0x4000000, /* 6 */
+ 0x80000000, /* 7 */
+};
+
static unsigned long
utf8_to_uv(p, lenp)
char *p;
@@ -1882,7 +1892,6 @@ utf8_to_uv(p, lenp)
return 0xfffd;
}
*lenp = n--;
-
if (n != 0) {
while (n--) {
c = *p++ & 0xff;
@@ -1893,20 +1902,16 @@ utf8_to_uv(p, lenp)
}
else {
c &= 0x3f;
- if (uv == 0 && c == 0) {
- int i;
-
- for (i=0; n-i>0 && (p[i] & 0x3f) == 0; i++)
- ;
- rb_warning("redundant UTF-8 sequence (skip %d bytes)", i+1);
- n -= i;
- p += i;
- continue;
- }
uv = uv << 6 | c;
}
}
}
+ n = *lenp - 1;
+ if (n < 6) {
+ if (uv < utf8_limits[n] || utf8_limits[n+1] <= uv) {
+ rb_warning("redundant UTF-8 sequence");
+ }
+ }
return uv;
}