summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-02-08 09:19:27 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-02-08 09:19:27 +0000
commited520cf6e96dcae2b7900127e325fcea1f4abc26 (patch)
tree89c098f2e02099588c8b4f74fbb8e37c15045d49 /parse.y
parentb576f57aa02c4983eeb081f625c45b9445c50538 (diff)
* parse.y (parse_quotedwords): %w should allow parenthesis escape.
* parse.y (parse_qstring): %q should allow terminator escape. * re.c (rb_reg_options): new method to give an option values. * parse.y (cond0): disable special treating of integer literal in conditional unless option -e is supplied. changes current behavior. experimental. * parse.y (cond0): give warning for string/integer literals and dot operators in conditionals unless option -e is supplied. * re.c (rb_reg_equal): all option flags should be same to be equal. * error.c (Init_Exception): make Interrupt a subclass of SignalException. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y42
1 files changed, 30 insertions, 12 deletions
diff --git a/parse.y b/parse.y
index 00ca543606..d7b5d30e41 100644
--- a/parse.y
+++ b/parse.y
@@ -2545,13 +2545,12 @@ parse_qstring(term, paren)
c = '\\';
break;
- case '\'':
- if (term == '\'') {
- c = '\'';
- break;
- }
- /* fall through */
default:
+ /* fall through */
+ if (c == term || (paren && c == paren)) {
+ tokadd(c);
+ continue;
+ }
tokadd('\\');
}
}
@@ -2606,7 +2605,7 @@ parse_quotedwords(term, paren)
c = '\\';
break;
default:
- if (c == term) {
+ if (c == term || (paren && c == paren)) {
tokadd(c);
continue;
}
@@ -4436,12 +4435,26 @@ assign_in_cond(node)
return 1;
}
+static int
+e_option_supplied()
+{
+ if (strcmp(ruby_sourcefile, "-e") == 0)
+ return Qtrue;
+ return Qfalse;
+}
+
static void
warn_unless_e_option(str)
const char *str;
{
- if (strcmp(ruby_sourcefile, "-e") != 0)
- rb_warning(str);
+ if (e_option_supplied()) rb_warn(str);
+}
+
+static void
+warning_unless_e_option(str)
+ const char *str;
+{
+ if (e_option_supplied()) rb_warning(str);
}
static NODE*
@@ -4456,12 +4469,15 @@ cond0(node, logop)
case NODE_DSTR:
if (logop) break;
nd_set_type(node, NODE_DREGX);
- /* fall through */
+ warn_unless_e_option("string literal in condition");
+ goto dregex;
+
case NODE_DREGX:
case NODE_DREGX_ONCE:
+ warning_unless_e_option("regex literal in condition");
+ dregex:
local_cnt('_');
local_cnt('~');
- warn_unless_e_option("string/regex literal in condition");
return NEW_MATCH2(node, NEW_GVAR(rb_intern("$_")));
case NODE_DOT2:
@@ -4477,20 +4493,22 @@ cond0(node, logop)
case NODE_STR:
if (logop) break;
node->nd_lit = rb_reg_new(RSTRING(node->nd_lit)->ptr,RSTRING(node->nd_lit)->len,0);
+ warn_unless_e_option("string literal in condition");
goto regexp;
case NODE_LIT:
switch (TYPE(node->nd_lit)) {
case T_REGEXP:
+ warning_unless_e_option("regex literal in condition");
regexp:
nd_set_type(node, NODE_MATCH);
local_cnt('_');
local_cnt('~');
- warn_unless_e_option("string/regex literal in condition");
break;
case T_FIXNUM:
if (logop) break;
+ if (!e_option_supplied()) break;
warn_unless_e_option("integer literal in condition");
return call_op(node,tEQ,1,NEW_GVAR(rb_intern("$.")));
}