summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--MANIFEST2
-rw-r--r--Makefile.in4
-rw-r--r--beos/ruby.def.in1
-rw-r--r--configure83
-rw-r--r--configure.in3
-rw-r--r--dir.c2
-rw-r--r--error.c2
-rw-r--r--eval.c344
-rw-r--r--ext/Setup2
-rw-r--r--ext/socket/socket.c33
-rw-r--r--ext/tcltklib/tcltklib.c87
-rw-r--r--file.c9
-rw-r--r--gc.c2
-rw-r--r--glob.c2
-rw-r--r--hash.c3
-rw-r--r--intern.h22
-rw-r--r--io.c30
-rw-r--r--lib/Env.rb14
-rw-r--r--lib/cgi-lib.rb10
-rw-r--r--lib/delegate.rb46
-rw-r--r--lib/eregex.rb11
-rw-r--r--lib/importenv.rb15
-rw-r--r--lib/mkmf.rb2
-rw-r--r--lib/thwait.rb71
-rw-r--r--lib/tk.rb63
-rw-r--r--lib/tkafter.rb265
-rw-r--r--lib/tkdialog.rb2
-rw-r--r--lib/tkpalette.rb4
-rw-r--r--lib/tktext.rb33
-rw-r--r--marshal.c1
-rw-r--r--missing/nt.h2
-rw-r--r--pack.c17
-rw-r--r--parse.y49
-rw-r--r--process.c24
-rw-r--r--re.c25
-rw-r--r--ruby.16
-rw-r--r--ruby.c4
-rw-r--r--ruby.h2
-rw-r--r--rubyio.h1
-rw-r--r--rubysig.h18
-rw-r--r--sample/cal.rb118
-rw-r--r--signal.c4
-rw-r--r--sprintf.c7
-rw-r--r--string.c3
-rw-r--r--time.c7
-rw-r--r--version.h4
-rw-r--r--win32/Makefile12
48 files changed, 1041 insertions, 445 deletions
diff --git a/ChangeLog b/ChangeLog
index 982b956..1772757 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Fri Jun 26 18:02:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_28.
+
+Fri Jun 26 11:01:26 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * string.c (str_aset_method): needed to convert to string.
+
Thu Jun 25 02:05:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* regex.c (re_search): optimize for `.*' at beginning of the
@@ -9,15 +17,16 @@ Thu Jun 25 02:05:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* regex.c (re_compile_pattern): detect optimization potential for
the compiled patterns.
+Thu Jun 25 00:02:26 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * re.c (reg_s_new): flag value was wrong.
+
Wed Jun 24 23:45:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* regex.c (re_search): wrong anchor handling for reverse search.
Wed Jun 24 02:18:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
- * eval.c: rename function prefix `thread_' to `thred_' to avoid
- conflict on some machine.
-
* parse.y (mlhs): `((a,b)),c = [[1,2]],3' assigns a=1,b=2,c=3.
Tue Jun 23 11:46:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
diff --git a/MANIFEST b/MANIFEST
index d4c6039..5863d5d 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -122,6 +122,7 @@ lib/tempfile.rb
lib/thread.rb
lib/thwait.rb
lib/tk.rb
+lib/tkafter.rb
lib/tkcanvas.rb
lib/tkclass.rb
lib/tkdialog.rb
@@ -154,6 +155,7 @@ missing/strtol.c
missing/strtoul.c
missing/x68.c
sample/biorhythm.rb
+sample/cal.rb
sample/cbreak.rb
sample/clnt.rb
sample/dbmtest.rb
diff --git a/Makefile.in b/Makefile.in
index 09ae22c..3195e89 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -192,12 +192,14 @@ enum.o: enum.c ruby.h config.h defines.h intern.h
error.o: error.c ruby.h config.h defines.h intern.h env.h
eval.o: eval.c ruby.h config.h defines.h intern.h node.h env.h rubysig.h st.h dln.h
file.o: file.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h
+fnmatch.o: fnmatch.c config.h fnmatch.h
gc.o: gc.c ruby.h config.h defines.h intern.h rubysig.h st.h node.h env.h re.h regex.h
+glob.o: config.h glob.c fnmatch.h
hash.o: hash.c ruby.h config.h defines.h intern.h st.h rubysig.h
inits.o: inits.c ruby.h config.h defines.h intern.h
io.o: io.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h
main.o: main.c ruby.h config.h defines.h intern.h
-marshal.o: marshal.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h st.h
+marshal.o: marshal.c ruby.h config.h defines.h intern.h rubyio.h st.h
math.o: math.c ruby.h config.h defines.h intern.h
numeric.o: numeric.c ruby.h config.h defines.h intern.h
object.o: object.c ruby.h config.h defines.h intern.h st.h
diff --git a/beos/ruby.def.in b/beos/ruby.def.in
index 3bdc536..04de159 100644
--- a/beos/ruby.def.in
+++ b/beos/ruby.def.in
@@ -304,6 +304,7 @@ st_init_table_with_size
st_insert
st_lookup
str2inum
+str2cstr
str_cat
str_cicmp
str_cmp
diff --git a/configure b/configure
index 5be0784..a8233bb 100644
--- a/configure
+++ b/configure
@@ -3178,17 +3178,16 @@ else
#line 3179 "configure"
#include "confdefs.h"
-#define FIXNUM_FLAG 0x01
int
main()
{
- if (-1==(((-1)<<1)|FIXNUM_FLAG)>>1);
+ if (-1==((-1)>>1))
return 0;
return 1;
}
EOF
-if { (eval echo configure:3192: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3191: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
rb_cv_rshift_sign=yes
else
@@ -3216,19 +3215,19 @@ EOF
fi
echo $ac_n "checking count field in FILE structures""... $ac_c" 1>&6
-echo "configure:3220: checking count field in FILE structures" >&5
+echo "configure:3219: checking count field in FILE structures" >&5
if eval "test \"`echo '$''{'rb_cv_fcnt'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3225 "configure"
+#line 3224 "configure"
#include "confdefs.h"
#include <stdio.h>
int main() {
FILE *f = stdin; f->_cnt = 0;
; return 0; }
EOF
-if { (eval echo configure:3232: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3231: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_fcnt="_cnt"
else
@@ -3238,14 +3237,14 @@ fi
rm -f conftest*
if test "$rb_cv_fcnt" = ""; then
cat > conftest.$ac_ext <<EOF
-#line 3242 "configure"
+#line 3241 "configure"
#include "confdefs.h"
#include <stdio.h>
int main() {
FILE *f = stdin; f->__cnt = 0;
; return 0; }
EOF
-if { (eval echo configure:3249: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3248: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_fcnt="__cnt"
else
@@ -3256,14 +3255,14 @@ rm -f conftest*
fi
if test "$rb_cv_fcnt" = ""; then
cat > conftest.$ac_ext <<EOF
-#line 3260 "configure"
+#line 3259 "configure"
#include "confdefs.h"
#include <stdio.h>
int main() {
FILE *f = stdin; f->_r = 0;
; return 0; }
EOF
-if { (eval echo configure:3267: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3266: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_fcnt="_r"
else
@@ -3274,14 +3273,14 @@ rm -f conftest*
fi
if test "$rb_cv_fcnt" = ""; then
cat > conftest.$ac_ext <<EOF
-#line 3278 "configure"
+#line 3277 "configure"
#include "confdefs.h"
#include <stdio.h>
int main() {
FILE *f = stdin; f->readCount = 0;
; return 0; }
EOF
-if { (eval echo configure:3285: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3284: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_fcnt="readCount"
else
@@ -3306,9 +3305,9 @@ fi
if test "$ac_cv_func_getpwent" = yes; then
echo $ac_n "checking struct passwd""... $ac_c" 1>&6
-echo "configure:3310: checking struct passwd" >&5
+echo "configure:3309: checking struct passwd" >&5
cat > conftest.$ac_ext <<EOF
-#line 3312 "configure"
+#line 3311 "configure"
#include "confdefs.h"
#include <pwd.h>
EOF
@@ -3323,7 +3322,7 @@ fi
rm -f conftest*
cat > conftest.$ac_ext <<EOF
-#line 3327 "configure"
+#line 3326 "configure"
#include "confdefs.h"
#include <pwd.h>
EOF
@@ -3338,7 +3337,7 @@ fi
rm -f conftest*
cat > conftest.$ac_ext <<EOF
-#line 3342 "configure"
+#line 3341 "configure"
#include "confdefs.h"
#include <pwd.h>
EOF
@@ -3353,7 +3352,7 @@ fi
rm -f conftest*
cat > conftest.$ac_ext <<EOF
-#line 3357 "configure"
+#line 3356 "configure"
#include "confdefs.h"
#include <pwd.h>
EOF
@@ -3368,7 +3367,7 @@ fi
rm -f conftest*
cat > conftest.$ac_ext <<EOF
-#line 3372 "configure"
+#line 3371 "configure"
#include "confdefs.h"
#include <pwd.h>
EOF
@@ -3383,7 +3382,7 @@ fi
rm -f conftest*
cat > conftest.$ac_ext <<EOF
-#line 3387 "configure"
+#line 3386 "configure"
#include "confdefs.h"
#include <pwd.h>
EOF
@@ -3398,7 +3397,7 @@ fi
rm -f conftest*
cat > conftest.$ac_ext <<EOF
-#line 3402 "configure"
+#line 3401 "configure"
#include "confdefs.h"
#include <pwd.h>
EOF
@@ -3431,7 +3430,7 @@ fi
case "$host_os" in
linux*)
echo $ac_n "checking whether ELF binaries are produced""... $ac_c" 1>&6
-echo "configure:3435: checking whether ELF binaries are produced" >&5
+echo "configure:3434: checking whether ELF binaries are produced" >&5
if eval "test \"`echo '$''{'rb_cv_linux_elf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -3439,7 +3438,7 @@ else
:
else
cat > conftest.$ac_ext <<EOF
-#line 3443 "configure"
+#line 3442 "configure"
#include "confdefs.h"
/* Test for whether ELF binaries are produced */
@@ -3459,7 +3458,7 @@ main() {
}
EOF
-if { (eval echo configure:3463: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3462: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
rb_cv_linux_elf=yes
else
@@ -3489,7 +3488,7 @@ STATIC=
if test "$with_dln_a_out" != yes; then
rb_cv_dlopen=unknown
echo $ac_n "checking whether OS depend dynamic link works""... $ac_c" 1>&6
-echo "configure:3493: checking whether OS depend dynamic link works" >&5
+echo "configure:3492: checking whether OS depend dynamic link works" >&5
if test "$GCC" = yes; then
case "$host_os" in
nextstep*) ;;
@@ -3567,13 +3566,13 @@ dln_a_out_works=no
if test "$ac_cv_header_a_out_h" = yes; then
if test "$with_dln_a_out" = yes || test "$rb_cv_dlopen" = unknown; then
echo $ac_n "checking whether matz's dln works""... $ac_c" 1>&6
-echo "configure:3571: checking whether matz's dln works" >&5
+echo "configure:3570: checking whether matz's dln works" >&5
cat confdefs.h > config.h
if eval "test \"`echo '$''{'rb_cv_dln_a_out'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3577 "configure"
+#line 3576 "configure"
#include "confdefs.h"
#define USE_DLN_A_OUT
@@ -3583,7 +3582,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:3587: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3586: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
rb_cv_dln_a_out=yes
else
@@ -3680,7 +3679,7 @@ fi
case "$host_os" in
human*)
echo $ac_n "checking for _harderr in -lsignal""... $ac_c" 1>&6
-echo "configure:3684: checking for _harderr in -lsignal" >&5
+echo "configure:3683: checking for _harderr in -lsignal" >&5
ac_lib_var=`echo signal'_'_harderr | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3688,7 +3687,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lsignal $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3692 "configure"
+#line 3691 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3699,7 +3698,7 @@ int main() {
_harderr()
; return 0; }
EOF
-if { (eval echo configure:3703: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3702: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -3727,7 +3726,7 @@ else
fi
echo $ac_n "checking for hmemset in -lhmem""... $ac_c" 1>&6
-echo "configure:3731: checking for hmemset in -lhmem" >&5
+echo "configure:3730: checking for hmemset in -lhmem" >&5
ac_lib_var=`echo hmem'_'hmemset | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3735,7 +3734,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lhmem $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3739 "configure"
+#line 3738 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3746,7 +3745,7 @@ int main() {
hmemset()
; return 0; }
EOF
-if { (eval echo configure:3750: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3749: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -3776,12 +3775,12 @@ fi
for ac_func in select
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3780: checking for $ac_func" >&5
+echo "configure:3779: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3785 "configure"
+#line 3784 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -3804,7 +3803,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:3808: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3807: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -3829,7 +3828,7 @@ fi
done
echo $ac_n "checking whether PD libc _dtos18 fail to convert big number""... $ac_c" 1>&6
-echo "configure:3833: checking whether PD libc _dtos18 fail to convert big number" >&5
+echo "configure:3832: checking whether PD libc _dtos18 fail to convert big number" >&5
if eval "test \"`echo '$''{'rb_cv_missing__dtos18'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -3837,7 +3836,7 @@ else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3841 "configure"
+#line 3840 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -3849,7 +3848,7 @@ main ()
}
EOF
-if { (eval echo configure:3853: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3852: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
rb_cv_missing__dtos18=yes
else
@@ -3871,7 +3870,7 @@ EOF
fi
echo $ac_n "checking whether PD libc fconvert fail to round""... $ac_c" 1>&6
-echo "configure:3875: checking whether PD libc fconvert fail to round" >&5
+echo "configure:3874: checking whether PD libc fconvert fail to round" >&5
if eval "test \"`echo '$''{'rb_cv_missing_fconvert'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -3879,7 +3878,7 @@ else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 3883 "configure"
+#line 3882 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -3892,7 +3891,7 @@ main ()
}
EOF
-if { (eval echo configure:3896: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3895: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
rb_cv_missing_fconvert=yes
else
diff --git a/configure.in b/configure.in
index 2c7a14b..9d5c4cc 100644
--- a/configure.in
+++ b/configure.in
@@ -234,11 +234,10 @@ AC_CHAR_UNSIGNED
AC_MSG_CHECKING(whether right shift preserve sign bit)
AC_CACHE_VAL(rb_cv_rshift_sign,
[AC_TRY_RUN([
-#define FIXNUM_FLAG 0x01
int
main()
{
- if (-1==(((-1)<<1)|FIXNUM_FLAG)>>1);
+ if (-1==((-1)>>1))
return 0;
return 1;
}
diff --git a/dir.c b/dir.c
index cce2572..a6c96ce 100644
--- a/dir.c
+++ b/dir.c
@@ -427,8 +427,6 @@ dir_foreach(io, dirname)
void
Init_Dir()
{
- extern VALUE mEnumerable;
-
cDir = rb_define_class("Dir", cObject);
rb_include_module(cDir, mEnumerable);
diff --git a/error.c b/error.c
index 277e431..b8bf252 100644
--- a/error.c
+++ b/error.c
@@ -217,7 +217,7 @@ rb_check_type(x, t)
}
/* exception classes */
-#include "errno.h"
+#include <errno.h>
VALUE eException;
VALUE eSystemExit, eInterrupt, eFatal;
diff --git a/eval.c b/eval.c
index 7357e42..cc2f935 100644
--- a/eval.c
+++ b/eval.c
@@ -929,9 +929,9 @@ eval_node(self)
int rb_in_eval;
#ifdef THREAD
-static void thred_cleanup _((void));
-static void thred_wait_other_threads _((void));
-static VALUE thred_current _((void));
+static void thread_cleanup _((void));
+static void thread_wait_other_threads _((void));
+static VALUE thread_current _((void));
#endif
static int exit_status;
@@ -963,8 +963,8 @@ ruby_run()
if ((state = EXEC_TAG()) == 0) {
rb_trap_exit();
#ifdef THREAD
- thred_cleanup();
- thred_wait_other_threads();
+ thread_cleanup();
+ thread_wait_other_threads();
#endif
exec_end_proc();
gc_call_finalizer_at_exit();
@@ -1546,7 +1546,7 @@ call_trace_func(event, file, line, self, id)
trace = trace_func;
trace_func = 0;
#ifdef THREAD
- thred_critical++;
+ thread_critical++;
#endif
prev = the_frame;
@@ -1568,7 +1568,7 @@ call_trace_func(event, file, line, self, id)
POP_FRAME();
#ifdef THREAD
- thred_critical--;
+ thread_critical--;
#endif
if (!trace_func) trace_func = trace;
if (state) JUMP_TAG(state);
@@ -4172,16 +4172,14 @@ static int
rb_provided(feature)
char *feature;
{
- struct RArray *features = RARRAY(rb_features);
VALUE *p, *pend;
char *f;
int len;
- p = features->ptr;
- pend = p + features->len;
+ p = RARRAY(rb_features)->ptr;
+ pend = p + RARRAY(rb_features)->len;
while (p < pend) {
- Check_Type(*p, T_STRING);
- f = RSTRING(*p)->ptr;
+ f = STR2CSTR(*p);
if (strcmp(f, feature) == 0) return TRUE;
len = strlen(feature);
if (strncmp(f, feature, len) == 0
@@ -4194,8 +4192,8 @@ rb_provided(feature)
}
#ifdef THREAD
-static int thred_loading _((char*));
-static void thred_loading_done _((void));
+static int thread_loading _((char*));
+static void thread_loading_done _((void));
#endif
void
@@ -4270,7 +4268,7 @@ f_require(obj, fname)
dyna_load:
#ifdef THREAD
- if (thred_loading(feature)) return FALSE;
+ if (thread_loading(feature)) return FALSE;
else {
int state;
PUSH_TAG(PROT_NONE);
@@ -4283,7 +4281,7 @@ f_require(obj, fname)
#ifdef THREAD
}
POP_TAG();
- thred_loading_done();
+ thread_loading_done();
if (state) JUMP_TAG(state);
}
#endif
@@ -4291,7 +4289,7 @@ f_require(obj, fname)
rb_load:
#ifdef THREAD
- if (thred_loading(feature)) return FALSE;
+ if (thread_loading(feature)) return FALSE;
else {
int state;
PUSH_TAG(PROT_NONE);
@@ -4302,7 +4300,7 @@ f_require(obj, fname)
#ifdef THREAD
}
POP_TAG();
- thred_loading_done();
+ thread_loading_done();
if (state) JUMP_TAG(state);
}
#endif
@@ -4855,7 +4853,7 @@ f_binding(self)
MEMCPY(data, the_block, struct BLOCK, 1);
#ifdef THREAD
- data->orig_thread = thred_current();
+ data->orig_thread = thread_current();
#endif
data->iter = f_iterator_p();
if (the_frame->prev) {
@@ -4898,7 +4896,7 @@ proc_s_new(klass)
*data = *the_block;
#ifdef THREAD
- data->orig_thread = thred_current();
+ data->orig_thread = thread_current();
#endif
data->iter = data->prev?TRUE:FALSE;
data->frame.argv = ALLOC_N(VALUE, data->frame.argc);
@@ -4945,7 +4943,7 @@ blk_orphan(data)
return 1;
}
#ifdef THREAD
- if (data->orig_thread != thred_current()) {
+ if (data->orig_thread != thread_current()) {
return 1;
}
#endif
@@ -5269,7 +5267,7 @@ Init_Proc()
static VALUE eThreadError;
-int thred_pending = 0;
+int thread_pending = 0;
VALUE cThread;
@@ -5378,7 +5376,7 @@ static thread_t main_thread;
#define STACK(addr) (th->stk_pos<(addr) && (addr)<th->stk_pos+th->stk_len)
static void
-thred_mark(th)
+thread_mark(th)
thread_t th;
{
struct FRAME *frame;
@@ -5425,12 +5423,12 @@ gc_mark_threads()
thread_t th;
FOREACH_THREAD(th) {
- thred_mark(th);
+ thread_mark(th);
} END_FOREACH(th);
}
static void
-thred_free(th)
+thread_free(th)
thread_t th;
{
if (th->stk_ptr) free(th->stk_ptr);
@@ -5439,10 +5437,10 @@ thred_free(th)
}
static thread_t
-thred_check(data)
+thread_check(data)
VALUE data;
{
- if (TYPE(data) != T_DATA || RDATA(data)->dfree != thred_free) {
+ if (TYPE(data) != T_DATA || RDATA(data)->dfree != thread_free) {
TypeError("wrong argument type %s (expected Thread)",
rb_class2name(CLASS_OF(data)));
}
@@ -5450,7 +5448,7 @@ thred_check(data)
}
static void
-thred_save_context(th)
+thread_save_context(th)
thread_t th;
{
VALUE v;
@@ -5484,7 +5482,7 @@ thred_save_context(th)
th->line = sourceline;
}
-static void thred_restore_context _((thread_t,int));
+static void thread_restore_context _((thread_t,int));
static void
stack_extend(th, exit)
@@ -5494,7 +5492,7 @@ stack_extend(th, exit)
VALUE space[1024];
memset(space, 0, 1); /* prevent array from optimization */
- thred_restore_context(th, exit);
+ thread_restore_context(th, exit);
}
static int th_raise_argc;
@@ -5505,7 +5503,7 @@ static VALUE th_cmd;
static int th_sig;
static void
-thred_restore_context(th, exit)
+thread_restore_context(th, exit)
thread_t th;
int exit;
{
@@ -5576,7 +5574,7 @@ thred_restore_context(th, exit)
}
static void
-thred_ready(th)
+thread_ready(th)
thread_t th;
{
/* The thread is no longer waiting on anything */
@@ -5594,24 +5592,24 @@ thred_ready(th)
}
static void
-thred_remove()
+thread_remove()
{
- thred_ready(curr_thread);
+ thread_ready(curr_thread);
curr_thread->status = THREAD_KILLED;
curr_thread->prev->next = curr_thread->next;
curr_thread->next->prev = curr_thread->prev;
- thred_schedule();
+ thread_schedule();
}
static int
-thred_dead(th)
+thread_dead(th)
thread_t th;
{
return th->status == THREAD_KILLED;
}
static void
-thred_deadlock()
+thread_deadlock()
{
curr_thread = main_thread;
th_raise_argc = 1;
@@ -5622,14 +5620,14 @@ thred_deadlock()
}
void
-thred_schedule()
+thread_schedule()
{
thread_t next; /* OK */
thread_t th;
thread_t curr;
select_err:
- thred_pending = 0;
+ thread_pending = 0;
if (curr_thread == curr_thread->next) return;
next = 0;
@@ -5649,7 +5647,7 @@ thred_schedule()
if (num_waiting_on_join) {
FOREACH_THREAD_FROM(curr, th) {
- if ((th->wait_for&WAIT_JOIN) && thred_dead(th->join)) {
+ if ((th->wait_for&WAIT_JOIN) && thread_dead(th->join)) {
th->join = 0;
th->wait_for &= ~WAIT_JOIN;
th->status = THREAD_RUNNABLE;
@@ -5755,7 +5753,7 @@ thred_schedule()
}
END_FOREACH_FROM(curr, th);
/* raise fatal error to main thread */
- thred_deadlock();
+ thread_deadlock();
}
if (next->status == THREAD_RUNNABLE && next == curr_thread) {
return;
@@ -5763,7 +5761,7 @@ thred_schedule()
/* context switch */
if (curr == curr_thread) {
- thred_save_context(curr);
+ thread_save_context(curr);
if (setjmp(curr->context)) {
return;
}
@@ -5772,13 +5770,13 @@ thred_schedule()
curr_thread = next;
if (next->status == THREAD_TO_KILL) {
/* execute ensure-clause if any */
- thred_restore_context(next, 1);
+ thread_restore_context(next, 1);
}
- thred_restore_context(next, 0);
+ thread_restore_context(next, 0);
}
void
-thred_wait_fd(fd)
+thread_wait_fd(fd)
int fd;
{
if (curr_thread == curr_thread->next) return;
@@ -5787,11 +5785,11 @@ thred_wait_fd(fd)
curr_thread->fd = fd;
num_waiting_on_fd++;
curr_thread->wait_for |= WAIT_FD;
- thred_schedule();
+ thread_schedule();
}
void
-thred_fd_writable(fd)
+thread_fd_writable(fd)
int fd;
{
struct timeval zero;
@@ -5804,12 +5802,12 @@ thred_fd_writable(fd)
FD_ZERO(&fds);
FD_SET(fd, &fds);
if (select(fd+1, 0, &fds, 0, &zero) == 1) break;
- thred_schedule();
+ thread_schedule();
}
}
void
-thred_wait_for(time)
+thread_wait_for(time)
struct timeval time;
{
double date;
@@ -5845,19 +5843,19 @@ thred_wait_for(time)
curr_thread->delay = date;
num_waiting_on_timer++;
curr_thread->wait_for |= WAIT_TIME;
- thred_schedule();
+ thread_schedule();
}
-void thred_sleep_forever _((void));
+void thread_sleep_forever _((void));
int
-thred_alone()
+thread_alone()
{
return curr_thread == curr_thread->next;
}
int
-thred_select(max, read, write, except, timeout)
+thread_select(max, read, write, except, timeout)
int max;
fd_set *read, *write, *except;
struct timeval *timeout;
@@ -5869,10 +5867,10 @@ thred_select(max, read, write, except, timeout)
if (!read && !write && !except) {
if (!timeout) {
- thred_sleep_forever();
+ thread_sleep_forever();
return 0;
}
- thred_wait_for(*timeout);
+ thread_wait_for(*timeout);
return 0;
}
@@ -5939,109 +5937,109 @@ thred_select(max, read, write, except, timeout)
if (limit <= timeofday()) return 0;
}
- thred_schedule();
+ thread_schedule();
CHECK_INTS;
}
}
static VALUE
-thred_join(dmy, thread)
+thread_join(dmy, thread)
VALUE dmy;
VALUE thread;
{
- thread_t th = thred_check(thread);
+ thread_t th = thread_check(thread);
- if (thred_dead(th)) return thread;
+ if (thread_dead(th)) return thread;
if ((th->wait_for & WAIT_JOIN) && th->join == curr_thread)
Raise(eThreadError, "Thread.join: deadlock");
curr_thread->status = THREAD_STOPPED;
curr_thread->join = th;
num_waiting_on_join++;
curr_thread->wait_for |= WAIT_JOIN;
- thred_schedule();
+ thread_schedule();
return thread;
}
static VALUE
-thred_current()
+thread_current()
{
return curr_thread->thread;
}
static VALUE
-thred_main()
+thread_main()
{
return main_thread->thread;
}
static VALUE
-thred_wakeup(thread)
+thread_wakeup(thread)
VALUE thread;
{
- thread_t th = thred_check(thread);
+ thread_t th = thread_check(thread);
if (th->status == THREAD_KILLED) Raise(eThreadError, "killed thread");
- thred_ready(th);
+ thread_ready(th);
return thread;
}
static VALUE
-thred_run(thread)
+thread_run(thread)
VALUE thread;
{
- thred_wakeup(thread);
- if (!thred_critical) thred_schedule();
+ thread_wakeup(thread);
+ if (!thread_critical) thread_schedule();
return thread;
}
static VALUE
-thred_kill(thread)
+thread_kill(thread)
VALUE thread;
{
- thread_t th = thred_check(thread);
+ thread_t th = thread_check(thread);
if (th->status == THREAD_TO_KILL || th->status == THREAD_KILLED)
return thread;
if (th == th->next || th == main_thread) rb_exit(0);
- thred_ready(th);
+ thread_ready(th);
th->status = THREAD_TO_KILL;
- thred_schedule();
+ thread_schedule();
return Qnil; /* not reached */
}
static VALUE
-thred_s_kill(obj, th)
+thread_s_kill(obj, th)
VALUE obj, th;
{
- return thred_kill(th);
+ return thread_kill(th);
}
static VALUE
-thred_exit()
+thread_exit()
{
- return thred_kill(curr_thread->thread);
+ return thread_kill(curr_thread->thread);
}
static VALUE
-thred_pass()
+thread_pass()
{
- thred_schedule();
+ thread_schedule();
return Qnil;
}
static VALUE
-thred_stop()
+thread_stop()
{
- thred_critical = 0;
+ thread_critical = 0;
curr_thread->status = THREAD_STOPPED;
if (curr_thread == curr_thread->next) {
Raise(eThreadError, "stopping only thread");
}
- thred_schedule();
+ thread_schedule();
return Qnil;
}
@@ -6049,7 +6047,7 @@ thred_stop()
struct timeval time_timeval();
void
-thred_sleep(sec)
+thread_sleep(sec)
int sec;
{
if (curr_thread == curr_thread->next) {
@@ -6058,11 +6056,11 @@ thred_sleep(sec)
TRAP_END;
return;
}
- thred_wait_for(time_timeval(INT2FIX(sec)));
+ thread_wait_for(time_timeval(INT2FIX(sec)));
}
void
-thred_sleep_forever()
+thread_sleep_forever()
{
if (curr_thread == curr_thread->next) {
TRAP_BEG;
@@ -6075,46 +6073,46 @@ thred_sleep_forever()
curr_thread->delay = DELAY_INFTY;
curr_thread->wait_for |= WAIT_TIME;
curr_thread->status = THREAD_STOPPED;
- thred_schedule();
+ thread_schedule();
}
-static int thred_abort;
+static int thread_abort;
static VALUE
-thred_s_abort_exc()
+thread_s_abort_exc()
{
- return thred_abort?TRUE:FALSE;
+ return thread_abort?TRUE:FALSE;
}
static VALUE
-thred_s_abort_exc_set(self, val)
+thread_s_abort_exc_set(self, val)
VALUE self, val;
{
- thred_abort = RTEST(val);
+ thread_abort = RTEST(val);
return val;
}
static VALUE
-thred_abort_exc(thread)
+thread_abort_exc(thread)
VALUE thread;
{
- thread_t th = thred_check(thread);
+ thread_t th = thread_check(thread);
return th->abort?TRUE:FALSE;
}
static VALUE
-thred_abort_exc_set(thread, val)
+thread_abort_exc_set(thread, val)
VALUE thread, val;
{
- thread_t th = thred_check(thread);
+ thread_t th = thread_check(thread);
th->abort = RTEST(val);
return val;
}
static thread_t
-thred_alloc()
+thread_alloc()
{
thread_t th;
@@ -6146,7 +6144,7 @@ thred_alloc()
th->last_match = 0;
th->abort = 0;
- th->thread = data_object_alloc(cThread, th, 0, thred_free);
+ th->thread = data_object_alloc(cThread, th, 0, thread_free);
if (curr_thread) {
th->prev = curr_thread;
@@ -6170,23 +6168,23 @@ catch_timer(sig)
#if !defined(POSIX_SIGNAL) && !defined(BSD_SIGNAL)
signal(sig, catch_timer);
#endif
- if (!thred_critical) {
+ if (!thread_critical) {
if (trap_immediate) {
- thred_schedule();
+ thread_schedule();
}
- else thred_pending = 1;
+ else thread_pending = 1;
}
}
#else
-int thred_tick = THREAD_TICK;
+int thread_tick = THREAD_TICK;
#endif
VALUE
-thred_create(fn, arg)
+thread_create(fn, arg)
VALUE (*fn)();
void *arg;
{
- thread_t th = thred_alloc();
+ thread_t th = thread_alloc();
int state;
#if defined(HAVE_SETITIMER) && !defined(__BOW__)
@@ -6217,14 +6215,14 @@ thred_create(fn, arg)
}
#endif
- thred_save_context(curr_thread);
+ thread_save_context(curr_thread);
if (setjmp(curr_thread->context)) {
return th->thread;
}
PUSH_TAG(PROT_THREAD);
if ((state = EXEC_TAG()) == 0) {
- thred_save_context(th);
+ thread_save_context(th);
if (setjmp(th->context) == 0) {
curr_thread = th;
th->result = (*fn)(arg, th);
@@ -6236,21 +6234,21 @@ thred_create(fn, arg)
/* fatal error or global exit within this thread */
/* need to stop whole script */
main_thread->errinfo = errinfo;
- thred_cleanup();
+ thread_cleanup();
}
- else if (thred_abort || curr_thread->abort || RTEST(debug)) {
+ else if (thread_abort || curr_thread->abort || RTEST(debug)) {
f_abort();
}
else {
curr_thread->errinfo = errinfo;
}
}
- thred_remove();
+ thread_remove();
return 0;
}
static VALUE
-thred_yield(arg, th)
+thread_yield(arg, th)
int arg;
thread_t th;
{
@@ -6259,21 +6257,21 @@ thred_yield(arg, th)
}
static VALUE
-thred_start()
+thread_start()
{
if (!iterator_p()) {
Raise(eThreadError, "must be called as iterator");
}
- return thred_create(thred_yield, 0);
+ return thread_create(thread_yield, 0);
}
static VALUE
-thred_value(thread)
+thread_value(thread)
VALUE thread;
{
- thread_t th = thred_check(thread);
+ thread_t th = thread_check(thread);
- thred_join(0, thread);
+ thread_join(0, thread);
if (!NIL_P(th->errinfo)) {
VALUE oldbt = get_backtrace(th->errinfo);
VALUE errat = make_backtrace();
@@ -6287,12 +6285,12 @@ thred_value(thread)
}
static VALUE
-thred_status(thread)
+thread_status(thread)
VALUE thread;
{
- thread_t th = thred_check(thread);
+ thread_t th = thread_check(thread);
- if (thred_dead(th)) {
+ if (thread_dead(th)) {
if (NIL_P(th->errinfo)) return FALSE;
return Qnil;
}
@@ -6301,27 +6299,27 @@ thred_status(thread)
}
static VALUE
-thred_stop_p(thread)
+thread_stop_p(thread)
VALUE thread;
{
- thread_t th = thred_check(thread);
+ thread_t th = thread_check(thread);
- if (thred_dead(th)) return TRUE;
+ if (thread_dead(th)) return TRUE;
if (th->status == THREAD_STOPPED) return TRUE;
return FALSE;
}
static void
-thred_wait_other_threads()
+thread_wait_other_threads()
{
/* wait other threads to terminate */
while (curr_thread != curr_thread->next) {
- thred_schedule();
+ thread_schedule();
}
}
static void
-thred_cleanup()
+thread_cleanup()
{
thread_t th;
@@ -6338,86 +6336,86 @@ thred_cleanup()
END_FOREACH(th);
}
-int thred_critical;
+int thread_critical;
static VALUE
-thred_get_critical()
+thread_get_critical()
{
- return thred_critical?TRUE:FALSE;
+ return thread_critical?TRUE:FALSE;
}
static VALUE
-thred_set_critical(obj, val)
+thread_set_critical(obj, val)
VALUE obj, val;
{
- thred_critical = RTEST(val);
+ thread_critical = RTEST(val);
return val;
}
void
-thred_interrupt()
+thread_interrupt()
{
- thred_critical = 0;
- thred_ready(main_thread);
+ thread_critical = 0;
+ thread_ready(main_thread);
if (curr_thread == main_thread) {
rb_interrupt();
}
- thred_save_context(curr_thread);
+ thread_save_context(curr_thread);
if (setjmp(curr_thread->context)) {
return;
}
curr_thread = main_thread;
- thred_restore_context(curr_thread, 2);
+ thread_restore_context(curr_thread, 2);
}
void
-thred_trap_eval(cmd, sig)
+thread_trap_eval(cmd, sig)
VALUE cmd;
int sig;
{
- thred_critical = 0;
- if (!thred_dead(curr_thread)) {
- thred_ready(curr_thread);
+ thread_critical = 0;
+ if (!thread_dead(curr_thread)) {
+ thread_ready(curr_thread);
rb_trap_eval(cmd, sig);
return;
}
- thred_ready(main_thread);
- thred_save_context(curr_thread);
+ thread_ready(main_thread);
+ thread_save_context(curr_thread);
if (setjmp(curr_thread->context)) {
return;
}
th_cmd = cmd;
th_sig = sig;
curr_thread = main_thread;
- thred_restore_context(curr_thread, 3);
+ thread_restore_context(curr_thread, 3);
}
static VALUE
-thred_raise(argc, argv, thread)
+thread_raise(argc, argv, thread)
int argc;
VALUE *argv;
VALUE thread;
{
- thread_t th = thred_check(thread);
+ thread_t th = thread_check(thread);
- if (thred_dead(th)) return thread;
+ if (thread_dead(th)) return thread;
if (curr_thread == th) {
f_raise(argc, argv);
}
- thred_save_context(curr_thread);
+ thread_save_context(curr_thread);
if (setjmp(curr_thread->context)) {
return thread;
}
rb_scan_args(argc, argv, "11", &th_raise_argv[0], &th_raise_argv[1]);
- thred_ready(th);
+ thread_ready(th);
curr_thread = th;
th_raise_argc = argc;
th_raise_file = sourcefile;
th_raise_line = sourceline;
- thred_restore_context(curr_thread, 4);
+ thread_restore_context(curr_thread, 4);
return Qnil; /* not reached */
}
@@ -6425,12 +6423,12 @@ static thread_t loading_thread;
static int loading_nest;
static int
-thred_loading(feature)
+thread_loading(feature)
char *feature;
{
if (curr_thread != curr_thread->next && loading_thread) {
while (loading_thread != curr_thread) {
- thred_schedule();
+ thread_schedule();
CHECK_INTS;
}
if (rb_provided(feature)) return TRUE; /* no need to load */
@@ -6443,7 +6441,7 @@ thred_loading(feature)
}
static void
-thred_loading_done()
+thread_loading_done()
{
if (--loading_nest == 0) {
loading_thread = 0;
@@ -6456,38 +6454,38 @@ Init_Thread()
eThreadError = rb_define_class("ThreadError", eStandardError);
cThread = rb_define_class("Thread", cObject);
- rb_define_singleton_method(cThread, "new", thred_start, 0);
- rb_define_singleton_method(cThread, "start", thred_start, 0);
- rb_define_singleton_method(cThread, "fork", thred_start, 0);
+ rb_define_singleton_method(cThread, "new", thread_start, 0);
+ rb_define_singleton_method(cThread, "start", thread_start, 0);
+ rb_define_singleton_method(cThread, "fork", thread_start, 0);
- rb_define_singleton_method(cThread, "stop", thred_stop, 0);
- rb_define_singleton_method(cThread, "kill", thred_s_kill, 1);
- rb_define_singleton_method(cThread, "exit", thred_exit, 0);
- rb_define_singleton_method(cThread, "pass", thred_pass, 0);
- rb_define_singleton_method(cThread, "join", thred_join, 1);
- rb_define_singleton_method(cThread, "current", thred_current, 0);
- rb_define_singleton_method(cThread, "main", thred_main, 0);
+ rb_define_singleton_method(cThread, "stop", thread_stop, 0);
+ rb_define_singleton_method(cThread, "kill", thread_s_kill, 1);
+ rb_define_singleton_method(cThread, "exit", thread_exit, 0);
+ rb_define_singleton_method(cThread, "pass", thread_pass, 0);
+ rb_define_singleton_method(cThread, "join", thread_join, 1);
+ rb_define_singleton_method(cThread, "current", thread_current, 0);
+ rb_define_singleton_method(cThread, "main", thread_main, 0);
- rb_define_singleton_method(cThread, "critical", thred_get_critical, 0);
- rb_define_singleton_method(cThread, "critical=", thred_set_critical, 1);
+ rb_define_singleton_method(cThread, "critical", thread_get_critical, 0);
+ rb_define_singleton_method(cThread, "critical=", thread_set_critical, 1);
- rb_define_singleton_method(cThread, "abort_on_exception", thred_s_abort_exc, 0);
- rb_define_singleton_method(cThread, "abort_on_exception=", thred_s_abort_exc_set, 1);
+ rb_define_singleton_method(cThread, "abort_on_exception", thread_s_abort_exc, 0);
+ rb_define_singleton_method(cThread, "abort_on_exception=", thread_s_abort_exc_set, 1);
- rb_define_method(cThread, "run", thred_run, 0);
- rb_define_method(cThread, "wakeup", thred_wakeup, 0);
- rb_define_method(cThread, "exit", thred_kill, 0);
- rb_define_method(cThread, "value", thred_value, 0);
- rb_define_method(cThread, "status", thred_status, 0);
- rb_define_method(cThread, "alive?", thred_status, 0);
- rb_define_method(cThread, "stop?", thred_stop_p, 0);
- rb_define_method(cThread, "raise", thred_raise, -1);
+ rb_define_method(cThread, "run", thread_run, 0);
+ rb_define_method(cThread, "wakeup", thread_wakeup, 0);
+ rb_define_method(cThread, "exit", thread_kill, 0);
+ rb_define_method(cThread, "value", thread_value, 0);
+ rb_define_method(cThread, "status", thread_status, 0);
+ rb_define_method(cThread, "alive?", thread_status, 0);
+ rb_define_method(cThread, "stop?", thread_stop_p, 0);
+ rb_define_method(cThread, "raise", thread_raise, -1);
- rb_define_method(cThread, "abort_on_exception", thred_abort_exc, 0);
- rb_define_method(cThread, "abort_on_exception=", thred_abort_exc_set, 1);
+ rb_define_method(cThread, "abort_on_exception", thread_abort_exc, 0);
+ rb_define_method(cThread, "abort_on_exception=", thread_abort_exc_set, 1);
/* allocate main thread */
- main_thread = thred_alloc();
+ main_thread = thread_alloc();
}
#endif
diff --git a/ext/Setup b/ext/Setup
index 4258bd4..9e3a247 100644
--- a/ext/Setup
+++ b/ext/Setup
@@ -1,7 +1,7 @@
#option nodynamic
#GD
-curses
+#curses
#dbm
#etc
#fcntl
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 6748655..18ab8bc 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -10,6 +10,7 @@
#include "ruby.h"
#include "rubyio.h"
+#include "rubysig.h"
#include <stdio.h>
#include <sys/types.h>
#ifndef NT
@@ -24,7 +25,7 @@
#ifdef USE_CWGUSI
extern int fileno(FILE *stream); /* <unix.mac.h> */
-extern int thred_select(int, fd_set*, fd_set*, fd_set*, struct timeval*); /* thread.c */
+extern int thread_select(int, fd_set*, fd_set*, fd_set*, struct timeval*); /* thread.c */
# include <sys/errno.h>
# include <GUSI.h>
#endif
@@ -41,9 +42,6 @@ extern int thred_select(int, fd_set*, fd_set*, fd_set*, struct timeval*); /* thr
#define EWOULDBLOCK EAGAIN
#endif
-extern VALUE cIO;
-extern VALUE cInteger;
-
VALUE cBasicSocket;
VALUE cIPsocket;
VALUE cTCPsocket;
@@ -55,7 +53,6 @@ VALUE cUNIXserver;
#endif
VALUE cSocket;
-extern VALUE eStandardError;
static VALUE eSocket;
#ifdef SOCKS
@@ -243,7 +240,7 @@ bsock_send(argc, argv, sock)
fd = fileno(f);
retry:
#ifdef THREAD
- thred_fd_writable(fd);
+ thread_fd_writable(fd);
#endif
m = str2cstr(msg, &mlen);
if (RTEST(to)) {
@@ -262,7 +259,7 @@ bsock_send(argc, argv, sock)
case EAGAIN:
#endif
#ifdef THREAD
- thred_schedule();
+ thread_schedule();
#endif
goto retry;
}
@@ -309,7 +306,7 @@ s_recv(sock, argc, argv, from)
GetOpenFile(sock, fptr);
fd = fileno(fptr->f);
#ifdef THREAD
- thred_wait_fd(fd);
+ thread_wait_fd(fd);
#endif
TRAP_BEG;
retry:
@@ -325,7 +322,7 @@ s_recv(sock, argc, argv, from)
case EAGAIN:
#endif
#ifdef THREAD
- thred_schedule();
+ thread_schedule();
#endif
goto retry;
}
@@ -370,7 +367,7 @@ bsock_recv(argc, argv, sock)
#if defined(THREAD) && defined(HAVE_FCNTL)
static int
-thred_connect(fd, sockaddr, len, type)
+thread_connect(fd, sockaddr, len, type)
int fd;
struct sockaddr *sockaddr;
int len;
@@ -412,9 +409,9 @@ thred_connect(fd, sockaddr, len, type)
FD_ZERO(&fds);
FD_SET(fd, &fds);
#ifndef USE_CWGUSI
- thred_select(fd+1, 0, &fds, 0, 0, 0);
+ thread_select(fd+1, 0, &fds, 0, 0, 0);
#else
- thred_select(fd+1, 0, &fds, 0, 0);
+ thread_select(fd+1, 0, &fds, 0, 0);
#endif
continue;
#endif
@@ -535,7 +532,7 @@ open_inet(class, h, serv, type)
}
else {
#if defined(THREAD) && defined(HAVE_FCNTL)
- status = thred_connect(fd, (struct sockaddr*)&sockaddr,
+ status = thread_connect(fd, (struct sockaddr*)&sockaddr,
sizeof(sockaddr), type);
#else
#ifdef SOCKS
@@ -611,7 +608,7 @@ s_accept(class, fd, sockaddr, len)
retry:
#ifdef THREAD
- thred_wait_fd(fd);
+ thread_wait_fd(fd);
#endif
TRAP_BEG;
fd2 = accept(fd, sockaddr, len);
@@ -624,7 +621,7 @@ s_accept(class, fd, sockaddr, len)
case EAGAIN:
#endif
#ifdef THREAD
- thred_schedule();
+ thread_schedule();
#endif
goto retry;
}
@@ -889,7 +886,7 @@ udp_connect(sock, host, port)
case EAGAIN:
#endif
#ifdef THREAD
- thred_schedule();
+ thread_schedule();
#endif
goto retry;
}
@@ -948,7 +945,7 @@ udp_send(argc, argv, sock)
case EAGAIN:
#endif
#ifdef THREAD
- thred_schedule();
+ thread_schedule();
#endif
goto retry;
}
@@ -1203,7 +1200,7 @@ sock_connect(sock, addr)
case EAGAIN:
#endif
#ifdef THREAD
- thred_schedule();
+ thread_schedule();
#endif
goto retry;
}
diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c
index 1eb2a48..ada4c7a 100644
--- a/ext/tcltklib/tcltklib.c
+++ b/ext/tcltklib/tcltklib.c
@@ -52,7 +52,7 @@ void _timer_for_tcl (ClientData clientData)
timer->flag = 0;
CHECK_INTS;
#ifdef THREAD
- if (!thred_critical) thred_schedule();
+ if (!thread_critical) thread_schedule();
#endif
timer->token = Tk_CreateTimerHandler(200, _timer_for_tcl,
@@ -102,22 +102,36 @@ ip_eval_rescue(VALUE *failed, VALUE einfo)
}
static int
+#if TCL_MAJOR_VERSION >= 8
+ip_ruby(ClientData clientData, Tcl_Interp *interp,
+ int argc, Tcl_Obj *CONST argv[])
+#else
ip_ruby(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
+#endif
{
VALUE res;
int old_trapflg;
VALUE failed = 0;
+ char *arg;
+ int dummy;
/* ruby command has 1 arg. */
if (argc != 2) {
ArgError("wrong # of arguments (%d for 1)", argc);
}
+ /* get C string from Tcl object */
+#if TCL_MAJOR_VERSION >= 8
+ arg = Tcl_GetStringFromObj(argv[1], &dummy);
+#else
+ arg = argv[1];
+#endif
+
/* evaluate the argument string by ruby */
- DUMP2("rb_eval_string(%s)", argv[1]);
+ DUMP2("rb_eval_string(%s)", arg);
old_trapflg = trap_immediate;
trap_immediate = 0;
- res = rb_rescue(rb_eval_string, (VALUE)argv[1], ip_eval_rescue, (VALUE)&failed);
+ res = rb_rescue(rb_eval_string, (VALUE)arg, ip_eval_rescue, (VALUE)&failed);
trap_immediate = old_trapflg;
Tcl_ResetResult(interp);
@@ -178,9 +192,15 @@ ip_new(VALUE self)
(Tcl_PackageInitProc *) NULL);
/* add ruby command to the interpreter */
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"ruby\")");
+ Tcl_CreateObjCommand(ptr->ip, "ruby", ip_ruby, (ClientData *)NULL,
+ (Tcl_CmdDeleteProc *)NULL);
+#else
DUMP1("Tcl_CreateCommand(\"ruby\")");
Tcl_CreateCommand(ptr->ip, "ruby", ip_ruby, (ClientData *)NULL,
(Tcl_CmdDeleteProc *)NULL);
+#endif
return obj;
}
@@ -216,28 +236,71 @@ ip_invoke(int argc, VALUE *argv, VALUE obj)
{
struct tcltkip *ptr; /* tcltkip data struct */
int i;
+ int object = 0;
Tcl_CmdInfo info;
- char **av;
+ char *cmd;
+ char **av = (char **)NULL;
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_Obj **ov = (Tcl_Obj **)NULL;
+ Tcl_Obj *resultPtr;
+#endif
/* get the data struct */
Data_Get_Struct(obj, struct tcltkip, ptr);
- av = (char **)ALLOCA_N(char **, argc+1);
- for (i = 0; i < argc; ++i) {
+ /* get the command name string */
+ cmd = STR2CSTR(argv[0]);
+
+ /* map from the command name to a C procedure */
+ if (!Tcl_GetCommandInfo(ptr->ip, cmd, &info)) {
+ NameError("invalid command name `%s'", cmd);
+ }
+#if TCL_MAJOR_VERSION >= 8
+ object = info.isNativeObjectProc;
+#endif
+
+ /* memory allocation for arguments of this command */
+ if (object) {
+#if TCL_MAJOR_VERSION >= 8
+ /* object interface */
+ ov = (Tcl_Obj **)ALLOCA_N(Tcl_Obj *, argc+1);
+ for (i = 0; i < argc; ++i) {
+ char *s = STR2CSTR(argv[i]);
+ ov[i] = Tcl_NewStringObj(s, strlen(s));
+ }
+ ov[argc] = (Tcl_Obj *)NULL;
+#endif
+ } else {
+ /* string interface */
+ av = (char **)ALLOCA_N(char *, argc+1);
+ for (i = 0; i < argc; ++i) {
char *s = STR2CSTR(argv[i]);
av[i] = ALLOCA_N(char, strlen(s)+1);
strcpy(av[i], s);
+ }
+ av[argc] = (char *)NULL;
}
- av[argc] = NULL;
- if (!Tcl_GetCommandInfo(ptr->ip, av[0], &info)) {
- NameError("invalid command name `%s'", av[0]);
+ Tcl_ResetResult(ptr->ip);
+
+ /* Invoke the C procedure */
+ if (object) {
+#if TCL_MAJOR_VERSION >= 8
+ int dummy;
+ ptr->return_value = (*info.objProc)(info.objClientData,
+ ptr->ip, argc, ov);
+
+ /* get the string value from the result object */
+ resultPtr = Tcl_GetObjResult(ptr->ip);
+ Tcl_SetResult(ptr->ip, Tcl_GetStringFromObj(resultPtr, &dummy),
+ TCL_VOLATILE);
+#endif
+ } else {
+ ptr->return_value = (*info.proc)(info.clientData,
+ ptr->ip, argc, av);
}
- Tcl_ResetResult(ptr->ip);
- ptr->return_value = (*info.proc)(info.clientData,
- ptr->ip, argc, av);
if (ptr->return_value == TCL_ERROR) {
Fail(ptr->ip->result);
}
diff --git a/file.c b/file.c
index df17d65..68d3a3c 100644
--- a/file.c
+++ b/file.c
@@ -12,6 +12,7 @@
#include "ruby.h"
#include "rubyio.h"
+#include "rubysig.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -1376,10 +1377,10 @@ file_truncate(obj, len)
#if defined(THREAD) && defined(EWOULDBLOCK)
static int
-thred_flock(fd, op)
+thread_flock(fd, op)
int fd, op;
{
- if (thred_alone() || (op & LOCK_NB)) {
+ if (thread_alone() || (op & LOCK_NB)) {
return flock(fd, op);
}
op |= LOCK_NB;
@@ -1387,7 +1388,7 @@ thred_flock(fd, op)
switch (errno) {
case EINTR: /* can be happen? */
case EWOULDBLOCK:
- thred_schedule(); /* busy wait */
+ thread_schedule(); /* busy wait */
break;
default:
return -1;
@@ -1395,7 +1396,7 @@ thred_flock(fd, op)
}
return 0;
}
-#define flock thred_flock
+#define flock thread_flock
#endif
static VALUE
diff --git a/gc.c b/gc.c
index c25f4bc..d21d58b 100644
--- a/gc.c
+++ b/gc.c
@@ -959,8 +959,6 @@ static VALUE
add_final(os, proc)
VALUE os, proc;
{
- extern VALUE cProc;
-
if (!obj_is_kind_of(proc, cProc)) {
ArgError("wrong type argument %s (Proc required)",
rb_class2name(CLASS_OF(proc)));
diff --git a/glob.c b/glob.c
index 13ccdc6..543ca0c 100644
--- a/glob.c
+++ b/glob.c
@@ -19,7 +19,7 @@
Unix programs use to perform this function. I wrote this from scratch
based on specifications for the pattern matching. --RMS. */
-#include <config.h>
+#include "config.h"
#if !defined (__GNUC__) && !defined (HAVE_ALLOCA_H) && defined (_AIX)
#pragma alloca
diff --git a/hash.c b/hash.c
index f8750de..a1da061 100644
--- a/hash.c
+++ b/hash.c
@@ -925,7 +925,6 @@ f_setenv(obj, name, value)
VALUE obj, name, value;
{
if (rb_safe_level() >= 4) {
- extern VALUE eSecurityError;
Raise(eSecurityError, "cannot change environment variable");
}
@@ -1157,8 +1156,6 @@ env_to_hash(obj)
void
Init_Hash()
{
- extern VALUE mEnumerable;
-
hash = rb_intern("hash");
cHash = rb_define_class("Hash", cObject);
diff --git a/intern.h b/intern.h
index 5637563..aa724d0 100644
--- a/intern.h
+++ b/intern.h
@@ -123,17 +123,17 @@ VALUE class_new_instance _((int, VALUE*, VALUE));
VALUE f_lambda _((void));
void rb_set_end_proc _((void (*)(),VALUE));
void gc_mark_threads _((void));
-void thred_schedule _((void));
-void thred_wait_fd _((int));
-void thred_fd_writable _((int));
-int thred_alone _((void));
-void thred_sleep _((int));
-void thred_sleep_forever _((void));
-VALUE thred_create _((VALUE (*)(), void*));
-void thred_interrupt _((void));
-void thred_trap_eval _((VALUE, int));
-int thred_select();
-void thred_wait_for();
+void thread_schedule _((void));
+void thread_wait_fd _((int));
+void thread_fd_writable _((int));
+int thread_alone _((void));
+void thread_sleep _((int));
+void thread_sleep_forever _((void));
+VALUE thread_create _((VALUE (*)(), void*));
+void thread_interrupt _((void));
+void thread_trap_eval _((VALUE, int));
+int thread_select();
+void thread_wait_for();
/* file.c */
VALUE file_open _((char*, char*));
int eaccess _((char*, int));
diff --git a/io.c b/io.c
index 0cf2593..8349da0 100644
--- a/io.c
+++ b/io.c
@@ -12,6 +12,7 @@
#include "ruby.h"
#include "rubyio.h"
+#include "rubysig.h"
#include <ctype.h>
#include <errno.h>
@@ -109,7 +110,7 @@ extern int ReadDataPending();
# define READ_CHECK(fp) 0
#else
# define READ_CHECK(fp) do {\
- if (!READ_DATA_PENDING(fp)) thred_wait_fd(fileno(fp));\
+ if (!READ_DATA_PENDING(fp)) thread_wait_fd(fileno(fp));\
} while(0)
#endif
@@ -881,7 +882,7 @@ io_syswrite(io, str)
f = GetWriteFile(fptr);
#ifdef THREAD
- thred_fd_writable(fileno(f));
+ thread_fd_writable(fileno(f));
#endif
n = write(fileno(f), RSTRING(str)->ptr, RSTRING(str)->len);
@@ -905,7 +906,7 @@ io_sysread(io, len)
str = str_new(0, ilen);
#ifdef THREAD
- thred_wait_fd(fileno(fptr->f));
+ thread_wait_fd(fileno(fptr->f));
#endif
TRAP_BEG;
n = read(fileno(fptr->f), RSTRING(str)->ptr, RSTRING(str)->len);
@@ -1184,7 +1185,7 @@ pipe_open(pname, mode)
case -1: /* fork failed */
if (errno == EAGAIN) {
#ifdef THREAD
- thred_sleep(1);
+ thread_sleep(1);
#else
sleep(1);
#endif
@@ -1244,10 +1245,12 @@ io_s_popen(argc, argv, self)
mode = "r";
}
else {
- Check_Type(pmode, T_STRING);
- if (RSTRING(pmode)->len == 0 || RSTRING(pmode)->len > 3)
+ int len;
+
+ mode = STR2CSTR(pmode);
+ len = strlen(mode);
+ if (len == 0 || len > 3)
ArgError("illegal access mode");
- mode = RSTRING(pmode)->ptr;
}
return pipe_open(RSTRING(pname)->ptr, mode);
}
@@ -1279,10 +1282,12 @@ f_open(argc, argv)
mode = "r";
}
else {
- Check_Type(pmode, T_STRING);
- if (RSTRING(pmode)->len == 0 || RSTRING(pmode)->len > 3)
+ int len;
+
+ mode = STR2CSTR(pmode);
+ len = strlen(mode);
+ if (len == 0 || len > 3)
ArgError("illegal access mode");
- mode = RSTRING(pmode)->ptr;
}
port = io_open(RSTRING(pname)->ptr, mode);
@@ -2055,7 +2060,7 @@ f_select(argc, argv, obj)
max++;
#ifdef THREAD
- n = thred_select(max, rp, wp, ep, tp);
+ n = thread_select(max, rp, wp, ep, tp);
if (n < 0) {
rb_sys_fail(0);
}
@@ -2565,8 +2570,7 @@ opt_i_set(val)
inplace = 0;
return;
}
- Check_Type(val, T_STRING);
- inplace = RSTRING(val)->ptr;
+ inplace = STR2CSTR(val);
}
void
diff --git a/lib/Env.rb b/lib/Env.rb
index e52501f..df14023 100644
--- a/lib/Env.rb
+++ b/lib/Env.rb
@@ -20,9 +20,11 @@ for k,v in ENV
EOS
end
-p $TERM
-$TERM = nil
-p $TERM
-p ENV["TERM"]
-$TERM = "foo"
-p ENV["TERM"]
+if __FILE__ == $0
+ p $TERM
+ $TERM = nil
+ p $TERM
+ p ENV["TERM"]
+ $TERM = "foo"
+ p ENV["TERM"]
+end
diff --git a/lib/cgi-lib.rb b/lib/cgi-lib.rb
index 6c20237..6a846b2 100644
--- a/lib/cgi-lib.rb
+++ b/lib/cgi-lib.rb
@@ -25,7 +25,7 @@ class CGI < SimpleDelegator
words = Shellwords.shellwords(if not ARGV.empty? then
ARGV.join(' ')
else
- print "(offline mode: enter name=value pairs on standard input)\n" if STDOUT.tty?
+ STDERR.print "(offline mode: enter name=value pairs on standard input)\n" if STDOUT.tty?
readlines.join(' ').gsub(/\n/, '')
end.gsub(/\\=/, '%3D').gsub(/\\&/, '%26'))
@@ -47,14 +47,18 @@ class CGI < SimpleDelegator
module_function :escape, :unescape
def initialize(input = $stdin)
- # exception messages should be printed to stdout.
- STDERR.reopen(STDOUT)
@inputs = {}
case ENV['REQUEST_METHOD']
when "GET"
+ # exception messages should be printed to stdout.
+ STDERR.reopen(STDOUT)
+
ENV['QUERY_STRING'] or ""
when "POST"
+ # exception messages should be printed to stdout.
+ STDERR.reopen(STDOUT)
+
input.read ENV['CONTENT_LENGTH'].to_i
else
read_from_cmdline
diff --git a/lib/delegate.rb b/lib/delegate.rb
index 7889c82..925b4ec 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -9,6 +9,12 @@
# foo = Object.new
# foo2 = SimpleDelegator.new(foo)
# foo.hash == foo2.hash # => true
+#
+# Foo = DelegateClass(Array)
+#
+# class ExtArray<DelegateClass(Array)
+# ...
+# end
class Delegator
@@ -18,7 +24,7 @@ class Delegator
preserved |= t.instance_methods
break if t == Delegator
end
- preserved -= ["__getobj__","to_s","nil?","to_a","hash","dup","==","=~"]
+ preserved -= ["__getobj__","to_s","to_a","inspect","hash","eql?","==","=~","==="]
for method in obj.methods
next if preserved.include? method
eval <<EOS
@@ -61,7 +67,44 @@ end
Delegater = Delegator
SimpleDelegater = SimpleDelegator
+#
+def DelegateClass(superclass)
+ klass = Class.new
+ methods = superclass.instance_methods
+ methods -= ::Kernel.instance_methods
+ methods |= ["to_s","to_a","inspect","hash","eql?","==","=~","==="]
+ klass.module_eval <<EOS
+ def initialize(obj)
+ @obj = obj
+ end
+EOS
+ for method in methods
+ klass.module_eval <<EOS
+ def #{method}(*args, &block)
+ begin
+ @obj.__send__(:#{method}, *args, &block)
+ rescue
+ $@[0,2] = nil
+ raise
+ end
+ end
+EOS
+ end
+ return klass;
+end
+
if __FILE__ == $0
+ class ExtArray<DelegateClass(Array)
+ def initialize()
+ super([])
+ end
+ end
+
+ ary = ExtArray.new
+ p ary.type
+ ary.push 25
+ p ary
+
foo = Object.new
def foo.test
raise 'this is OK'
@@ -69,4 +112,5 @@ if __FILE__ == $0
foo2 = SimpleDelegator.new(foo)
p foo.hash == foo2.hash # => true
foo.test # raise error!
+
end
diff --git a/lib/eregex.rb b/lib/eregex.rb
index f214f6a..384d531 100644
--- a/lib/eregex.rb
+++ b/lib/eregex.rb
@@ -30,10 +30,7 @@ class Regexp
end
end
-p "abc" =~ /b/|/c/
-p "abc" =~ /b/&/c/
-
-
-
-
-
+if __FILE__ == $0
+ p "abc" =~ /b/|/c/
+ p "abc" =~ /b/&/c/
+end
diff --git a/lib/importenv.rb b/lib/importenv.rb
index 4125376..10b2891 100644
--- a/lib/importenv.rb
+++ b/lib/importenv.rb
@@ -21,9 +21,12 @@ for k,v in ENV
EOS
end
-p $TERM
-$TERM = nil
-p $TERM
-p ENV["TERM"]
-$TERM = "foo"
-p ENV["TERM"]
+if __FILE__ == $0
+ p $TERM
+ $TERM = nil
+ p $TERM
+ p ENV["TERM"]
+ $TERM = "foo"
+ p ENV["TERM"]
+end
+
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 8ef5bfd..306f239 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -260,7 +260,7 @@ SHELL = /bin/sh
srcdir = #{$srcdir}
hdrdir = #{$hdrdir}
-CC = gcc
+CC = #{CONFIG["CC"]}
prefix = #{CONFIG["prefix"]}
CFLAGS = #{CONFIG["CCDLFLAGS"]} -I#{$hdrdir} -I#{CONFIG["includedir"]} #{CFLAGS} #{$CFLAGS} #{$defs.join(" ")}
diff --git a/lib/thwait.rb b/lib/thwait.rb
index c638335..84ba2c8 100644
--- a/lib/thwait.rb
+++ b/lib/thwait.rb
@@ -1,34 +1,60 @@
#
-# thwait.rb -
-# $Release Version: $
-# $Revision: 1.1 $
-# $Date: 1997/08/18 03:13:14 $
-# by Keiju ISHITSUKA(Nippon Rational Inc.)
+# thwait.rb - スレッド同期クラス
+# $Release Version: 0.9 $
+# $Revision: 1.3 $
+# $Date: 1998/06/26 03:19:34 $
+# by Keiju ISHITSUKA(Nihpon Rational Software Co.,Ltd.)
#
# --
+# 機能:
+# 複数のスレッドを関しそれらのスレッドが終了するまでwaitする機能を提
+# 供する.
#
-#
+# クラスメソッド:
+# * ThreadsWait.all_waits(thread1,...)
+# 全てのスレッドが終了するまで待つ. イテレータとして呼ばれた時には,
+# スレッドが終了する度にイテレータを実行する.
+# * th = ThreadsWait.new(thread1,...)
+# 同期するスレッドを指定し同期オブジェクトを生成.
+#
+# メソッド:
+# * th.threads
+# 同期すべきスレッドの一覧
+# * th.empty?
+# 同期すべきスレッドがあるかどうか
+# * th.finished?
+# すでに終了したスレッドがあるかどうか
+# * th.join(thread1,...)
+# 同期するスレッドを指定し, いずれかのスレッドが終了するまで待ちにはいる.
+# * th.join_nowait(threa1,...)
+# 同期するスレッドを指定する. 待ちには入らない.
+# * th.next_wait
+# いずれかのスレッドが終了するまで待ちにはいる.
+# * th.all_waits
+# 全てのスレッドが終了するまで待つ. イテレータとして呼ばれた時には,
+# スレッドが終了する度にイテレータを実行する.
#
require "thread.rb"
require "e2mmap.rb"
class ThreadsWait
- RCS_ID='-$Header: /home/keiju/var/src/var.lib/ruby/RCS/thwait.rb,v 1.1 1997/08/18 03:13:14 keiju Exp keiju $-'
+ RCS_ID='-$Id: thwait.rb,v 1.3 1998/06/26 03:19:34 keiju Exp keiju $-'
Exception2MessageMapper.extend_to(binding)
- def_exception("ErrWaitThreadsNothing", "Wait threads nothing.")
- def_exception("FinshedThreadsNothing", "finished thread nothing.")
+ def_exception("ErrNoWaitingThread", "No threads for waiting.")
+ def_exception("ErrNoFinshedThread", "No finished threads.")
# class mthods
# all_waits
#
# 指定したスレッドが全て終了するまで待つ. イテレータとして呼ばれると
- # 指定したスレッドが終了するとイテレータを呼び出す.
+ # 指定したスレッドが終了するとその終了したスレッドを引数としてイテレー
+ # タを呼び出す.
#
def ThreadsWait.all_waits(*threads)
- tw = ThreadsWait.new(th1, th2, th3, th4, th5)
+ tw = ThreadsWait.new(*threads)
if iterator?
tw.all_waits do
|th|
@@ -81,7 +107,8 @@ class ThreadsWait
# all_wait
#
- # 待っているスレッドを追加し待ちにはいる.
+ # 待っているスレッドを追加し. いずれかのスレッドが1つ終了するまで待
+ # ちにはいる.
#
def join(*threads)
join_nowait(*threads)
@@ -102,17 +129,19 @@ class ThreadsWait
end
#
- # 次の待ちにはいる.
- # 待つべきスレッドがなければ, 例外ErrWaitThreadsNothing を返す.
+ # いずれかのスレッドが終了するまで待ちにはいる.
+ # 待つべきスレッドがなければ, 例外ErrNoWaitingThreadを返す.
# nonnlockが真の時には, nonblockingで調べる. 存在しなければ, 例外
- # FinishedThreadNothingを返す.
+ # ErrNoFinishedThreadを返す.
#
def next_wait(nonblock = nil)
- Threads.Wait.fail ErrWaitThreadsNothing if @threads.empty?
-
- th = @wait_queue.pop(nonblock)
- @threads.delete th
- th
+ ThreadsWait.fail ErrNoWaitingThread if @threads.empty?
+ begin
+ @threads.delete(th = @wait_queue.pop(nonblock))
+ th
+ rescue ThreadError
+ ThreadsWait.fail ErrNoFinshedThread
+ end
end
#
@@ -126,3 +155,5 @@ class ThreadsWait
end
end
end
+
+ThWait = ThreadsWait
diff --git a/lib/tk.rb b/lib/tk.rb
index 5d1d68d..204e22a 100644
--- a/lib/tk.rb
+++ b/lib/tk.rb
@@ -165,7 +165,7 @@ module TkComm
end
private :_get_eval_string
- Tk_IDs = [0] # [0]-cmdid, [1]-winid
+ Tk_IDs = [0, 0] # [0]-cmdid, [1]-winid
def _curr_cmd_id
id = format("c%.4d", Tk_IDs[0])
end
@@ -188,8 +188,8 @@ module TkComm
private :install_cmd, :uninstall_cmd
def install_win(ppath)
- id = format("w%.4d", Tk_IDs[0])
- Tk_IDs[0] += 1
+ id = format("w%.4d", Tk_IDs[1])
+ Tk_IDs[1] += 1
if !ppath or ppath == "."
@path = format(".%s", id);
else
@@ -413,10 +413,10 @@ module Tk
list(w) if args.size == 0
end
def group(*args)
- tk_call 'wm', 'path', path, *args
+ tk_call 'wm', 'group', path, *args
end
def iconbitmap(*args)
- tk_call 'wm', 'bitmap', path, *args
+ tk_call 'wm', 'iconbitmap', path, *args
end
def iconify
tk_call 'wm', 'iconify', path
@@ -504,6 +504,10 @@ class TkVariable
end
end
+ def wait
+ INTERP._eval("tkwait variable #{@id}")
+ end
+
def id
@id
end
@@ -867,6 +871,12 @@ module TkWinfo
def winfo_y
TkWinfo.y self
end
+ def TkWinfo.viewable(window)
+ bool(tk_call 'winfo', 'viewable', window.path)
+ end
+ def winfo_viewable
+ TkWinfo.viewable self
+ end
end
module TkPack
@@ -912,11 +922,11 @@ module TkGrid
tk_call "grid", 'configure', *(wins+hash_kv(keys))
end
- def columnconfigure(master, index, *args)
+ def columnconfigure(master, index, args)
tk_call "grid", 'columnconfigure', master, index, *hash_kv(args)
end
- def rowconfigure(master, index, *args)
+ def rowconfigure(master, index, args)
tk_call "grid", 'rowconfigure', master, index, *hash_kv(args)
end
@@ -948,7 +958,7 @@ module TkGrid
tk_call 'grid', 'size', master
end
- def slaves(*args)
+ def slaves(args)
list(tk_call('grid', 'slaves', *hash_kv(args)))
end
@@ -1190,6 +1200,15 @@ class TkWindow<TkObject
end
uninstall_win
end
+
+ def wait_visibility
+ tk_call 'tkwait', 'visibility', path
+ end
+ alias wait wait_visibility
+
+ def wait_destroy
+ tk_call 'tkwait', 'window', path
+ end
end
class TkRoot<TkWindow
@@ -1442,6 +1461,9 @@ class TkMenu<TkWindow
def yposition(index)
number(tk_send('yposition', index))
end
+ def entryconfigure(index, keys=nil)
+ tk_send 'entryconfigure', index, *hash_kv(keys)
+ end
end
class TkMenubutton<TkLabel
@@ -1495,6 +1517,31 @@ module TkComposite
end
end
+module TkClipboard
+ include Tk
+ extend Tk
+
+ def clear
+ tk_call 'clipboard', 'clear'
+ end
+ def get
+ begin
+ tk_call 'selection', 'get', '-selection', 'CLIPBOARD'
+ rescue
+ ''
+ end
+ end
+ def set(data)
+ clear
+ append(data)
+ end
+ def append(data)
+ tk_call 'clipboard', 'append', data
+ end
+
+ module_function :clear, :set, :get, :append
+end
+
autoload :TkCanvas, 'tkcanvas'
autoload :TkImage, 'tkcanvas'
autoload :TkBitmapImage, 'tkcanvas'
diff --git a/lib/tkafter.rb b/lib/tkafter.rb
new file mode 100644
index 0000000..708d051
--- /dev/null
+++ b/lib/tkafter.rb
@@ -0,0 +1,265 @@
+#
+# tkafter.rb : methods for Tcl/Tk after command
+# 1998/06/23 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+#
+require 'tk'
+
+class TkAfter
+ include TkCore
+ extend TkCore
+
+ Tk_CBID = [0]
+ Tk_CBTBL = {}
+
+ INTERP._invoke("proc", "rb_after", "args", "ruby [format \"TkAfter.callback %%Q!%s!\" $args]")
+
+ ###############################
+ # class methods
+ ###############################
+ def TkAfter.callback(arg)
+ @after_id = nil
+ arg = Array(tk_split_list(arg))
+ obj_id = arg.shift
+ return nil if Tk_CBTBL[obj_id] == nil; # canceled
+ ret = _get_eval_string(Tk_CBTBL[obj_id].do_callback(*arg))
+ Tk_CBTBL[obj_id].set_next_callback(*arg)
+ ret
+ end
+
+ def TkAfter.info
+ tk_call('after', 'info').split(' ').filter{|id|
+ ret = Tk_CBTBL.find{|key,val| val.after_id == id}
+ (ret == nil)? id: ret[1]
+ }
+ end
+
+ ###############################
+ # instance methods
+ ###############################
+ def do_callback(*args)
+ @current_proc.call(*args)
+ end
+
+ def set_callback(sleep, args=nil)
+ @after_script = "rb_after #{@id} #{_get_eval_string(args)}"
+ @after_id = tk_call('after', sleep, @after_script)
+ @current_script = [sleep, @after_script]
+ end
+
+ def set_next_callback(*args)
+ if @running == false || @proc_max == 0 || @do_loop == 0
+ Tk_CBTBL[@id] = nil ;# for GC
+ return
+ end
+ if @current_pos >= @proc_max
+ if @do_loop < 0 || (@do_loop -= 1) > 0
+ @current_pos = 0
+ else
+ Tk_CBTBL[@id] = nil ;# for GC
+ return
+ end
+ end
+
+ @current_args = args
+
+ if @sleep_time.kind_of? Proc
+ sleep = @sleep_time.call(*args)
+ else
+ sleep = @sleep_time
+ end
+ @current_sleep = sleep
+
+ cmd, *cmd_args = @loop_proc[@current_pos]
+ @current_pos += 1
+ @current_proc = cmd
+
+ if cmd_args[0].kind_of? Proc
+ #c = cmd_args.shift
+ #cb_args = c.call(*(cmd_args + args))
+ cb_args = cmd_args[0].call(*args)
+ else
+ cb_args = cmd_args
+ end
+
+ set_callback(sleep, cb_args)
+ end
+
+ def initialize(*args)
+ @id = format("a%.4d", Tk_CBID[0])
+ Tk_CBID[0] += 1
+
+ @init_sleep=0
+ @init_proc=nil
+ @init_args=[]
+
+ @current_script = []
+ @current_proc = nil
+ @current_args = nil
+
+ @sleep_time = 0
+ @current_sleep = 0
+ @loop_exec = 0
+ @do_loop = 0
+ @loop_proc = []
+ @proc_max = 0
+ @current_pos = 0
+
+ @after_id = nil
+ @after_script = nil
+
+ set_procs(*args) if args != []
+
+ @running = false
+ end
+
+ attr :after_id
+ attr :after_script
+ attr :current_proc
+ attr :current_sleep
+
+ attr_accessor :loop_exec
+
+ def get_procs
+ [@init_sleep, @init_proc, @init_args, @sleep_time, @loop_exec, @loop_proc]
+ end
+
+ def current_status
+ [@running, @current_sleep, @current_proc, @current_args, @do_loop]
+ end
+
+ def running?
+ @running
+ end
+
+ def loop_rest
+ @do_loop
+ end
+
+ def loop_rest=(rest)
+ @do_loop = rest
+ end
+
+ def set_procs(interval, loop_exec, *procs)
+ if !interval == 'idle' \
+ && !interval.kind_of?(Integer) && !interval.kind_of?(Proc)
+ fail format("%s need to be Integer or Proc", interval.inspect)
+ end
+ @sleep_time = interval
+
+ @loop_proc = []
+ procs.each{|e|
+ if e.kind_of? Proc
+ @loop_proc.push([e])
+ else
+ @loop_proc.push(e)
+ end
+ }
+ @proc_max = @loop_proc.size
+ @current_pos = 0
+
+ @do_loop = 0
+ if loop_exec
+ if loop_exec.kind_of?(Integer) && loop_exec < 0
+ @loop_exec = -1
+ elsif loop_exec == nil || loop_exec == false || loop_exec == 0
+ @loop_exec = 1
+ else
+ if not loop_exec.kind_of?(Integer)
+ fail format("%s need to be Integer", loop_exec.inspect)
+ end
+ @loop_exec = loop_exec
+ end
+ @do_loop = @loop_exec
+ end
+
+ self
+ end
+
+ def add_procs(*procs)
+ procs.each{|e|
+ if e.kind_of? Proc
+ @loop_proc.push([e])
+ else
+ @loop_proc.push(e)
+ end
+ }
+ @proc_max = @loop_proc.size
+
+ self
+ end
+
+ def start(sleep=0, init_proc=nil, *init_args)
+ return nil if @running
+
+ Tk_CBTBL[@id] = self
+ @do_loop = @loop_exec
+ @current_pos = 0
+
+ if !sleep == 'idle' && !sleep.kind_of?(Integer)
+ fail format("%s need to be Integer", sleep.inspect)
+ end
+
+ @init_proc = init_proc
+ @init_args = init_args
+ @current_sleep = @init_sleep = sleep
+ @running = true
+ if init_proc
+ if not init_proc.kind_of? Proc
+ fail format("%s need to be Proc", init_proc.inspect)
+ end
+ @current_proc = init_proc
+ set_callback(sleep, init_args)
+ else
+ set_next_callback(*init_args)
+ end
+
+ self
+ end
+
+ def restart
+ cancel if @running
+ start(@init_sleep, @init_proc, @init_args)
+ end
+
+ def cancel
+ @running = false
+ tk_call 'after', 'cancel', @after_id if @after_id
+ @after_id = nil
+ Tk_CBTBL[@id] = nil ;# for GC
+ self
+ end
+ alias stop cancel
+
+ def continue(wait=nil)
+ sleep, cmd = @current_script
+ return nil if cmd == nil || @running == true
+ if wait
+ if not wait.kind_of? Integer
+ fail format("%s need to be Integer", wait.inspect)
+ end
+ sleep = wait
+ end
+ Tk_CBTBL[@id] = self
+ @running = true
+ @after_id = tk_call('after', sleep, cmd)
+ self
+ end
+
+ def skip
+ return nil if @running == false
+ cancel
+ Tk_CBTBL[@id] = self
+ @running = true
+ set_next_callback(@current_args)
+ self
+ end
+
+ def info
+ if @after_id
+ inf = tk_split_list(tk_call('after', 'info', @after_id))
+ [Tk_CBTBL[inf[0][1]], inf[1]]
+ else
+ nil
+ end
+ end
+end
diff --git a/lib/tkdialog.rb b/lib/tkdialog.rb
index e8f2142..011d431 100644
--- a/lib/tkdialog.rb
+++ b/lib/tkdialog.rb
@@ -9,7 +9,7 @@ class TkDialog < TkWindow
INTERP._eval('eval {global '+id+';'+
'set '+id+' [tk_dialog '+
@path+" "+title+" \"#{message}\" "+bitmap+" "+
- default_button+" "+buttons+']}')
+ String(default_button)+" "+buttons+']}')
end
def value
return @var.value.to_i
diff --git a/lib/tkpalette.rb b/lib/tkpalette.rb
index b317330..a2dc7c8 100644
--- a/lib/tkpalette.rb
+++ b/lib/tkpalette.rb
@@ -1,7 +1,9 @@
#
# tkpalette.rb : methods for Tcl/Tk standard library 'palette.tcl'
-# 1998/06/18 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+# 1998/06/21 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
#
+require 'tk'
+
module TkPalette
include Tk
extend Tk
diff --git a/lib/tktext.rb b/lib/tktext.rb
index 8e6772c..146944d 100644
--- a/lib/tktext.rb
+++ b/lib/tktext.rb
@@ -146,21 +146,12 @@ class TkTextTag<TkObject
end
def nextrange(first, last=nil)
- l = tk_split_list(tk_call(@t.path, 'tag', 'nextrange', @id, first, last))
- r = []
- while key=l.shift
- r.push [key, l.shift]
- end
- r
+ tk_split_list(tk_call(@t.path, 'tag', 'nextrange', @id, first, last))
end
def prevrange(first, last=nil)
+ tk_split_list(tk_call(@t.path, 'tag', 'prevrange', @id, first, last))
l = tk_split_list(tk_call(@t.path, 'tag', 'prevrange', @id, first, last))
- r = []
- while key=l.shift
- r.push [key, l.shift]
- end
- r
end
def [](key)
@@ -175,17 +166,17 @@ class TkTextTag<TkObject
tk_call @t.path, 'tag', 'cget', @id, "-#{key}"
end
- def configure(keys)
- tk_call @t.path, 'tag', 'configure', @id, *hash_kv(keys)
+ def configure(key, val=nil)
+ if key.kind_of? Hash
+ tk_call @t.path, 'tag', 'configure', @id, *hash_kv(key)
+ else
+ tk_call @t.path, 'tag', 'configure', @id, "-#{key}", val
+ end
+ end
+
+ def configinfo
+ tk_split_list(tk_call(@t.path, 'tag', 'configure', @id))
end
-# def configure(key, value)
-# if value == FALSE
-# value = "0"
-# elsif value.kind_of? Proc
-# value = install_cmd(value)
-# end
-# tk_call @t.path, 'tag', 'configure', @id, "-#{key}", value
-# end
def bind(seq, cmd=Proc.new, args=nil)
id = install_bind(cmd, args)
diff --git a/marshal.c b/marshal.c
index fe7b6a1..73ae8a6 100644
--- a/marshal.c
+++ b/marshal.c
@@ -397,7 +397,6 @@ marshal_dump(argc, argv)
{
VALUE obj, port, a1, a2;
int limit = -1;
- extern VALUE cIO;
struct dump_arg arg;
struct dump_call_arg c_arg;
diff --git a/missing/nt.h b/missing/nt.h
index 915a748..a571570 100644
--- a/missing/nt.h
+++ b/missing/nt.h
@@ -221,6 +221,8 @@ extern char *mystrerror(int);
#define EWOULDBLOCK 10035 /* EBASEERR + 35 (winsock.h) */
#endif
+#define O_BINMODE 0x8000
+
#ifdef popen
#undef popen
#define popen mypopen
diff --git a/pack.c b/pack.c
index 400d81c..840b837 100644
--- a/pack.c
+++ b/pack.c
@@ -103,10 +103,9 @@ pack_pack(ary, fmt)
char *ptr;
int plen;
- Check_Type(fmt, T_STRING);
-
- p = RSTRING(fmt)->ptr;
- pend = RSTRING(fmt)->ptr + RSTRING(fmt)->len;
+
+ p = str2cstr(fmt, &plen);
+ pend = p + plen;
res = str_new(0, 0);
items = RARRAY(ary)->len;
@@ -551,12 +550,10 @@ pack_unpack(str, fmt)
char type;
int len;
- Check_Type(fmt, T_STRING);
-
- s = RSTRING(str)->ptr;
- send = s + RSTRING(str)->len;
- p = RSTRING(fmt)->ptr;
- pend = p + RSTRING(fmt)->len;
+ s = str2cstr(str, &len);
+ send = s + len;
+ p = str2cstr(fmt, &len);
+ pend = p + len;
ary = ary_new();
while (p < pend) {
diff --git a/parse.y b/parse.y
index 2ae0664..a7844d4 100644
--- a/parse.y
+++ b/parse.y
@@ -570,7 +570,6 @@ reswords : k__LINE__ | k__FILE__ | klBEGIN | klEND
arg : variable '=' arg
{
- value_expr($3);
$$ = assignable($1, $3);
fixpos($$, $3);
}
@@ -592,7 +591,6 @@ arg : variable '=' arg
}
| variable tOP_ASGN arg
{
- value_expr($3);
if (is_local_id($1)) {
if (local_id($1)||!dyna_in_block()) {
local_cnt($1);
@@ -601,26 +599,58 @@ arg : variable '=' arg
dyna_var_asgn($1, TRUE);
}
}
- $$ = assignable($1,call_op(gettable($1),$2,1,$3));
+ if ($2 == tOROP) {
+ $$ = NEW_UNLESS(gettable($1), assignable($1, $3), 0);
+ }
+ else if ($2 == tANDOP) {
+ $$ = NEW_IF(gettable($1), assignable($1, $3), 0);
+ }
+ else {
+ $$ = assignable($1,call_op(gettable($1),$2,1,$3));
+ }
fixpos($$, $3);
}
| primary '[' aref_args ']' tOP_ASGN arg
{
- NODE *args = NEW_LIST($6);
+ if ($5 == tOROP) {
+ $$ = NEW_UNLESS(NEW_CALL($1, tAREF, $3), aryset($1, $3, $6), 0);
+ }
+ else if ($5 == tANDOP) {
+ $$ = NEW_IF(NEW_CALL($1, tAREF, $3), aryset($1, $3, $6), 0);
+ }
+ else {
+ NODE *args = NEW_LIST($6);
- list_append($3, NEW_NIL());
- list_concat(args, $3);
- $$ = NEW_OP_ASGN1($1, $5, args);
+ list_append($3, NEW_NIL());
+ list_concat(args, $3);
+ $$ = NEW_OP_ASGN1($1, $5, args);
+ }
fixpos($$, $1);
}
| primary '.' tIDENTIFIER tOP_ASGN arg
{
- $$ = NEW_OP_ASGN2($1, $3, $4, $5);
+ if ($4 == tOROP) {
+ $$ = NEW_UNLESS(new_call($1, $3, 0), attrset($1, $3, $5), 0);
+ }
+ else if ($4 == tANDOP) {
+ $$ = NEW_IF(new_call($1, $3, 0), attrset($1, $3, $5), 0);
+ }
+ else {
+ $$ = NEW_OP_ASGN2($1, $3, $4, $5);
+ }
fixpos($$, $1);
}
| primary '.' tCONSTANT tOP_ASGN arg
{
- $$ = NEW_OP_ASGN2($1, $3, $4, $5);
+ if ($4 == tOROP) {
+ $$ = NEW_UNLESS(new_call($1, $3, 0), attrset($1, $3, $5), 0);
+ }
+ else if ($4 == tANDOP) {
+ $$ = NEW_IF(new_call($1, $3, 0), attrset($1, $3, $5), 0);
+ }
+ else {
+ $$ = NEW_OP_ASGN2($1, $3, $4, $5);
+ }
fixpos($$, $1);
}
| backref tOP_ASGN arg
@@ -3435,6 +3465,7 @@ assignable(id, val)
{
NODE *lhs = 0;
+ value_expr(val);
if (id == kSELF) {
yyerror("Can't change the value of self");
}
diff --git a/process.c b/process.c
index 4ecfae8..ffb1fdf 100644
--- a/process.c
+++ b/process.c
@@ -81,7 +81,7 @@ rb_waitpid(pid, flags, st)
int result;
#if defined(THREAD) && (defined(HAVE_WAITPID) || defined(HAVE_WAIT4))
int oflags = flags;
- if (!thred_alone()) { /* there're other threads to run */
+ if (!thread_alone()) { /* there're other threads to run */
flags |= WNOHANG;
}
#endif
@@ -92,7 +92,7 @@ rb_waitpid(pid, flags, st)
if (result < 0) {
if (errno == EINTR) {
#ifdef THREAD
- thred_schedule();
+ thread_schedule();
#endif
goto retry;
}
@@ -101,8 +101,8 @@ rb_waitpid(pid, flags, st)
#ifdef THREAD
if (result == 0) {
if (oflags & WNOHANG) return 0;
- thred_schedule();
- if (thred_alone()) flags = oflags;
+ thread_schedule();
+ if (thread_alone()) flags = oflags;
goto retry;
}
#endif
@@ -120,8 +120,8 @@ rb_waitpid(pid, flags, st)
#ifdef THREAD
if (result == 0) {
if (oflags & WNOHANG) return 0;
- thred_schedule();
- if (thred_alone()) flags = oflags;
+ thread_schedule();
+ if (thread_alone()) flags = oflags;
goto retry;
}
#endif
@@ -141,7 +141,7 @@ rb_waitpid(pid, flags, st)
if (result < 0) {
if (errno == EINTR) {
#ifdef THREAD
- thred_schedule();
+ thread_schedule();
#endif
continue;
}
@@ -197,7 +197,7 @@ f_wait()
while ((pid = wait(&state)) < 0) {
if (errno == EINTR) {
#ifdef THREAD
- thred_schedule();
+ thread_schedule();
#endif
continue;
}
@@ -257,8 +257,6 @@ static void
security(str)
char *str;
{
- extern VALUE eSecurityError;
-
if (rb_safe_level() > 0) {
#ifndef USE_CWGUSI
if (env_path_tainted()) {
@@ -728,7 +726,7 @@ f_system(argc, argv)
case -1:
if (errno == EAGAIN) {
#ifdef THREAD
- thred_sleep(1);
+ thread_sleep(1);
#else
sleep(1);
#endif
@@ -758,10 +756,10 @@ f_sleep(argc, argv)
beg = time(0);
#ifdef THREAD
if (argc == 0) {
- thred_sleep_forever();
+ thread_sleep_forever();
}
else if (argc == 1) {
- thred_wait_for(time_timeval(argv[0]));
+ thread_wait_for(time_timeval(argv[0]));
}
#else
if (argc == 0) {
diff --git a/re.c b/re.c
index 8e2f6ec..d9962cb 100644
--- a/re.c
+++ b/re.c
@@ -629,7 +629,7 @@ reg_new_1(klass, s, len, options)
re->ptr = 0;
re->str = 0;
- if (options & 0x1) {
+ if (options & RE_OPTION_IGNORECASE) {
FL_SET(re, REG_IGNORECASE);
}
switch (options & ~0x3) {
@@ -763,19 +763,21 @@ reg_s_new(argc, argv, self)
ArgError("wrong # of argument");
}
if (argc >= 2 && RTEST(argv[1])) {
- flag = 1;
+ flag = RE_OPTION_IGNORECASE;
}
if (argc == 3) {
- Check_Type(argv[2], T_STRING);
- switch (RSTRING(argv[2])->ptr[0]) {
+ char *kcode = STR2CSTR(argv[2]);
+
+ if (!kcode) TypeError("wrong char-code");
+ switch (kcode[0]) {
case 'n': case 'N':
- flag |= 2;
+ flag |= 4;
break;
case 'e': case 'E':
- flag |= 4;
+ flag |= 8;
break;
case 's': case 'S':
- flag |= 6;
+ flag |= 12;
break;
default:
break;
@@ -801,12 +803,11 @@ reg_s_quote(re, str)
{
char *s, *send, *t;
char *tmp;
+ int len;
- Check_Type(str, T_STRING);
-
- tmp = ALLOCA_N(char, RSTRING(str)->len*2);
-
- s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
+ s = str2cstr(str, &len);
+ send = s + len;
+ tmp = ALLOCA_N(char, len*2);
t = tmp;
for (; s != send; s++) {
diff --git a/ruby.1 b/ruby.1
index 8a349ea..c013afd 100644
--- a/ruby.1
+++ b/ruby.1
@@ -1,4 +1,4 @@
-.\"Ruby is copyrighted by Yukihiro Matsumoto <matz@ruby.club.co.jp>.
+.\"Ruby is copyrighted by Yukihiro Matsumoto <matz@netlab.co.jp>.
.\"
.\"This source is distributed under the conditions blow:
.\"
@@ -37,7 +37,7 @@
.\" $Id$
.\"
.na
-.TH RUBY 1 "ruby 1.0" "19/Sep/97" "Ruby Programmers Reference Guide"
+.TH RUBY 1 "ruby 1.1" "22/Jun/98" "Ruby Programmers Reference Guide"
.SH NAME
ruby - Interpreted scripting language
.SH SYNOPSIS
@@ -326,4 +326,4 @@ specify this switch, unless you are going to debug the ruby
interpreter itself.
.PP
.SH AUTHOR
- Ruby is designed and implemented by Yukihiro Matsumoto <matz@ruby.club.co.jp>.
+ Ruby is designed and implemented by Yukihiro Matsumoto <matz@netlab.co.jp>.
diff --git a/ruby.c b/ruby.c
index e675b3b..eb75630 100644
--- a/ruby.c
+++ b/ruby.c
@@ -613,7 +613,6 @@ set_arg0(val, id)
static int len;
if (origargv == 0) Fail("$0 not initialized");
- Check_Type(val, T_STRING);
if (len == 0) {
s = origargv[0];
s += strlen(s);
@@ -624,8 +623,7 @@ set_arg0(val, id)
}
len = s - origargv[0];
}
- s = RSTRING(val)->ptr;
- i = RSTRING(val)->len;
+ s = str2cstr(val, &i);
if (i > len) {
memcpy(origargv[0], s, len);
origargv[0][len] = '\0';
diff --git a/ruby.h b/ruby.h
index b8a2635..edc3de9 100644
--- a/ruby.h
+++ b/ruby.h
@@ -463,7 +463,7 @@ void Raise __((VALUE, char*, ...)) NORETURN;
void Fail __((char*, ...)) NORETURN;
void Fatal __((char*, ...)) NORETURN;
void Bug __((char*, ...)) NORETURN;
-void rb_sys_fail _((char *)) NORETURN;
+void rb_sys_fail _((char*)) NORETURN;
void rb_iter_break _((void)) NORETURN;
void rb_exit _((int)) NORETURN;
void rb_raise _((VALUE)) NORETURN;
diff --git a/rubyio.h b/rubyio.h
index a9b2dec..78d3d60 100644
--- a/rubyio.h
+++ b/rubyio.h
@@ -14,7 +14,6 @@
#ifndef IO_H
#define IO_H
-#include "rubysig.h"
#include <stdio.h>
#include <errno.h>
diff --git a/rubysig.h b/rubysig.h
index 0e5e8eb..fa99c84 100644
--- a/rubysig.h
+++ b/rubysig.h
@@ -23,24 +23,24 @@ extern int trap_pending;
void trap_restore_mask _((void));
#ifdef THREAD
-extern int thred_critical;
-void thred_schedule _((void));
+extern int thread_critical;
+void thread_schedule _((void));
#if defined(HAVE_SETITIMER) && !defined(__BOW__)
-extern int thred_pending;
+extern int thread_pending;
# define CHECK_INTS if (!prohibit_interrupt) {\
if (trap_pending) rb_trap_exec();\
- if (thred_pending && !thred_critical) thred_schedule();\
+ if (thread_pending && !thread_critical) thread_schedule();\
}
# else
/* pseudo preemptive thread switching */
-extern int thred_tick;
+extern int thread_tick;
#define THREAD_TICK 500
# define CHECK_INTS if (!prohibit_interrupt) {\
if (trap_pending) rb_trap_exec();\
- if (!thred_critical) {\
- if (thred_tick-- <= 0) {\
- thred_tick = THREAD_TICK;\
- thred_schedule();\
+ if (!thread_critical) {\
+ if (thread_tick-- <= 0) {\
+ thread_tick = THREAD_TICK;\
+ thread_schedule();\
}\
}\
}
diff --git a/sample/cal.rb b/sample/cal.rb
new file mode 100644
index 0000000..b0f5d88
--- /dev/null
+++ b/sample/cal.rb
@@ -0,0 +1,118 @@
+#! /usr/local/bin/ruby
+
+# cal.rb (bsd compatible version): Written by Tadayoshi Funaba 1998
+# $Id: bsdcal.rb,v 1.1 1998/06/01 12:53:01 tadf Exp $
+
+require 'date2'
+
+$tab =
+{
+ 'cn' => true, # China
+ 'de' => 2342032, # Germany (protestant states)
+ 'dk' => 2342032, # Denmark
+ 'es' => 2299161, # Spain
+ 'fi' => 2361390, # Finland
+ 'fr' => 2299227, # France
+ 'gb' => 2361222, # United Kingdom
+ 'gr' => 2423868, # Greece
+ 'hu' => 2301004, # Hungary
+ 'it' => 2299161, # Italy
+ 'jp' => true, # Japan
+ 'no' => 2342032, # Norway
+ 'pl' => 2299161, # Poland
+ 'pt' => 2299161, # Portugal
+ 'ru' => 2421639, # Russia
+ 'se' => 2361390, # Sweden
+ 'us' => 2361222, # United States
+ 'os' => false, # (old style)
+ 'ns' => true # (new style)
+}
+
+$cc = 'gb'
+
+def usage
+ $stderr.puts 'usage: cal [-c iso3166] [-jy] [[month] year]'
+ exit 1
+end
+
+def cal(m, y, gs)
+ for d in 1..31
+ break if jd = Date.exist?(y, m, d, gs)
+ end
+ fst = cur = Date.new(jd, gs)
+ ti = Date::MONTHNAMES[m]
+ ti << ' ' << y.to_s unless $yr
+ mo = ti.center((($w + 1) * 7) - 1) << "\n"
+ mo << ['S', 'M', 'Tu', 'W', 'Th', 'F', 'S'].
+ collect{|x| x.rjust($w)}.join(' ') << "\n"
+ mo << ' ' * (($w + 1) * fst.wday)
+ while cur.mon == fst.mon
+ mo << (if $jd then cur.yday else cur.mday end).to_s.rjust($w)
+ mo << (if (cur += 1).wday != 0 then "\s" else "\n" end)
+ end
+ mo << "\n" * (6 - ((fst.wday + (cur - fst)) / 7))
+ mo
+end
+
+def zip(xs)
+ yr = ''
+ until xs.empty?
+ ln = (if $jd then l, r, *xs = xs; [l, r]
+ else l, c, r, *xs = xs; [l, c, r] end).
+ collect{|x| x.split(/\n/no)}
+ 8.times do
+ yr << ln.collect{|x|
+ x.shift.ljust((($w + 1) * 7) - 1)}.join(' ') << "\n"
+ end
+ end
+ yr
+end
+
+while /^-(.*)$/no =~ $*[0]
+ a = $1
+ if /^c(.+)?$/no =~ a then
+ if $1 then
+ $cc = $1.downcase
+ elsif $*.length >= 2 then
+ $cc = $*[1].downcase
+ $*.shift
+ else
+ usage
+ end
+ else
+ a.scan(/./no) do |c|
+ case c
+ when 'j'; $jd = true
+ when 'y'; $yr = true
+ else usage
+ end
+ end
+ end
+ $*.shift
+end
+usage if (gs = $tab[$cc]).nil?
+case $*.length
+when 0
+ td = Date.today
+ m = td.mon
+ y = td.year
+when 1
+ y = $*[0].to_i
+ $yr = true
+when 2
+ m = $*[0].to_i
+ y = $*[1].to_i
+else
+ usage
+end
+usage unless m.nil? or (1..12) === m
+usage unless y >= -4712
+$w = if $jd then 3 else 2 end
+unless $yr then
+ print cal(m, y, gs)
+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"
+end
diff --git a/signal.c b/signal.c
index f66c828..a8e5ae6 100644
--- a/signal.c
+++ b/signal.c
@@ -286,8 +286,8 @@ posix_signal(signum, handler)
#endif
#ifdef THREAD
-# define rb_interrupt thred_interrupt
-# define rb_trap_eval thred_trap_eval
+# define rb_interrupt thread_interrupt
+# define rb_trap_eval thread_trap_eval
#endif
static RETSIGTYPE
diff --git a/sprintf.c b/sprintf.c
index bc7f77b..dac3659 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -141,14 +141,13 @@ f_sprintf(argc, argv)
((argc == 0)?(ArgError("too few argument."),0):(argc--,((argv++)[0])))
fmt = GETARG();
- Check_Type(fmt, T_STRING);
-
+ p = str2cstr(fmt, &blen);
+ end = p + blen;
blen = 0;
bsiz = 120;
buf = ALLOC_N(char, bsiz);
- end = RSTRING(fmt)->ptr + RSTRING(fmt)->len;
- for (p = RSTRING(fmt)->ptr; p < end; p++) {
+ for (; p < end; p++) {
char *t;
for (t = p; t < end && *t != '%'; t++) ;
diff --git a/string.c b/string.c
index 90787cd..013238d 100644
--- a/string.c
+++ b/string.c
@@ -344,7 +344,6 @@ str_modify(str)
char *ptr;
if (rb_safe_level() >= 5) {
- extern VALUE eSecurityError;
Raise(eSecurityError, "cannot change string status");
}
if (FL_TEST(str, STR_FREEZE))
@@ -1091,7 +1090,7 @@ str_aset(str, indx, val)
{
int beg, end;
if (range_beg_end(indx, &beg, &end)) {
- str_replace2(str, beg, end, val);
+ str_replace2(str, beg, end, str_to_str(val));
return val;
}
}
diff --git a/time.c b/time.c
index 00289b0..b906bb5 100644
--- a/time.c
+++ b/time.c
@@ -737,18 +737,19 @@ time_strftime(time, format)
{
struct time_object *tobj;
char buffer[SMALLBUF];
+ char *fmt;
char *buf = buffer;
int len;
VALUE str;
- Check_Type(format, T_STRING);
GetTimeval(time, tobj);
if (tobj->tm_got == 0) {
time_localtime(time);
}
- if (strlen(RSTRING(format)->ptr) < RSTRING(format)->len) {
+ fmt = str2cstr(format, &len);
+ if (strlen(fmt) < len) {
/* Ruby string may contain \0's. */
- char *p = RSTRING(format)->ptr, *pe = p + RSTRING(format)->len;
+ char *p = fmt, *pe = fmt + len;
str = str_new(0, 0);
while (p < pe) {
diff --git a/version.h b/version.h
index 4ed0fc6..39d4f69 100644
--- a/version.h
+++ b/version.h
@@ -1,2 +1,2 @@
-#define RUBY_VERSION "1.1b9_27"
-#define VERSION_DATE "98/06/19"
+#define RUBY_VERSION "1.1b9_28"
+#define VERSION_DATE "98/06/26"
diff --git a/win32/Makefile b/win32/Makefile
index d2af7c1..135d657 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -210,26 +210,26 @@ dln.obj: dln.c config.h defines.h dln.h st.h
dmyext.obj: dmyext.c
enum.obj: enum.c ruby.h config.h defines.h
error.obj: error.c ruby.h config.h defines.h env.h
-eval.obj: eval.c ruby.h config.h defines.h env.h node.h sig.h st.h dln.h
-file.obj: file.c ruby.h config.h defines.h io.h sig.h
+eval.obj: eval.c ruby.h config.h defines.h env.h node.h rubysig.h st.h dln.h
+file.obj: file.c ruby.h config.h defines.h rubyio.h rubysig.h
fnmatch.obj: fnmatch.c config.h fnmatch.h
-gc.obj: gc.c ruby.h config.h defines.h env.h sig.h st.h node.h re.h regex.h
+gc.obj: gc.c ruby.h config.h defines.h env.h rubysig.h st.h node.h re.h regex.h
glob.obj: glob.c config.h fnmatch.h
hash.obj: hash.c ruby.h config.h defines.h st.h
inits.obj: inits.c ruby.h config.h defines.h
-io.obj: io.c ruby.h config.h defines.h io.h sig.h
+io.obj: io.c ruby.h config.h defines.h rubyio.h rubysig.h
main.obj: main.c
math.obj: math.c ruby.h config.h defines.h
numeric.obj: numeric.c ruby.h config.h defines.h
object.obj: object.c ruby.h config.h defines.h st.h
pack.obj: pack.c ruby.h config.h defines.h
-process.obj: process.c ruby.h config.h defines.h sig.h st.h
+process.obj: process.c ruby.h config.h defines.h rubysig.h st.h
random.obj: random.c ruby.h config.h defines.h
range.obj: range.c ruby.h config.h defines.h
re.obj: re.c ruby.h config.h defines.h re.h regex.h
regex.obj: regex.c config.h defines.h regex.h util.h
ruby.obj: ruby.c ruby.h config.h defines.h re.h regex.h dln.h
-signal.obj: signal.c ruby.h config.h defines.h sig.h
+signal.obj: signal.c ruby.h config.h defines.h rubysig.h
sprintf.obj: sprintf.c ruby.h config.h defines.h
st.obj: st.c config.h st.h
string.obj: string.c ruby.h config.h defines.h re.h regex.h