summaryrefslogtreecommitdiff
path: root/pack.c
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 /pack.c
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
Diffstat (limited to 'pack.c')
-rw-r--r--pack.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/pack.c b/pack.c
index d482465111..74ef708d42 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;
}