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

* parse.y (arg): parse 'lhs = a rescue b' as 'lhs=(a rescue b)'.

* io.c (rb_io_fread): should not clearerr() if there's no filled
  buffer (i.e. rb_io_fread() returning zero).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-03-03 05:17:39 +00:00
parent 0cd0eab641
commit 6a6d0ad220
7 changed files with 62 additions and 46 deletions

View file

@ -1,3 +1,12 @@
Mon Mar 3 11:29:04 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (arg): parse 'lhs = a rescue b' as 'lhs=(a rescue b)'.
Mon Mar 3 02:53:52 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_io_fread): should not clearerr() if there's no filled
buffer (i.e. rb_io_fread() returning zero).
Mon Mar 03 01:42:35 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* misc/ruby-mode.el (ruby-expr-beg): escaped char syntax.

6
io.c
View file

@ -710,8 +710,10 @@ rb_io_fread(ptr, len, f)
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
clearerr(f);
return len - n;
if (len - n > 0) {
clearerr(f);
return len - n;
}
}
return 0;
}

View file

@ -365,7 +365,7 @@ class Date
when Numeric; return @ajd <=> other
when Date; return @ajd <=> other.ajd
end
raise TypeError, 'expected numeric or date'
nil
end
def === (other)
@ -373,7 +373,7 @@ class Date
when Numeric; return jd == other
when Date; return jd == other.jd
end
raise TypeError, 'expected numeric or date'
false
end
def >> (n)

View file

@ -158,10 +158,9 @@ class Context
def debug_eval(str, binding)
begin
val = eval(str, binding)
val
rescue StandardError, ScriptError
at = eval("caller(0)", binding)
stdout.printf "%s:%s\n", at.shift, $!.to_s.sub(/\(eval\):1:(in `.*?':)?/, '') #`
rescue StandardError, ScriptError => e
at = eval("caller(1)", binding)
stdout.printf "%s:%s\n", at.shift, e.to_s.sub(/\(eval\):1:(in `.*?':)?/, '')
for i in at
stdout.printf "\tfrom %s\n", i
end
@ -297,6 +296,12 @@ class Context
stdout.print "Trace off.\n"
end
when /^\s*b(?:reak)?\s+(.+)[#.](.+)$/
pos = $2.intern.id2name
file = debug_eval($1, binding)
break_points.push [true, 0, file, pos]
stdout.printf "Set breakpoint %d at %s.%s\n", break_points.size, file, pos
when /^\s*b(?:reak)?\s+(?:(.+):)?(.+)$/
pos = $2
file = File.basename($1 || file)
@ -646,7 +651,7 @@ EOHELP
def check_break_points(file, pos, binding, id)
return false if break_points.empty?
file = File.basename(file)
# file = File.basename(file)
n = 1
for b in break_points
if b[0]
@ -709,7 +714,8 @@ EOHELP
when 'call'
@frames.unshift [binding, file, line, id]
if check_break_points(file, id.id2name, binding, id) or
check_break_points(klass.to_s, id.id2name, binding, id)
check_break_points(klass.to_s, id.id2name, binding, id) or
check_break_points(klass, id.id2name, binding, id)
suspend_all
debug_command(file, line, id, binding)
end

62
parse.y
View file

@ -240,7 +240,7 @@ static void top_local_setup();
%type <node> singleton strings string string1 xstring regexp
%type <node> string_contents xstring_contents string_content
%type <node> words qwords word_list qword_list word
%type <node> literal numeric dsym cpath clhs
%type <node> literal numeric dsym cpath
%type <node> bodystmt compstmt stmts stmt expr arg primary command command_call method_call
%type <node> expr_value arg_value primary_value
%type <node> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure
@ -290,7 +290,7 @@ static void top_local_setup();
%nonassoc tLOWEST
%nonassoc tLBRACE_ARG
%left kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD
%nonassoc kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD
%left kOR kAND
%right kNOT
%nonassoc kDEFINED
@ -451,6 +451,10 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
nd_set_type($$, NODE_WHILE);
}
}
| stmt kRESCUE_MOD stmt
{
$$ = NEW_RESCUE($1, NEW_RESBODY(0,$3,0), 0);
}
| klBEGIN
{
if (in_def || in_single) {
@ -475,6 +479,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
}
| lhs '=' command_call
{
value_expr($3);
$$ = node_assign($1, $3);
}
| mlhs '=' command_call
@ -483,10 +488,6 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
$1->nd_value = NEW_RESTARY($3);
$$ = $1;
}
| clhs '=' command_call
{
$$ = node_assign($1, $3);
}
| var_lhs tOP_ASGN command_call
{
value_expr($3);
@ -574,10 +575,6 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
{
$$ = node_assign($1, NEW_SVALUE($3));
}
| clhs '=' mrhs
{
$$ = node_assign($1, NEW_SVALUE($3));
}
| mlhs '=' arg_value
{
$1->nd_value = $3;
@ -588,10 +585,6 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
$1->nd_value = $3;
$$ = $1;
}
| clhs '=' arg
{
$$ = node_assign($1, $3);
}
| expr
;
@ -612,10 +605,6 @@ expr : command_call
{
$$ = NEW_NOT(cond($2));
}
| arg kRESCUE_MOD command_call
{
$$ = NEW_RESCUE($1, NEW_RESBODY(0,$3,0), 0);
}
| arg
;
@ -808,6 +797,12 @@ mlhs_node : variable
{
$$ = attrset($1, $3);
}
| primary_value tCOLON2 tCONSTANT
{
if (in_def || in_single)
yyerror("dynamic constant assignment");
$$ = NEW_CDECL(0, 0, NEW_COLON2($1, $3));
}
| backref
{
rb_backref_error($1);
@ -835,19 +830,17 @@ lhs : variable
{
$$ = attrset($1, $3);
}
| backref
{
rb_backref_error($1);
$$ = 0;
}
;
clhs : primary_value tCOLON2 tCONSTANT
| primary_value tCOLON2 tCONSTANT
{
if (in_def || in_single)
yyerror("dynamic constant assignment");
$$ = NEW_CDECL(0, 0, NEW_COLON2($1, $3));
}
| backref
{
rb_backref_error($1);
$$ = 0;
}
;
cname : tIDENTIFIER
@ -933,14 +926,17 @@ reswords : k__LINE__ | k__FILE__ | klBEGIN | klEND
| kDEFINED | kDO | kELSE | kELSIF | kEND | kENSURE | kFALSE
| kFOR | kIF_MOD | kIN | kMODULE | kNEXT | kNIL | kNOT
| kOR | kREDO | kRESCUE | kRETRY | kRETURN | kSELF | kSUPER
| kTHEN | kTRUE | kUNDEF | kUNLESS_MOD | kUNTIL_MOD | kWHEN
| kWHILE_MOD | kYIELD | kRESCUE_MOD
| kTHEN | kTRUE | kUNDEF | kWHEN | kYIELD
;
arg : lhs '=' arg
{
$$ = node_assign($1, $3);
}
| lhs '=' arg kRESCUE_MOD arg
{
$$ = node_assign($1, NEW_RESCUE($3, NEW_RESBODY(0,$5,0), 0));
}
| var_lhs tOP_ASGN arg
{
value_expr($3);
@ -1019,6 +1015,10 @@ arg : lhs '=' arg
$$ = NEW_OP_ASGN2($1, $3, $4, $5);
fixpos($$, $1);
}
| primary_value tCOLON2 tCONSTANT tOP_ASGN arg
{
yyerror("constant re-assignment");
}
| backref tOP_ASGN arg
{
rb_backref_error($1);
@ -1157,10 +1157,6 @@ arg : lhs '=' arg
{
$$ = logop(NODE_OR, $1, $3);
}
| arg kRESCUE_MOD arg
{
$$ = NEW_RESCUE($1, NEW_RESBODY(0,$3,0), 0);
}
| kDEFINED opt_nl {in_defined = 1;} arg
{
in_defined = 0;
@ -1674,11 +1670,13 @@ primary_value : primary
;
then : term
| ':'
| kTHEN
| term kTHEN
;
do : term
| ':'
| kDO_COND
;

View file

@ -1,5 +1,6 @@
#! /usr/bin/env ruby
$KCODE = "none"
$testnum=0
$ntest=0
$failed = 0

View file

@ -1,11 +1,11 @@
#define RUBY_VERSION "1.8.0"
#define RUBY_RELEASE_DATE "2003-02-28"
#define RUBY_RELEASE_DATE "2003-03-03"
#define RUBY_VERSION_CODE 180
#define RUBY_RELEASE_CODE 20030228
#define RUBY_RELEASE_CODE 20030303
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2003
#define RUBY_RELEASE_MONTH 02
#define RUBY_RELEASE_DAY 28
#define RUBY_RELEASE_MONTH 03
#define RUBY_RELEASE_DAY 03