summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-04-09 18:04:08 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-04-09 18:04:08 +0000
commit178a2f7064af173ed2b223b9a1c70e77dd016e49 (patch)
tree16c6920c4e3a7a6abb9144fdd1c91ee166a7bbba
parent529bc6166cb3e6083678c278d8a871e803420804 (diff)
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog17
-rw-r--r--MANIFEST2
-rw-r--r--eval.c24
-rw-r--r--io.c4
-rw-r--r--lib/telnet.rb404
-rw-r--r--parse.y22
-rw-r--r--re.c4
-rw-r--r--rubytest.rb2
-rw-r--r--sample/test.rb22
9 files changed, 282 insertions, 219 deletions
diff --git a/ChangeLog b/ChangeLog
index 093461db4e..061d3e05d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Thu Apr 8 18:10:37 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.2.4 (stable) released.
+
+Tue Apr 6 17:33:00 1999 Inaba Hiroto <inaba@st.rim.or.jp>
+
+ * eval.c (rb_eval): flip3 did not work properly.
+
+Tue Apr 6 14:02:39 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * re.c (reg_match): should return false, not nil.
+
+ * re.c (reg_match2): ditto.
+
Fri Mar 12 12:27:55 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* string.c (str_index): negative offset.
@@ -58,6 +72,7 @@ Tue Feb 16 23:42:51 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
* configure.in: FreeBSD objformat patch
+>>>>>>> 1.1.1.2.2.163
Tue Feb 16 12:40:55 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* version 1.2.3 (stable) released.
@@ -275,7 +290,7 @@ Sat Oct 31 23:18:34 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* string.c (rb_str_split_method): if LIMIT is unspecified,
trailing null fields are stripped.
-Sat Oct 31 04:16:14 1998 Inaba Hiroto <inaba@st.rim.or.jp>
+Sat Oct 31 04:16:14 1998 Inaba Hiroto <inaba@st.rim.or.jp>
* string.c (str_aref): regexp index SEGVed.
diff --git a/MANIFEST b/MANIFEST
index 9a354082fa..7378c0e98c 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -103,6 +103,7 @@ lib/finalize.rb
lib/ftplib.rb
lib/ftools.rb
lib/getopts.rb
+lib/getoptlong.rb
lib/importenv.rb
lib/jcode.rb
lib/mailread.rb
@@ -117,6 +118,7 @@ lib/ostruct.rb
lib/parsearg.rb
lib/parsedate.rb
lib/ping.rb
+lib/profile.rb
lib/pstore.rb
lib/rational.rb
lib/readbytes.rb
diff --git a/eval.c b/eval.c
index d6b801fcfd..56be8c72d4 100644
--- a/eval.c
+++ b/eval.c
@@ -922,22 +922,19 @@ static VALUE
eval_node(self)
VALUE self;
{
- VALUE result = Qnil;
- NODE *tree;
+ NODE *beg_tree, *tree;
- if (eval_tree_begin) {
- tree = eval_tree_begin;
+ beg_tree = eval_tree_begin;
+ tree = eval_tree;
+ if (beg_tree) {
eval_tree_begin = 0;
- rb_eval(self, tree);
+ rb_eval(self, beg_tree);
}
- if (!eval_tree) return Qnil;
-
- tree = eval_tree;
+ if (!tree) return Qnil;
eval_tree = 0;
- result = rb_eval(self, tree);
- return result;
+ return rb_eval(self, tree);
}
int rb_in_eval;
@@ -1950,7 +1947,7 @@ rb_eval(self, node)
case NODE_FLIP2: /* like AWK */
if (node->nd_state == 0) {
if (RTEST(rb_eval(self, node->nd_beg))) {
- node->nd_state = rb_eval(self, node->nd_end)?0:1;
+ node->nd_state = RTEST(rb_eval(self, node->nd_end))?0:1;
result = TRUE;
}
else {
@@ -1971,7 +1968,9 @@ rb_eval(self, node)
node->nd_state = 1;
result = TRUE;
}
- result = FALSE;
+ else {
+ result = FALSE;
+ }
}
else {
if (RTEST(rb_eval(self, node->nd_end))) {
@@ -4894,6 +4893,7 @@ blk_copy_prev(block)
tmp = ALLOC_N(struct BLOCK, 1);
MEMCPY(tmp, block->prev, struct BLOCK, 1);
tmp->frame.argv = ALLOC_N(VALUE, tmp->frame.argc);
+ scope_dup(tmp->scope);
MEMCPY(tmp->frame.argv, block->frame.argv, VALUE, tmp->frame.argc);
block->prev = tmp;
block = tmp;
diff --git a/io.c b/io.c
index 8a2a5bc3a9..3e0ff9e90b 100644
--- a/io.c
+++ b/io.c
@@ -1744,8 +1744,8 @@ next_argv()
next_p = 0;
if (RARRAY(rb_argv)->len > 0) {
filename = ary_shift(rb_argv);
- fn = RSTRING(filename)->ptr;
- if (RSTRING(filename)->len == 1 && fn[0] == '-') {
+ fn = STR2CSTR(filename);
+ if (strlen(fn) == 1 && fn[0] == '-') {
file = rb_stdin;
if (inplace) {
rb_defout = rb_stdout;
diff --git a/lib/telnet.rb b/lib/telnet.rb
index e3c590c35d..098cbc9772 100644
--- a/lib/telnet.rb
+++ b/lib/telnet.rb
@@ -1,166 +1,193 @@
-#
-# telnet.rb
-# ver0.16 1998/10/09
-# Wakou Aoyama <wakou@fsinet.or.jp>
-#
-# ver0.16 1998/10/09
-# preprocess method change for the better
-# add binmode method.
-# change default Binmode
-# TRUE --> FALSE
-#
-# ver0.15 1998/10/04
-# add telnetmode method.
-#
-# ver0.141 1998/09/22
-# change default prompt
-# /[$%#>] $/ --> /[$%#>] \Z/
-#
-# ver0.14 1998/09/01
-# IAC WILL SGA send EOL --> CR+NULL
-# IAC WILL SGA IAC DO BIN send EOL --> CR
-# NONE send EOL --> LF
-# add Dump_log option.
-#
-# ver0.13 1998/08/25
-# add print method.
-#
-# ver0.122 1998/08/05
-# support for HP-UX 10.20 thanks to WATANABE Tetsuya <tetsu@jpn.hp.com>
-# socket.<< --> socket.write
-#
-# ver0.121 1998/07/15
-# string.+= --> string.concat
-#
-# ver0.12 1998/06/01
-# add timeout, waittime.
-#
-# ver0.11 1998/04/21
-# add realtime output.
-#
-# ver0.10 1998/04/13
-# first release.
-#
-# == make new Telnet object
-# host = Telnet.new({"Binmode" => FALSE, default: FALSE
-# "Host" => "localhost", default: "localhost"
-# "Output_log" => "output_log", default: not output
-# "Dump_log" => "dump_log", default: not output
-# "Port" => 23, default: 23
-# "Prompt" => /[$%#>] \Z/, default: /[$%#>] \Z/
-# "Telnetmode" => TRUE, default: TRUE
-# "Timeout" => 10, default: 10
-# "Waittime" => 0}) default: 0
-#
-# if set "Telnetmode" option FALSE. not TELNET command interpretation.
-# "Waittime" is time to confirm "Prompt". There is a possibility that
-# the same character as "Prompt" is included in the data, and, when
-# the network or the host is very heavy, the value is enlarged.
-#
-# == wait for match
-# line = host.waitfor(/match/)
-# line = host.waitfor({"Match" => /match/,
-# "String" => "string",
-# "Timeout" => secs})
-# if set "String" option. Match = Regexp.new(quote(string))
-#
-# realtime output. of cource, set sync=TRUE or flush is necessary.
-# host.waitfor(/match/){|c| print c }
-# host.waitfor({"Match" => /match/,
-# "String" => "string",
-# "Timeout" => secs}){|c| print c}
-#
-# == send string and wait prompt
-# line = host.cmd("string")
-# line = host.cmd({"String" => "string",
-# "Prompt" => /[$%#>] \Z/,
-# "Timeout" => 10})
-#
-# realtime output. of cource, set sync=TRUE or flush is necessary.
-# host.cmd("string"){|c| print c }
-# host.cmd({"String" => "string",
-# "Prompt" => /[$%#>] \Z/,
-# "Timeout" => 10}){|c| print c }
-#
-# == send string
-# host.print("string")
-#
-# == turn telnet command interpretation
-# host.telnetmode # turn on/off
-# host.telnetmode(TRUE) # on
-# host.telnetmode(FALSE) # off
-#
-# == toggle newline translation
-# host.binmode # turn TRUE/FALSE
-# host.binmode(TRUE) # no translate newline
-# host.binmode(FALSE) # translate newline
-#
-# == login
-# host.login("username", "password")
-# host.login({"Name" => "username",
-# "Password" => "password",
-# "Prompt" => /[$%#>] \Z/,
-# "Timeout" => 10})
-#
-# realtime output. of cource, set sync=TRUE or flush is necessary.
-# host.login("username", "password"){|c| print c }
-# host.login({"Name" => "username",
-# "Password" => "password",
-# "Prompt" => /[$%#>] \Z/,
-# "Timeout" => 10}){|c| print c }
-#
-# and Telnet object has socket class methods
-#
-# == sample
-# localhost = Telnet.new({"Host" => "localhost",
-# "Timeout" => 10,
-# "Prompt" => /[$%#>] \Z/})
-# localhost.login("username", "password"){|c| print c }
-# localhost.cmd("command"){|c| print c }
-# localhost.close
-#
-# == sample 2
-# checks a POP server to see if you have mail.
-#
-# pop = Telnet.new({"Host" => "your_destination_host_here",
-# "Port" => 110,
-# "Telnetmode" => FALSE,
-# "Prompt" => /^\+OK/})
-# pop.cmd("user " + "your_username_here"){|c| print c}
-# pop.cmd("pass " + "your_password_here"){|c| print c}
-# pop.cmd("list"){|c| print c}
+=begin
+
+= simple telnet cliant library
+
+telnet.rb ver0.162 1999/03/18
+
+Wakou Aoyama <wakou@fsinet.or.jp>
+
+
+= methods
+
+== new (make new Telnet object)
+
+ host = Telnet.new({"Binmode" => FALSE, # default: FALSE
+ "Host" => "localhost", # default: "localhost"
+ "Output_log" => "output_log", # default: not output
+ "Dump_log" => "dump_log", # default: not output
+ "Port" => 23, # default: 23
+ "Prompt" => /[$%#>] \Z/, # default: /[$%#>] \Z/
+ "Telnetmode" => TRUE, # default: TRUE
+ "Timeout" => 10, # default: 10
+ "Waittime" => 0, # default: 0
+ "Proxy" => proxy}) # default: nil
+ # proxy is Telnet or TCPsocket object
+
+Telnet object has socket class methods.
+
+if set "Telnetmode" option FALSE. not TELNET command interpretation.
+"Waittime" is time to confirm "Prompt". There is a possibility that
+the same character as "Prompt" is included in the data, and, when
+the network or the host is very heavy, the value is enlarged.
+
+
+== waitfor (wait for match)
+
+ line = host.waitfor(/match/)
+ line = host.waitfor({"Match" => /match/,
+ "String" => "string",
+ "Timeout" => secs})
+
+if set "String" option. Match = Regexp.new(quote(string))
+
+
+=== realtime output
+
+ host.waitfor(/match/){|c| print c }
+ host.waitfor({"Match" => /match/,
+ "String" => "string",
+ "Timeout" => secs}){|c| print c}
+
+of cource, set sync=TRUE or flush is necessary.
+
+
+== cmd (send string and wait prompt)
+
+ line = host.cmd("string")
+ line = host.cmd({"String" => "string",
+ "Prompt" => /[$%#>] \Z/,
+ "Timeout" => 10})
+
+
+=== realtime output
+
+ host.cmd("string"){|c| print c }
+ host.cmd({"String" => "string",
+ "Prompt" => /[$%#>] \Z/,
+ "Timeout" => 10}){|c| print c }
+
+of cource, set sync=TRUE or flush is necessary.
+
+
+== print (send string)
+
+ host.print("string")
+
+
+== telnetmode (turn telnet command interpretation)
+
+ host.telnetmode # turn on/off
+ host.telnetmode(TRUE) # on
+ host.telnetmode(FALSE) # off
+
+
+== binmode (toggle newline translation)
+
+ host.binmode # turn TRUE/FALSE
+ host.binmode(TRUE) # no translate newline
+ host.binmode(FALSE) # translate newline
+
+
+== login
+
+ host.login("username", "password")
+ host.login({"Name" => "username",
+ "Password" => "password",
+ "Prompt" => /[$%#>] \Z/,
+ "Timeout" => 10})
+
+
+=== realtime output
+
+ host.login("username", "password"){|c| print c }
+ host.login({"Name" => "username",
+ "Password" => "password",
+ "Prompt" => /[$%#>] \Z/,
+ "Timeout" => 10}){|c| print c }
+
+of cource, set sync=TRUE or flush is necessary.
+
+
+= sample
+
+== login and send command
+
+ localhost = Telnet.new({"Host" => "localhost",
+ "Timeout" => 10,
+ "Prompt" => /[$%#>] \Z/})
+ localhost.login("username", "password"){|c| print c }
+ localhost.cmd("command"){|c| print c }
+ localhost.close
+
+
+== checks a POP server to see if you have mail
+
+ pop = Telnet.new({"Host" => "your_destination_host_here",
+ "Port" => 110,
+ "Telnetmode" => FALSE,
+ "Prompt" => /^\+OK/})
+ pop.cmd("user " + "your_username_here"){|c| print c}
+ pop.cmd("pass " + "your_password_here"){|c| print c}
+ pop.cmd("list"){|c| print c}
+
+
+= history
+
+ver0.162 1999/03/17
+add "Proxy" option
+required timeout.rb
+
+ver0.161 1999/02/03
+select --> IO::select
+
+ver0.16 1998/10/09
+preprocess method change for the better
+add binmode method.
+change default Binmode
+TRUE --> FALSE
+
+ver0.15 1998/10/04
+add telnetmode method.
+
+ver0.141 1998/09/22
+change default prompt
+/[$%#>] $/ --> /[$%#>] \Z/
+
+ver0.14 1998/09/01
+IAC WILL SGA send EOL --> CR+NULL
+IAC WILL SGA IAC DO BIN send EOL --> CR
+NONE send EOL --> LF
+add Dump_log option.
+
+ver0.13 1998/08/25
+add print method.
+
+ver0.122 1998/08/05
+support for HP-UX 10.20 thanks to WATANABE Tetsuya <tetsu@jpn.hp.com>
+socket.<< --> socket.write
+
+ver0.121 1998/07/15
+string.+= --> string.concat
+
+ver0.12 1998/06/01
+add timeout, waittime.
+
+ver0.11 1998/04/21
+add realtime output.
+
+ver0.10 1998/04/13
+first release.
+
+=end
require "socket"
require "delegate"
require "thread"
-
-class TimeOut < Exception
-end
+require "timeout"
+TimeOut = TimeoutError
class Telnet < SimpleDelegator
- def timeout(sec)
- is_timeout = FALSE
- begin
- x = Thread.current
- y = Thread.start {
- sleep sec
- if x.alive?
- #print "timeout!\n"
- x.raise TimeOut, "timeout"
- end
- }
- begin
- yield
- rescue TimeOut
- is_timeout = TRUE
- end
- ensure
- Thread.kill y if y && y.alive?
- end
- is_timeout
- end
-
IAC = 255.chr # interpret as command:
DONT = 254.chr # you are not to use option
DO = 253.chr # please, you use option
@@ -254,32 +281,45 @@ class Telnet < SimpleDelegator
@dumplog.binmode
end
- message = "Trying " + @options["Host"] + "...\n"
- STDOUT.write(message)
- @log.write(message) if @options.include?("Output_log")
- @dumplog.write(message) if @options.include?("Dump_log")
+ if @options.include?("Proxy")
+ if @options["Proxy"].kind_of?(Telnet)
+ @sock = @options["Proxy"].sock
+ elsif @options["Proxy"].kind_of?(TCPsocket)
+ @sock = @options["Proxy"]
+ else
+ raise "Error; Proxy is Telnet or TCPSocket object."
+ end
+ else
+ message = "Trying " + @options["Host"] + "...\n"
+ STDOUT.write(message)
+ @log.write(message) if @options.include?("Output_log")
+ @dumplog.write(message) if @options.include?("Dump_log")
- is_timeout = timeout(@options["Timeout"]){
begin
- @sock = TCPsocket.open(@options["Host"], @options["Port"])
+ timeout(@options["Timeout"]){
+ @sock = TCPsocket.open(@options["Host"], @options["Port"])
+ }
+ rescue TimeoutError
+ raise TimeOut, "timed-out; opening of the host"
rescue
@log.write($! + "\n") if @options.include?("Output_log")
@dumplog.write($! + "\n") if @options.include?("Dump_log")
raise
end
- }
- raise TimeOut, "timed-out; opening of the host" if is_timeout
- @sock.sync = TRUE
- @sock.binmode
+ @sock.sync = TRUE
+ @sock.binmode
- message = "Connected to " + @options["Host"] + ".\n"
- STDOUT.write(message)
- @log.write(message) if @options.include?("Output_log")
- @dumplog.write(message) if @options.include?("Dump_log")
+ message = "Connected to " + @options["Host"] + ".\n"
+ STDOUT.write(message)
+ @log.write(message) if @options.include?("Output_log")
+ @dumplog.write(message) if @options.include?("Dump_log")
+ end
super(@sock)
end
+ attr :sock
+
def telnetmode(mode = 'turn')
if 'turn' == mode
@options["Telnetmode"] = @options["Telnetmode"] ? FALSE : TRUE
@@ -342,12 +382,12 @@ class Telnet < SimpleDelegator
end
def waitfor(options)
- timeout = @options["Timeout"]
+ time_out = @options["Timeout"]
waittime = @options["Waittime"]
if options.kind_of?(Hash)
prompt = options["Prompt"] if options.include?("Prompt")
- timeout = options["Timeout"] if options.include?("Timeout")
+ time_out = options["Timeout"] if options.include?("Timeout")
waittime = options["Waittime"] if options.include?("Waittime")
prompt = Regexp.new( Regexp.quote(options["String"]) ) if
options.include?("String")
@@ -356,9 +396,9 @@ class Telnet < SimpleDelegator
end
line = ''
- until(not select([@sock], nil, nil, waittime) and prompt === line)
+ until(not IO::select([@sock], nil, nil, waittime) and prompt === line)
raise TimeOut, "timed-out; wait for the next data" if
- not select([@sock], nil, nil, timeout)
+ not IO::select([@sock], nil, nil, time_out)
buf = ''
begin
buf = @sock.sysread(1024 * 1024)
@@ -394,23 +434,23 @@ class Telnet < SimpleDelegator
end
def cmd(options)
- match = @options["Prompt"]
- timeout = @options["Timeout"]
+ match = @options["Prompt"]
+ time_out = @options["Timeout"]
if options.kind_of?(Hash)
- string = options["String"]
- match = options["Match"] if options.include?("Match")
- timeout = options["Timeout"] if options.include?("Timeout")
+ string = options["String"]
+ match = options["Match"] if options.include?("Match")
+ time_out = options["Timeout"] if options.include?("Timeout")
else
string = options
end
- select(nil, [@sock])
+ IO::select(nil, [@sock])
print(string)
if iterator?
- waitfor({"Prompt" => match, "Timeout" => timeout}){|c| yield c }
+ waitfor({"Prompt" => match, "Timeout" => time_out}){|c| yield c }
else
- waitfor({"Prompt" => match, "Timeout" => timeout})
+ waitfor({"Prompt" => match, "Timeout" => time_out})
end
end
diff --git a/parse.y b/parse.y
index ea0976dfef..091c6c52e0 100644
--- a/parse.y
+++ b/parse.y
@@ -65,6 +65,7 @@ static enum lex_state {
static int class_nest = 0;
static int in_single = 0;
+static int compile_for_eval = 0;
static ID cur_mid = 0;
static int value_expr();
@@ -361,7 +362,7 @@ stmt : iterator iter_do_block
}
| klEND '{' compstmt '}'
{
- if (cur_mid || in_single) {
+ if (compile_for_eval && (cur_mid || in_single)) {
yyerror("END in method; use at_exit");
}
@@ -378,7 +379,7 @@ expr : mlhs '=' mrhs
| kRETURN ret_args
{
value_expr($2);
- if (!cur_mid && !in_single)
+ if (!compile_for_eval && !cur_mid && !in_single)
yyerror("return appeared outside of method");
$$ = NEW_RET($2);
}
@@ -427,7 +428,7 @@ command_call : operation call_args
}
| kSUPER call_args
{
- if (!cur_mid && !in_single && !in_defined)
+ if (!compile_for_eval && !cur_mid && !in_single)
yyerror("super called outside of method");
$$ = NEW_SUPER($2);
fixpos($$, $2);
@@ -970,20 +971,20 @@ primary : literal
}
| kRETURN '(' ret_args ')'
{
- if (!cur_mid && !in_single)
+ if (!compile_for_eval && !cur_mid && !in_single)
yyerror("return appeared outside of method");
value_expr($3);
$$ = NEW_RET($3);
}
| kRETURN '(' ')'
{
- if (!cur_mid && !in_single)
+ if (!compile_for_eval && !cur_mid && !in_single)
yyerror("return appeared outside of method");
$$ = NEW_RET(0);
}
| kRETURN
{
- if (!cur_mid && !in_single)
+ if (!compile_for_eval && !cur_mid && !in_single)
yyerror("return appeared outside of method");
$$ = NEW_RET(0);
}
@@ -1304,13 +1305,15 @@ method_call : operation '(' opt_call_args ')'
}
| kSUPER '(' opt_call_args ')'
{
- if (!cur_mid && !in_single && !in_defined)
+ if (!compile_for_eval && !cur_mid &&
+ !in_single && !in_defined)
yyerror("super called outside of method");
$$ = NEW_SUPER($3);
}
| kSUPER
{
- if (!cur_mid && !in_single && !in_defined)
+ if (!compile_for_eval && !cur_mid &&
+ !in_single && !in_defined)
yyerror("super called outside of method");
$$ = NEW_ZSUPER();
}
@@ -1659,6 +1662,7 @@ yycompile(f)
sourcefile = f;
rb_in_compile = 1;
n = yyparse();
+ cur_mid = 0;
rb_in_compile = 0;
if (n == 0) return eval_tree;
@@ -1675,6 +1679,8 @@ compile_string(f, s, len)
lex_input = 0;
if (!sourcefile || strcmp(f, sourcefile)) /* not in eval() */
sourceline = 1;
+ else /* in eval() */
+ compile_for_eval = 1;
return yycompile(f);
}
diff --git a/re.c b/re.c
index 1561c58e31..c666467992 100644
--- a/re.c
+++ b/re.c
@@ -722,7 +722,7 @@ reg_match(re, str)
str = str_to_str(str);
start = reg_search(re, str, 0, 0);
if (start >= 0) return INT2FIX(start);
- return Qnil;
+ return FALSE;
}
VALUE
@@ -735,7 +735,7 @@ reg_match2(re)
if (TYPE(line) != T_STRING) return Qnil;
start = reg_search(re, line, 0, 0);
if (start >= 0) return INT2FIX(start);
- return Qnil;
+ return FALSE;
}
static VALUE
diff --git a/rubytest.rb b/rubytest.rb
index cf583c1dfb..6d0c0123d9 100644
--- a/rubytest.rb
+++ b/rubytest.rb
@@ -5,7 +5,7 @@ include Config
$stderr.reopen($stdout)
error = ''
-`./ruby #{CONFIG["srcdir"]}/sample/test.rb`.each do |line|
+`./miniruby #{CONFIG["srcdir"]}/sample/test.rb`.each do |line|
if line =~ /^end of test/
print "test succeeded\n"
exit 0
diff --git a/sample/test.rb b/sample/test.rb
index 55893cfc61..174b553029 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -1,4 +1,4 @@
-#! /usr/local/bin/ruby
+#! /usr/local/bin/miniruby
$testnum=0
$ntest=0
@@ -818,32 +818,32 @@ ok(i6 == nil)
check "system"
ok(`echo foobar` == "foobar\n")
-ok(`./ruby -e 'print "foobar"'` == 'foobar')
+ok(`./miniruby -e 'print "foobar"'` == 'foobar')
tmp = open("script_tmp", "w")
tmp.print "print $zzz\n";
tmp.close
-ok(`./ruby -s script_tmp -zzz` == 'true')
-ok(`./ruby -s script_tmp -zzz=555` == '555')
+ok(`./miniruby -s script_tmp -zzz` == 'true')
+ok(`./miniruby -s script_tmp -zzz=555` == '555')
tmp = open("script_tmp", "w")
-tmp.print "#! /usr/local/bin/ruby -s\n";
+tmp.print "#! /usr/local/bin/miniruby -s\n";
tmp.print "print $zzz\n";
tmp.close
-ok(`./ruby script_tmp -zzz=678` == '678')
+ok(`./miniruby script_tmp -zzz=678` == '678')
tmp = open("script_tmp", "w")
tmp.print "this is a leading junk\n";
-tmp.print "#! /usr/local/bin/ruby -s\n";
+tmp.print "#! /usr/local/bin/miniruby -s\n";
tmp.print "print $zzz\n";
tmp.print "__END__\n";
tmp.print "this is a trailing junk\n";
tmp.close
-ok(`./ruby -x script_tmp` == 'nil')
-ok(`./ruby -x script_tmp -zzz=555` == '555')
+ok(`./miniruby -x script_tmp` == 'nil')
+ok(`./miniruby -x script_tmp -zzz=555` == '555')
tmp = open("script_tmp", "w")
for i in 1..5
@@ -851,7 +851,7 @@ for i in 1..5
end
tmp.close
-`./ruby -i.bak -pe 'sub(/^[0-9]+$/){$&.to_i * 5}' script_tmp`
+`./miniruby -i.bak -pe 'sub(/^[0-9]+$/){$&.to_i * 5}' script_tmp`
done = true
tmp = open("script_tmp", "r")
while tmp.gets
@@ -868,7 +868,7 @@ File.unlink "script_tmp.bak" or `/bin/rm -f "script_tmp.bak"`
$bad = false
for script in Dir["{lib,sample}/*.rb"]
- unless `./ruby -c #{script}`.chomp == "Syntax OK"
+ unless `./miniruby -c #{script}`.chomp == "Syntax OK"
$bad = true
end
end