mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
96f82b243f
commit
a526e3fe02
6 changed files with 41 additions and 12 deletions
|
@ -11,7 +11,7 @@ ChangeLog.pre1_1
|
|||
Makefile
|
||||
README.fat-patch
|
||||
README.v6
|
||||
a.rb
|
||||
README.atheos
|
||||
archive
|
||||
autom4te*.cache
|
||||
automake
|
||||
|
|
|
@ -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.
|
||||
|
|
16
gc.c
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;
|
||||
|
|
1
intern.h
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));
|
||||
|
|
1
object.c
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:
|
||||
|
|
27
pack.c
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue