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

ruby-changes:5239

From: naruse <ko1@a...>
Date: Mon, 2 Jun 2008 03:29:22 +0900 (JST)
Subject: [ruby-changes:5239] Ruby:r16737 (trunk): * enc/gb18030.c (gb18030_mbc_to_code): mask by 0x7FFFFFFF

naruse	2008-06-02 03:29:08 +0900 (Mon, 02 Jun 2008)

  New Revision: 16737

  Modified files:
    trunk/ChangeLog
    trunk/enc/gb18030.c

  Log:
    * enc/gb18030.c (gb18030_mbc_to_code): mask by 0x7FFFFFFF
      because OnigCodePoint will be used as 32bit signed int.
      Masking by 0x7FFFFFFF is ok on GB18030;
      Minumum 4bytes character is 0x81308130.

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16737&r2=16736&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/enc/gb18030.c?r1=16737&r2=16736&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 16736)
+++ ChangeLog	(revision 16737)
@@ -1,3 +1,10 @@
+Mon Jun  2 03:23:25 2008  NARUSE, Yui  <naruse@r...>
+
+	* enc/gb18030.c (gb18030_mbc_to_code): mask by 0x7FFFFFFF
+	  because OnigCodePoint will be used as 32bit signed int.
+	  Masking by 0x7FFFFFFF is ok on GB18030;
+	  Minumum 4bytes character is 0x81308130.
+
 Sun Jun  1 22:29:35 2008  NARUSE, Yui  <naruse@r...>
 
 	* rational.c (string_to_r_internal): use rb_isdigit.
Index: enc/gb18030.c
===================================================================
--- enc/gb18030.c	(revision 16736)
+++ enc/gb18030.c	(revision 16737)
@@ -166,7 +166,20 @@
 static OnigCodePoint
 gb18030_mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)
 {
-  return onigenc_mbn_mbc_to_code(enc, p, end);
+  int c, i, len;
+  OnigCodePoint n;
+
+  len = enclen(enc, p, end);
+  n = (OnigCodePoint )(*p++);
+  if (len == 1) return n;
+
+  for (i = 1; i < len; i++) {
+    if (p >= end) break;
+    c = *p++;
+    n <<= 8;  n += c;
+  }
+  n &= 0x7FFFFFFF;
+  return n;
 }
 
 static int

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

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