1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
matz 2008-01-14 13:49:29 +00:00
parent 45432a6d2b
commit d9ff499bf3
5 changed files with 16 additions and 11 deletions

View file

@ -1,3 +1,10 @@
Mon Jan 14 22:48:16 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* 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 <eban@ruby-lang.org> Mon Jan 14 22:25:02 2008 WATANABE Hirofumi <eban@ruby-lang.org>
* golf_prelude.rb: Shorter method name completion. Same method * golf_prelude.rb: Shorter method name completion. Same method

View file

@ -14,7 +14,7 @@ TRANSSODIR = $(ENCSODIR)/trans
DLEXT = @DLEXT@ DLEXT = @DLEXT@
OBJEXT = @OBJEXT@ OBJEXT = @OBJEXT@
BUILTIN_ENCS = ascii.c \ BUILTIN_ENCS = ascii.c us_ascii.c\
unicode.c utf8.c unicode.c utf8.c
RUBY_SO_NAME = @RUBY_SO_NAME@ RUBY_SO_NAME = @RUBY_SO_NAME@

View file

@ -304,9 +304,12 @@ rb_enc_alias(const char *alias, const char *orig)
enum { enum {
ENCINDEX_ASCII, ENCINDEX_ASCII,
ENCINDEX_UTF8, ENCINDEX_UTF8,
ENCINDEX_US_ASCII,
ENCINDEX_BUILTIN_MAX ENCINDEX_BUILTIN_MAX
}; };
extern rb_encoding OnigEncodingUS_ASCII;
void void
rb_enc_init(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) #define ENC_REGISTER(enc) enc_register_at(ENCINDEX_##enc, rb_enc_name(ONIG_ENCODING_##enc), ONIG_ENCODING_##enc)
ENC_REGISTER(ASCII); ENC_REGISTER(ASCII);
ENC_REGISTER(UTF8); ENC_REGISTER(UTF8);
enc_register_at(ENCINDEX_US_ASCII, rb_enc_name(&OnigEncodingUS_ASCII), &OnigEncodingUS_ASCII);
#undef ENC_REGISTER #undef ENC_REGISTER
} }

12
re.c
View file

@ -142,12 +142,6 @@ rb_memsearch(const void *x0, long m, const void *y0, long n)
#define ARG_ENCODING_FIXED 16 #define ARG_ENCODING_FIXED 16
#define ARG_ENCODING_NONE 32 #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 static int
char_to_option(int c) char_to_option(int c)
{ {
@ -191,13 +185,13 @@ rb_char_to_option_kcode(int c, int *option, int *kcode)
*kcode = -1; *kcode = -1;
return (*option = ARG_ENCODING_NONE); return (*option = ARG_ENCODING_NONE);
case 'e': case 'e':
*kcode = ARG_KCODE_EUC; *kcode = rb_enc_find_index("EUC-JP");
break; break;
case 's': case 's':
*kcode = ARG_KCODE_SJIS; *kcode = rb_enc_find_index("Shitf_JIS");
break; break;
case 'u': case 'u':
*kcode = ARG_KCODE_UTF8; *kcode = rb_enc_find_index("UTF-8");
break; break;
default: default:
*kcode = -1; *kcode = -1;

View file

@ -37,7 +37,7 @@ $stderr.reopen($stdout)
error = '' error = ''
srcdir = File.dirname(__FILE__) 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/ if line =~ /^end of test/
print "\ntest succeeded\n" print "\ntest succeeded\n"
exit true exit true