From f4592d7bb0c88ab22e15e632afb70279f119af4e Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 9 Dec 2007 21:48:05 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 17 +++++++++++++++++ file.c | 2 +- parse.y | 2 +- re.c | 2 +- regerror.c | 6 +++--- ruby.c | 2 +- string.c | 4 ++-- test/ruby/test_regexp.rb | 2 +- test/ruby/test_string.rb | 2 +- 9 files changed, 28 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2c89b1e624..5f082e5bdb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +Mon Dec 10 06:44:47 2007 Tanaka Akira + + * 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 * re.c (rb_reg_names): new method Regexp#names. diff --git a/file.c b/file.c index c3cf72cb33..514bd1de35 100644 --- a/file.c +++ b/file.c @@ -3486,7 +3486,7 @@ rb_f_test(int argc, VALUE *argv) 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 */ } diff --git a/parse.y b/parse.y index 2aff7adaa9..ddfca76626 100644 --- a/parse.y +++ b/parse.y @@ -7070,7 +7070,7 @@ parser_yylex(struct parser_params *parser) 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; } diff --git a/re.c b/re.c index 9592e91591..563acbf3af 100644 --- a/re.c +++ b/re.c @@ -259,7 +259,7 @@ rb_reg_expr_str(VALUE str, const char *s, long len) 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 { diff --git a/regerror.c b/regerror.c index 61187d4a61..cede3f8da6 100644 --- a/regerror.c +++ b/regerror.c @@ -197,7 +197,7 @@ static int to_ascii(OnigEncoding enc, UChar *s, UChar *end, 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 @@ onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist) 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 @@ onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist) } 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++; diff --git a/ruby.c b/ruby.c index 486780467b..fa21bb53b1 100644 --- a/ruby.c +++ b/ruby.c @@ -863,7 +863,7 @@ proc_options(int argc, char **argv, struct cmdline_options *opt) } 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); } } diff --git a/string.c b/string.c index b716c16b15..a6f8bf1160 100644 --- a/string.c +++ b/string.c @@ -2971,7 +2971,7 @@ rb_str_inspect(VALUE str) 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 @@ rb_str_dump(VALUE str) } else { *q++ = '\\'; - sprintf(q, "%03o", c&0xff); + sprintf(q, "x%02x", c&0xff); q += 3; } } diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 52b62f6421..5cb6c810da 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -37,7 +37,7 @@ class TestRegexp < Test::Unit::TestCase 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 diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index ff9b6f8e70..5657197834 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -444,7 +444,7 @@ class TestString < Test::Unit::TestCase 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