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

ruby-changes:2673

From: ko1@a...
Date: 10 Dec 2007 06:48:22 +0900
Subject: [ruby-changes:2673] akr - Ruby:r14164 (trunk): * re.c (rb_reg_expr_str): use \xHH instead of \OOO.

akr	2007-12-10 06:48:05 +0900 (Mon, 10 Dec 2007)

  New Revision: 14164

  Modified files:
    trunk/ChangeLog
    trunk/file.c
    trunk/parse.y
    trunk/re.c
    trunk/regerror.c
    trunk/ruby.c
    trunk/string.c
    trunk/test/ruby/test_regexp.rb
    trunk/test/ruby/test_string.rb

  Log:
    * re.c (rb_reg_expr_str): use \xHH instead of \OOO.
    
    * regerror.c (to_ascii): ditto.
      (onig_snprintf_with_pattern): ditto.
      (onig_snprintf_with_pattern): ditto.
    
    * string.c (rb_str_inspect): ditto.
      (rb_str_dump): ditto.
    
    * parse.y (parser_yylex): ditto.
    
    * ruby.c (proc_options): ditto.
    
    * file.c (rb_f_test): ditto.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_string.rb?r1=14164&r2=14163
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/string.c?r1=14164&r2=14163
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/file.c?r1=14164&r2=14163
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ruby.c?r1=14164&r2=14163
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/parse.y?r1=14164&r2=14163
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14164&r2=14163
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_regexp.rb?r1=14164&r2=14163
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/re.c?r1=14164&r2=14163
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/regerror.c?r1=14164&r2=14163

Index: re.c
===================================================================
--- re.c	(revision 14163)
+++ re.c	(revision 14164)
@@ -259,7 +259,7 @@
 	    else if (!rb_enc_isspace(c, enc)) {
 		char b[8];
 
-		sprintf(b, "\\%03o", c);
+		sprintf(b, "\\x%02x", c);
 		rb_str_buf_cat(str, b, 4);
 	    }
 	    else {
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 14163)
+++ ChangeLog	(revision 14164)
@@ -1,3 +1,20 @@
+Mon Dec 10 06:44:47 2007  Tanaka Akira  <akr@f...>
+
+	* re.c (rb_reg_expr_str): use \xHH instead of \OOO.
+
+	* regerror.c (to_ascii): ditto.
+	  (onig_snprintf_with_pattern): ditto.
+	  (onig_snprintf_with_pattern): ditto.
+
+	* string.c (rb_str_inspect): ditto.
+	  (rb_str_dump): ditto.
+
+	* parse.y (parser_yylex): ditto.
+
+	* ruby.c (proc_options): ditto.
+
+	* file.c (rb_f_test): ditto.
+
 Mon Dec 10 06:41:00 2007  Tanaka Akira  <akr@f...>
 
 	* re.c (rb_reg_names): new method Regexp#names.
Index: regerror.c
===================================================================
--- regerror.c	(revision 14163)
+++ regerror.c	(revision 14164)
@@ -197,7 +197,7 @@
       code = ONIGENC_MBC_TO_CODE(enc, p, end);
       if (code >= 0x80) {
 	if (len + 5 <= buf_size) {
-	  sprintf((char* )(&(buf[len])), "\\%03o",
+	  sprintf((char* )(&(buf[len])), "\\x%02x",
 		  (unsigned int )(code & 0377));
 	  len += 5;
 	}
@@ -346,7 +346,7 @@
           int blen;
 
           while (len-- > 0) {
-            sprintf((char* )bs, "\\%03o", *p++ & 0377);
+            sprintf((char* )bs, "\\x%02x", *p++ & 0377);
             blen = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs);
             bp = bs;
             while (blen-- > 0) *s++ = *bp++;
@@ -355,7 +355,7 @@
       }
       else if (!ONIGENC_IS_CODE_PRINT(enc, *p) &&
 	       !ONIGENC_IS_CODE_SPACE(enc, *p)) {
-	sprintf((char* )bs, "\\%03o", *p++ & 0377);
+	sprintf((char* )bs, "\\x%02x", *p++ & 0377);
 	len = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs);
         bp = bs;
 	while (len-- > 0) *s++ = *bp++;
Index: string.c
===================================================================
--- string.c	(revision 14163)
+++ string.c	(revision 14164)
@@ -2971,7 +2971,7 @@
 escape_codepoint:
             for (q = p-n; q < p; q++) {
                 s = buf;
-                sprintf(buf, "\\%03o", *q & 0377);
+                sprintf(buf, "\\x%02x", *q & 0377);
                 while (*s) {
                     str_cat_char(result, *s++, enc);
                 }
@@ -3083,7 +3083,7 @@
 	}
 	else {
 	    *q++ = '\\';
-	    sprintf(q, "%03o", c&0xff);
+	    sprintf(q, "x%02x", c&0xff);
 	    q += 3;
 	}
     }
Index: parse.y
===================================================================
--- parse.y	(revision 14163)
+++ parse.y	(revision 14164)
@@ -7070,7 +7070,7 @@
 
       default:
 	if (!parser_is_identchar()) {
-	    rb_compile_error(PARSER_ARG  "Invalid char `\\%03o' in expression", c);
+	    rb_compile_error(PARSER_ARG  "Invalid char `\\x%02x' in expression", c);
 	    goto retry;
 	}
 
Index: ruby.c
===================================================================
--- ruby.c	(revision 14163)
+++ ruby.c	(revision 14164)
@@ -863,7 +863,7 @@
 		}
 		else {
                     rb_raise(rb_eRuntimeError,
-			"invalid option -\\%03o  (-h will show valid options)",
+			"invalid option -\\x%02x  (-h will show valid options)",
                         (int)(unsigned char)*s);
 		}
 	    }
Index: test/ruby/test_regexp.rb
===================================================================
--- test/ruby/test_regexp.rb	(revision 14163)
+++ test/ruby/test_regexp.rb	(revision 14164)
@@ -37,7 +37,7 @@
   end
 
   def test_to_s
-    assert_equal '(?-mix:\000)', Regexp.new("\0").to_s
+    assert_equal '(?-mix:\x00)', Regexp.new("\0").to_s
   end
 
   def test_union
Index: test/ruby/test_string.rb
===================================================================
--- test/ruby/test_string.rb	(revision 14163)
+++ test/ruby/test_string.rb	(revision 14164)
@@ -444,7 +444,7 @@
 
   def test_dump
     a= S("Test") << 1 << 2 << 3 << 9 << 13 << 10
-    assert_equal(S('"Test\\001\\002\\003\\t\\r\\n"'), a.dump)
+    assert_equal(S('"Test\\x01\\x02\\x03\\t\\r\\n"'), a.dump)
   end
 
   def test_dup
Index: file.c
===================================================================
--- file.c	(revision 14163)
+++ file.c	(revision 14164)
@@ -3486,7 +3486,7 @@
 	rb_raise(rb_eArgError, "unknown command ?%c", cmd);
     }
     else {
-	rb_raise(rb_eArgError, "unknown command ?\\%03o", cmd);
+	rb_raise(rb_eArgError, "unknown command ?\\x%02x", cmd);
     }
     return Qnil;		/* not reached */
 }

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

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