From d9ff499bf3b4772b2657c8182f33180e9f70db49 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 14 Jan 2008 13:49:29 +0000 Subject: [PATCH] * re.c (rb_char_to_option_kcode): use rb_enc_find_index() instead of using fixed index value. * enc/Makefile.in (encsrcdir): make US-ASCII built-in. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ enc/Makefile.in | 2 +- encoding.c | 4 ++++ re.c | 12 +++--------- rubytest.rb | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 92ebac53e0..b8229f1590 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Jan 14 22:48:16 2008 Yukihiro Matsumoto + + * re.c (rb_char_to_option_kcode): use rb_enc_find_index() instead + of using fixed index value. + + * enc/Makefile.in (encsrcdir): make US-ASCII built-in. + Mon Jan 14 22:25:02 2008 WATANABE Hirofumi * golf_prelude.rb: Shorter method name completion. Same method diff --git a/enc/Makefile.in b/enc/Makefile.in index f33a75d3d2..a1f9142a16 100644 --- a/enc/Makefile.in +++ b/enc/Makefile.in @@ -14,7 +14,7 @@ TRANSSODIR = $(ENCSODIR)/trans DLEXT = @DLEXT@ OBJEXT = @OBJEXT@ -BUILTIN_ENCS = ascii.c \ +BUILTIN_ENCS = ascii.c us_ascii.c\ unicode.c utf8.c RUBY_SO_NAME = @RUBY_SO_NAME@ diff --git a/encoding.c b/encoding.c index 01677d1b92..4e3a02f173 100644 --- a/encoding.c +++ b/encoding.c @@ -304,9 +304,12 @@ rb_enc_alias(const char *alias, const char *orig) enum { ENCINDEX_ASCII, ENCINDEX_UTF8, + ENCINDEX_US_ASCII, ENCINDEX_BUILTIN_MAX }; +extern rb_encoding OnigEncodingUS_ASCII; + void rb_enc_init(void) { @@ -314,6 +317,7 @@ rb_enc_init(void) #define ENC_REGISTER(enc) enc_register_at(ENCINDEX_##enc, rb_enc_name(ONIG_ENCODING_##enc), ONIG_ENCODING_##enc) ENC_REGISTER(ASCII); ENC_REGISTER(UTF8); + enc_register_at(ENCINDEX_US_ASCII, rb_enc_name(&OnigEncodingUS_ASCII), &OnigEncodingUS_ASCII); #undef ENC_REGISTER } diff --git a/re.c b/re.c index 76857dd86a..3f898d7121 100644 --- a/re.c +++ b/re.c @@ -142,12 +142,6 @@ rb_memsearch(const void *x0, long m, const void *y0, long n) #define ARG_ENCODING_FIXED 16 #define ARG_ENCODING_NONE 32 -#define ARG_KCODE_NONE 0 -#define ARG_KCODE_EUC 1 -#define ARG_KCODE_SJIS 2 -#define ARG_KCODE_UTF8 3 -#define ARG_KCODE_MASK 3 - static int char_to_option(int c) { @@ -191,13 +185,13 @@ rb_char_to_option_kcode(int c, int *option, int *kcode) *kcode = -1; return (*option = ARG_ENCODING_NONE); case 'e': - *kcode = ARG_KCODE_EUC; + *kcode = rb_enc_find_index("EUC-JP"); break; case 's': - *kcode = ARG_KCODE_SJIS; + *kcode = rb_enc_find_index("Shitf_JIS"); break; case 'u': - *kcode = ARG_KCODE_UTF8; + *kcode = rb_enc_find_index("UTF-8"); break; default: *kcode = -1; diff --git a/rubytest.rb b/rubytest.rb index eecc588256..6c3939a0ac 100755 --- a/rubytest.rb +++ b/rubytest.rb @@ -37,7 +37,7 @@ $stderr.reopen($stdout) error = '' srcdir = File.dirname(__FILE__) -`#{ruby} -I#{srcdir} -I#{srcdir}/lib #{srcdir}/sample/test.rb`.each_line do |line| +`#{ruby} -I.ext/#{RUBY_PLATFORM} -I#{srcdir}/lib #{srcdir}/sample/test.rb`.each_line do |line| if line =~ /^end of test/ print "\ntest succeeded\n" exit true