mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* parse.y, re.c: re-applied revision 13092.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7eeabe2f58
commit
c456863bd6
3 changed files with 34 additions and 25 deletions
|
@ -1,7 +1,9 @@
|
|||
Sat Aug 25 15:20:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Sat Aug 25 16:06:40 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* io.c (swallow): removed condition using an unset variable.
|
||||
|
||||
* parse.y, re.c: re-applied revision 13092.
|
||||
|
||||
Sat Aug 25 11:45:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* encoding.c: provide basic features for M17N.
|
||||
|
|
16
parse.y
16
parse.y
|
@ -430,8 +430,8 @@ extern int rb_dvar_defined(ID);
|
|||
extern int rb_local_defined(ID);
|
||||
extern int rb_parse_in_eval(void);
|
||||
|
||||
static VALUE reg_compile_gen(struct parser_params*, const char *, long, int);
|
||||
#define reg_compile(ptr,len,options) reg_compile_gen(parser, ptr, len, options)
|
||||
static VALUE reg_compile_gen(struct parser_params*, VALUE, int);
|
||||
#define reg_compile(str,options) reg_compile_gen(parser, str, options)
|
||||
#else
|
||||
#define remove_begin(node) (node)
|
||||
#endif /* !RIPPER */
|
||||
|
@ -3629,14 +3629,14 @@ regexp : tREGEXP_BEG xstring_contents tREGEXP_END
|
|||
int options = $3;
|
||||
NODE *node = $2;
|
||||
if (!node) {
|
||||
node = NEW_LIT(rb_reg_compile(0, options & ~RE_OPTION_ONCE));
|
||||
node = NEW_LIT(reg_compile(0, options & ~RE_OPTION_ONCE));
|
||||
}
|
||||
else switch (nd_type(node)) {
|
||||
case NODE_STR:
|
||||
{
|
||||
VALUE src = node->nd_lit;
|
||||
nd_set_type(node, NODE_LIT);
|
||||
node->nd_lit = rb_reg_compile(src, options&~RE_OPTION_ONCE);
|
||||
node->nd_lit = reg_compile(src, options&~RE_OPTION_ONCE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -5277,7 +5277,6 @@ static int
|
|||
parser_heredoc_identifier(struct parser_params *parser)
|
||||
{
|
||||
int c = nextc(), term, func = 0, len;
|
||||
unsigned int uc;
|
||||
|
||||
if (c == '-') {
|
||||
c = nextc();
|
||||
|
@ -5662,7 +5661,6 @@ parser_yylex(struct parser_params *parser)
|
|||
register int c;
|
||||
int space_seen = 0;
|
||||
int cmd_state;
|
||||
unsigned char uc;
|
||||
enum lex_state_e last_state;
|
||||
#ifdef RIPPER
|
||||
int fallthru = Qfalse;
|
||||
|
@ -8117,10 +8115,12 @@ dvar_curr_gen(struct parser_params *parser, ID id)
|
|||
vtable_included(lvtbl->vars, id));
|
||||
}
|
||||
|
||||
VALUE rb_reg_compile(VALUE str, int options);
|
||||
|
||||
static VALUE
|
||||
reg_compile_gen(struct parser_params* parser, const char *ptr, long len, int options)
|
||||
reg_compile_gen(struct parser_params* parser, VALUE str, int options)
|
||||
{
|
||||
VALUE re = rb_reg_compile(STR_NEW(ptr, len), (options) & ~RE_OPTION_ONCE);
|
||||
VALUE re = rb_reg_compile(str, (options) & ~RE_OPTION_ONCE);
|
||||
|
||||
if (NIL_P(re)) {
|
||||
RB_GC_GUARD(re) = rb_obj_as_string(rb_errinfo());
|
||||
|
|
39
re.c
39
re.c
|
@ -624,10 +624,25 @@ rb_reg_raise(const char *s, long len, const char *err, VALUE re)
|
|||
rb_raise(rb_eRegexpError, "%s: %s", err, RSTRING_PTR(desc));
|
||||
}
|
||||
|
||||
static void
|
||||
rb_reg_raise_str(VALUE str, const char *err, VALUE re)
|
||||
static VALUE
|
||||
rb_reg_error_desc(VALUE str, int options, const char *err)
|
||||
{
|
||||
rb_reg_raise(RSTRING_PTR(str), RSTRING_LEN(str), err, re);
|
||||
char opts[6];
|
||||
VALUE desc = rb_str_buf_new2(err);
|
||||
|
||||
rb_str_buf_cat2(desc, ": /");
|
||||
rb_reg_expr_str(desc, RSTRING_PTR(str), RSTRING_LEN(str));
|
||||
opts[0] = '/';
|
||||
option_to_str(opts + 1, options);
|
||||
strlcat(opts, arg_kcode(options), sizeof(opts));
|
||||
rb_str_buf_cat2(desc, opts);
|
||||
return rb_exc_new3(rb_eRegexpError, desc);
|
||||
}
|
||||
|
||||
static void
|
||||
rb_reg_raise_str(VALUE str, int options, const char *err)
|
||||
{
|
||||
rb_exc_raise(rb_reg_error_desc(str, options, err));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1552,7 +1567,7 @@ rb_reg_new(VALUE s, int options)
|
|||
onig_errmsg_buffer err;
|
||||
|
||||
if (rb_reg_initialize_str(re, s, options, err) != 0) {
|
||||
rb_reg_raise_str(s, err, re);
|
||||
rb_reg_raise_str(s, options, err);
|
||||
}
|
||||
|
||||
return re;
|
||||
|
@ -1566,15 +1581,8 @@ rb_reg_compile(VALUE str, int options)
|
|||
|
||||
if (!str) str = rb_str_new(0,0);
|
||||
if (rb_reg_initialize_str(re, str, options, err) != 0) {
|
||||
char opts[6];
|
||||
VALUE desc = rb_str_buf_new2(err);
|
||||
|
||||
rb_str_buf_cat2(desc, ": /");
|
||||
rb_reg_expr_str(desc, RSTRING_PTR(str), RSTRING_LEN(str));
|
||||
opts[0] = '/';
|
||||
option_to_str(opts + 1, options);
|
||||
strlcat(opts, arg_kcode(options), sizeof(opts));
|
||||
return rb_str_buf_cat2(desc, opts);
|
||||
rb_set_errinfo(rb_reg_error_desc(str, options, err));
|
||||
return Qnil;
|
||||
}
|
||||
FL_SET(re, REG_LITERAL);
|
||||
return re;
|
||||
|
@ -1889,7 +1897,7 @@ rb_reg_initialize_m(int argc, VALUE *argv, VALUE self)
|
|||
str = argv[0];
|
||||
}
|
||||
if (rb_reg_initialize_str(self, str, flags, err) != 0) {
|
||||
rb_reg_raise_str(str, err, self);
|
||||
rb_reg_raise_str(str, flags, err);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -2148,7 +2156,6 @@ rb_reg_init_copy(VALUE copy, VALUE re)
|
|||
onig_errmsg_buffer err;
|
||||
const char *s;
|
||||
long len;
|
||||
int options;
|
||||
|
||||
if (copy == re) return copy;
|
||||
rb_check_frozen(copy);
|
||||
|
@ -2160,7 +2167,7 @@ rb_reg_init_copy(VALUE copy, VALUE re)
|
|||
s = RREGEXP(re)->str;
|
||||
len = RREGEXP(re)->len;
|
||||
if (rb_reg_initialize(copy, s, len, rb_enc_get(re), rb_reg_options(re), err) != 0) {
|
||||
rb_reg_raise(s, len, err, copy);
|
||||
rb_reg_raise(s, len, err, re);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue