summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-07 08:34:10 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-07 08:34:10 +0000
commitba06b1a81f81e089849c7c877eba7b1d3618b126 (patch)
tree57e77c2ade50f201b4aafdc071cf86fb95eb7016
parentf8fc9136223c83c2791566d3efa52843f89aa127 (diff)
dynamic (nested) local variables
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog34
-rw-r--r--ToDo2
-rw-r--r--array.c22
-rw-r--r--bignum.c8
-rw-r--r--class.c49
-rw-r--r--config.guess415
-rw-r--r--config.sub113
-rw-r--r--error.c3
-rw-r--r--eval.c137
-rw-r--r--hash.c18
-rw-r--r--intern.h1
-rw-r--r--lib/delegate.rb8
-rw-r--r--mkconfig.rb4
-rw-r--r--numeric.c64
-rw-r--r--object.c15
-rw-r--r--parse.y4
-rw-r--r--ruby.h27
-rw-r--r--sample/test.rb11
-rw-r--r--string.c17
19 files changed, 742 insertions, 210 deletions
diff --git a/ChangeLog b/ChangeLog
index 550d743235..3de9e4c600 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+Tue Apr 7 01:16:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (ary_cmp): compare each element using `<=>'.
+
+ * hash.c (hash_each_with_index): yields [value, key] pair.
+
+ * class.c (class_protected_instance_methods): list protected
+ method names.
+
+ * class.c (ins_methods_i): exclude protected methods.
+
+ * eval.c (PUSH_BLOCK): dynamic variables can be accessed from
+ eval() with bindings.
+
+Mon Apr 6 14:49:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (thread_yield): must return evaluated value.
+
+Fri Apr 3 11:25:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * numeric.c (num2int): no implicit conversion from string.
+
+ * numeric.c (num2int): check that `to_i' returned Integer.
+
+ * numeric.c (num_zero_p): new method.
+
+ * numeric.c (num_nonzero_p): new method. returns the receiver if
+ it's not zero.
+
+ * eval.c (obj_instance_eval): the_class should be the object's
+ singleton class.
+
+ * error.c (exc_s_new): message is converted into a string.
+
Thu Apr 2 18:31:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (obj_call_init): every object call `initialize'.
diff --git a/ToDo b/ToDo
index 674ec3b554..9710c42302 100644
--- a/ToDo
+++ b/ToDo
@@ -1,5 +1,3 @@
-* call `initialize' for built-in classes.
-* 0 as flase value
* non-blocking open/write for thread
* package or access control for global variables
* format
diff --git a/array.c b/array.c
index 02f0af36f9..5093163986 100644
--- a/array.c
+++ b/array.c
@@ -1060,6 +1060,27 @@ ary_includes(ary, item)
return FALSE;
}
+VALUE
+ary_cmp(ary, ary2)
+ VALUE ary;
+ VALUE ary2;
+{
+ int i, len;
+
+ Check_Type(ary2, T_ARRAY);
+ len = RARRAY(ary)->len;
+ if (len > RARRAY(ary2)->len) {
+ len = RARRAY(ary2)->len;
+ }
+ for (i=0; i<len; i++) {
+ VALUE v = rb_funcall(RARRAY(ary)->ptr[i],cmp,1,RARRAY(ary2)->ptr[i]);
+ if (v != INT2FIX(0)) {
+ return v;
+ }
+ }
+ return INT2FIX(0);
+}
+
static VALUE
ary_diff(ary1, ary2)
VALUE ary1, ary2;
@@ -1261,6 +1282,7 @@ Init_Array()
rb_define_method(cArray, "fill", ary_fill, -1);
rb_define_method(cArray, "include?", ary_includes, 1);
rb_define_method(cArray, "===", ary_includes, 1);
+ rb_define_method(cArray, "<=>", ary_cmp, 1);
rb_define_method(cArray, "assoc", ary_assoc, 1);
rb_define_method(cArray, "rassoc", ary_rassoc, 1);
diff --git a/bignum.c b/bignum.c
index 8ca00fcd6f..5e9b28c4ec 100644
--- a/bignum.c
+++ b/bignum.c
@@ -1241,6 +1241,13 @@ big_size(big)
return INT2FIX(RBIGNUM(big)->len*sizeof(USHORT));
}
+static VALUE
+big_zero_p(big)
+ VALUE big;
+{
+ return FALSE;
+}
+
void
Init_Bignum()
{
@@ -1274,4 +1281,5 @@ Init_Bignum()
rb_define_method(cBignum, "to_f", big_to_f, 0);
rb_define_method(cBignum, "abs", big_abs, 0);
rb_define_method(cBignum, "size", big_size, 0);
+ rb_define_method(cBignum, "zero?", big_zero_p, 0);
}
diff --git a/class.c b/class.c
index 41a0b504da..40db68beb2 100644
--- a/class.c
+++ b/class.c
@@ -285,7 +285,7 @@ ins_methods_i(key, body, ary)
NODE *body;
VALUE ary;
{
- if ((body->nd_noex&NOEX_PRIVATE) == 0) {
+ if ((body->nd_noex&(NOEX_PRIVATE|NOEX_PROTECTED)) == 0) {
VALUE name = str_new2(rb_id2name(key));
if (!ary_includes(ary, name)) {
@@ -303,6 +303,30 @@ ins_methods_i(key, body, ary)
}
static int
+ins_methods_prot_i(key, body, ary)
+ ID key;
+ NODE *body;
+ VALUE ary;
+{
+ if (!body->nd_body) {
+ ary_push(ary, Qnil);
+ ary_push(ary, str_new2(rb_id2name(key)));
+ }
+ else if (body->nd_noex & NOEX_PROTECTED) {
+ VALUE name = str_new2(rb_id2name(key));
+
+ if (!ary_includes(ary, name)) {
+ ary_push(ary, name);
+ }
+ }
+ else if (nd_type(body->nd_body) == NODE_ZSUPER) {
+ ary_push(ary, Qnil);
+ ary_push(ary, str_new2(rb_id2name(key)));
+ }
+ return ST_CONTINUE;
+}
+
+static int
ins_methods_priv_i(key, body, ary)
ID key;
NODE *body;
@@ -366,6 +390,18 @@ class_instance_methods(argc, argv, mod)
}
VALUE
+class_protected_instance_methods(argc, argv, mod)
+ int argc;
+ VALUE *argv;
+ VALUE mod;
+{
+ VALUE option;
+
+ rb_scan_args(argc, argv, "01", &option);
+ return method_list(mod, RTEST(option), ins_methods_prot_i);
+}
+
+VALUE
class_private_instance_methods(argc, argv, mod)
int argc;
VALUE *argv;
@@ -429,6 +465,17 @@ rb_define_method(klass, name, func, argc)
}
void
+rb_define_protected_method(klass, name, func, argc)
+ VALUE klass;
+ char *name;
+ VALUE (*func)();
+ int argc;
+{
+ rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc),
+ NOEX_PROTECTED|NOEX_CFUNC);
+}
+
+void
rb_define_private_method(klass, name, func, argc)
VALUE klass;
char *name;
diff --git a/config.guess b/config.guess
index 91dad5ee6a..a51656dd7b 100644
--- a/config.guess
+++ b/config.guess
@@ -1,6 +1,6 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright (C) 1992, 93, 94, 95, 1996 Free Software Foundation, Inc.
+# Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -63,11 +63,53 @@ trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
alpha:OSF1:*:*)
+ if test $UNAME_RELEASE = "V4.0"; then
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ fi
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
- echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//'`
+ cat <<EOF >dummy.s
+ .globl main
+ .ent main
+main:
+ .frame \$30,0,\$26,0
+ .prologue 0
+ .long 0x47e03d80 # implver $0
+ lda \$2,259
+ .long 0x47e20c21 # amask $2,$1
+ srl \$1,8,\$2
+ sll \$2,2,\$2
+ sll \$0,3,\$0
+ addl \$1,\$0,\$0
+ addl \$2,\$0,\$0
+ ret \$31,(\$26),1
+ .end main
+EOF
+ ${CC-cc} dummy.s -o dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ ./dummy
+ case "$?" in
+ 7)
+ UNAME_MACHINE="alpha"
+ ;;
+ 15)
+ UNAME_MACHINE="alphaev5"
+ ;;
+ 14)
+ UNAME_MACHINE="alphaev56"
+ ;;
+ 10)
+ UNAME_MACHINE="alphapca56"
+ ;;
+ 16)
+ UNAME_MACHINE="alphaev6"
+ ;;
+ esac
+ fi
+ rm -f dummy.s dummy
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]`
exit 0 ;;
21064:Windows_NT:50:3)
echo alpha-dec-winnt3.5
@@ -78,17 +120,48 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
amiga:NetBSD:*:*)
echo m68k-cbm-netbsd${UNAME_RELEASE}
exit 0 ;;
+ amiga:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ arc64:OpenBSD:*:*)
+ echo mips64el-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ arc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ hkmips:OpenBSD:*:*)
+ echo mips-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ pmax:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sgi:OpenBSD:*:*)
+ echo mips-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ wgrisc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit 0;;
- Pyramid*:OSx*:*:*)
+ arm32:NetBSD:*:*)
+ echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ exit 0 ;;
+ SR2?01:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit 0;;
+ Pyramid*:OSx*:*:*|MIS*:OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
if test "`(/bin/universe) 2>/dev/null`" = att ; then
echo pyramid-pyramid-sysv3
else
echo pyramid-pyramid-bsd
fi
exit 0 ;;
- sun4*:SunOS:5.*:*)
+ NILE:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit 0 ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
i86pc:SunOS:5.*:*)
@@ -112,25 +185,81 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
sun3*:SunOS:*:*)
echo m68k-sun-sunos${UNAME_RELEASE}
exit 0 ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit 0 ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit 0 ;;
atari*:NetBSD:*:*)
echo m68k-atari-netbsd${UNAME_RELEASE}
exit 0 ;;
+ atari*:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
sun3*:NetBSD:*:*)
echo m68k-sun-netbsd${UNAME_RELEASE}
exit 0 ;;
+ sun3*:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
mac68k:NetBSD:*:*)
echo m68k-apple-netbsd${UNAME_RELEASE}
exit 0 ;;
+ mac68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme88k:OpenBSD:*:*)
+ echo m88k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit 0 ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit 0 ;;
RISC*:ULTRIX:*:*)
echo mips-dec-ultrix${UNAME_RELEASE}
exit 0 ;;
VAX*:ULTRIX*:*:*)
echo vax-dec-ultrix${UNAME_RELEASE}
exit 0 ;;
- mips:*:4*:UMIPS)
- echo mips-mips-riscos4sysv
+ 2020:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
exit 0 ;;
- mips:*:5*:RISCos)
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ sed 's/^ //' << EOF >dummy.c
+ int main (argc, argv) int argc; char **argv; {
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ ${CC-cc} dummy.c -o dummy \
+ && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+ && rm dummy.c dummy && exit 0
+ rm -f dummy.c dummy
echo mips-mips-riscos${UNAME_RELEASE}
exit 0 ;;
Night_Hawk:Power_UNIX:*:*)
@@ -174,10 +303,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:IRIX*:*:*)
echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
exit 0 ;;
- ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
- i[34]86:AIX:*:*)
+ i?86:AIX:*:*)
echo i386-ibm-aix
exit 0 ;;
*:AIX:2:3)
@@ -240,7 +369,7 @@ EOF
case "${UNAME_MACHINE}" in
9000/31? ) HP_ARCH=m68000 ;;
9000/[34]?? ) HP_ARCH=m68k ;;
- 9000/7?? | 9000/8?[679] ) HP_ARCH=hppa1.1 ;;
+ 9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;;
9000/8?? ) HP_ARCH=hppa1.0 ;;
esac
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
@@ -288,6 +417,13 @@ EOF
hp8??:OSF1:*:*)
echo hppa1.0-hp-osf
exit 0 ;;
+ i?86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit 0 ;;
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
exit 0 ;;
@@ -315,16 +451,32 @@ EOF
CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE}
exit 0 ;;
- CRAY*C90:*:*:*)
- echo c90-cray-unicos${UNAME_RELEASE}
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
+ exit 0 ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE}
exit 0 ;;
CRAY-2:*:*:*)
echo cray2-cray-unicos
exit 0 ;;
+ F300:UNIX_System_V:*:*)
+ FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit 0 ;;
+ F301:UNIX_System_V:*:*)
+ echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
+ exit 0 ;;
hp3[0-9][05]:NetBSD:*:*)
echo m68k-hp-netbsd${UNAME_RELEASE}
exit 0 ;;
- i[34]86:BSD/386:*:* | *:BSD/OS:*:*)
+ hp300:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ i?86:BSD/386:*:* | *:BSD/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit 0 ;;
*:FreeBSD:*:*)
@@ -342,6 +494,9 @@ EOF
i*:CYGWIN*:*)
echo i386-pc-cygwin32
exit 0 ;;
+ i*:MINGW*:*)
+ echo i386-pc-mingw32
+ exit 0 ;;
p*:CYGWIN*:*)
echo powerpcle-unknown-cygwin32
exit 0 ;;
@@ -349,24 +504,155 @@ EOF
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
*:GNU:*:*)
- echo `echo ${UNAME_MACHINE}|sed -e 's,/.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit 0 ;;
*:Linux:*:*)
- echo ${UNAME_MACHINE}-pc-linux
- exit 0 ;;
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us.
+ ld_help_string=`ld --help 2>&1`
+ ld_supported_emulations=`echo $ld_help_string \
+ | sed -ne '/supported emulations:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported emulations: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_emulations" in
+ i?86linux) echo "${UNAME_MACHINE}-pc-linux-aout" ; exit 0 ;;
+ i?86coff) echo "${UNAME_MACHINE}-pc-linux-coff" ; exit 0 ;;
+ sparclinux) echo "${UNAME_MACHINE}-unknown-linux-aout" ; exit 0 ;;
+ m68klinux) echo "${UNAME_MACHINE}-unknown-linux-aout" ; exit 0 ;;
+ elf32ppc) echo "powerpc-unknown-linux" ; exit 0 ;;
+ esac
+
+ if test "${UNAME_MACHINE}" = "alpha" ; then
+ sed 's/^ //' <<EOF >dummy.s
+ .globl main
+ .ent main
+ main:
+ .frame \$30,0,\$26,0
+ .prologue 0
+ .long 0x47e03d80 # implver $0
+ lda \$2,259
+ .long 0x47e20c21 # amask $2,$1
+ srl \$1,8,\$2
+ sll \$2,2,\$2
+ sll \$0,3,\$0
+ addl \$1,\$0,\$0
+ addl \$2,\$0,\$0
+ ret \$31,(\$26),1
+ .end main
+EOF
+ LIBC=""
+ ${CC-cc} dummy.s -o dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ ./dummy
+ case "$?" in
+ 7)
+ UNAME_MACHINE="alpha"
+ ;;
+ 15)
+ UNAME_MACHINE="alphaev5"
+ ;;
+ 14)
+ UNAME_MACHINE="alphaev56"
+ ;;
+ 10)
+ UNAME_MACHINE="alphapca56"
+ ;;
+ 16)
+ UNAME_MACHINE="alphaev6"
+ ;;
+ esac
+
+ objdump --private-headers dummy | \
+ grep ld.so.1 > /dev/null
+ if test "$?" = 0 ; then
+ LIBC="libc1"
+ fi
+ fi
+ rm -f dummy.s dummy
+ echo ${UNAME_MACHINE}-unknown-linux-{LIBC} ; exit 0
+ elif test "${UNAME_MACHINE}" = "mips" ; then
+ cat >dummy.c <<EOF
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+#ifdef __MIPSEB__
+ printf ("%s-unknown-linux\n", argv[1]);
+#endif
+#ifdef __MIPSEL__
+ printf ("%sel-unknown-linux\n", argv[1]);
+#endif
+ return 0;
+}
+EOF
+ ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
+ rm -f dummy.c dummy
+ else
+ # Either a pre-BFD a.out linker (linux-oldld)
+ # or one that does not give us useful --help.
+ # GCC wants to distinguish between linux-oldld and linux-aout.
+ # If ld does not provide *any* "supported emulations:"
+ # that means it is gnuoldld.
+ echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:"
+ test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-oldld" && exit 0
+
+ case "${UNAME_MACHINE}" in
+ i?86)
+ VENDOR=pc;
+ ;;
+ *)
+ VENDOR=unknown;
+ ;;
+ esac
+ # Determine whether the default compiler is a.out or elf
+ cat >dummy.c <<EOF
+#include <features.h>
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+#ifdef __ELF__
+# ifdef __GLIBC__
+# if __GLIBC__ >= 2
+ printf ("%s-${VENDOR}-linux\n", argv[1]);
+# else
+ printf ("%s-${VENDOR}-linux-libc1\n", argv[1]);
+# endif
+# else
+ printf ("%s-${VENDOR}-linux-libc1\n", argv[1]);
+# endif
+#else
+ printf ("%s-${VENDOR}-linux-aout\n", argv[1]);
+#endif
+ return 0;
+}
+EOF
+ ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
+ rm -f dummy.c dummy
+ fi ;;
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
# are messed up and put the nodename in both sysname and nodename.
- i[34]86:DYNIX/ptx:4*:*)
+ i?86:DYNIX/ptx:4*:*)
echo i386-sequent-sysv4
exit 0 ;;
- i[34]86:*:4.*:* | i[34]86:SYSTEM_V:4.*:*)
+ i?86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit 0 ;;
+ i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
else
echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
fi
exit 0 ;;
- i[34]86:*:3.2:*)
+ i?86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
@@ -380,6 +666,11 @@ EOF
echo ${UNAME_MACHINE}-pc-sysv32
fi
exit 0 ;;
+ pc:*:*:*)
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+ exit 0 ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
exit 0 ;;
@@ -397,28 +688,36 @@ EOF
# "miniframe"
echo m68010-convergent-sysv
exit 0 ;;
- M680[234]0:*:R3V[567]*:*)
+ M68*:*:R3V[567]*:*)
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
- 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0)
- uname -p 2>/dev/null | grep 86 >/dev/null \
- && echo i486-ncr-sysv4.3 && exit 0 ;;
+ 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
- uname -p 2>/dev/null | grep 86 >/dev/null \
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& echo i486-ncr-sysv4 && exit 0 ;;
- m680[234]0:LynxOS:2.[23]*:*)
- echo m68k-lynx-lynxos${UNAME_RELEASE}
+ m68*:LynxOS:2.*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit 0 ;;
- i[34]86:LynxOS:2.[23]*:*)
- echo i386-lynx-lynxos${UNAME_RELEASE}
+ i?86:LynxOS:2.*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
- TSUNAMI:LynxOS:2.[23]*:*)
- echo sparc-lynx-lynxos${UNAME_RELEASE}
+ rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
- rs6000:LynxOS:2.[23]*:*)
- echo rs6000-lynx-lynxos${UNAME_RELEASE}
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
exit 0 ;;
RM*:SINIX-*:*:*)
echo mips-sni-sysv4
@@ -431,43 +730,35 @@ EOF
echo ns32k-sni-sysv
fi
exit 0 ;;
+ PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit 0 ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit 0 ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit 0 ;;
mc68*:A/UX:*:*)
echo m68k-apple-aux${UNAME_RELEASE}
exit 0 ;;
X680[02346]0:Human68k:*:*)
echo m68k-sharp-human
exit 0 ;;
- R[34]000:*System_V*:*:*)
+ news*:NEWS-OS:*:6*)
+ echo mips-sony-newsos6
+ exit 0 ;;
+ R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*)
if [ -d /usr/nec ]; then
echo mips-nec-sysv${UNAME_RELEASE}
else
echo mips-unknown-sysv${UNAME_RELEASE}
fi
exit 0 ;;
- R[34]???:UNIX_SV:4.?MP:*)
- if [ -x /sbin/uversion ]; then
- UVERSION_RELEASE=`(/sbin/uversion -r) 2>/dev/null` \
- || UVERSION_RELEASE=unknown
- UVERSION_SYSTEM=`(/sbin/uversion -s) 2>/dev/null` \
- || UVERSION_SYSTEM=unknown
- case "${UVERSION_RELEASE}:${UVERSION_SYSTEM}" in
- Release*:EWS4800/*)
- suffix=`echo ${UNAME_RELEASE} | tr '[A-Z]' '[a-z]'`
- suffix=${suffix}r`echo ${UVERSION_RELEASE} | \
- sed -e 's/Release//' -e 's/ Rev.*$//'`
- echo mips-nec-sysv${suffix}
- exit 0 ;;
- esac
- fi;;
- *:machten:*:*)
- echo ${UNAME_MACHINE}-apple-machten
- exit 0 ;;
- powerpc:JCC_BSD+:*:*)
- echo powerpc-jcc-bsd4.4
- exit 0 ;;
- DS/90*:*:*:V20*)
- echo sparc-fujitsu-uxpds
- exit 0 ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
@@ -511,7 +802,7 @@ main ()
#endif
int version;
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
- printf ("%s-next-nextstep%s\n", __ARCHITECTURE__, version==2 ? "2" : "3");
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
exit (0);
#endif
@@ -567,16 +858,12 @@ main ()
printf ("i860-alliant-bsd\n"); exit (0);
#endif
-#if defined (__human68k__) || defined (HUMAN68K)
- printf ("m68k-sharp-human\n"); exit (0);
-#endif
-
exit (1);
}
EOF
-${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm -f dummy.c dummy.x dummy && exit 0
-rm -f dummy.c dummy.x dummy
+${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
+rm -f dummy.c dummy
# Apollos put the system type in the environment.
diff --git a/config.sub b/config.sub
index 002d408812..9027a69b36 100644
--- a/config.sub
+++ b/config.sub
@@ -1,6 +1,6 @@
#! /bin/sh
# Configuration validation subroutine script, version 1.1.
-# Copyright (C) 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
+# Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# can handle that machine. It does not imply ALL GNU software can.
@@ -149,35 +149,43 @@ esac
case $basic_machine in
# Recognize the basic CPU types without company name.
# Some are omitted here because they have special meanings below.
- tahoe | i860 | m68k | m68000 | m88k | ns32k | arm \
- | arme[lb] | pyramid \
- | tron | a29k | 580 | i960 | h8300 | hppa1.0 | hppa1.1 \
- | alpha | we32k | ns16k | clipper | i370 | sh \
- | powerpc | powerpcle | 1750a | dsp16xx | mips64 | mipsel \
- | pdp11 | mips64el | mips64orion | mips64orionel \
- | sparc | sparclet | sparclite | sparc64)
- basic_machine=$basic_machine-unknown
- ;;
+ tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
+ | arme[lb] | pyramid | mn10200 | mn10300 \
+ | tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \
+ | alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \
+ | i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \
+ | mips64 | mipsel | mips64el | mips64orion | mips64orionel \
+ | mipstx39 | mipstx39el \
+ | sparc | sparclet | sparclite | sparc64 | v850)
+ basic_machine=$basic_machine-unknown
+ ;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
i[3456]86)
basic_machine=$basic_machine-pc
;;
+ i[3456]86-TOWNS-pc)
+ basic_machine=`echo $basic_machine | sed -e 's/-pc//'`
+ ;;
# Object if more than one company name word.
*-*-*)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
;;
# Recognize the basic CPU types with company name.
- vax-* | tahoe-* | i[3456]86-* | i860-* | m68k-* | m68000-* | m88k-* \
- | sparc-* | ns32k-* | fx80-* | arm-* | c[123]* \
- | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* | power-* \
- | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \
- | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \
- | pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \
- | pdp11-* | sh-* | powerpc-* | powerpcle-* | sparc64-* | mips64-* | mipsel-* \
- | mips64el-* | mips64orion-* | mips64orionel-*)
+ vax-* | tahoe-* | i[3456]86-* | i860-* | m32r-* | m68k-* | m68000-* \
+ | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
+ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
+ | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \
+ | xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* \
+ | alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \
+ | ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \
+ | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
+ | sparc64-* | mips64-* | mipsel-* \
+ | mips64el-* | mips64orion-* | mips64orionel-* \
+ | mipstx39-* | mipstx39el-* \
+ | f301-*)
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
@@ -204,9 +212,9 @@ case $basic_machine in
amiga | amiga-*)
basic_machine=m68k-cbm
;;
- amigados)
+ amigaos | amigados)
basic_machine=m68k-cbm
- os=-amigados
+ os=-amigaos
;;
amigaunix | amix)
basic_machine=m68k-cbm
@@ -292,10 +300,6 @@ case $basic_machine in
encore | umax | mmax)
basic_machine=ns32k-encore
;;
- ews4800)
- basic_machine=mips-nec
- os=-sysv4
- ;;
fx2800)
basic_machine=i860-alliant
;;
@@ -341,6 +345,9 @@ case $basic_machine in
hp9k8[0-9][0-9] | hp8[0-9][0-9])
basic_machine=hppa1.0-hp
;;
+ hppa-next)
+ os=-nextstep3
+ ;;
i370-ibm* | ibm*)
basic_machine=i370-ibm
os=-mvs
@@ -390,6 +397,14 @@ case $basic_machine in
miniframe)
basic_machine=m68000-convergent
;;
+ mipsel*-linux*)
+ basic_machine=mipsel-unknown
+ os=-linux
+ ;;
+ mips*-linux*)
+ basic_machine=mips-unknown
+ os=-linux
+ ;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
;;
@@ -559,6 +574,12 @@ case $basic_machine in
basic_machine=i386-sequent
os=-dynix
;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
tower | tower-32)
basic_machine=m68k-ncr
;;
@@ -578,6 +599,9 @@ case $basic_machine in
basic_machine=vax-dec
os=-vms
;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
vxworks960)
basic_machine=i960-wrs
os=-vxworks
@@ -605,7 +629,11 @@ case $basic_machine in
# Here we handle the default manufacturer of certain CPU types. It is in
# some cases the only manufacturer, in others, it is the most popular.
mips)
- basic_machine=mips-mips
+ if [ x$os = x-linux ]; then
+ basic_machine=mips-unknown
+ else
+ basic_machine=mips-mips
+ fi
;;
romp)
basic_machine=romp-ibm
@@ -634,10 +662,6 @@ case $basic_machine in
orion105)
basic_machine=clipper-highlevel
;;
- human)
- basic_machine=m68k-sharp
- os=-human
- ;;
*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
@@ -670,9 +694,12 @@ case $os in
-solaris)
os=-solaris2
;;
- -unixware* | svr4*)
+ -svr4*)
os=-sysv4
;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
-gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;;
@@ -683,9 +710,10 @@ case $os in
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
- | -amigados* | -msdos* | -newsos* | -unicos* | -aof* | -aos* \
- | -nindy* | -vxworks* | -ebmon* | -hms* | -mvs* | -clix* \
- | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
@@ -749,11 +777,6 @@ case $os in
-xenix)
os=-xenix
;;
- -uxpds)
- os=-uxpds
- ;;
- -human)
- ;;
-none)
;;
*)
@@ -819,7 +842,7 @@ case $basic_machine in
os=-sysv
;;
*-cbm)
- os=-amigados
+ os=-amigaos
;;
*-dg)
os=-dgux
@@ -869,6 +892,9 @@ case $basic_machine in
*-masscomp)
os=-rtu
;;
+ f301-fujitsu)
+ os=-uxpv
+ ;;
*)
os=-none
;;
@@ -887,9 +913,6 @@ case $basic_machine in
-sunos*)
vendor=sun
;;
- -lynxos*)
- vendor=lynx
- ;;
-aix*)
vendor=ibm
;;
@@ -917,7 +940,7 @@ case $basic_machine in
-ptx*)
vendor=sequent
;;
- -vxworks*)
+ -vxsim* | -vxworks*)
vendor=wrs
;;
-aux*)
diff --git a/error.c b/error.c
index 74c2cbb8be..a4e433a869 100644
--- a/error.c
+++ b/error.c
@@ -274,8 +274,7 @@ exc_s_new(argc, argv, etype)
exc = exc_new(etype, 0, 0);
}
else {
- Check_Type(arg, T_STRING);
- exc = exc_new3(etype, arg);
+ exc = exc_new3(etype, obj_as_string(arg));
}
obj_call_init(exc);
return exc;
diff --git a/eval.c b/eval.c
index 0d49cb6b28..1d90375279 100644
--- a/eval.c
+++ b/eval.c
@@ -45,12 +45,14 @@ static VALUE block_pass _((VALUE,NODE*));
static VALUE cMethod;
static VALUE method_proc _((VALUE));
+static int scope_vmode;
#define SCOPE_PUBLIC 0
-#define SCOPE_PRIVATE FL_USER4
-#define SCOPE_PROTECTED FL_USER5
-#define SCOPE_MODFUNC (FL_USER4|FL_USER5)
-#define SCOPE_MASK (FL_USER4|FL_USER5)
-#define SCOPE_SET(x,f) do {FL_UNSET(x,SCOPE_MASK);FL_SET(x,(f))} while(0)
+#define SCOPE_PRIVATE 1
+#define SCOPE_PROTECTED 2
+#define SCOPE_MODFUNC 5
+#define SCOPE_MASK 7
+#define SCOPE_SET(f) do {scope_vmode=(f);} while(0)
+#define SCOPE_TEST(f) (scope_vmode&(f))
#define CACHE_SIZE 0x200
#define CACHE_MASK 0x1ff
@@ -324,11 +326,11 @@ rb_attr(klass, id, read, write, ex)
if (!ex) noex = NOEX_PUBLIC;
else {
- if (FL_TEST(the_scope, SCOPE_PRIVATE)) {
+ if (SCOPE_TEST(SCOPE_PRIVATE)) {
noex = NOEX_PRIVATE;
Warning("private attribute?");
}
- else if (FL_TEST(the_scope, SCOPE_PROTECTED)) {
+ else if (SCOPE_TEST(SCOPE_PROTECTED)) {
noex = NOEX_PROTECTED;
}
else {
@@ -396,6 +398,7 @@ struct BLOCK {
VALUE klass;
struct tag *tag;
int iter;
+ int vmode;
struct RVarmap *d_vars;
#ifdef THREAD
VALUE orig_thread;
@@ -417,6 +420,7 @@ struct BLOCK {
_block.d_vars = the_dyna_vars; \
_block.prev = the_block; \
_block.iter = the_iter->iter; \
+ _block.vmode = scope_vmode; \
the_block = &_block;
#define PUSH_BLOCK2(b) { \
@@ -431,7 +435,7 @@ struct BLOCK {
struct RVarmap *the_dyna_vars;
#define PUSH_VARS() { \
- struct RVarmap *_old; \
+ struct RVarmap * volatile _old; \
_old = the_dyna_vars; \
the_dyna_vars = 0;
@@ -439,6 +443,30 @@ struct RVarmap *the_dyna_vars;
the_dyna_vars = _old; \
}
+static struct RVarmap*
+new_dvar(id, value)
+ ID id;
+ VALUE value;
+{
+ NEWOBJ(vars, struct RVarmap);
+ OBJSETUP(vars, 0, T_VARMAP);
+ vars->id = id;
+ vars->val = value;
+ if (id == 0) {
+ vars->next = the_dyna_vars;
+ }
+ else if (the_dyna_vars) {
+ vars->next = the_dyna_vars->next;
+ the_dyna_vars->next = vars;
+ }
+ else { /* complie time dyna_var check */
+ vars->next = the_dyna_vars;
+ the_dyna_vars = vars;
+ }
+
+ return vars;
+}
+
VALUE
dyna_var_defined(id)
ID id;
@@ -481,14 +509,7 @@ dyna_var_asgn(id, value)
}
vars = vars->next;
}
- {
- NEWOBJ(_vars, struct RVarmap);
- OBJSETUP(_vars, 0, T_VARMAP);
- _vars->id = id;
- _vars->val = value;
- _vars->next = the_dyna_vars;
- the_dyna_vars = _vars;
- }
+ new_dvar(id, value);
return value;
}
@@ -568,7 +589,8 @@ VALUE the_class;
#define POP_CLASS() the_class = _class; }
#define PUSH_SCOPE() { \
- struct SCOPE *_old; \
+ int volatile _vmode = scope_vmode; \
+ struct SCOPE * volatile _old; \
NEWOBJ(_scope, struct SCOPE); \
OBJSETUP(_scope, 0, T_SCOPE); \
_scope->local_tbl = 0; \
@@ -576,6 +598,7 @@ VALUE the_class;
_scope->flag = 0; \
_old = the_scope; \
the_scope = _scope; \
+ scope_vmode = SCOPE_PUBLIC;
#define POP_SCOPE() \
if (the_scope->flag == SCOPE_ALLOCA) {\
@@ -798,7 +821,7 @@ ruby_init()
the_scope->local_tbl = 0;
top_scope = the_scope;
/* default visibility is private at toplevel */
- SCOPE_SET(top_scope, SCOPE_PRIVATE);
+ SCOPE_SET(SCOPE_PRIVATE);
PUSH_TAG(PROT_NONE)
if ((state = EXEC_TAG()) == 0) {
@@ -1355,8 +1378,9 @@ is_defined(self, node, buf)
return "assignment";
case NODE_LVAR:
- case NODE_DVAR:
return "local-variable";
+ case NODE_DVAR:
+ return "local-variable(nested)";
case NODE_GVAR:
if (rb_gvar_defined(node->nd_entry)) {
@@ -1679,6 +1703,7 @@ rb_eval(self, node)
{
iter_retry:
PUSH_BLOCK(node->nd_var, node->nd_body);
+ _block.d_vars = new_dvar(0,0);
PUSH_TAG(PROT_FUNC);
state = EXEC_TAG();
@@ -2241,10 +2266,10 @@ rb_eval(self, node)
rb_clear_cache_by_id(node->nd_mid);
}
- if (FL_TEST(the_scope, SCOPE_PRIVATE) || node->nd_mid == init) {
+ if (SCOPE_TEST(SCOPE_PRIVATE) || node->nd_mid == init) {
noex = NOEX_PRIVATE;
}
- else if (FL_TEST(the_scope, SCOPE_PROTECTED)) {
+ else if (SCOPE_TEST(SCOPE_PROTECTED)) {
noex = NOEX_PROTECTED;
}
else {
@@ -2254,7 +2279,7 @@ rb_eval(self, node)
noex |= NOEX_UNDEF;
}
rb_add_method(the_class, node->nd_mid, node->nd_defn, noex);
- if (FL_TEST(the_scope,SCOPE_MODFUNC) == SCOPE_MODFUNC) {
+ if (scope_vmode == SCOPE_MODFUNC) {
rb_add_method(rb_singleton_class(the_class),
node->nd_mid, node->nd_defn, NOEX_PUBLIC);
rb_funcall(the_class, rb_intern("singleton_method_added"),
@@ -2942,6 +2967,7 @@ rb_iterate(it_proc, data1, bl_proc, data2)
iter_retry:
PUSH_ITER(ITER_PRE);
PUSH_BLOCK(0, node);
+ _block.d_vars = new_dvar(0,0);
PUSH_TAG(PROT_NONE);
state = EXEC_TAG();
@@ -3703,6 +3729,7 @@ eval(self, src, scope, file, line)
struct SCOPE * volatile old_scope;
struct BLOCK * volatile old_block;
struct RVarmap * volatile old_d_vars;
+ int volatile old_vmode;
struct FRAME frame;
char *filesave = sourcefile;
int linesave = sourceline;
@@ -3713,12 +3740,6 @@ eval(self, src, scope, file, line)
file = sourcefile;
line = sourceline;
}
- else {
- sourcefile = file;
- if (line > 0) {
- sourceline = line;
- }
- }
if (!NIL_P(scope)) {
if (TYPE(scope) != T_DATA || RDATA(scope)->dfree != blk_free) {
TypeError("wrong argument type %s (expected Proc/Binding)",
@@ -3737,6 +3758,8 @@ eval(self, src, scope, file, line)
the_block = data->prev;
old_d_vars = the_dyna_vars;
the_dyna_vars = data->d_vars;
+ old_vmode = scope_vmode;
+ scope_vmode = data->vmode;
self = data->self;
the_frame->iter = data->iter;
@@ -3770,6 +3793,8 @@ eval(self, src, scope, file, line)
the_scope = old_scope;
the_block = old_block;
the_dyna_vars = old_d_vars;
+ data->vmode = scope_vmode; /* write back visibility mode */
+ scope_vmode = old_vmode;
}
else {
the_frame->iter = iter;
@@ -3827,6 +3852,7 @@ exec_under(func, under, args)
{
VALUE val; /* OK */
int state;
+ int mode;
VALUE cbase = the_frame->cbase;
PUSH_CLASS();
@@ -3837,11 +3863,14 @@ exec_under(func, under, args)
the_frame->argc = _frame.prev->argc;
the_frame->argv = _frame.prev->argv;
the_frame->cbase = (VALUE)node_newnode(NODE_CREF,under,0,cbase);
+ mode = scope_vmode;
+ SCOPE_SET(SCOPE_PUBLIC);
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
val = (*func)(args);
}
POP_TAG();
+ SCOPE_SET(mode);
POP_FRAME();
POP_CLASS();
if (state) JUMP_TAG(state);
@@ -3887,15 +3916,12 @@ obj_instance_eval(argc, argv, self)
VALUE *argv;
VALUE self;
{
- VALUE src;
-
if (argc == 0) {
if (!iterator_p()) {
ArgError("block not supplied");
}
- return yield_under(CLASS_OF(self), self);
}
- if (argc == 1) {
+ else if (argc == 1) {
Check_SafeStr(argv[0]);
}
else {
@@ -3904,7 +3930,12 @@ obj_instance_eval(argc, argv, self)
rb_id2name(the_frame->last_func));
}
- return eval_under(CLASS_OF(self), self, argv[0]);
+ if (argc == 0) {
+ return yield_under(rb_singleton_class(self), self);
+ }
+ else {
+ return eval_under(rb_singleton_class(self), self, argv[0]);
+ }
}
static VALUE
@@ -3913,10 +3944,6 @@ mod_module_eval(argc, argv, mod)
VALUE *argv;
VALUE mod;
{
- int state;
- int mode;
- VALUE result = Qnil;
-
if (argc == 0) {
if (!iterator_p()) {
ArgError("block not supplied");
@@ -3931,21 +3958,12 @@ mod_module_eval(argc, argv, mod)
rb_id2name(the_frame->last_func));
}
- mode = FL_TEST(the_scope, SCOPE_MASK);
- SCOPE_SET(the_scope, SCOPE_PUBLIC);
- PUSH_TAG(PROT_NONE);
- if ((state = EXEC_TAG()) == 0) {
- if (argc == 0) {
- result = yield_under(mod, mod);
- }
- else {
- result = eval_under(mod, mod, argv[0]);
- }
+ if (argc == 0) {
+ return yield_under(mod, mod);
+ }
+ else {
+ return eval_under(mod, mod, argv[0]);
}
- POP_TAG();
- SCOPE_SET(the_scope, mode);
- if (state) JUMP_TAG(state);
- return result;
}
VALUE rb_load_path;
@@ -4017,7 +4035,7 @@ f_load(obj, fname)
the_scope->local_vars = vars;
}
/* default visibility is private at loading toplevel */
- SCOPE_SET(the_scope, SCOPE_PRIVATE);
+ SCOPE_SET(SCOPE_PRIVATE);
state = EXEC_TAG();
last_func = the_frame->last_func;
@@ -4209,7 +4227,7 @@ mod_public(argc, argv, module)
VALUE module;
{
if (argc == 0) {
- SCOPE_SET(the_scope, SCOPE_PUBLIC);
+ SCOPE_SET(SCOPE_PUBLIC);
}
else {
set_method_visibility(module, argc, argv, NOEX_PUBLIC);
@@ -4224,7 +4242,7 @@ mod_protected(argc, argv, module)
VALUE module;
{
if (argc == 0) {
- SCOPE_SET(the_scope, SCOPE_PROTECTED);
+ SCOPE_SET(SCOPE_PROTECTED);
}
else {
set_method_visibility(module, argc, argv, NOEX_PROTECTED);
@@ -4239,7 +4257,7 @@ mod_private(argc, argv, module)
VALUE module;
{
if (argc == 0) {
- SCOPE_SET(the_scope, SCOPE_PRIVATE);
+ SCOPE_SET(SCOPE_PRIVATE);
}
else {
set_method_visibility(module, argc, argv, NOEX_PRIVATE);
@@ -4294,7 +4312,7 @@ mod_modfunc(argc, argv, module)
NODE *body;
if (argc == 0) {
- SCOPE_SET(the_scope, SCOPE_MODFUNC);
+ SCOPE_SET(SCOPE_MODFUNC);
return module;
}
@@ -4714,7 +4732,6 @@ f_binding(self)
data->orig_thread = thread_current();
#endif
data->iter = f_iterator_p();
- data->frame.last_func = 0;
data->frame.argv = ALLOC_N(VALUE, data->frame.argc);
MEMCPY(data->frame.argv, the_block->frame.argv, VALUE, data->frame.argc);
@@ -5177,6 +5194,7 @@ struct thread {
struct FRAME *frame;
struct SCOPE *scope;
+ int vmode;
struct RVarmap *dyna_vars;
struct BLOCK *block;
struct iter *iter;
@@ -5330,6 +5348,7 @@ thread_save_context(th)
th->klass = the_class;
th->dyna_vars = the_dyna_vars;
th->block = the_block;
+ th->vmode = scope_vmode;
th->iter = the_iter;
th->tag = prot_tag;
th->errat = errat;
@@ -5387,6 +5406,7 @@ thread_restore_context(th, exit)
the_class = th->klass;
the_dyna_vars = th->dyna_vars;
the_block = th->block;
+ scope_vmode = th->vmode;
the_iter = th->iter;
prot_tag = th->tag;
errat = th->errat;
@@ -6105,8 +6125,7 @@ thread_yield(arg, th)
thread_t th;
{
scope_dup(the_block->scope);
- rb_yield(th->thread);
- return th->thread;
+ return rb_yield(th->thread);
}
static VALUE
diff --git a/hash.c b/hash.c
index 4d170873f8..daa1e624a8 100644
--- a/hash.c
+++ b/hash.c
@@ -526,11 +526,14 @@ hash_each_key(hash)
}
static int
-each_pair_i(key, value)
+each_pair_i(key, value, rev)
VALUE key, value;
{
if (key == Qnil) return ST_CONTINUE;
- rb_yield(assoc_new(key, value));
+ if (rev)
+ rb_yield(assoc_new(value, key));
+ else
+ rb_yield(assoc_new(key, value));
return ST_CONTINUE;
}
@@ -538,7 +541,15 @@ static VALUE
hash_each_pair(hash)
VALUE hash;
{
- hash_foreach(hash, each_pair_i);
+ hash_foreach(hash, each_pair_i, 0);
+ return hash;
+}
+
+static VALUE
+hash_each_with_index(hash)
+ VALUE hash;
+{
+ hash_foreach(hash, each_pair_i, 1);
return hash;
}
@@ -1138,6 +1149,7 @@ Init_Hash()
rb_define_method(cHash,"each_value", hash_each_value, 0);
rb_define_method(cHash,"each_key", hash_each_key, 0);
rb_define_method(cHash,"each_pair", hash_each_pair, 0);
+ rb_define_method(cHash,"each_with_index", hash_each_with_index, 0);
rb_define_method(cHash,"keys", hash_keys, 0);
rb_define_method(cHash,"values", hash_values, 0);
diff --git a/intern.h b/intern.h
index d4123a8633..aa7e7f7a2e 100644
--- a/intern.h
+++ b/intern.h
@@ -69,6 +69,7 @@ VALUE class_private_instance_methods _((int, VALUE *, VALUE));
VALUE obj_singleton_methods _((VALUE));
void rb_define_method_id _((VALUE, ID, VALUE (*)(), int));
void rb_undef_method _((VALUE, char *));
+void rb_define_protected_method _((VALUE, char *, VALUE (*)(), int));
void rb_define_private_method _((VALUE, char *, VALUE (*)(), int));
void rb_define_singleton_method _((VALUE,char*,VALUE(*)(),int));
void rb_define_private_method _((VALUE,char*,VALUE(*)(),int));
diff --git a/lib/delegate.rb b/lib/delegate.rb
index 30b1a32c12..205d5e1fbd 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -8,12 +8,12 @@
# Usage:
# foo = Object.new
# foo = SimpleDelegator.new(foo)
-# foo.type # => Object
+# foo.hash == foo2.hash # => true
class Delegator
def initialize(obj)
- preserved = ["id", "equal?", "__getobj__"]
+ preserved = ["type", "id", "equal?", "__getobj__"]
for t in self.type.ancestors
preserved |= t.instance_methods
break if t == Delegator
@@ -52,6 +52,6 @@ SimpleDelegater = SimpleDelegator
if __FILE__ == $0
foo = Object.new
- foo = SimpleDelegator.new(foo)
- p foo.type # => Object
+ foo2 = SimpleDelegator.new(foo)
+ p foo.hash == foo2.hash # => true
end
diff --git a/mkconfig.rb b/mkconfig.rb
index 5232943d8d..91ce78c856 100644
--- a/mkconfig.rb
+++ b/mkconfig.rb
@@ -32,8 +32,10 @@ File.foreach "config.status" do |$_|
name = $1
val = $2 || ""
next if name =~ /^(INSTALL|DEFS|configure_input|srcdir|top_srcdir)$/
+ p defined? val
+ p val
v = " CONFIG[\"" + name + "\"] = " +
- val.sub(/^\s*(.*)\s*$/, '"\1"').gsub(/\$\{?([^}]*)\}?/) {
+ val.sub(/^\s*(.*)\s*$/, '"\1"').gsub(/\$\{?([^}]*)\}?/) {
"\#{CONFIG[\\\"#{$1}\\\"]}"
} + "\n"
if fast[name]
diff --git a/numeric.c b/numeric.c
index 527d65d2a3..f5b0fc24fe 100644
--- a/numeric.c
+++ b/numeric.c
@@ -150,6 +150,26 @@ num_abs(num)
return num;
}
+static VALUE
+num_zero_p(num)
+ VALUE num;
+{
+ if (RTEST(rb_equal(num, INT2FIX(0)))) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static VALUE
+num_nonzero_p(num)
+ VALUE num;
+{
+ if (RTEST(rb_funcall(num, rb_intern("zero?"), 0, 0))) {
+ return FALSE;
+ }
+ return num;
+}
+
VALUE
float_new(d)
double d;
@@ -566,6 +586,16 @@ flo_abs(flt)
}
static VALUE
+flo_zero_p(num)
+ VALUE num;
+{
+ if (RFLOAT(num)->value == 0.0) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static VALUE
to_integer(val)
VALUE val;
{
@@ -589,33 +619,35 @@ num2int(val)
switch (TYPE(val)) {
case T_FIXNUM:
if (sizeof(int) < sizeof(INT)) {
-#ifndef INT_MAX
-/* assuming 32bit(2's compliment) int */
-# define INT_MAX 2147483647
-# define INT_MIN (- INT_MAX - 1)
-#endif
INT i = FIX2INT(val);
if (INT_MIN < i && i < INT_MAX) {
return i;
}
- ArgError("Fixnum too big to convert into `int'");
+ TypeError("Fixnum too big to convert into `int'");
}
return FIX2INT(val);
case T_FLOAT:
- if (RFLOAT(val)->value <= (double) LONG_MAX
- && RFLOAT(val)->value >= (double) LONG_MIN) {
+ if (RFLOAT(val)->value <= (double)INT_MAX
+ && RFLOAT(val)->value >= (double)INT_MIN) {
return (int)(RFLOAT(val)->value);
}
else {
- Fail("float %g out of rang of integer", RFLOAT(val)->value);
+ TypeError("float %g out of rang of integer", RFLOAT(val)->value);
}
case T_BIGNUM:
return big2int(val);
+ case T_STRING:
+ TypeError("no implicit conversion from string");
+ return Qnil; /* not reached */
+
default:
val = rb_rescue(to_integer, val, fail_to_integer, val);
+ if (!obj_is_kind_of(val, cInteger)) {
+ TypeError("`to_i' need to return integer");
+ }
return NUM2INT(val);
}
}
@@ -1220,6 +1252,16 @@ fix_dotimes(num)
return num;
}
+static VALUE
+fix_zero_p(num)
+ VALUE num;
+{
+ if (FIX2INT(num) == 0) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
extern VALUE mComparable;
extern VALUE eException;
@@ -1247,6 +1289,8 @@ Init_Numeric()
rb_define_method(cNumeric, "times", num_dotimes, 0);
rb_define_method(cNumeric, "integer?", num_int_p, 0);
rb_define_method(cNumeric, "chr", num_chr, 0);
+ rb_define_method(cNumeric, "zero?", num_zero_p, 0);
+ rb_define_method(cNumeric, "nonzero?", num_nonzero_p, 0);
cInteger = rb_define_class("Integer", cNumeric);
rb_define_method(cInteger, "integer?", int_int_p, 0);
@@ -1300,6 +1344,7 @@ Init_Numeric()
rb_define_method(cFixnum, "downto", fix_downto, 1);
rb_define_method(cFixnum, "step", fix_step, 2);
rb_define_method(cFixnum, "times", fix_dotimes, 0);
+ rb_define_method(cFixnum, "zero?", fix_zero_p, 0);
cFloat = rb_define_class("Float", cNumeric);
@@ -1326,4 +1371,5 @@ Init_Numeric()
rb_define_method(cFloat, "to_i", flo_to_i, 0);
rb_define_method(cFloat, "to_f", flo_to_f, 0);
rb_define_method(cFloat, "abs", flo_abs, 0);
+ rb_define_method(cFloat, "zero?", flo_zero_p, 0);
}
diff --git a/object.c b/object.c
index afd51f8f22..fa7c3b05c5 100644
--- a/object.c
+++ b/object.c
@@ -558,6 +558,7 @@ VALUE mod_name();
VALUE mod_included_modules();
VALUE mod_ancestors();
VALUE class_instance_methods();
+VALUE class_protected_instance_methods();
VALUE class_private_instance_methods();
static VALUE
@@ -678,6 +679,16 @@ obj_methods(obj)
VALUE obj_singleton_methods();
static VALUE
+obj_protected_methods(obj)
+ VALUE obj;
+{
+ VALUE argv[1];
+
+ argv[0] = TRUE;
+ return class_protected_instance_methods(1, argv, CLASS_OF(obj));
+}
+
+static VALUE
obj_private_methods(obj)
VALUE obj;
{
@@ -915,7 +926,9 @@ Init_Object()
rb_define_method(mKernel, "to_s", any_to_s, 0);
rb_define_method(mKernel, "inspect", obj_inspect, 0);
rb_define_method(mKernel, "methods", obj_methods, 0);
+ rb_define_method(mKernel, "public_methods", obj_methods, 0);
rb_define_method(mKernel, "singleton_methods", obj_singleton_methods, 0);
+ rb_define_method(mKernel, "protected_methods", obj_protected_methods, 0);
rb_define_method(mKernel, "private_methods", obj_private_methods, 0);
rb_define_method(mKernel, "instance_variables", obj_instance_variables, 0);
rb_define_method(mKernel, "remove_instance_variable", obj_remove_instance_variable, 0);
@@ -969,6 +982,8 @@ Init_Object()
rb_define_singleton_method(cModule, "new", module_s_new, 0);
rb_define_method(cModule, "instance_methods", class_instance_methods, -1);
+ rb_define_method(cModule, "public_instance_methods", class_instance_methods, -1);
+ rb_define_method(cModule, "protected_instance_methods", class_protected_instance_methods, -1);
rb_define_method(cModule, "private_instance_methods", class_private_instance_methods, -1);
rb_define_method(cModule, "constants", mod_constants, 0);
diff --git a/parse.y b/parse.y
index 35ce02c544..37334900eb 100644
--- a/parse.y
+++ b/parse.y
@@ -3778,7 +3778,7 @@ local_id(id)
int i, max;
if (lvtbl == 0) return FALSE;
- for (i=1, max=lvtbl->cnt+1; i<max; i++) {
+ for (i=3, max=lvtbl->cnt+1; i<max; i++) {
if (lvtbl->tbl[i] == id) return TRUE;
}
return FALSE;
@@ -3796,7 +3796,7 @@ top_local_init()
else {
lvtbl->tbl = 0;
}
- if (the_dyna_vars && the_dyna_vars->id)
+ if (the_dyna_vars)
lvtbl->dlev = 1;
else
lvtbl->dlev = 0;
diff --git a/ruby.h b/ruby.h
index e6c437369c..dcf6f140f9 100644
--- a/ruby.h
+++ b/ruby.h
@@ -51,13 +51,14 @@
#pragma alloca
#endif
-typedef unsigned short USHORT;
-typedef unsigned long UINT;
-
#if SIZEOF_INT == SIZEOF_VOIDP
typedef int INT;
+typedef unsigned int UINT;
+# define PTR_SIZED_MAX INT_MAX
#elif SIZEOF_LONG == SIZEOF_VOIDP
typedef long INT;
+typedef unsigned long UINT;
+# define PTR_SIZED_MAX LONG_MAX
#else
---->> ruby requires sizeof(void*) == sizeof(int/long) to be compiled. <<----
#endif
@@ -65,6 +66,7 @@ typedef UINT VALUE;
typedef unsigned int ID;
typedef unsigned char UCHAR;
+typedef unsigned short USHORT;
#ifdef __STDC__
# include <limits.h>
@@ -73,23 +75,26 @@ typedef unsigned char UCHAR;
# ifdef HAVE_LIMITS_H
# include <limits.h>
# else
-# define LONG_MAX 2147483647 /* assuming 32bit(2's compliment) LONG */
+ /* assuming 32bit(2's compliment) LONG */
+# define LONG_MAX 2147483647
# endif
# endif
# ifndef LONG_MIN
-# if (0 != ~0)
-# define LONG_MIN (-LONG_MAX-1)
-# else
-# define LONG_MIN (-LONG_MAX)
-# endif
+# define LONG_MIN (-LONG_MAX-1)
+# endif
+# ifndef INT_MAX
+ /* assuming 32bit(2's compliment) int */
+# define INT_MAX 2147483647
+# define INT_MIN (-INT_MAX-1)
# endif
# ifndef CHAR_BIT
# define CHAR_BIT 8
# endif
#endif
-#define FIXNUM_MAX (LONG_MAX>>1)
-#define FIXNUM_MIN RSHIFT((INT)LONG_MIN,1)
+#define PTR_SIZED_MIN (-PTR_SIZED_MAX-1)
+#define FIXNUM_MAX (PTR_SIZED_MAX>>1)
+#define FIXNUM_MIN RSHIFT((INT)PTR_SIZED_MIN,1)
#define FIXNUM_FLAG 0x01
#define INT2FIX(i) (VALUE)(((INT)(i))<<1 | FIXNUM_FLAG)
diff --git a/sample/test.rb b/sample/test.rb
index 98c913667a..29670987fa 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -638,14 +638,14 @@ ok($proc.call(2) == 4)
ok($proc.call(3) == 6)
proc{
- iii=5 # dynamic local variable
+ iii=5 # nested local variable
$proc = proc{|i|
iii = i
}
$proc2 = proc {
- $x = iii # dynamic variables shared by procs
+ $x = iii # nested variables shared by procs
}
- # scope of dynamic variables
+ # scope of nested variables
ok(defined?(iii))
}.call
ok(!defined?(iii)) # out of scope
@@ -653,6 +653,7 @@ ok(!defined?(iii)) # out of scope
$x=0
$proc.call(5)
$proc2.call
+p $x
ok($x == 5)
if defined? Process.kill
@@ -715,8 +716,8 @@ def test_ev
end
$x = test_ev
-ok(eval("local1", $x) == "local1") # static local var
-ok(eval("local2", $x) == "local2") # dynamic local var
+ok(eval("local1", $x) == "local1") # normal local var
+ok(eval("local2", $x) == "local2") # nested local var
$bad = true
begin
p eval("local1")
diff --git a/string.c b/string.c
index 178c256798..17f31b085d 100644
--- a/string.c
+++ b/string.c
@@ -204,7 +204,11 @@ str_plus(str1, str2)
{
VALUE str3;
+#if 0
str2 = obj_as_string(str2);
+#else
+ Check_Type(str2, T_STRING);
+#endif
str3 = str_new(0, RSTRING(str1)->len+RSTRING(str2)->len);
memcpy(RSTRING(str3)->ptr, RSTRING(str1)->ptr, RSTRING(str1)->len);
memcpy(RSTRING(str3)->ptr+RSTRING(str1)->len, RSTRING(str2)->ptr, RSTRING(str2)->len);
@@ -422,7 +426,11 @@ static VALUE
str_concat(str1, str2)
VALUE str1, str2;
{
+#if 0
str2 = obj_as_string(str2);
+#else
+ Check_Type(str2, T_STRING);
+#endif
str_cat(str1, RSTRING(str2)->ptr, RSTRING(str2)->len);
return str1;
}
@@ -499,7 +507,11 @@ str_cmp_method(str1, str2)
{
int result;
+#if 0
str2 = obj_as_string(str2);
+#else
+ Check_Type(str2, T_STRING);
+#endif
result = str_cmp(str1, str2);
return INT2FIX(result);
}
@@ -1386,7 +1398,7 @@ str_inspect(str)
*b++ = c;
*b++ = *p++;
}
- if (c & 0x80) {
+ else if (c & 0x80) {
CHECK(1);
*b++ = c;
}
@@ -2459,7 +2471,8 @@ str_crypt(str, salt)
VALUE str, salt;
{
extern char *crypt();
- salt = obj_as_string(salt);
+
+ Check_Type(salt, T_STRING);
if (RSTRING(salt)->len < 2)
ArgError("salt too short(need >2 bytes)");
return str_new2(crypt(RSTRING(str)->ptr, RSTRING(salt)->ptr));