summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-10 08:44:29 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-10 08:44:29 +0000
commit997ff23758884944f28a089eaa50ac7eb1c026c6 (patch)
treef99563ed31c2f6a8facc7160cccde602d39af79b /lib
parentd148ffef297193fe5f6639a8bd8c9ee3d3374479 (diff)
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/cgi-lib.rb43
-rw-r--r--lib/date2.rb24
-rw-r--r--lib/mkmf.rb3
3 files changed, 41 insertions, 29 deletions
diff --git a/lib/cgi-lib.rb b/lib/cgi-lib.rb
index 2089a9c9a5..83ea6118b9 100644
--- a/lib/cgi-lib.rb
+++ b/lib/cgi-lib.rb
@@ -38,6 +38,11 @@
# CGI.tag("HR")
# }
# }
+#
+# print HTTP header and strings to STDOUT
+# CGI.print{ "string" } # add HTTP header "Content-Type: text/html"
+# CGI.print("Content-Type: text/plain"){ "string" }
+# CGI.print("HTTP/1.0 200 OK", "Content-Type: text/html"){ "string" }
# if running on Windows(IIS or PWS) then change cwd.
@@ -150,25 +155,33 @@ class CGI < SimpleDelegator
(iterator? ? yield.to_s + "</" + escapeHTML(element) + ">" : "")
end
- def CGI.message(msg, title = "", header = ["Content-Type: text/html"])
- print CGI.header(*header)
- print "<html><head><title>"
- print title
- print "</title></head><body>\n"
- print msg
- print "</body></html>\n"
+ def CGI.print(*header)
+ header.push("Content-Type: text/html") if header.empty?
+ STDOUT.print CGI.header(*header) + yield.to_s
+ end
+
+ def CGI.message(message, title = "", header = ["Content-Type: text/html"])
+ if message.kind_of?(Hash)
+ title = message['title']
+ header = message['header']
+ message = message['body']
+ end
+ CGI.print(*header){
+ CGI.tag("HTML"){
+ CGI.tag("HEAD"){ CGI.tag("TITLE"){ title } } +
+ CGI.tag("BODY"){ message }
+ }
+ }
TRUE
end
def CGI.error
- m = $!.to_s.dup
- m.gsub!(/&/, '&amp;')
- m.gsub!(/</, '&lt;')
- m.gsub!(/>/, '&gt;')
- msgs = ["<pre>ERROR: <strong>#{m}</strong>"]
- msgs << $@
- msgs << "</pre>"
- CGI.message(msgs.join("\n"), "ERROR")
+ CGI.message({'title'=>'ERROR', 'body'=>
+ CGI.tag("PRE"){
+ "ERROR: " + CGI.tag("STRONG"){ escapeHTML($!.to_s) } + "\n" +
+ escapeHTML($@.join("\n"))
+ }
+ })
exit
end
end
diff --git a/lib/date2.rb b/lib/date2.rb
index 50c2ccfbd9..6e87824b38 100644
--- a/lib/date2.rb
+++ b/lib/date2.rb
@@ -1,11 +1,11 @@
-# date.rb: Written by Tadayoshi Funaba 1998
-# $Id: date.rb,v 1.4 1998/06/01 12:52:33 tadf Exp $
+# date.rb: Written by Tadayoshi Funaba 1998, 1999
+# $Id: date.rb,v 1.5 1999/02/06 08:51:56 tadf Exp $
class Date
include Comparable
- MONTHNAMES = [ '', 'January', 'February', 'March', 'April', 'May', 'June',
+ MONTHNAMES = [ nil, 'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December' ]
DAYNAMES = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',
@@ -162,26 +162,24 @@ class Date
end
def + (other)
- if other.kind_of? Numeric then
- return Date.new(@jd + other, @gs)
+ case other
+ when Numeric; return Date.new(@jd + other, @gs)
end
fail TypeError, 'expected numeric'
end
def - (other)
- if other.kind_of? Numeric then
- return Date.new(@jd - other, @gs)
- elsif other.kind_of? Date then
- return @jd - other.jd
+ case other
+ when Numeric; return Date.new(@jd - other, @gs)
+ when Date; return @jd - other.jd
end
fail TypeError, 'expected numeric or date'
end
def <=> (other)
- if other.kind_of? Numeric then
- return @jd <=> other
- elsif other.kind_of? Date then
- return @jd <=> other.jd
+ case other
+ when Numeric; return @jd <=> other
+ when Date; return @jd <=> other.jd
end
fail TypeError, 'expected numeric or date'
end
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 0e7595531f..52b4ed20a9 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -31,7 +31,8 @@ if File.exist?($config_cache) then
end
$srcdir = CONFIG["srcdir"]
-$libdir = CONFIG["libdir"]+"/"+CONFIG["ruby_install_name"]
+#$libdir = CONFIG["libdir"]+"/"+CONFIG["ruby_install_name"]
+$libdir = CONFIG["libdir"]+"/ruby"
$libdir += "/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
$archdir = $libdir+"/"+CONFIG["arch"]
$install = CONFIG["INSTALL_PROGRAM"]