summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog46
-rw-r--r--ToDo4
-rw-r--r--array.c1
-rw-r--r--configure8
-rw-r--r--configure.bat1
-rw-r--r--configure.in8
-rw-r--r--eval.c68
-rw-r--r--ext/Setup.nt2
-rw-r--r--ext/extmk.rb.in14
-rw-r--r--ext/fcntl/fcntl.c1
-rw-r--r--ext/nkf/nkf.c4
-rw-r--r--ext/socket/extconf.rb2
-rw-r--r--ext/socket/getaddrinfo.c4
-rw-r--r--ext/socket/getnameinfo.c4
-rw-r--r--ext/tcltklib/tcltklib.c4
-rw-r--r--ext/tk/tkutil.c1
-rw-r--r--gc.c8
-rw-r--r--lib/date2.rb182
-rw-r--r--lib/debug.rb8
-rw-r--r--lib/telnet.rb18
-rw-r--r--numeric.c3
-rw-r--r--parse.y13
-rw-r--r--regex.c10
-rw-r--r--sample/cal.rb16
-rw-r--r--sample/goodfriday.rb19
-rw-r--r--version.h4
-rw-r--r--win32/Makefile2
-rw-r--r--win32/win32.c25
-rw-r--r--win32/win32.h7
29 files changed, 309 insertions, 178 deletions
diff --git a/ChangeLog b/ChangeLog
index 550b5b3..723bcd9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,48 @@
+Wed Aug 11 10:10:02 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): parse `[].length==0' as `([].length)==0', not
+ `([].length=)=0'
+
+ * parse.y (yylex): parse `[].length!=0' as `([].length)!=0', not
+ `([].length!)=0'
+
+ * parse.y (peek): peek-in lexical buffer.
+
+Wed Aug 11 00:34:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): bug on backward jump adjustment concerning
+ stop_paren.
+
+Tue Aug 10 14:54:25 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/nkf/nkf.c (rb_nkf_guess): binary detection was wrong.
+
+Tue Aug 10 00:07:36 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_clone): should use CLONESETUP().
+
+Mon Aug 9 23:57:07 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.h (CLONESETUP): should have copied generic instance
+ variables too.
+
+Mon Aug 9 10:46:54 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/socket/extconf.rb: add check for <arpa/nameser.h> and
+ <resolv.h>.
+
+Sat Aug 7 13:19:06 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * numeric.c (flo_cmp): comparing NaN should not return value.
+ raises FloatDomainError.
+
+Sat Aug 7 03:09:08 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (blk_free): free copied frames too.
+
+ * eval.c (frame_dup): should copy previous frames from stack to
+ heap to preserve frame information.
+
Fri Aug 6 15:01:07 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* version 1.3.7 - version 1.4 beta
@@ -2420,7 +2465,6 @@ Fri Sep 4 11:27:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* regex.c (re_search): wrong return value for \A.
->>>>>>> 1.1.1.2.2.154
Thu Sep 3 14:08:14 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* version 1.1c4 released.
diff --git a/ToDo b/ToDo
index 021e07d..1ecd529 100644
--- a/ToDo
+++ b/ToDo
@@ -1,12 +1,13 @@
Language Spec.
+* compile time string concatenation, "hello" "world" => "helloworld"
* ../... outside condition invokes operator method too.
* %w(a\ b\ c abc) => ["a b c", "abc"]
* package or access control for global variables
* class variable (prefix?)
* named arguments like foo(nation:="german") or foo(nation: "german").
* method to retrieve argument information (need new C API)
-* multiple return values, yield values. maybe incompatible
+* multiple return values, yield values. maybe incompatible ???
* cascading method invocation ???
* def Class#method .. end ??
* class Foo::Bar<Baz .. end, module Boo::Bar .. end
@@ -24,6 +25,7 @@ Hacking Interpreter
Standard Libraries
+* Struct::new([name,]member,...) ??
* String#scanf(?)
* Object#fmt(?)
* Time::strptime
diff --git a/array.c b/array.c
index 766d304..9cc0ac1 100644
--- a/array.c
+++ b/array.c
@@ -86,6 +86,7 @@ rb_ary_new2(len)
ary->len = 0;
ary->capa = len;
ary->ptr = 0;
+ if (len == 0) len++;
ary->ptr = ALLOC_N(VALUE, len);
return (VALUE)ary;
diff --git a/configure b/configure
index 04a8c14..700b05c 100644
--- a/configure
+++ b/configure
@@ -4056,7 +4056,7 @@ echo "configure:4028: checking whether OS depend dynamic link works" >&5
LDFLAGS="-Wl,-E"
rb_cv_dlopen=yes;;
solaris*) if test "$GCC" = yes; then
- LDSHARED='gcc -Wl,-G'
+ LDSHARED='$(CC) -Wl,-G'
`$CC --print-prog-name=ld` -v 2>&1 | grep "GNU ld" > /dev/null && LDFLAGS="-Wl,-E"
else
LDSHARED='ld -G'
@@ -4070,11 +4070,11 @@ echo "configure:4028: checking whether OS depend dynamic link works" >&5
rb_cv_dlopen=yes;;
esix*|uxpds*) LDSHARED="ld -G"
rb_cv_dlopen=yes ;;
- osf*) LDSHARED="gcc -shared"
+ osf*) LDSHARED="$CC -shared"
rb_cv_dlopen=yes ;;
- linux*) LDSHARED="gcc -shared"
+ linux*) LDSHARED="$CC -shared"
rb_cv_dlopen=yes ;;
- freebsd*) LDSHARED="gcc -shared"
+ freebsd*) LDSHARED="$CC -shared"
if test -x /usr/bin/objformat && \
test `/usr/bin/objformat` = "elf" ; then
LDFLAGS="-rdynamic"
diff --git a/configure.bat b/configure.bat
index bbde277..ce0aa8b 100644
--- a/configure.bat
+++ b/configure.bat
@@ -14,7 +14,6 @@ if errorlevel 0 goto not_seen
:not_seen
sed -f top.sed < Makefile.in > Makefile
sed -f top.sed < ext\extmk.rb.in > ext\extmk.rb
-copy ext\Setup.dj ext\Setup
copy config_h.dj config.h
if not (%OS%) == (Windows_NT) goto LFN
copy missing\vsnprintf.c missing\vsnprint.c
diff --git a/configure.in b/configure.in
index 6c36e1b..8e86e42 100644
--- a/configure.in
+++ b/configure.in
@@ -400,7 +400,7 @@ if test "$with_dln_a_out" != yes; then
LDFLAGS="-Wl,-E"
rb_cv_dlopen=yes;;
solaris*) if test "$GCC" = yes; then
- LDSHARED='gcc -Wl,-G'
+ LDSHARED='$(CC) -Wl,-G'
`$CC --print-prog-name=ld` -v 2>&1 | grep "GNU ld" > /dev/null && LDFLAGS="-Wl,-E"
else
LDSHARED='ld -G'
@@ -414,11 +414,11 @@ if test "$with_dln_a_out" != yes; then
rb_cv_dlopen=yes;;
esix*|uxpds*) LDSHARED="ld -G"
rb_cv_dlopen=yes ;;
- osf*) LDSHARED="gcc -shared"
+ osf*) LDSHARED="$CC -shared"
rb_cv_dlopen=yes ;;
- linux*) LDSHARED="gcc -shared"
+ linux*) LDSHARED="$CC -shared"
rb_cv_dlopen=yes ;;
- freebsd*) LDSHARED="gcc -shared"
+ freebsd*) LDSHARED="$CC -shared"
if test -x /usr/bin/objformat && \
test `/usr/bin/objformat` = "elf" ; then
LDFLAGS="-rdynamic"
diff --git a/eval.c b/eval.c
index ea9f49f..0562300 100644
--- a/eval.c
+++ b/eval.c
@@ -404,6 +404,7 @@ static struct SCOPE *top_scope;
_frame.iter = ruby_iter->iter; \
_frame.cbase = ruby_frame->cbase; \
_frame.argc = 0; \
+ _frame.argv = 0; \
ruby_frame = &_frame; \
#define POP_FRAME() \
@@ -2212,7 +2213,10 @@ rb_eval(self, node)
case NODE_SCOPE:
{
- VALUE save = ruby_frame->cbase;
+ struct FRAME frame = *ruby_frame;
+
+ frame.tmp = ruby_frame;
+ ruby_frame = &frame;
PUSH_SCOPE();
PUSH_TAG(PROT_NONE);
@@ -2233,7 +2237,7 @@ rb_eval(self, node)
}
POP_TAG();
POP_SCOPE();
- ruby_frame->cbase = save;
+ ruby_frame = frame.tmp;
if (state) JUMP_TAG(state);
}
break;
@@ -2847,12 +2851,15 @@ module_setup(module, node)
NODE * volatile node;
{
int state;
- VALUE save = ruby_frame->cbase;
+ struct FRAME frame = *ruby_frame;
VALUE result; /* OK */
char *file = ruby_sourcefile;
int line = ruby_sourceline;
TMP_PROTECT;
+ frame.tmp = ruby_frame;
+ ruby_frame = &frame;
+
/* fill c-ref */
node->nd_clss = module;
node = node->nd_body;
@@ -2888,7 +2895,7 @@ module_setup(module, node)
POP_SCOPE();
POP_CLASS();
- ruby_frame->cbase = save;
+ ruby_frame = frame.tmp;
if (trace_func) {
call_trace_func("end", file, line, 0, ruby_frame->last_func, 0);
}
@@ -4199,7 +4206,6 @@ eval(self, src, scope, file, line)
struct BLOCK * volatile old_block;
struct RVarmap * volatile old_d_vars;
int volatile old_vmode;
- struct FRAME * volatile old_frame;
struct FRAME frame;
char *filesave = ruby_sourcefile;
int linesave = ruby_sourceline;
@@ -4221,7 +4227,6 @@ eval(self, src, scope, file, line)
/* PUSH BLOCK from data */
frame = data->frame;
frame.tmp = ruby_frame; /* gc protection */
- old_frame = ruby_frame;
ruby_frame = &(frame);
old_scope = ruby_scope;
ruby_scope = data->scope;
@@ -4259,7 +4264,7 @@ eval(self, src, scope, file, line)
POP_CLASS();
ruby_in_eval--;
if (!NIL_P(scope)) {
- ruby_frame = old_frame;
+ ruby_frame = frame.tmp;
if (FL_TEST(ruby_scope, SCOPE_DONT_RECYCLE))
FL_SET(old_scope, SCOPE_DONT_RECYCLE);
ruby_scope = old_scope;
@@ -5324,10 +5329,20 @@ static void
blk_free(data)
struct BLOCK *data;
{
- struct BLOCK *tmp;
+ struct FRAME *frame;
+ void *tmp;
+ frame = data->frame.prev;
+ while (frame) {
+ if (frame->argc > 0)
+ free(frame->argv);
+ tmp = frame;
+ frame = frame->prev;
+ free(tmp);
+ }
while (data) {
- free(data->frame.argv);
+ if (data->frame.argc > 0)
+ free(data->frame.argv);
tmp = data;
data = data->prev;
free(tmp);
@@ -5343,14 +5358,36 @@ blk_copy_prev(block)
while (block->prev) {
tmp = ALLOC_N(struct BLOCK, 1);
MEMCPY(tmp, block->prev, struct BLOCK, 1);
- tmp->frame.argv = ALLOC_N(VALUE, tmp->frame.argc);
+ if (tmp->frame.argc > 0) {
+ tmp->frame.argv = ALLOC_N(VALUE, tmp->frame.argc);
+ MEMCPY(tmp->frame.argv, block->frame.argv, VALUE, tmp->frame.argc);
+ }
scope_dup(tmp->scope);
- MEMCPY(tmp->frame.argv, block->frame.argv, VALUE, tmp->frame.argc);
block->prev = tmp;
block = tmp;
}
}
+static void
+frame_dup(frame)
+ struct FRAME *frame;
+{
+ VALUE *argv;
+ struct FRAME *tmp;
+
+ for (;;) {
+ if (frame->argc > 0) {
+ argv = ALLOC_N(VALUE, frame->argc);
+ MEMCPY(argv, frame->argv, VALUE, frame->argc);
+ frame->argv = argv;
+ }
+ if (!frame->prev) break;
+ tmp = ALLOC(struct FRAME);
+ *tmp = *frame->prev;
+ frame->prev = tmp;
+ frame = tmp;
+ }
+}
static VALUE
bind_clone(self)
@@ -5363,8 +5400,7 @@ bind_clone(self)
bind = Data_Make_Struct(rb_cBinding,struct BLOCK,blk_mark,blk_free,data);
CLONESETUP(bind,self);
MEMCPY(data, orig, struct BLOCK, 1);
- data->frame.argv = ALLOC_N(VALUE, orig->frame.argc);
- MEMCPY(data->frame.argv, orig->frame.argv, VALUE, orig->frame.argc);
+ frame_dup(&data->frame);
if (data->iter) {
blk_copy_prev(data);
@@ -5389,11 +5425,10 @@ rb_f_binding(self)
data->orig_thread = rb_thread_current();
data->iter = rb_f_iterator_p();
+ frame_dup(&data->frame);
if (ruby_frame->prev) {
data->frame.last_func = ruby_frame->prev->last_func;
}
- data->frame.argv = ALLOC_N(VALUE, data->frame.argc);
- MEMCPY(data->frame.argv, ruby_block->frame.argv, VALUE, data->frame.argc);
if (data->iter) {
blk_copy_prev(data);
@@ -5467,8 +5502,7 @@ proc_s_new(klass)
data->orig_thread = rb_thread_current();
data->iter = data->prev?Qtrue:Qfalse;
- data->frame.argv = ALLOC_N(VALUE, data->frame.argc);
- MEMCPY(data->frame.argv, ruby_block->frame.argv, VALUE, data->frame.argc);
+ frame_dup(&data->frame);
if (data->iter) {
blk_copy_prev(data);
}
diff --git a/ext/Setup.nt b/ext/Setup.nt
index 4d9244e..cd7969b 100644
--- a/ext/Setup.nt
+++ b/ext/Setup.nt
@@ -1,4 +1,4 @@
-option nodynamic
+#option nodynamic
#GD
Win32API
diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in
index f4f8c8c..66f5e92 100644
--- a/ext/extmk.rb.in
+++ b/ext/extmk.rb.in
@@ -17,6 +17,8 @@ end
SRC_EXT = ["c", "cc", "m", "cxx", "cpp", "C"]
$extlist = []
+$includedir = "@includedir@".gsub(/\$\{prefix\}|\$\(prefix\)/,'@prefix@')
+
$cache_mod = false
$lib_cache = {}
$func_cache = {}
@@ -67,8 +69,8 @@ if RUBY_PLATFORM == "m68k-human"
else
CFLAGS = "@CFLAGS@"
end
-LINK = "@CC@ -o conftest -I#$topdir -I#$top_srcdir #{CFLAGS} -I@includedir@ @LDFLAGS@ %s %s conftest.c %s %s @LIBS@"
-CPP = "@CPP@ @CPPFLAGS@ -I#$topdir -I#$top_srcdir #{CFLAGS} -I@includedir@ %s %s conftest.c"
+LINK = "@CC@ -o conftest -I#$topdir -I#$top_srcdir #{CFLAGS} -I#$includedir @LDFLAGS@ %s %s conftest.c %s %s @LIBS@"
+CPP = "@CPP@ @CPPFLAGS@ -I#$topdir -I#$top_srcdir #{CFLAGS} -I#$includedir %s %s conftest.c"
if /cygwin|mswin32|djgpp|mingw32|m68k-human|i386-os2_emx/i =~ RUBY_PLATFORM
$null = open("nul", "w")
@@ -80,6 +82,7 @@ $orgerr = $stderr.dup
$orgout = $stdout.dup
def xsystem command
if $DEBUG
+ puts command
return system(command)
end
$stderr.reopen($null)
@@ -378,7 +381,7 @@ def create_makefile(target)
if "@DLEXT@" == $OBJEXT
libs = $libs.split
for lib in libs
- lib.sub!(/-l(.*)/, '"lib\1.#{$LIBEXT}"')
+ lib.sub!(/-l(.*)/, %%"lib\\1.#{$LIBEXT}"%)
end
$defs.push(format("-DEXTLIB='%s'", libs.join(",")))
end
@@ -687,7 +690,10 @@ if $cache_mod
f.close
end
-exit if $install or $clean
+if $install or $clean
+ Dir.chdir ".."
+ exit
+end
$extinit = "" unless $extinit
ruby = "@RUBY_INSTALL_NAME@@EXEEXT@"
diff --git a/ext/fcntl/fcntl.c b/ext/fcntl/fcntl.c
index 186f9ac..80e0112 100644
--- a/ext/fcntl/fcntl.c
+++ b/ext/fcntl/fcntl.c
@@ -34,6 +34,7 @@ pack up your own arguments to pass as args for locking functions, etc.
#include "ruby.h"
#include <fcntl.h>
+void
Init_fcntl()
{
VALUE mFcntl = rb_define_module("Fcntl");
diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c
index aa38bad..f275e28 100644
--- a/ext/nkf/nkf.c
+++ b/ext/nkf/nkf.c
@@ -133,9 +133,9 @@ rb_nkf_guess(obj, src)
if (*p == '\033') {
return INT2FIX(_JIS);
}
- if ('\000' < *p && *p < '\006'
+ if ('\000' <= *p && *p < '\006'
|| *p == 0x7f
- || *p == 0xdf) {
+ || *p == 0xff) {
return INT2FIX(_BINARY);
}
if (0x81 <= *p && *p <= 0x8d) {
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index 3626793..da1a2a6 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -259,6 +259,8 @@ else
$objs += ["getnameinfo.#{$OBJEXT}"]
have_func("inet_ntop") or have_func("inet_ntoa")
have_func("inet_pton") or have_func("inet_aton")
+ have_header("arpa/nameser.h")
+ have_header("resolv.h")
end
have_header("sys/un.h")
diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c
index d09d726..c71a56c 100644
--- a/ext/socket/getaddrinfo.c
+++ b/ext/socket/getaddrinfo.c
@@ -49,9 +49,13 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#if defined(HAVE_ARPA_NAMESER_H)
#include <arpa/nameser.h>
+#endif
#include <netdb.h>
+#if defined(HAVE_RESOLV_H)
#include <resolv.h>
+#endif
#include <unistd.h>
#else
#include <winsock2.h>
diff --git a/ext/socket/getnameinfo.c b/ext/socket/getnameinfo.c
index fbb39e0..abadd8f 100644
--- a/ext/socket/getnameinfo.c
+++ b/ext/socket/getnameinfo.c
@@ -39,10 +39,14 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#if defined(HAVE_ARPA_NAMESER_H)
#include <arpa/nameser.h>
+#endif
#include <netdb.h>
+#if defined(HAVE_RESOLV_H)
#include <resolv.h>
#endif
+#endif
#ifdef NT
#include <winsock2.h>
#include <stdio.h>
diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c
index b1dae08..3142468 100644
--- a/ext/tcltklib/tcltklib.c
+++ b/ext/tcltklib/tcltklib.c
@@ -4,10 +4,6 @@
* Oct. 24, 1997 Y. Matsumoto
*/
-#if defined(NT)
-# include <windows.h>
-#endif
-
#include <stdio.h>
#include <string.h>
#include <tcl.h>
diff --git a/ext/tk/tkutil.c b/ext/tk/tkutil.c
index efa3fd7..9d4ca0a 100644
--- a/ext/tk/tkutil.c
+++ b/ext/tk/tkutil.c
@@ -33,6 +33,7 @@ tk_s_new(argc, argv, klass)
return obj;
}
+void
Init_tkutil()
{
VALUE mTK = rb_define_module("TkUtil");
diff --git a/gc.c b/gc.c
index ce668cf..7e2a4f7 100644
--- a/gc.c
+++ b/gc.c
@@ -909,7 +909,13 @@ rb_gc()
rb_gc_mark_frame(frame);
}
for (frame = ruby_frame; frame; frame = frame->prev) {
- if (frame->tmp) rb_gc_mark_frame(frame->tmp);
+ if (frame->tmp) {
+ struct FRAME *tmp = frame->tmp;
+ while (tmp) {
+ rb_gc_mark_frame(tmp);
+ tmp = tmp->prev;
+ }
+ }
}
rb_gc_mark(ruby_class);
rb_gc_mark(ruby_scope);
diff --git a/lib/date2.rb b/lib/date2.rb
index a1045a9..58bfbe5 100644
--- a/lib/date2.rb
+++ b/lib/date2.rb
@@ -1,5 +1,5 @@
-# date.rb: Written by Tadayoshi Funaba 1998, 1999
-# $Id: date.rb,v 1.7 1999/03/06 02:05:59 tadf Exp $
+# date2.rb: Written by Tadayoshi Funaba 1998, 1999
+# $Id: date2.rb,v 1.13 1999/08/11 01:10:02 tadf Exp $
class Date
@@ -12,12 +12,21 @@ class Date
DAYNAMES = [ 'Sunday', 'Monday', 'Tuesday',
'Wednesday', 'Thursday', 'Friday', 'Saturday' ]
- ITALY = 2299161 # Oct 15, 1582
+ ITALY = 2299161 # Oct 15, 1582
ENGLAND = 2361222 # Sept 14, 1752
class << self
- def civil_to_jd(y, m, d, gs=true)
+ def os? (jd, sg)
+ case sg
+ when Numeric; jd < sg
+ else; not sg
+ end
+ end
+
+ def ns? (jd, sg) not os?(jd, sg) end
+
+ def civil_to_jd(y, m, d, sg=true)
if m <= 2
y -= 1
m += 12
@@ -27,16 +36,14 @@ class Date
jd = (365.25 * (y + 4716)).to_i +
(30.6001 * (m + 1)).to_i +
d + b - 1524
- unless
- (if gs.kind_of? Numeric then jd >= gs else gs end)
+ if os?(jd, sg)
jd -= b
end
jd
end
- def jd_to_civil(jd, gs=true)
- unless
- (if gs.kind_of? Numeric then jd >= gs else gs end)
+ def jd_to_civil(jd, sg=true)
+ if os?(jd, sg)
a = jd
else
x = ((jd - 1867216.25) / 36524.25).to_i
@@ -57,87 +64,89 @@ class Date
return y, m, dom
end
- def ordinal_to_jd(y, d, gs=true)
- civil_to_jd(y, 1, d, gs)
+ def ordinal_to_jd(y, d, sg=true)
+ civil_to_jd(y, 1, d, sg)
end
- def jd_to_ordinal(jd, gs=true)
- y, *_ = jd_to_civil(jd, gs)
- ns = if gs.kind_of? Numeric then jd >= gs else gs end
- pl = civil_to_jd(y - 1, 12, 31, ns)
+ def jd_to_ordinal(jd, sg=true)
+ y = jd_to_civil(jd, sg)[0]
+ pl = civil_to_jd(y - 1, 12, 31, ns?(jd, sg))
doy = jd - pl
return y, doy
end
- def mjd_to_jd(mjd)
- mjd + 2400000.5
- end
-
- def jd_to_mjd(jd)
- jd - 2400000.5
- end
-
- def tjd_to_jd(tjd)
- tjd + 2440000.5
- end
-
- def jd_to_tjd(jd)
- jd - 2440000.5
- end
+ def mjd_to_jd(mjd) mjd + 2400000.5 end
+ def jd_to_mjd(jd) jd - 2400000.5 end
+ def tjd_to_jd(tjd) tjd + 2440000.5 end
+ def jd_to_tjd(jd) jd - 2440000.5 end
- def julian_leap? (y)
- y % 4 == 0
- end
-
- def gregorian_leap? (y)
- y % 4 == 0 and y % 100 != 0 or y % 400 == 0
- end
+ def julian_leap? (y) y % 4 == 0 end
+ def gregorian_leap? (y) y % 4 == 0 and y % 100 != 0 or y % 400 == 0 end
alias_method :leap?, :gregorian_leap?
- def exist3? (y, m, d, gs=true)
- jd = civil_to_jd(y, m, d, gs)
- if [y, m, d] == jd_to_civil(jd, gs)
+ def exist3? (y, m, d, sg=ITALY)
+ if m < 0
+ m += 13
+ end
+ if d < 0
+ ljd = nil
+ 31.downto 1 do |ld|
+ break if ljd = exist3?(y, m, ld, sg)
+ end
+ x = y * 12 + m
+ ny = x / 12
+ nm = x % 12 + 1
+ d = jd_to_civil(civil_to_jd(ny, nm, 1, ns?(ljd, sg)) + d,
+ ns?(ljd, sg))[-1]
+ end
+ jd = civil_to_jd(y, m, d, sg)
+ if [y, m, d] == jd_to_civil(jd, sg)
jd
end
end
alias_method :exist?, :exist3?
- def new3(y=-4712, m=1, d=1, gs=ITALY)
- unless jd = exist3?(y, m, d, gs)
+ def new3(y=-4712, m=1, d=1, sg=ITALY)
+ unless jd = exist3?(y, m, d, sg)
fail ArgumentError, 'invalid date'
end
- new(jd, gs)
+ new(jd, sg)
end
- def exist2? (y, d, gs=true)
- jd = ordinal_to_jd(y, d, gs)
- if [y, d] == jd_to_ordinal(jd, gs)
+ def exist2? (y, d, sg=ITALY)
+ if d < 0
+ ljd = nil
+ 366.downto 1 do |ld|
+ break if ljd = exist2?(y, ld, sg)
+ end
+ ny = y + 1
+ d = jd_to_ordinal(ordinal_to_jd(ny, 1, ns?(ljd, sg)) + d,
+ ns?(ljd, sg))[-1]
+ end
+ jd = ordinal_to_jd(y, d, sg)
+ if [y, d] == jd_to_ordinal(jd, sg)
jd
end
end
- def new2(y=-4712, d=1, gs=ITALY)
- unless jd = exist2?(y, d, gs)
+ def new2(y=-4712, d=1, sg=ITALY)
+ unless jd = exist2?(y, d, sg)
fail ArgumentError, 'invalid date'
end
- new(jd, gs)
+ new(jd, sg)
end
- def today(gs=ITALY)
- new(civil_to_jd(*(Time.now.to_a[3..5].reverse << gs)), gs)
+ def today(sg=ITALY)
+ new(civil_to_jd(*(Time.now.to_a[3..5].reverse << sg)), sg)
end
end
- def initialize(jd=0, gs=ITALY)
- @jd, @gs = jd, gs
- end
+ def initialize(jd=0, sg=ITALY) @jd, @sg = jd, sg end
- def jd
- @jd
- end
+ def jd() @jd end
def mjd
def self.mjd() @mjd end
@@ -152,8 +161,10 @@ class Date
def civil
def self.year() @year end
def self.mon() @mon end
+ def self.month() @mon end
def self.mday() @mday end
- @year, @mon, @mday = Date.jd_to_civil(@jd, @gs)
+ def self.day() @mday end
+ @year, @mon, @mday = Date.jd_to_civil(@jd, @sg)
end
private :civil
@@ -165,7 +176,7 @@ class Date
def yday
def self.yday() @yday end
- _, @yday = Date.jd_to_ordinal(@jd, @gs)
+ @yday = Date.jd_to_ordinal(@jd, @sg)[-1]
@yday
end
@@ -174,33 +185,39 @@ class Date
@mon
end
+ alias_method :month, :mon
+
def mday
civil
@mday
end
+ alias_method :day, :mday
+
def wday
def self.wday() @wday end
@wday = (@jd + 1) % 7
end
+ def os? () Date.os?(@jd, @sg) end
+ def ns? () Date.ns?(@jd, @sg) end
+
def leap?
def self.leap?() @leap_p end
- ns = if @gs.kind_of? Numeric then @jd >= @gs else @gs end
- jd = Date.civil_to_jd(year, 2, 28, ns)
- @leap_p = Date.jd_to_civil(jd + 1, ns)[1] == 2
+ @leap_p = Date.jd_to_civil(Date.civil_to_jd(year, 3, 1, ns?) - 1,
+ ns?)[-1] == 29
end
def + (other)
case other
- when Numeric; return Date.new(@jd + other, @gs)
+ when Numeric; return Date.new(@jd + other, @sg)
end
fail TypeError, 'expected numeric'
end
def - (other)
case other
- when Numeric; return Date.new(@jd - other, @gs)
+ when Numeric; return Date.new(@jd - other, @sg)
when Date; return @jd - other.jd
end
fail TypeError, 'expected numeric or date'
@@ -216,40 +233,35 @@ class Date
def downto(min)
@jd.downto(min.jd) do |jd|
- yield Date.new(jd, @gs)
+ yield Date.new(jd, @sg)
end
+ self
end
def upto(max)
@jd.upto(max.jd) do |jd|
- yield Date.new(jd, @gs)
+ yield Date.new(jd, @sg)
end
+ self
end
- def step(max, step)
- @jd.step(max.jd, step) do |jd|
- yield Date.new(jd, @gs)
+ def step(limit, step)
+ @jd.step(limit.jd, step) do |jd|
+ yield Date.new(jd, @sg)
end
+ self
end
- def eql? (other)
- self == other
- end
+ def succ() self + 1 end
- def hash
- @jd
- end
+ alias_method :next, :succ
- def to_s
- format('%04d-%02d-%02d', year, mon, mday)
- end
+ def eql? (other) self == other end
+ def hash() @jd end
+ def inspect() format('#<Date: %s,%s>', @jd, @sg) end
+ def to_s() format('%.4d-%02d-%02d', year, mon, mday) end
- def _dump(limit)
- Marshal.dump([@jd, @gs], -1)
- end
-
- def Date._load(str)
- Date.new(*Marshal.load(str))
- end
+ def _dump(limit) Marshal.dump([@jd, @sg], -1) end
+ def Date._load(str) Date.new(*Marshal.load(str)) end
end
diff --git a/lib/debug.rb b/lib/debug.rb
index 91bad1f..d2f1da8 100644
--- a/lib/debug.rb
+++ b/lib/debug.rb
@@ -157,7 +157,7 @@ class DEBUGGER__
when /^c(?:ont)?$/
return
- when /^s(?:tep)?\s+(\d+)?$/
+ when /^s(?:tep)?(?:\s+(\d+))?$/
if $1
lev = $1.to_i
else
@@ -166,7 +166,7 @@ class DEBUGGER__
@stop_next = lev
return
- when /^n(?:ext)?\s+(\d+)?$/
+ when /^n(?:ext)?(?:\s+(\d+))?$/
if $1
lev = $1.to_i
else
@@ -221,7 +221,7 @@ class DEBUGGER__
STDOUT.printf "no sourcefile available for %s\n", binding_file
end
- when /^up\s+(\d+)?$/
+ when /^up(?:\s+(\d+))?$/
previus_line = nil
if $1
lev = $1.to_i
@@ -237,7 +237,7 @@ class DEBUGGER__
info, binding_file, binding_line = frame_info(frame_pos)
STDOUT.printf "#%d %s\n", frame_pos, info
- when /^down\s+(\d+)?$/
+ when /^down(?:\s+(\d+))?$/
previus_line = nil
if $1
lev = $1.to_i
diff --git a/lib/telnet.rb b/lib/telnet.rb
index 5a0ae40..96e2cac 100644
--- a/lib/telnet.rb
+++ b/lib/telnet.rb
@@ -1,11 +1,11 @@
=begin
-$Date: 1999/07/16 13:39:42 $
+$Date: 1999/08/10 05:20:21 $
== SIMPLE TELNET CLIANT LIBRARY
telnet.rb
-Version 0.231
+Version 0.232
Wakou Aoyama <wakou@fsinet.or.jp>
@@ -34,7 +34,7 @@ the network or the host is very heavy, the value is enlarged.
=== STATUS OUTPUT
- host = Telnet.new({"Hosh" => "localhost"){|c| print c }
+ host = Telnet.new({"Host" => "localhost"){|c| print c }
connection status output.
@@ -147,6 +147,14 @@ of cource, set sync=true or flush is necessary.
== HISTORY
+=== Version 0.232
+
+1999/08/10 05:20:21
+
+- STATUS OUTPUT sample code typo. thanks to Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ host = Telnet.new({"Hosh" => "localhost"){|c| print c }
+ host = Telnet.new({"Host" => "localhost"){|c| print c }
+
=== Version 0.231
1999/07/16 13:39:42
@@ -362,8 +370,8 @@ class Telnet < SimpleDelegator
EOL = CR + LF
v = $-v
$-v = false
- VERSION = "0.231"
- RELEASE_DATE = "$Date: 1999/07/16 13:39:42 $"
+ VERSION = "0.232"
+ RELEASE_DATE = "$Date: 1999/08/10 05:20:21 $"
$-v = v
def initialize(options)
diff --git a/numeric.c b/numeric.c
index d1f5905..568d6c0 100644
--- a/numeric.c
+++ b/numeric.c
@@ -443,7 +443,8 @@ flo_cmp(x, y)
}
if (a == b) return INT2FIX(0);
if (a > b) return INT2FIX(1);
- return INT2FIX(-1);
+ if (a < b) return INT2FIX(-1);
+ rb_raise(rb_eFloatDomainError, "comparing NaN");
}
static VALUE
diff --git a/parse.y b/parse.y
index af7ab6f..103d01b 100644
--- a/parse.y
+++ b/parse.y
@@ -1865,6 +1865,8 @@ pushback(c)
lex_p--;
}
+#define peek(c) (lex_p != lex_pend && (c) == *lex_p)
+
#define tokfix() (tokenbuf[tokidx]='\0')
#define tok() tokenbuf
#define toklen() tokidx
@@ -3186,15 +3188,8 @@ yylex()
}
c = nextc();
}
- if ((c == '!' || c == '?') && is_identchar(tok()[0])) {
+ if ((c == '!' || c == '?') && is_identchar(tok()[0]) && !peek('=')) {
tokadd(c);
- if (c == '!') {
- c = nextc();
- if (c == '=') {
- rb_warn("identifier! immediately followed by `='");
- }
- pushback(c);
- }
}
else {
pushback(c);
@@ -3238,7 +3233,7 @@ yylex()
} else {
result = tIDENTIFIER;
if (lex_state == EXPR_FNAME || lex_state == EXPR_DOT) {
- if ((c = nextc()) == '=') {
+ if ((c = nextc()) == '=' && !peek('=')) {
tokadd(c);
}
else {
diff --git a/regex.c b/regex.c
index d4eea4c..aa0b613 100644
--- a/regex.c
+++ b/regex.c
@@ -2941,7 +2941,9 @@ re_search(bufp, string, size, startpos, range, regs)
if (range > 0) {
if (startpos > 0)
return -1;
- return re_match(bufp, string, size, 0, regs);
+ else if (re_match(bufp, string, size, 0, regs) >= 0)
+ return 0;
+ return -1;
}
break;
@@ -4066,12 +4068,6 @@ re_match(bufp, string_arg, size, pos, regs)
loop, need to pop this failure point and use the next one. */
pop_loop:
switch ((enum regexpcode)*p1) {
- case stop_paren:
-#if 0
- failed_paren = 1;
- p1++;
- goto pop_loop;
-#endif
case jump_n:
case finalize_push_n:
is_a_jump_n = 1;
diff --git a/sample/cal.rb b/sample/cal.rb
index c65f7a7..cf82c64 100644
--- a/sample/cal.rb
+++ b/sample/cal.rb
@@ -1,7 +1,7 @@
#! /usr/local/bin/ruby
-# cal.rb (bsd compatible version): Written by Tadayoshi Funaba 1998, 1999
-# $Id: bsdcal.rb,v 1.4 1999/03/06 02:05:59 tadf Exp $
+# cal.rb: Written by Tadayoshi Funaba 1998, 1999
+# $Id: cal.rb,v 1.5 1999/08/04 14:54:18 tadf Exp $
require 'date2'
@@ -35,11 +35,11 @@ def usage
exit 1
end
-def cal(m, y, gs)
+def cal(m, y, sg)
for d in 1..31
- break if jd = Date.exist?(y, m, d, gs)
+ break if jd = Date.exist?(y, m, d, sg)
end
- fst = cur = Date.new(jd, gs)
+ fst = cur = Date.new(jd, sg)
ti = Date::MONTHNAMES[m]
ti << ' ' << y.to_s unless $yr
mo = ti.center((($w + 1) * 7) - 1) << "\n"
@@ -91,7 +91,7 @@ while /^-([^-].*)$/no =~ $*[0]
$*.shift
end
$*.shift if /^--/no =~ $*[0]
-usage if (gs = $tab[$cc]).nil?
+usage if (sg = $tab[$cc]).nil?
case $*.length
when 0
td = Date.today
@@ -110,10 +110,10 @@ usage unless m.nil? or (1..12) === m
usage unless y >= -4712
$w = if $jd then 3 else 2 end
unless $yr
- print cal(m, y, gs)
+ print cal(m, y, sg)
else
print y.to_s.center(((($w + 1) * 7) - 1) *
(if $jd then 2 else 3 end) +
(if $jd then 2 else 4 end)), "\n\n",
- zip((1..12).collect{|m| cal(m, y, gs)}), "\n"
+ zip((1..12).collect{|m| cal(m, y, sg)}), "\n"
end
diff --git a/sample/goodfriday.rb b/sample/goodfriday.rb
index f0027ec..cc541af 100644
--- a/sample/goodfriday.rb
+++ b/sample/goodfriday.rb
@@ -1,25 +1,12 @@
#! /usr/local/bin/ruby
# goodfriday.rb: Written by Tadayoshi Funaba 1998
-# $Id: goodfriday.rb,v 1.1 1998/03/08 09:44:44 tadf Exp $
+# $Id: goodfriday.rb,v 1.3 1999/08/04 14:54:18 tadf Exp $
require 'date2'
+require 'holiday'
-def easter(y)
- g = (y % 19) + 1
- c = (y / 100) + 1
- x = (3 * c / 4) - 12
- z = ((8 * c + 5) / 25) - 5
- d = (5 * y / 4) - x - 10
- e = (11 * g + 20 + z - x) % 30
- e += 1 if e == 25 and g > 11 or e == 24
- n = 44 - e
- n += 30 if n < 21
- n = n + 7 - ((d + n) % 7)
- if n <= 31 then [y, 3, n] else [y, 4, n - 31] end
-end
-
-es = Date.new3(*easter(Time.now.year))
+es = Date.easter(Date.today.year)
[[-9*7, 'Septuagesima Sunday'],
[-8*7, 'Sexagesima Sunday'],
[-7*7, 'Quinquagesima Sunday (Shrove Sunday)'],
diff --git a/version.h b/version.h
index 2354f06..e5d5c71 100644
--- a/version.h
+++ b/version.h
@@ -1,4 +1,4 @@
#define RUBY_VERSION "1.3.7"
-#define RUBY_RELEASE_DATE "1999-08-06"
+#define RUBY_RELEASE_DATE "1999-08-11"
#define RUBY_VERSION_CODE 137
-#define RUBY_RELEASE_CODE 19990806
+#define RUBY_RELEASE_CODE 19990811
diff --git a/win32/Makefile b/win32/Makefile
index 6477476..5275069 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -82,7 +82,7 @@ OBJS = array.obj \
all: miniruby$(EXEEXT) rbconfig.rb ext/extmk.rb ext/Setup.nt rubymw.lib $(MISCLIBS)
set LIB=..\..\win32;$(ORGLIBPATH)
- @.\miniruby$(EXEEXT) -Xext extmk.rb static
+ @.\miniruby$(EXEEXT) -Xext extmk.rb
ext/extmk.rb: ext/extmk.rb.in rbconfig.rb
@echo Creating ext/extmk.rb
diff --git a/win32/win32.c b/win32/win32.c
index db43ce6..fd70242 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -2317,3 +2317,28 @@ wait()
return 0;
}
+char *
+win32_getenv(const char *name)
+{
+ static char *curitem = NULL; /* XXX threadead */
+ static DWORD curlen = 0; /* XXX threadead */
+ DWORD needlen;
+ if (!curitem) {
+ curlen = 512;
+ curitem = ALLOC_N(char, curlen);
+ }
+
+ needlen = GetEnvironmentVariable(name,curitem,curlen);
+ if (needlen != 0) {
+ while (needlen > curlen) {
+ REALLOC_N(curitem, char, needlen);
+ curlen = needlen;
+ needlen = GetEnvironmentVariable(name, curitem, curlen);
+ }
+ }
+ else {
+ return NULL;
+ }
+
+ return curitem;
+}
diff --git a/win32/win32.h b/win32/win32.h
index fd96632..04cb192 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -198,6 +198,7 @@ extern struct protoent * mygetprotobyname(char *);
extern struct protoent * mygetprotobynumber(int);
extern struct servent * mygetservbyname(char *, char *);
extern struct servent * mygetservbyport(int, char *);
+extern char *win32_getenv(const char *);
extern int chown(const char *, int, int);
extern int link(char *, char *);
@@ -385,4 +386,10 @@ extern char *mystrerror(int);
#undef get_osfhandle
#endif
#define get_osfhandle myget_osfhandle
+
+#ifdef getenv
+#undef getenv
+#endif
+#define getenv win32_getenv
+
#endif