diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-10-06 02:45:15 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-10-06 02:45:15 +0000 |
commit | 6536fb84b35a5ef03fcc0b22cd34f1122d53d976 (patch) | |
tree | f6dc9277400077a0cc7c102fef65e72d11153938 /lib | |
parent | 9d04ee7eddb098f0450f3e6b1c1ab5f6e81b3c48 (diff) |
1.1c6
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/find.rb | 2 | ||||
-rw-r--r-- | lib/open3.rb | 55 | ||||
-rw-r--r-- | lib/shell.rb | 3 | ||||
-rw-r--r-- | lib/telnet.rb | 40 | ||||
-rw-r--r-- | lib/tk.rb | 8 | ||||
-rw-r--r-- | lib/tkafter.rb | 1 | ||||
-rw-r--r-- | lib/tkcanvas.rb | 2 |
7 files changed, 88 insertions, 23 deletions
diff --git a/lib/find.rb b/lib/find.rb index 7a6dbce17a..3f1b82d2b3 100644 --- a/lib/find.rb +++ b/lib/find.rb @@ -1,5 +1,5 @@ # Usage: -# require "find.rb" +# require "find" # # Find.find('/foo','/bar') {|f| ...} # or diff --git a/lib/open3.rb b/lib/open3.rb new file mode 100644 index 0000000000..e8ba2783da --- /dev/null +++ b/lib/open3.rb @@ -0,0 +1,55 @@ +# Usage: +# require "open3" +# +# in, out, err = Open3.popen3('nroff -man') +# or +# include Open3 +# in, out, err = popen3('nroff -man') +# + +module Open3 + #[stdin, stdout, stderr] = popen3(command); + def popen3(cmd) + pw = pipe # pipe[0] for read, pipe[1] for write + pr = pipe + pe = pipe + + pid = fork + if pid == nil then # child + pw[1].close + STDIN.reopen(pw[0]) + pw[0].close + + pr[0].close + STDOUT.reopen(pr[1]) + pr[1].close + + pe[0].close + STDERR.reopen(pe[1]) + pe[1].close + + exec(cmd) + exit + else + pw[0].close + pr[1].close + pe[1].close + pi = [ pw[1], pr[0], pe[0] ] + end + end + module_function :popen3 +end + +if $0 == __FILE__ + a = Open3.popen3("nroff -man") + Thread.start do + while gets + a[0].print $_ + end + a[0].close + end + while a[1].gets + print ":", $_ + end +end + diff --git a/lib/shell.rb b/lib/shell.rb index 3d8dda0445..de6ee85be0 100644 --- a/lib/shell.rb +++ b/lib/shell.rb @@ -364,7 +364,8 @@ class Shell end end @system_commands[command] = FALSE - Shell.fail CommandNotFound, command +# Shell.fail CommandNotFound, command + raise CommandNotFound, command end # diff --git a/lib/telnet.rb b/lib/telnet.rb index 9c99e026d7..e5a8aa6b7b 100644 --- a/lib/telnet.rb +++ b/lib/telnet.rb @@ -1,8 +1,12 @@ # # telnet.rb -# ver0.14 1998/09/01 +# ver0.141 1998/09/22 # Wakou Aoyama <wakou@fsinet.or.jp> # +# 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 @@ -34,7 +38,7 @@ # "Output_log" => "output_log", default: not output # "Dump_log" => "dump_log", default: not output # "Port" => 23, default: 23 -# "Prompt" => /[$%#>] $/, default: /[$%#>] $/ +# "Prompt" => /[$%#>] \Z/, default: /[$%#>] \Z/ # "Telnetmode" => TRUE, default: TRUE # "Timeout" => 10, default: 10 # "Waittime" => 0}) default: 0 @@ -60,13 +64,13 @@ # == send string and wait prompt # line = host.cmd("string") # line = host.cmd({"String" => "string", -# "Prompt" => /[$%#>] $//, +# "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" => /[$%#>] $//, +# "Prompt" => /[$%#>] \Z/, # "Timeout" => 10}){|c| print c } # # == send string @@ -76,14 +80,14 @@ # host.login("username", "password") # host.login({"Name" => "username", # "Password" => "password", -# "Prompt" => /[$%#>] $/, +# "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" => /[$%#>] $/, +# "Prompt" => /[$%#>] \Z/, # "Timeout" => 10}){|c| print c } # # and Telnet object has socket class methods @@ -91,7 +95,7 @@ # == sample # localhost = Telnet.new({"Host" => "localhost", # "Timeout" => 10, -# "Prompt" => /[$%#>] $/}) +# "Prompt" => /[$%#>] \Z/}) # localhost.login("username", "password"){|c| print c } # localhost.cmd("command"){|c| print c } # localhost.close @@ -208,13 +212,13 @@ class Telnet < SimpleDelegator def initialize(options) @options = options - @options["Binmode"] = TRUE if not @options.include?("Binmode") - @options["Host"] = "localhost" if not @options.include?("Host") - @options["Port"] = 23 if not @options.include?("Port") - @options["Prompt"] = /[$%#>] $/ if not @options.include?("Prompt") - @options["Telnetmode"] = TRUE if not @options.include?("Telnetmode") - @options["Timeout"] = 10 if not @options.include?("Timeout") - @options["Waittime"] = 0 if not @options.include?("Waittime") + @options["Binmode"] = TRUE if not @options.include?("Binmode") + @options["Host"] = "localhost" if not @options.include?("Host") + @options["Port"] = 23 if not @options.include?("Port") + @options["Prompt"] = /[$%#>] \Z/ if not @options.include?("Prompt") + @options["Telnetmode"] = TRUE if not @options.include?("Telnetmode") + @options["Timeout"] = 10 if not @options.include?("Timeout") + @options["Waittime"] = 0 if not @options.include?("Waittime") @telnet_option = { "SGA" => FALSE, "BINARY" => FALSE } @@ -378,14 +382,14 @@ class Telnet < SimpleDelegator end if iterator? - line = waitfor(/login[: ]*$/){|c| yield c } + line = waitfor(/login[: ]*\Z/){|c| yield c } line.concat( cmd({"String" => username, - "Match" => /Password[: ]*$/}){|c| yield c } ) + "Match" => /Password[: ]*\Z/}){|c| yield c } ) line.concat( cmd(password){|c| yield c } ) else - line = waitfor(/login[: ]*$/) + line = waitfor(/login[: ]*\Z/) line.concat( cmd({"String" => username, - "Match" => /Password[: ]*$/}) ) + "Match" => /Password[: ]*\Z/}) ) line.concat( cmd(password) ) end line @@ -17,7 +17,7 @@ module TkComm Tk_WINDOWS = {} def error_at - frames = caller(1) + frames = caller() frames.delete_if do |c| c =~ %r!/tk(|core|thcore|canvas|text|entry|scrollbox)\.rb:\d+! end @@ -1575,7 +1575,11 @@ class TkObject<TkKernel when 1 configure name, args[0] when 0 - fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", error_at + begin + cget name + rescue + fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", error_at + end else fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at end diff --git a/lib/tkafter.rb b/lib/tkafter.rb index 23fc87dedb..be2e50ff3a 100644 --- a/lib/tkafter.rb +++ b/lib/tkafter.rb @@ -203,6 +203,7 @@ class TkAfter if !sleep == 'idle' && !sleep.kind_of?(Integer) fail format("%s need to be Integer", sleep.inspect) end + @init_sleep = sleep @init_proc = init_proc @init_args = init_args self diff --git a/lib/tkcanvas.rb b/lib/tkcanvas.rb index c4a7478c23..1cf24eeb7b 100644 --- a/lib/tkcanvas.rb +++ b/lib/tkcanvas.rb @@ -740,7 +740,7 @@ class TkImage<TkObject tk_call('image', 'type', @path) end def width - number(tk_call('image', 'height', @path)) + number(tk_call('image', 'width', @path)) end def TkImage.names |