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

ruby-changes:30696

From: nobu <ko1@a...>
Date: Mon, 2 Sep 2013 17:53:46 +0900 (JST)
Subject: [ruby-changes:30696] nobu:r42775 (trunk): parse.y: force_encoding

nobu	2013-09-02 17:53:40 +0900 (Mon, 02 Sep 2013)

  New Revision: 42775

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

  Log:
    parse.y: force_encoding
    
    * parse.y (str_suffix_gen): String#b creates new string object, use
      force_encoding instead.

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42774)
+++ ChangeLog	(revision 42775)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Sep  2 17:53:33 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (str_suffix_gen): String#b creates new string object, use
+	  force_encoding instead.
+
 Mon Sep  2 16:06:00 2013  Charlie Somerville  <charliesome@r...>
 
 	* NEWS: Add note about frozen string literals
Index: parse.y
===================================================================
--- parse.y	(revision 42774)
+++ parse.y	(revision 42775)
@@ -6006,12 +6006,12 @@ parser_str_options(struct parser_params https://github.com/ruby/ruby/blob/trunk/parse.y#L6006
 	switch (c) {
 #if STR_OPTION_FROZEN
 	  case 'f':
-            options |= STR_OPTION_FROZEN;
+	    options |= STR_OPTION_FROZEN;
 	    break;
 #endif
 #if STR_OPTION_BINARY
 	  case 'b':
-            options |= STR_OPTION_BINARY;
+	    options |= STR_OPTION_BINARY;
 	    break;
 #endif
 	  default:
@@ -8576,7 +8576,9 @@ str_suffix_gen(struct parser_params *par https://github.com/ruby/ruby/blob/trunk/parse.y#L8576
     else {
 #if STR_OPTION_BINARY
 	if (opt & STR_OPTION_BINARY) {
-	    node = NEW_CALL(node, rb_intern("b"), 0);
+	    VALUE ascii8bit = rb_enc_from_encoding(rb_ascii8bit_encoding());
+	    NODE *args = NEW_LIST(NEW_LIT(ascii8bit));
+	    node = NEW_CALL(node, rb_intern("force_encoding"), args);
 	}
 #endif
 #if STR_OPTION_FROZEN

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

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