Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* object.c (copy_object): copy finalizers as well if any.

* gc.c (rb_gc_copy_finalizer): new function to copy finalizers.


git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
commit d14560a36ff2f0ad8eb26b7c603776a07b63679a 1 parent f2bfa4d
matz authored
Showing with 41 additions and 12 deletions.
  1. +1 −1  .cvsignore
  2. +6 −0 ChangeLog
  3. +16 −0 gc.c
  4. +1 −0  intern.h
  5. +1 −0  object.c
  6. +16 −11 pack.c
View
2  .cvsignore
@@ -11,7 +11,7 @@ ChangeLog.pre1_1
Makefile
README.fat-patch
README.v6
-a.rb
+README.atheos
archive
autom4te*.cache
automake
View
6 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.
View
16 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;
View
1  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));
View
1  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:
View
27 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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.