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

ruby-changes:30025

From: nobu <ko1@a...>
Date: Sat, 20 Jul 2013 12:13:50 +0900 (JST)
Subject: [ruby-changes:30025] nobu:r42077 (trunk): encoding.c: add rb_enc_code_to_mbclen

nobu	2013-07-20 12:13:40 +0900 (Sat, 20 Jul 2013)

  New Revision: 42077

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42077

  Log:
    encoding.c: add rb_enc_code_to_mbclen
    
    * encoding.c (rb_enc_code_to_mbclen): add new function which returns
      mbclen from codepoint like as rb_enc_codelen() but 0 for invalid
      char.
    * include/ruby/encoding.h (rb_enc_code_to_mbclen): declaration and
      shortcut macro.

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

Index: encoding.c
===================================================================
--- encoding.c	(revision 42076)
+++ encoding.c	(revision 42077)
@@ -996,6 +996,13 @@ rb_enc_codelen(int c, rb_encoding *enc) https://github.com/ruby/ruby/blob/trunk/encoding.c#L996
     return n;
 }
 
+#undef rb_enc_code_to_mbclen
+int
+rb_enc_code_to_mbclen(int code, rb_encoding *enc)
+{
+    return ONIGENC_CODE_TO_MBCLEN(enc, code);
+}
+
 int
 rb_enc_toupper(int c, rb_encoding *enc)
 {
Index: include/ruby/encoding.h
===================================================================
--- include/ruby/encoding.h	(revision 42076)
+++ include/ruby/encoding.h	(revision 42077)
@@ -147,6 +147,9 @@ unsigned int rb_enc_codepoint(const char https://github.com/ruby/ruby/blob/trunk/include/ruby/encoding.h#L147
 
 /* -> codelen>0 or raise exception */
 int rb_enc_codelen(int code, rb_encoding *enc);
+/* -> 0 for invalid codepoint */
+int rb_enc_code_to_mbclen(int code, rb_encoding *enc);
+#define rb_enc_code_to_mbclen(c, enc) ONIGENC_CODE_TO_MBCLEN((enc), (c));
 
 /* code,ptr,encoding -> write buf */
 #define rb_enc_mbcput(c,buf,enc) ONIGENC_CODE_TO_MBC((enc),(c),(UChar*)(buf))
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42076)
+++ ChangeLog	(revision 42077)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Jul 20 12:13:37 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* encoding.c (rb_enc_code_to_mbclen): add new function which returns
+	  mbclen from codepoint like as rb_enc_codelen() but 0 for invalid
+	  char.
+
+	* include/ruby/encoding.h (rb_enc_code_to_mbclen): declaration and
+	  shortcut macro.
+
 Fri Jul 19 21:59:12 2013  Koichi Sasada  <ko1@a...>
 
 	* gc.c: declare type_name() at the beggining of file.

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

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