summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--io.c6
-rw-r--r--sample/biorhythm.rb36
-rw-r--r--version.h8
4 files changed, 34 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 1c27c07fb39..ee9c427662f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Tue Jul 25 15:16:00 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_p): redirect to $defout.
+
Mon Jul 24 18:52:55 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
* win32/win32.c (win32_getenv): should remove `static'.
diff --git a/io.c b/io.c
index dabc6805491..5e3a48e8cec 100644
--- a/io.c
+++ b/io.c
@@ -2108,10 +2108,8 @@ void
rb_p(obj) /* for debug print within C code */
VALUE obj;
{
- obj = rb_obj_as_string(rb_inspect(obj));
- fwrite(RSTRING(obj)->ptr, 1, RSTRING(obj)->len, stdout);
- obj = rb_default_rs;
- fwrite(RSTRING(obj)->ptr, 1, RSTRING(obj)->len, stdout);
+ rb_io_write(rb_defout, rb_obj_as_string(rb_inspect(obj)));
+ rb_io_write(rb_defout, rb_default_rs);
}
static VALUE
diff --git a/sample/biorhythm.rb b/sample/biorhythm.rb
index 146e5da2441..d0fc60bd2a8 100644
--- a/sample/biorhythm.rb
+++ b/sample/biorhythm.rb
@@ -28,6 +28,7 @@
include Math
require "date.rb"
require "parsearg.rb"
+require "parsedate.rb"
def usage()
print "Usage:\n"
@@ -56,22 +57,31 @@ def getPosition(z)
return phys, emot, geist
end
+def parsedate(s)
+ ParseDate::parsedate(s).indexes(0, 1, 2)
+end
+
+def name_of_week(date)
+ Date::DAYNAMES[(date.jd + 1) % 7]
+end
+
#
# main program
#
parseArgs(0, nil, "vg", "D:", "sdate", "date:", "birthday:", "days:")
if $OPT_D
- dd = Date.new(Time.now.strftime("%Y%m%d"))
- bd = Date.new($OPT_D)
+ now = Time.now
+ dd = Date.new(now.year, now.month, now.day)
+ bd = Date.new(*parsedate($OPT_D))
ausgabeart = "g"
else
if $OPT_birthday
- bd = Date.new($OPT_birthday)
+ bd = Date.new(*parsedate($OPT_birthday))
else
printf(STDERR, "Birthday (YYYYMMDD) : ")
if (si = STDIN.gets.chop) != ""
- bd = Date.new(si)
+ bd = Date.new(*parsedate(si))
end
end
if !bd
@@ -80,17 +90,19 @@ else
end
if $OPT_sdate
- dd = Date.new(Time.now.strftime("%Y%m%d"))
+ now = Time.now
+ dd = Date.new(now.year, now.month, now.day)
elsif $OPT_date
- dd = Date.new($OPT_date)
+ dd = Date.new(*parsedate($OPT_date))
else
printf(STDERR, "Date [<RETURN> for Systemdate] (YYYYMMDD) : ")
if (si = STDIN.gets.chop) != ""
- dd = Date.new(si)
+ dd = Date.new(*parsedate(si))
end
end
if !dd
- dd = Date.new(Time.now.strftime("%Y%m%d"))
+ now = Time.now
+ dd = Date.new(now.year, now.month, now.day)
end
if $OPT_v
@@ -103,10 +115,10 @@ else
end
end
if (ausgabeart == "v")
- printHeader(bd.year, bd.month, bd.day, dd.period - bd.period, bd.name_of_week)
+ printHeader(bd.year, bd.month, bd.day, dd.jd - bd.jd, name_of_week(bd))
print "\n"
- phys, emot, geist = getPosition(dd.period - bd.period)
+ phys, emot, geist = getPosition(dd.jd - bd.jd)
printf "Biorhythm: %04d.%02d.%02d\n", dd.year, dd.month, dd.day
printf "Physical: %d%%\n", phys
printf "Emotional: %d%%\n", emot
@@ -127,13 +139,13 @@ else
end
end
- printHeader(bd.year, bd.month, bd.day, dd.period - bd.period, bd.name_of_week)
+ printHeader(bd.year, bd.month, bd.day, dd.jd - bd.jd, name_of_week(bd))
print " P=physical, E=emotional, M=mental\n"
print " -------------------------+-------------------------\n"
print " Bad Condition | Good Condition\n"
print " -------------------------+-------------------------\n"
- for z in (dd.period - bd.period)..(dd.period - bd.period + display_period)
+ for z in (dd.jd - bd.jd)..(dd.jd - bd.jd + display_period)
phys, emot, geist = getPosition(z)
printf "%04d.%02d.%02d : ", dd.year, dd.month, dd.day
diff --git a/version.h b/version.h
index a9ff808d37f..789b9035c64 100644
--- a/version.h
+++ b/version.h
@@ -1,4 +1,4 @@
-#define RUBY_VERSION "1.5.4"
-#define RUBY_RELEASE_DATE "2000-07-24"
-#define RUBY_VERSION_CODE 154
-#define RUBY_RELEASE_CODE 20000724
+#define RUBY_VERSION "1.5.5"
+#define RUBY_RELEASE_DATE "2000-07-25"
+#define RUBY_VERSION_CODE 155
+#define RUBY_RELEASE_CODE 20000725