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

ruby-changes:2369

From: ko1@a...
Date: 10 Nov 2007 14:46:05 +0900
Subject: [ruby-changes:2369] davidflanagan - Ruby:r13860 (trunk): * parse.y: use ASCII encoding for string literals that are

davidflanagan	2007-11-10 14:45:52 +0900 (Sat, 10 Nov 2007)

  New Revision: 13860

  Modified files:
    trunk/ChangeLog
    trunk/parse.y

  Log:
    * parse.y: use ASCII encoding for string literals that are
    7-bit clean, fixing regression from my previous patch
    


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/parse.y?r1=13860&r2=13859
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13860&r2=13859

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 13859)
+++ ChangeLog	(revision 13860)
@@ -1,3 +1,8 @@
+Sat Nov 10 14:43:30 2007  David Flanagan  <davidflanagan@r...>
+
+	* parse.y: use ASCII encoding for string literals that are
+		7-bit clean, fixing regression from my previous patch
+
 Sat Nov 10 13:18:54 2007  Nobuyoshi Nakada  <nobu@r...>
 
 	* {bcc32,win32}/Makefile.sub: vendor_ruby support.
Index: parse.y
===================================================================
--- parse.y	(revision 13859)
+++ parse.y	(revision 13860)
@@ -4842,9 +4842,23 @@
 static VALUE
 parser_str_new2(const char *p, long n, rb_encoding *enc, int has8bit,int hasmb)
 {
+    /*
+     * Set coderange bit flags based on the presence of 8-bit and 
+     * multi-byte characters in the string
+     */
     int coderange = ENC_CODERANGE_SINGLE;
     if (hasmb) coderange = ENC_CODERANGE_MULTI;
     else if (has8bit) coderange = ENC_CODERANGE_UNKNOWN;
+
+    /*
+     * If it is all single byte characters with the 8th bit clear,
+     * and if the specified encoding is ASCII-compatible, then this
+     * string is in the ASCII subset, and we just use the ASCII encoding
+     * instead.
+     */
+    if ((coderange == ENC_CODERANGE_SINGLE) && rb_enc_asciicompat(enc))
+	enc = rb_enc_default();
+
     return parser_str_new(p, n, enc, coderange);
 }
 

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

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