diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-10-06 03:28:28 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-10-06 03:28:28 +0000 |
commit | 75ff8fdb16fa0a733512e61350c9844ea530ad35 (patch) | |
tree | a057e60543c77d6e20ea2e91928928df80b2b6d3 /lib | |
parent | 5d71c8d89c6bd7af934e7a8de5882cda2991711b (diff) |
join 1.1c6
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1dev@310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/find.rb | 2 | ||||
-rw-r--r-- | lib/jcode.rb | 10 | ||||
-rw-r--r-- | lib/mkmf.rb | 23 | ||||
-rw-r--r-- | lib/open3.rb | 55 | ||||
-rw-r--r-- | lib/pstore.rb | 9 | ||||
-rw-r--r-- | lib/shell.rb | 21 | ||||
-rw-r--r-- | lib/telnet.rb | 40 | ||||
-rw-r--r-- | lib/thwait.rb | 2 | ||||
-rw-r--r-- | lib/tk.rb | 8 | ||||
-rw-r--r-- | lib/tkafter.rb | 1 | ||||
-rw-r--r-- | lib/tkcanvas.rb | 7 |
11 files changed, 130 insertions, 48 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/jcode.rb b/lib/jcode.rb index 6d71518c70..50b7beee9d 100644 --- a/lib/jcode.rb +++ b/lib/jcode.rb @@ -104,7 +104,7 @@ class String end def tr(from, to) - self.dup.tr!(from, to) + (str = self.dup).tr!(from, to) or str end def delete!(del) @@ -127,7 +127,7 @@ class String end def delete(del) - self.dup.delete!(del) + (str = self.dup).delete!(del) or str end def squeeze!(del=nil) @@ -155,7 +155,7 @@ class String end def squeeze(del=nil) - self.dup.squeeze!(del) + (str = self.dup).squeeze!(del) or str end def tr_s!(from, to) @@ -188,7 +188,7 @@ class String end def tr_s(from, to) - self.dup.tr_s!(from,to) + (str = self.dup).tr_s!(from,to) or str end alias original_chop! chop! @@ -202,7 +202,7 @@ class String end def chop - self.dup.chop! + (str = self.dup).chop! or str end end $VERBOSE = $vsave diff --git a/lib/mkmf.rb b/lib/mkmf.rb index e89ac7d507..0aa9d98b9c 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -2,6 +2,7 @@ # invoke like: ruby -r mkmf extconf.rb require 'rbconfig' +require 'find' include Config @@ -83,6 +84,24 @@ def try_cpp xsystem(format(CPP, $CFLAGS)) end +def install_rb(mfile) + path = [] + dir = [] + Find.find("lib") do |f| + next unless /\.rb$/ =~ f + f = f[4..-1] + path.push f + dir |= File.dirname(f) + end + for f in dir + next if f == "." + mfile.printf "\t@test -d $(libdir)/%s || mkdir $(libdir)/%s\n", f, f + end + for f in path + mfile.printf "\t$(INSTALL_DATA) lib/%s $(libdir)/%s\n", f, f + end +end + def have_library(lib, func) printf "checking for %s() in -l%s... ", func, lib STDOUT.flush @@ -299,9 +318,7 @@ $(libdir)/$(TARGET): $(TARGET) @test -d $(libdir) || mkdir $(libdir) $(INSTALL) $(TARGET) $(libdir)/$(TARGET) EOMF - for rb in Dir["lib/*.rb"] - mfile.printf "\t$(INSTALL_DATA) %s %s\n", rb, $libdir - end + install_rb(mfile) mfile.printf "\n" if CONFIG["DLEXT"] != "o" 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/pstore.rb b/lib/pstore.rb index 743b1da5d0..f075dbc8bb 100644 --- a/lib/pstore.rb +++ b/lib/pstore.rb @@ -121,10 +121,13 @@ if __FILE__ == $0 db.transaction do p db.roots ary = db["root"] = [1,2,3,4] - ary[0] = [1,1.5] + ary[1] = [1,1.5] end - db.transaction do - p db["root"] + 1000.times do + db.transaction do + db["root"][0] += 1 + p db["root"][0] + end end end diff --git a/lib/shell.rb b/lib/shell.rb index 3d8dda0445..4fdac0af12 100644 --- a/lib/shell.rb +++ b/lib/shell.rb @@ -159,7 +159,7 @@ class Shell @dir_stack.push @cwd chdir pop else - Shell.fail DirStackEmpty + Shell.Fail DirStackEmpty end end end @@ -169,7 +169,7 @@ class Shell if pop = @dir_stack.pop @cwd = pop else - Shell.fail DirStackEmpty + Shell.Fail DirStackEmpty end end alias popd popdir @@ -350,10 +350,10 @@ class Shell if sh.exists?(path) return path else - Shell.fail CommandNotFound, command + Shell.Fail CommandNotFound, command end when FALSE - Shell.fail CommandNotFound, command + Shell.Fail CommandNotFound, command end for p in @system_path @@ -364,7 +364,8 @@ class Shell end end @system_commands[command] = FALSE - Shell.fail CommandNotFound, command +# Shell.fail CommandNotFound, command + raise CommandNotFound, command end # @@ -380,7 +381,7 @@ class Shell eval d rescue print "Can't define self.#{command} path: #{path}\n" if debug? or verbose? - Shell.fail CanNotDefine, comamnd, path + Shell.Fail CanNotDefine, comamnd, path end if debug? print d @@ -402,7 +403,7 @@ class Shell eval d rescue print "Can't define #{command} path: #{path}\n" if debug? or verbose? - Shell.fail CanNotDefine, comamnd, path + Shell.Fail CanNotDefine, comamnd, path end if debug? print d @@ -474,7 +475,7 @@ class Shell @input = src self else - Filter.fail CanNotMethodApply, "<", to.type + Filter.Fail CanNotMethodApply, "<", to.type end end @@ -490,7 +491,7 @@ class Shell when IO each(){|l| to << l} else - Filter.fail CanNotMethodApply, ">", to.type + Filter.Fail CanNotMethodApply, ">", to.type end self end @@ -507,7 +508,7 @@ class Shell when IO each(){|l| to << l} else - Filter.fail CanNotMethodApply, ">>", to.type + Filter.Fail CanNotMethodApply, ">>", to.type end self 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 diff --git a/lib/thwait.rb b/lib/thwait.rb index d3b329911f..958163edef 100644 --- a/lib/thwait.rb +++ b/lib/thwait.rb @@ -99,7 +99,7 @@ class ThreadsWait @threads.concat threads for th in threads Thread.start do - th = Thread.join(th) + th = th.join @wait_queue.push th end end @@ -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 @@ -1581,7 +1581,11 @@ class TkObject 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..bc8560470d 100644 --- a/lib/tkcanvas.rb +++ b/lib/tkcanvas.rb @@ -733,14 +733,11 @@ class TkImage<TkObject Tk_IMGTBL[@id] = nil if @id tk_call('image', 'delete', @path) end - def height - number(tk_call('image', 'height', @path)) - end def itemtype tk_call('image', 'type', @path) end def width - number(tk_call('image', 'height', @path)) + number(tk_call('image', 'width', @path)) end def TkImage.names @@ -823,7 +820,7 @@ class TkPhotoImage<TkImage term end }.flatten - + tk_send 'write', file, *args end end |