diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-06-26 07:19:02 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-06-26 07:19:02 +0000 |
commit | fdfa583944cbe769f2085b0cfdce9ffd3ce8a3c8 (patch) | |
tree | da990130a4ebd05d4f0e6cfdbb2bd8cf268ba93b | |
parent | 12b0a1b2252eb99dad90bf87c9e39470451560bd (diff) |
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | Makefile.in | 1 | ||||
-rw-r--r-- | defines.h | 10 | ||||
-rw-r--r-- | re.c | 35 | ||||
-rw-r--r-- | regex.c | 29 |
4 files changed, 35 insertions, 40 deletions
diff --git a/Makefile.in b/Makefile.in index c41f0c1750..09ae22c6a9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -206,6 +206,7 @@ process.o: process.c ruby.h config.h defines.h intern.h rubysig.h st.h random.o: random.c ruby.h config.h defines.h intern.h range.o: range.c ruby.h config.h defines.h intern.h re.o: re.c ruby.h config.h defines.h intern.h re.h regex.h +regex.o: regex.c config.h regex.h util.h ruby.o: ruby.c ruby.h config.h defines.h intern.h dln.h signal.o: signal.c ruby.h config.h defines.h intern.h rubysig.h sprintf.o: sprintf.c ruby.h config.h defines.h intern.h @@ -12,13 +12,13 @@ #define RUBY -/* define EUC/SJIS for default kanji-code */ +/* define RUBY_USE_EUC/SJIS for default kanji-code */ #if defined(MSDOS) || defined(__CYGWIN32__) || defined(__human68k__) || defined(__MACOS__) -#undef EUC -#define SJIS +#undef RUBY_USE_EUC +#define RUBY_USE_SJIS #else -#define EUC -#undef SJIS +#define RUBY_USE_EUC +#undef RUBY_USE_SJIS #endif #ifdef NeXT @@ -98,10 +98,10 @@ str_cicmp(str1, str2) #define KCODE_MASK (KCODE_EUC|KCODE_SJIS) static int reg_kcode = -#ifdef EUC +#ifdef RUBY_USE_EUC KCODE_EUC; #else -# ifdef SJIS +# ifdef RUBY_USE_SJIS KCODE_SJIS; # else KCODE_NONE; @@ -783,20 +783,16 @@ reg_s_new(argc, argv, self) } src = argv[0]; - switch (TYPE(src)) { - case T_STRING: - return reg_new_1(self, RSTRING(src)->ptr, RSTRING(src)->len, flag); - break; - - case T_REGEXP: + if (TYPE(src) == T_REGEXP) { return reg_new_1(self, RREGEXP(src)->str, RREGEXP(src)->len, flag); - break; - - default: - Check_Type(src, T_STRING); } + else { + char *p; + int len; - return Qnil; /* not reached */ + p = str2cstr(src, &len); + return reg_new_1(self, p, len, flag); + } } static VALUE @@ -992,8 +988,7 @@ static void kcode_setter(val) struct RString *val; { - Check_Type(val, T_STRING); - rb_set_kcode(val->ptr); + rb_set_kcode(STR2CSTR(val)); } static VALUE @@ -1023,6 +1018,16 @@ Init_Regexp() | RE_BACKSLASH_ESCAPE_IN_LISTS); re_set_casetable(casetable); +#ifdef RUBY_USE_EUC + mbcinit(MBCTYPE_EUC); +#else +#ifdef RUBY_USE_SJIS + mbcinit(MBCTYPE_SJIS); +#else + mbcinit(MBCTYPE_ASCII); +#endif +#endif + rb_define_virtual_variable("$~", match_getter, match_setter); rb_define_virtual_variable("$&", last_match_getter, 0); rb_define_virtual_variable("$`", prematch_getter, 0); @@ -43,7 +43,6 @@ #endif #include "config.h" -#include "defines.h" void *xmalloc P((unsigned long)); void *xcalloc P((unsigned long,unsigned long)); @@ -54,17 +53,17 @@ void free P((void*)); #ifndef NO_ALLOCA /* Make alloca work the best possible way. */ #ifdef __GNUC__ -#ifndef atarist -#ifndef alloca -#define alloca __builtin_alloca -#endif -#endif /* atarist */ -#else -#if defined(HAVE_ALLOCA_H) && !defined(__GNUC__) -#include <alloca.h> +# ifndef atarist +# ifndef alloca +# define alloca __builtin_alloca +# endif +# endif /* atarist */ #else +# if defined(HAVE_ALLOCA_H) +# include <alloca.h> +# else char *alloca(); -#endif +# endif #endif /* __GNUC__ */ #ifdef _AIX @@ -4120,18 +4119,8 @@ static const unsigned char mbctab_sjis[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; -#ifdef EUC -const unsigned char *mbctab = mbctab_euc; -int current_mbctype = MBCTYPE_EUC; -#else -#ifdef SJIS -const unsigned char *mbctab = mbctab_sjis; -int current_mbctype = MBCTYPE_SJIS; -#else const unsigned char *mbctab = mbctab_ascii; int current_mbctype = MBCTYPE_ASCII; -#endif -#endif void mbcinit(mbctype) |