[前][次][番号順一覧][スレッド一覧]

ruby-changes:1796

From: ko1@a...
Date: 27 Aug 2007 22:48:26 +0900
Subject: [ruby-changes:1796] matz - Ruby:r13287 (trunk): * encoding.c (rb_enc_codelen): raises invalid sequence exception

matz	2007-08-27 22:48:09 +0900 (Mon, 27 Aug 2007)

  New Revision: 13287

  Modified files:
    trunk/ChangeLog
    trunk/encoding.c
    trunk/include/ruby/encoding.h

  Log:
    * encoding.c (rb_enc_codelen): raises invalid sequence exception
      if ONIGENC_CODE_TO_MBCLEN() returns zero.  [ruby-dev:31661]
    
    * encoding.c (rb_enc_mbclen): check invalid sequence.

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13287&r2=13286
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/encoding.h?r1=13287&r2=13286
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/encoding.c?r1=13287&r2=13286

Index: encoding.c
===================================================================
--- encoding.c	(revision 13286)
+++ encoding.c	(revision 13287)
@@ -217,6 +217,26 @@
 }
 
 int
+rb_enc_mbclen(const char *p, rb_encoding *enc)
+{
+    int n = ONIGENC_MBC_ENC_LEN(enc, (UChar*)p);
+    if (n == 0) {
+	rb_raise(rb_eArgError, "invalid mbstring sequence");
+    }
+    return n;
+}
+
+int
+rb_enc_codelen(int c, rb_encoding *enc)
+{
+    int n = ONIGENC_CODE_TO_MBCLEN(enc,c);
+    if (n == 0) {
+	rb_raise(rb_eArgError, "invalid mbstring sequence");
+    }
+    return n;
+}
+
+int
 rb_enc_toupper(int c, rb_encoding *enc)
 {
     return (ONIGENC_IS_ASCII_CODE(c)?ONIGENC_ASCII_CODE_TO_UPPER_CASE(c):(c));
Index: include/ruby/encoding.h
===================================================================
--- include/ruby/encoding.h	(revision 13286)
+++ include/ruby/encoding.h	(revision 13287)
@@ -50,9 +50,11 @@
 #define rb_enc_mbmaxlen(enc) (enc)->max_enc_len
 
 /* ptr,encoding -> mbclen */
-#define rb_enc_mbclen(p,enc) ONIGENC_MBC_ENC_LEN(enc, (UChar*)p)
-#define rb_enc_codelen(c,enc) ONIGENC_CODE_TO_MBCLEN(enc,c)
+int rb_enc_mbclen(const char*, rb_encoding*);
 
+/* code,encoding -> codelen */
+int rb_enc_codelen(int, rb_encoding*);
+
 /* code,ptr,encoding -> write buf */
 #define rb_enc_mbcput(c,buf,enc) ONIGENC_CODE_TO_MBC(enc,c,(UChar*)buf)
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 13286)
+++ ChangeLog	(revision 13287)
@@ -1,3 +1,10 @@
+Mon Aug 27 22:39:08 2007  Yukihiro Matsumoto  <matz@r...>
+
+	* encoding.c (rb_enc_codelen): raises invalid sequence exception
+	  if ONIGENC_CODE_TO_MBCLEN() returns zero.  [ruby-dev:31661]
+
+	* encoding.c (rb_enc_mbclen): check invalid sequence.
+
 Mon Aug 27 20:27:59 2007  Masaki Suketa  <masaki.suketa@n...>
 
 	* ext/win32ole/win32ole.c (ole_type_progid): fix the bug.

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧]