summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-02 04:49:46 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-02 04:49:46 +0000
commit6125313d69c158b423d1f4aff2e206cfd43a036a (patch)
treea1a78a9425305557dcff6569806876989c9098c3 /lib
parentf5a7f85917abed4d64ad908a4837e0db0499c951 (diff)
* array.c (push_values_at): Array#values_at should work with
ranges too. * range.c (rb_range_beg_len): length calculation was wrong. * eval.c (rb_call): should set T_ICLASS in the frame->last_class. [ruby-core:01110] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/cgi.rb30
-rw-r--r--lib/ftools.rb14
-rw-r--r--lib/getoptlong.rb4
-rw-r--r--lib/jcode.rb4
-rw-r--r--lib/mkmf.rb2
-rw-r--r--lib/optparse.rb2
6 files changed, 31 insertions, 25 deletions
diff --git a/lib/cgi.rb b/lib/cgi.rb
index dfeea5fc47..8f522ab7c1 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -494,7 +494,7 @@ status:
if defined?(MOD_RUBY)
table = Apache::request.headers_out
buf.scan(/([^:]+): (.+)#{EOL}/n){ |name, value|
- $stderr.printf("name:%s value:%s\n", name, value) if $DEBUG
+ warn sprintf("name:%s value:%s\n", name, value) if $DEBUG
case name
when 'Set-Cookie'
table.add(name, value)
@@ -942,24 +942,30 @@ convert string charset, and set language to "ja".
private :initialize_query
class Value < String
- def [](key)
- $stderr.puts <<END
-CAUTION! cgi['key'] == cgi.params['key'][0] If want Array, use cgi.params['key']
-END
- self
+ def initialize(str, params)
+ @params = params
+ super(str)
+ end
+ def [](idx)
+ p caller(1)
+ warn "#{caller(1)[0]}:CAUTION! cgi['key'] == cgi.params['key'][0]; if want Array, use cgi.params['key']"
+ self
end
def first
- $stderr.puts <<END
-CAUTION! cgi['key'] == cgi.params['key'][0] If want Array, use cgi.params['key']
-END
- self
+ warn "#{caller(1)[0]}:CAUTION! cgi['key'] == cgi.params['key'][0]; if want Array, use cgi.params['key']"
+ self
+ end
+ alias last first
+ def to_a
+ @params
end
end
def [](key)
- value = @params[key][0]
+ params = @params[key]
+ value = params[0]
value ||= ""
- Value.new(value)
+ Value.new(value,params)
end
def keys(*args)
diff --git a/lib/ftools.rb b/lib/ftools.rb
index 6e1c886e56..6e058a824c 100644
--- a/lib/ftools.rb
+++ b/lib/ftools.rb
@@ -39,7 +39,7 @@ class << File
end
def copy from, to, verbose = false
- $stderr.print from, " -> ", catname(from, to), "\n" if verbose
+ $deferr.print from, " -> ", catname(from, to), "\n" if verbose
syscopy from, to
end
@@ -49,7 +49,7 @@ class << File
def move from, to, verbose = false
to = catname(from, to)
- $stderr.print from, " -> ", to, "\n" if verbose
+ $deferr.print from, " -> ", to, "\n" if verbose
if RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw/ and FileTest.file? to
unlink to
@@ -79,7 +79,7 @@ class << File
# false: not identical
def compare from, to, verbose = false
- $stderr.print from, " <=> ", to, "\n" if verbose
+ $deferr.print from, " <=> ", to, "\n" if verbose
return false if stat(from).size != stat(to).size
@@ -116,11 +116,11 @@ class << File
def safe_unlink(*files)
verbose = if files[-1].is_a? String then false else files.pop end
begin
- $stderr.print files.join(" "), "\n" if verbose
+ $deferr.print files.join(" "), "\n" if verbose
chmod 0777, *files
unlink(*files)
rescue
-# STDERR.print "warning: Couldn't unlink #{files.join ' '}\n"
+# $deferr.print "warning: Couldn't unlink #{files.join ' '}\n"
end
end
@@ -134,7 +134,7 @@ class << File
next if FileTest.directory? dir
parent = dirname(dir)
makedirs parent unless FileTest.directory? parent
- $stderr.print "mkdir ", dir, "\n" if verbose
+ $deferr.print "mkdir ", dir, "\n" if verbose
if basename(dir) != ""
Dir.mkdir dir, mode
end
@@ -148,7 +148,7 @@ class << File
vsave, $VERBOSE = $VERBOSE, false
def chmod(mode, *files)
verbose = if files[-1].is_a? String then false else files.pop end
- $stderr.printf "chmod %04o %s\n", mode, files.join(" ") if verbose
+ $deferr.printf "chmod %04o %s\n", mode, files.join(" ") if verbose
o_chmod mode, *files
end
$VERBOSE = vsave
diff --git a/lib/getoptlong.rb b/lib/getoptlong.rb
index 9c8ed09db9..7bb9baef2d 100644
--- a/lib/getoptlong.rb
+++ b/lib/getoptlong.rb
@@ -67,7 +67,7 @@ class GetoptLong
@argument_flags = Hash.new
#
- # Whether error messages are output to stderr.
+ # Whether error messages are output to $deferr.
#
@quiet = FALSE
@@ -253,7 +253,7 @@ class GetoptLong
# Set an error (protected).
#
def set_error(type, message)
- $stderr.print("#{$0}: #{message}\n") if !@quiet
+ $deferr.print("#{$0}: #{message}\n") if !@quiet
@error = type
@error_message = message
diff --git a/lib/jcode.rb b/lib/jcode.rb
index 8064518017..8cd770be26 100644
--- a/lib/jcode.rb
+++ b/lib/jcode.rb
@@ -1,12 +1,12 @@
# jcode.rb - ruby code to handle japanese (EUC/SJIS) string
if $VERBOSE && $KCODE == "NONE"
- STDERR.puts "Warning: $KCODE is NONE."
+ warn "Warning: $KCODE is NONE."
end
$vsave, $VERBOSE = $VERBOSE, false
class String
- printf STDERR, "feel free for some warnings:\n" if $VERBOSE
+ warn "feel free for some warnings:\n" if $VERBOSE
def _regex_quote(str)
str.gsub(/(\\[\[\]\-\\])|\\(.)|([\[\]\\])/) do
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index a1fed2278b..32e76d7dca 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -78,7 +78,7 @@ if not $extmk and File.exist? Config::CONFIG["archdir"] + "/ruby.h"
elsif File.exist? $srcdir + "/ruby.h"
$hdrdir = $srcdir
else
- STDERR.print "can't find header files for ruby.\n"
+ warn "can't find header files for ruby."
exit 1
end
$topdir = $hdrdir
diff --git a/lib/optparse.rb b/lib/optparse.rb
index de88b648ec..295f2bc94b 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -1597,7 +1597,7 @@ Extends command line arguments array to parse itself.
begin
yield @optparse
rescue ParseError
- STDERR.puts @optparse.program_name + ': ' + $!
+ warn @optparse.program_name + ': ' + $!
nil
end
end