From 03d1c9cd8238af6f1063ea4eb98d17fa2a511107 Mon Sep 17 00:00:00 2001 From: matz Date: Sat, 14 Jul 2001 15:17:19 +0000 Subject: [PATCH] * regex.c (re_search): should consider reverse search. * dir.c (dir_s_chdir): warn only when invoked from multiple threads or block is not given. * object.c (rb_convert_type): should use rb_rescue(), not rb_rescue2(). * range.c (range_init): ditto. * object.c (rb_obj_dup): should free generic_ivar if original owns them. * string.c (rb_str_each_line): should propagate taint mark. * ext/nkf/nkf.c (rb_nkf_kconv): ditto. * eval.c (rb_f_require): revamp for simpler implementation. * file.c (rb_find_file_noext): use String object, instead of passing char* around. * file.c (rb_find_file): ditto. * dln.c (dln_load): should use NSLINKMODULE_OPTION_BINDNOW. * ruby.c (load_file): local variables 'c' remain uninitialized on xflag. * regex.c (re_match): prefetched escaped character too early. * eval.c (rb_call0): add argument check for attr_readers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 52 ++++ array.c | 26 +- config.guess | 705 +++++++++++++++++++++++++++++++++++---------------- config.sub | 299 ++++++++++++++++------ dir.c | 15 +- dln.c | 2 +- eval.c | 135 +++++----- file.c | 96 ++++--- intern.h | 9 +- io.c | 10 +- object.c | 20 +- range.c | 2 +- regex.c | 4 +- ruby.c | 2 +- ruby.h | 2 +- string.c | 13 +- variable.c | 9 +- version.h | 4 +- 18 files changed, 959 insertions(+), 446 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6c335b2a98..2b347ec38d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,10 @@ Sat Jul 14 02:55:02 2001 Akinori MUSHA * ext/.cvsignore: let cvs ignore extinit.c. +Fri Jul 13 23:47:35 2001 Yukihiro Matsumoto + + * regex.c (re_search): should consider reverse search. + Fri Jul 13 22:26:09 2001 Akinori MUSHA * lib/mkmf.rb: use File::split to split a target into a prefix and @@ -24,6 +28,11 @@ Fri Jul 13 22:26:09 2001 Akinori MUSHA * ext/extmk.rb.in: ditto. +Fri Jul 13 02:36:10 2001 Minero Aoki + + * dir.c (dir_s_chdir): warn only when invoked from multiple + threads or block is not given. + Thu Jul 12 15:11:48 2001 WATANABE Hirofumi * ext/socket/socket.c (ruby_connect): workaround for the setup of @@ -45,10 +54,53 @@ Sun Jul 8 16:04:35 2001 Minero Aoki * lib/net/protocol.rb (ProtoSocket#read): modify typo. +Sat Jul 7 17:45:35 2001 Yukihiro Matsumoto + + * object.c (rb_convert_type): should use rb_rescue(), not rb_rescue2(). + + * range.c (range_init): ditto. + +Fri Jul 6 18:01:10 2001 Yukihiro Matsumoto + + * object.c (rb_obj_dup): should free generic_ivar if original owns + them. + Fri Jul 6 02:15:06 2001 Akinori MUSHA * lib/tempfile.rb: a tempfile must be created with mode 0600. +Thu Jul 5 20:28:53 2001 Tietew + + * string.c (rb_str_each_line): should propagate taint mark. + + * ext/nkf/nkf.c (rb_nkf_kconv): ditto. + +Fri Jul 6 14:54:27 2001 Yukihiro Matsumoto + + * eval.c (rb_f_require): revamp for simpler implementation. + + * file.c (rb_find_file_noext): use String object, instead of + passing char* around. + + * file.c (rb_find_file): ditto. + +Thu Jul 5 22:01:02 2001 Mitsuhiro Kondo + + * dln.c (dln_load): should use NSLINKMODULE_OPTION_BINDNOW. + +Thu Jul 5 13:44:03 2001 Yukihiro Matsumoto + + * ruby.c (load_file): local variables 'c' remain uninitialized on + xflag. + +Thu Jul 5 10:00:59 2001 Yukihiro Matsumoto + + * regex.c (re_match): prefetched escaped character too early. + +Wed Jul 4 08:58:30 2001 Yukihiro Matsumoto + + * eval.c (rb_call0): add argument check for attr_readers. + Wed Jul 4 04:22:44 2001 Minero Aoki * lib/net/http.rb (HTTP#request_by_name): arg order changes. diff --git a/array.c b/array.c index 1b7a6fa455..5acc45a1b2 100644 --- a/array.c +++ b/array.c @@ -726,6 +726,18 @@ rb_ary_clone(ary) return clone; } +VALUE +rb_ary_dup(ary) + VALUE ary; +{ + VALUE dup = rb_ary_new2(RARRAY(ary)->len); + + OBJSETUP(dup, rb_obj_type(ary), T_ARRAY); + MEMCPY(RARRAY(dup)->ptr, RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len); + RARRAY(dup)->len = RARRAY(ary)->len; + return dup; +} + static VALUE to_ary(ary) VALUE ary; @@ -973,7 +985,7 @@ static VALUE rb_ary_reverse_m(ary) VALUE ary; { - return rb_ary_reverse(rb_obj_dup(ary)); + return rb_ary_reverse(rb_ary_dup(ary)); } static int @@ -1034,7 +1046,7 @@ VALUE rb_ary_sort(ary) VALUE ary; { - ary = rb_obj_dup(ary); + ary = rb_ary_dup(ary); rb_ary_sort_bang(ary); return ary; } @@ -1047,7 +1059,7 @@ rb_ary_collect(ary) VALUE collect; if (!rb_block_given_p()) { - return rb_obj_dup(ary); + return rb_ary_new4(RARRAY(ary)->len, RARRAY(ary)->ptr); } len = RARRAY(ary)->len; @@ -1566,7 +1578,7 @@ static VALUE rb_ary_uniq(ary) VALUE ary; { - ary = rb_obj_dup(ary); + ary = rb_ary_dup(ary); rb_ary_uniq_bang(ary); return ary; } @@ -1597,7 +1609,7 @@ static VALUE rb_ary_compact(ary) VALUE ary; { - ary = rb_obj_dup(ary); + ary = rb_ary_dup(ary); rb_ary_compact_bang(ary); return ary; } @@ -1675,7 +1687,7 @@ static VALUE rb_ary_flatten(ary) VALUE ary; { - ary = rb_obj_dup(ary); + ary = rb_ary_dup(ary); rb_ary_flatten_bang(ary); return ary; } @@ -1724,6 +1736,7 @@ Init_Array() rb_define_method(rb_cArray, "indexes", rb_ary_indexes, -1); rb_define_method(rb_cArray, "indices", rb_ary_indexes, -1); rb_define_method(rb_cArray, "clone", rb_ary_clone, 0); + rb_define_method(rb_cArray, "clone", rb_ary_dup, 0); rb_define_method(rb_cArray, "join", rb_ary_join_m, -1); rb_define_method(rb_cArray, "reverse", rb_ary_reverse_m, 0); rb_define_method(rb_cArray, "reverse!", rb_ary_reverse_bang, 0); @@ -1731,6 +1744,7 @@ Init_Array() rb_define_method(rb_cArray, "sort!", rb_ary_sort_bang, 0); rb_define_method(rb_cArray, "collect", rb_ary_collect, 0); rb_define_method(rb_cArray, "collect!", rb_ary_collect_bang, 0); + rb_define_method(rb_cArray, "map", rb_ary_collect, 0); rb_define_method(rb_cArray, "map!", rb_ary_collect_bang, 0); rb_define_method(rb_cArray, "filter", rb_ary_filter, 0); rb_define_method(rb_cArray, "delete", rb_ary_delete, 1); diff --git a/config.guess b/config.guess index c55635bd7b..990aa5293a 100644 --- a/config.guess +++ b/config.guess @@ -1,8 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999 +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. -# + +timestamp='2001-07-13' + # 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 # the Free Software Foundation; either version 2 of the License, or @@ -23,33 +25,93 @@ # the same distribution terms that you use for the rest of that program. # Written by Per Bothner . -# The master version of this file is at the FSF in /home/gd/gnu/lib. -# Please send patches to the Autoconf mailing list . +# Please send patches to . # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you -# don't specify an explicit system type (host/target name). -# -# Only a few systems have been added to this list; please add others -# (but try to keep the structure clean). -# +# don't specify an explicit build system type. -# Use $HOST_CC if defined. $CC may point to a cross-compiler -if test x"$CC_FOR_BUILD" = x; then - if test x"$HOST_CC" != x; then - CC_FOR_BUILD="$HOST_CC" - else - if test x"$CC" != x; then - CC_FOR_BUILD="$CC" - else - CC_FOR_BUILD=cc - fi - fi +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; +*) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 fi + +dummy=dummy-$$ +trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int dummy(){}" > $dummy.c + for c in cc gcc c89 ; do + ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 + if test $? = 0 ; then + CC_FOR_BUILD="$c"; break + fi + done + rm -f $dummy.c $dummy.o $dummy.rel + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac + # Modified for Human68k by K.Okabe 1997.07.09 # Last change: 1997.07.09 @@ -72,14 +134,53 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -dummy=dummy-$$ -trap 'rm -f $dummy.c $dummy.o $dummy; exit 1' 1 2 15 - # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:OS/2:*:*) - echo "i386-pc-os2_emx" + *:NetBSD:*:*) + # Netbsd (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # Determine the machine/vendor (is the vendor relevant). + case "${UNAME_MACHINE}" in + amiga) machine=m68k-unknown ;; + arm32) machine=arm-unknown ;; + atari*) machine=m68k-atari ;; + sun3*) machine=m68k-sun ;; + mac68k) machine=m68k-apple ;; + macppc) machine=powerpc-apple ;; + hp3[0-9][05]) machine=m68k-hp ;; + ibmrt|romp-ibm) machine=romp-ibm ;; + *) machine=${UNAME_MACHINE}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE}" in + i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" exit 0;; alpha:OSF1:*:*) if test $UNAME_RELEASE = "V4.0"; then @@ -90,41 +191,51 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. cat <$dummy.s + .data +\$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + + .text .globl main + .align 4 .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 + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit .end main EOF $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null if test "$?" = 0 ; then - ./$dummy - case "$?" in - 7) + case `./$dummy` in + 0-0) UNAME_MACHINE="alpha" ;; - 15) + 1-0) UNAME_MACHINE="alphaev5" ;; - 14) + 1-1) UNAME_MACHINE="alphaev56" ;; - 10) + 1-101) UNAME_MACHINE="alphapca56" ;; - 16) + 2-303) UNAME_MACHINE="alphaev6" ;; + 2-307) + UNAME_MACHINE="alphaev67" + ;; esac fi rm -f $dummy.s $dummy @@ -140,10 +251,7 @@ EOF echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) - echo m68k-cbm-sysv4 - exit 0;; - amiga:NetBSD:*:*) - echo m68k-cbm-netbsd${UNAME_RELEASE} + echo m68k-unknown-sysv4 exit 0 ;; amiga:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} @@ -169,13 +277,13 @@ EOF wgrisc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; - arm32:NetBSD:*:*) - echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - exit 0 ;; - SR2?01:HI-UX/MPP:*:*) + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit 0;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) @@ -231,9 +339,6 @@ EOF 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 ;; @@ -302,6 +407,7 @@ EOF mips:*:*:UMIPS | mips:*:*:RISCos) sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus +#include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { @@ -322,10 +428,13 @@ EOF EOF $CC_FOR_BUILD $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 && exit 0 rm -f $dummy.c $dummy echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; @@ -341,14 +450,17 @@ EOF AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ - -o ${TARGET_BINARY_INTERFACE}x = x ] ; then + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi - else echo i586-dg-dgux${UNAME_RELEASE} + else + echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) @@ -370,9 +482,17 @@ EOF ????????: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?86:AIX:*:*) + i*86:AIX:*:*) echo i386-ibm-aix exit 0 ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then sed 's/^ //' << EOF >$dummy.c @@ -386,7 +506,7 @@ EOF exit(0); } EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0 + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then @@ -395,9 +515,9 @@ EOF echo rs6000-ibm-aix3.2 fi exit 0 ;; - *:AIX:*:4) + *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` - if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc @@ -405,7 +525,7 @@ EOF if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV=4.${UNAME_RELEASE} + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; @@ -415,7 +535,7 @@ EOF ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) @@ -431,11 +551,31 @@ EOF echo m68k-hp-bsd4.4 exit 0 ;; 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) + case "${HPUX_REV}" in + 11.[0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + esac ;; + esac + fi ;; + esac + if [ "${HP_ARCH}" = "" ]; then sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE #include #include @@ -466,12 +606,17 @@ EOF exit (0); } EOF - ($CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` + (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` + if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi rm -f $dummy.c $dummy + fi ;; esac - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit 0 ;; 3050*:HI-UX:*:*) sed 's/^ //' << EOF >$dummy.c #include @@ -498,7 +643,7 @@ EOF exit (0); } EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0 + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo unknown-hitachi-hiuxwe2 exit 0 ;; @@ -517,7 +662,7 @@ EOF hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; - i?86:OSF1:*:*) + i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else @@ -560,29 +705,30 @@ EOF -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ exit 0 ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3D:*:*:*) + echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3E:*:*:*) - echo t3e-cray-unicosmk${UNAME_RELEASE} + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY-2:*:*:*) echo cray2-cray-unicos exit 0 ;; - F300:UNIX_System_V:*:*) + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | 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} + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; hp300:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; - i?86:BSD/386:*:* | i?86:BSD/OS:*:*) + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; sparc*:BSD/OS:*:*) @@ -592,29 +738,20 @@ EOF echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) - if test -x /usr/bin/objformat; then - if test "elf" = "`/usr/bin/objformat`"; then - echo ${UNAME_MACHINE}-unknown-freebsdelf`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'` - exit 0 - fi - fi echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; - *:NetBSD:*:*) - echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; - *:*:*BOW*:*) - echo i386-pc-bow - exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit 0 ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit 0 ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we @@ -633,31 +770,39 @@ EOF *:GNU:*:*) echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; - *:Linux:*:*) - # uname on the ARM produces all sorts of strangeness, and we need to - # filter it out. - case "$UNAME_MACHINE" in - armv*) UNAME_MACHINE=$UNAME_MACHINE ;; - arm* | sa110*) UNAME_MACHINE="arm" ;; - esac - - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - ld_help_string=`cd /; 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 ;; - armlinux) echo "${UNAME_MACHINE}-unknown-linux-aout" ; exit 0 ;; - m68klinux) echo "${UNAME_MACHINE}-unknown-linux-aout" ; exit 0 ;; - elf32ppc) + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit 0 ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux + exit 0 ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux + exit 0 ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux + exit 0 ;; + mips:Linux:*:*) + cat >$dummy.c < /* for printf() prototype */ +int main (int argc, char *argv[]) { +#else +int main (argc, argv) int argc; char *argv[]; { +#endif +#ifdef __MIPSEB__ + printf ("%s-unknown-linux\n", argv[1]); +#endif +#ifdef __MIPSEL__ + printf ("%sel-unknown-linux\n", argv[1]); +#endif + return 0; +} +EOF + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + ;; + ppc:Linux:*:*) # Determine Lib Version cat >$dummy.c < @@ -672,7 +817,7 @@ main(argc, argv) #if defined(__GLIBC__) printf("%s %s\n", __libc_version, __libc_release); #else - printf("unkown\n"); + printf("unknown\n"); #endif return 0; } @@ -681,91 +826,110 @@ EOF $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null if test "$?" = 0 ; then ./$dummy | grep 1\.99 > /dev/null - if test "$?" = 0 ; then - LIBC="-libc1" - fi + if test "$?" = 0 ; then LIBC="libc1" ; fi fi rm -f $dummy.c $dummy - echo powerpc-unknown-linux${LIBC} ; exit 0 ;; - esac - - if test "${UNAME_MACHINE}" = "alpha" ; then - sed 's/^ //' <$dummy.s + echo powerpc-unknown-linux-${LIBC} + exit 0 ;; + alpha:Linux:*:*) + cat <$dummy.s + .data + \$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + .text .globl main + .align 4 .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 + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit .end main EOF LIBC="" $CC_FOR_BUILD $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" - ;; + case `./$dummy` in + 0-0) UNAME_MACHINE="alpha" ;; + 1-0) UNAME_MACHINE="alphaev5" ;; + 1-1) UNAME_MACHINE="alphaev56" ;; + 1-101) UNAME_MACHINE="alphapca56" ;; + 2-303) UNAME_MACHINE="alphaev6" ;; + 2-307) UNAME_MACHINE="alphaev67" ;; esac - objdump --private-headers $dummy | \ grep ld.so.1 > /dev/null if test "$?" = 0 ; then - LIBC="-libc1" + 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 </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) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit 0 ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux ;; + PA8*) echo hppa2.0-unknown-linux ;; + *) echo hppa-unknown-linux ;; + esac + exit 0 ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux + exit 0 ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit 0 ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux + exit 0 ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux + exit 0 ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux + exit 0 ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + ld_supported_emulations=`cd /; ld --help 2>&1 \ + | 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 + ;; + elf_i*86) + TENTATIVE="${UNAME_MACHINE}-pc-linux" + ;; + i*86coff) + echo "${UNAME_MACHINE}-pc-linux-coff" + exit 0 + ;; + esac + # 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. + # GCC wants to distinguish between linux-oldld and linux-aout. # If ld does not provide *any* "supported emulations:" - # that means it is oldld. - echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:" - test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-oldld" && exit 0 - + # that means it is gnuoldld. + test -z "$ld_supported_emulations" && echo "${UNAME_MACHINE}-pc-linux-oldld" && exit 0 case "${UNAME_MACHINE}" in - i?86) + i*86) VENDOR=pc; ;; *) @@ -776,6 +940,7 @@ EOF cat >$dummy.c < #ifdef __cplusplus +#include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { @@ -796,15 +961,16 @@ EOF return 0; } EOF - $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0 + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy - fi ;; + test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + ;; # 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?86:DYNIX/ptx:4*:*) + i*86:DYNIX/ptx:4*:*) echo i386-sequent-sysv4 exit 0 ;; - i?86:UNIX_SV:4.2MP:2.*) + 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, @@ -812,22 +978,24 @@ EOF # 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.*:*) + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit 0 ;; - i?86:*:5:7*) - UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` - (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) && UNAME_MACHINE=i586 - (/bin/uname -X|egrep '^Machine.*Pent.*II' >/dev/null) && UNAME_MACHINE=i686 - (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) && UNAME_MACHINE=i585 - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}${UNAME_VERSION}-sysv${UNAME_RELEASE} + i*86:*:5:7*) + # Fixed at (any) Pentium or better + UNAME_MACHINE=i586 + if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then + echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} + fi exit 0 ;; - i?86:*:3.2:*) + i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - fi - echo ${UNAME_MACHINE}-unixware-${UNAME_RELEASE}-${UNAME_VERSION} + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp exit 0 ;; pc:*:*:*) + # Left here for compatibility: # 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 @@ -876,7 +1041,7 @@ EOF exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) + 3[34]??:*:4.0:3.0 | 3[34]??A:*: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` @@ -887,21 +1052,24 @@ EOF 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; - m68*:LynxOS:2.*:*) + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; - i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*) + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; - rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) + rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; @@ -935,19 +1103,16 @@ EOF mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; - news*:NEWS-OS:*:6*) + news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit 0 ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv`echo ${UNAME_RELEASE} | sed -n 's/\([.0-9]*\).*/\1/p'` + echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; - DS/90*:*:*:V20*) - echo sparc-fujitsu-uxpds - exit 0 ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit 0 ;; @@ -972,6 +1137,61 @@ EOF *:Darwin:*:*) echo `uname -p`-apple-darwin${UNAME_RELEASE} exit 0 ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + if test "${UNAME_MACHINE}" = "x86pc"; then + UNAME_MACHINE=pc + fi + echo `uname -p`-${UNAME_MACHINE}-nto-qnx + exit 0 ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit 0 ;; + NSR-[KW]:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit 0 ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit 0 ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit 0 ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit 0 ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit 0 ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit 0 ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit 0 ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit 0 ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit 0 ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit 0 ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 @@ -1064,7 +1284,20 @@ main () #if defined (vax) #if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else printf ("vax-dec-bsd\n"); exit (0); +# endif #else printf ("vax-dec-ultrix\n"); exit (0); #endif @@ -1078,7 +1311,7 @@ main () } EOF -$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0 +$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy # Apollos put the system type in the environment. @@ -1111,6 +1344,48 @@ then esac fi -#echo '(Unable to guess system type)' 1>&2 +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/config.sub b/config.sub index 1000343616..0387ee530f 100644 --- a/config.sub +++ b/config.sub @@ -1,6 +1,10 @@ #! /bin/sh -# Configuration validation subroutine script, version 1.1. -# Copyright (C) 1991, 92-97, 1998, 1999 Free Software Foundation, Inc. +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. + +timestamp='2001-04-20' + # 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. @@ -25,6 +29,8 @@ # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. +# Please send patches to . +# # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. @@ -45,30 +51,73 @@ # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. -if [ x$1 = x ] -then - echo Configuration name missing. 1>&2 - echo "Usage: $0 CPU-MFR-OPSYS" 1>&2 - echo "or $0 ALIAS" 1>&2 - echo where ALIAS is a recognized configuration type. 1>&2 - exit 1 -fi +me=`echo "$0" | sed -e 's,.*/,,'` -# First pass through any local machine types. +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + *local*) + # First pass through any local machine types. echo $1 - exit 0 - ;; + exit 0;; + *) - ;; + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - linux*) + nto-qnx* | linux-gnu* | storm-chaos* | os2-emx*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; @@ -94,7 +143,7 @@ case $os in -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple) + -apple | -axis) os= basic_machine=$1 ;; @@ -105,7 +154,7 @@ case $os in -scout) ;; -wrs) - os=vxworks + os=-vxworks basic_machine=$1 ;; -hiux*) @@ -156,61 +205,83 @@ case $os in -psos*) os=-psos ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. - tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ - | arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \ + tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \ + | arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \ + | pyramid | mn10200 | mn10300 | tron | a29k \ | 580 | i960 | h8300 \ + | x86 | ppcbe | mipsbe | mipsle | shbe | shle \ | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \ - | alpha | alphaev[4-7] | alphaev56 | alphapca5[67] \ - | we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \ - | 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \ + | hppa64 \ + | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \ + | alphaev6[78] \ + | we32k | ns16k | clipper | i370 | sh | sh[34] \ + | powerpc | powerpcle \ + | 1750a | dsp16xx | pdp10 | pdp11 \ + | mips16 | mips64 | mipsel | mips64el \ | mips64orion | mips64orionel | mipstx39 | mipstx39el \ | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \ - | mips64vr5000 | miprs64vr5000el \ - | sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \ - | thumb | d10v) + | mips64vr5000 | miprs64vr5000el | mcore | s390 | s390x \ + | sparc | sparclet | sparclite | sparc64 | sparcv9 | sparcv9b \ + | v850 | c4x \ + | thumb | d10v | d30v | fr30 | avr | openrisc | tic80 \ + | pj | pjl | h8500) basic_machine=$basic_machine-unknown ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65) + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | w65) ;; # 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[34567]86) + i*86 | x86_64) basic_machine=$basic_machine-pc ;; - i[3456]86-TOWNS*) - basic_machine=`echo $basic_machine | sed -e 's/-TOWNS.*/-TOWNS/'` - ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. - vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \ - | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \ + # FIXME: clean up the formatting here. + vax-* | tahoe-* | i*86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \ + | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \ + | arm-* | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \ | xmp-* | ymp-* \ - | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* | hppa2.0n-* \ - | alpha-* | alphaev[4-7]-* | alphaev56-* | alphapca5[67]-* \ + | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \ + | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \ + | hppa2.0n-* | hppa64-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \ + | alphaev6[78]-* \ | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \ | clipper-* | orion-* \ - | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ - | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \ + | sparclite-* | pdp10-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ + | sparc64-* | sparcv9-* | sparcv9b-* | sparc86x-* \ + | mips16-* | mips64-* | mipsel-* \ | mips64el-* | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \ - | mipstx39-* | mipstx39el-* \ - | f301-* | armv*-* | t3e-* \ + | mipstx39-* | mipstx39el-* | mcore-* \ + | f30[01]-* | f700-* | s390-* | s390x-* | sv1-* | t3e-* \ + | [cjt]90-* \ | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \ - | thumb-* | v850-* | d30v-* | tic30-* | c30-* ) + | thumb-* | v850-* | d30v-* | tic30-* | tic80-* | c30-* | fr30-* \ + | bs2000-* | tic54x-* | c54x-* | x86_64-* | pj-* | pjl-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. @@ -247,14 +318,14 @@ case $basic_machine in os=-sysv ;; amiga | amiga-*) - basic_machine=m68k-cbm + basic_machine=m68k-unknown ;; amigaos | amigados) - basic_machine=m68k-cbm + basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) - basic_machine=m68k-cbm + basic_machine=m68k-unknown os=-sysv4 ;; apollo68) @@ -301,13 +372,16 @@ case $basic_machine in basic_machine=cray2-cray os=-unicos ;; - [ctj]90-cray) - basic_machine=c90-cray + [cjt]90) + basic_machine=${basic_machine}-cray os=-unicos ;; crds | unos) basic_machine=m68k-crds ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; da30 | da30-*) basic_machine=m68k-da30 ;; @@ -355,6 +429,10 @@ case $basic_machine in basic_machine=tron-gmicro os=-sysv ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 @@ -428,22 +506,21 @@ case $basic_machine in ;; i370-ibm* | ibm*) basic_machine=i370-ibm - os=-mvs ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? - i[34567]86v32) + i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; - i[34567]86v4*) + i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; - i[34567]86v) + i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; - i[34567]86sol2) + i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; @@ -455,14 +532,6 @@ case $basic_machine in basic_machine=i386-unknown os=-vsta ;; - i386-go32 | go32) - basic_machine=i386-unknown - os=-go32 - ;; - i386-mingw32 | mingw32) - basic_machine=i386-unknown - os=-mingw32 - ;; iris | iris4d) basic_machine=mips-sgi case $os in @@ -488,10 +557,14 @@ case $basic_machine in basic_machine=ns32k-utek os=-sysv ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; miniframe) basic_machine=m68000-convergent ;; - *mint | *MiNT) + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; @@ -509,14 +582,22 @@ case $basic_machine in mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; + mmix*) + basic_machine=mmix-knuth + os=-mmixware + ;; monitor) basic_machine=m68k-rom68k os=-coff ;; msdos) - basic_machine=i386-unknown + basic_machine=i386-pc os=-msdos ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; ncr3000) basic_machine=i486-ncr os=-sysv4 @@ -525,12 +606,8 @@ case $basic_machine in basic_machine=i386-unknown os=-netbsd ;; - hpcmips*-*) - basic_machine=hpcmips-unknown - os=-netbsd - ;; netwinder) - basic_machine=armv4l-corel + basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) @@ -578,9 +655,16 @@ case $basic_machine in basic_machine=i960-intel os=-mon960 ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; np1) basic_machine=np1-gould ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf @@ -610,28 +694,28 @@ case $basic_machine in pc532 | pc532-*) basic_machine=ns32k-pc532 ;; - pentium | p5 | k5 | k6 | nexen) + pentium | p5 | k5 | k6 | nexgen) basic_machine=i586-pc ;; - pentiumpro | p6 | 6x86) + pentiumpro | p6 | 6x86 | athlon) basic_machine=i686-pc ;; pentiumii | pentium2) - basic_machine=i786-pc + basic_machine=i686-pc ;; - pentium-* | p5-* | k5-* | k6-* | nexen-*) + pentium-* | p5-* | k5-* | k6-* | nexgen-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - pentiumpro-* | p6-* | 6x86-*) + pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; - power) basic_machine=rs6000-ibm + power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; @@ -646,6 +730,10 @@ case $basic_machine in ps2) basic_machine=i386-ibm ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; rom68k) basic_machine=m68k-rom68k os=-coff @@ -725,6 +813,10 @@ case $basic_machine in sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; symmetry) basic_machine=i386-sequent os=-dynix @@ -733,6 +825,10 @@ case $basic_machine in basic_machine=t3e-cray os=-unicos ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; tx39) basic_machine=mipstx39-unknown ;; @@ -828,13 +924,20 @@ case $basic_machine in vax) basic_machine=vax-dec ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; - sparc | sparcv9) + sh3 | sh4) + basic_machine=sh-unknown + ;; + sparc | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) @@ -856,6 +959,9 @@ case $basic_machine in basic_machine=c4x-none os=-coff ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 @@ -914,13 +1020,26 @@ case $os in | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -rhapsody* | -openstep* | -oskit* \ - | -darwin*) + | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -os2*) # Remember, each alternative MUST END IN *, to match a version number. ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto*) + os=-nto-qnx + ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ - | -macos* | -mpw* | -magic* | -mon960* | -lnews*) + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` @@ -931,6 +1050,12 @@ case $os in -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; + -opened*) + os=-openedition + ;; + -wince*) + os=-wince + ;; -osfrose*) os=-osfrose ;; @@ -955,6 +1080,9 @@ case $os in -ns2 ) os=-nextstep2 ;; + -nsk*) + os=-nsk + ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` @@ -989,7 +1117,7 @@ case $os in -xenix) os=-xenix ;; - -mint* | -MiNT*) + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -uxpds) @@ -1025,12 +1153,15 @@ case $basic_machine in *-acorn) os=-riscix1.2 ;; - arm*-corel) + arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; + pdp10-*) + os=-tops20 + ;; pdp11-*) os=-none ;; @@ -1139,7 +1270,7 @@ case $basic_machine in *-masscomp) os=-rtu ;; - f301-fujitsu) + f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) @@ -1199,7 +1330,7 @@ case $basic_machine in -genix*) vendor=ns ;; - -mvs*) + -mvs* | -opened*) vendor=ibm ;; -ptx*) @@ -1217,7 +1348,7 @@ case $basic_machine in -mpw* | -macos*) vendor=apple ;; - -*mint | -*MiNT) + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; esac @@ -1226,3 +1357,11 @@ case $basic_machine in esac echo $basic_machine$os +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/dir.c b/dir.c index d2c2796c47..e0c3d42ecb 100644 --- a/dir.c +++ b/dir.c @@ -399,12 +399,15 @@ dir_chdir(path) } static int chdir_blocking = 0; +static VALUE chdir_thread = Qnil; static VALUE chdir_restore(path) const char *path; { chdir_blocking--; + if (chdir_blocking == 0) + chdir_thread = Qnil; dir_chdir(path); return Qnil; } @@ -436,14 +439,18 @@ dir_s_chdir(argc, argv, obj) } } - if (chdir_blocking > 0) - rb_warn("chdir during chdir block"); + if (chdir_blocking > 0) { + if (!rb_block_given_p() || rb_thread_current() != chdir_thread) + rb_warn("conflicting chdir during another chdir block"); + } if (rb_block_given_p()) { char cwd[MAXPATHLEN]; GETCWD(cwd); chdir_blocking++; + if (chdir_thread == Qnil) + chdir_thread = rb_thread_current(); dir_chdir(dist); return rb_ensure(rb_yield, path, chdir_restore, (VALUE)cwd); } @@ -618,7 +625,7 @@ static void glob_helper(path, flags, func, arg) char *path; int flags; - void (*func)(); + void (*func) _((const char*, VALUE)); VALUE arg; { struct stat st; @@ -763,7 +770,7 @@ rb_glob(path, func, arg) void rb_globi(path, func, arg) char *path; - void (*func)(); + void (*func) _((const char*, VALUE)); VALUE arg; { glob_helper(path, FNM_PERIOD|FNM_CASEFOLD, func, arg); diff --git a/dln.c b/dln.c index 4d9f541cf7..2dd7b87cf7 100644 --- a/dln.c +++ b/dln.c @@ -1383,7 +1383,7 @@ dln_load(file) rb_loaderror("Failed to load %.200s", file); } - NSLinkModule(obj_file, file, TRUE); + NSLinkModule(obj_file, file, NSLINKMODULE_OPTION_BINDNOW); /* lookup the initial function */ /*NSIsSymbolNameDefined require function name without "_" */ diff --git a/eval.c b/eval.c index 2b0d75e5e4..af3791059e 100644 --- a/eval.c +++ b/eval.c @@ -2584,7 +2584,7 @@ rb_eval(self, n) break; case NODE_ARGSPUSH: - result = rb_ary_push(rb_obj_dup(rb_eval(self, node->nd_head)), + result = rb_ary_push(rb_ary_dup(rb_eval(self, node->nd_head)), rb_eval(self, node->nd_body)); break; @@ -4421,11 +4421,14 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper) } break; + /* for attr get/set */ + case NODE_IVAR: + if (argc != 0) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)", argc); + } + case NODE_ATTRSET: /* for re-scoped/renamed method */ case NODE_ZSUPER: - /* for attr get/set */ - case NODE_ATTRSET: - case NODE_IVAR: result = rb_eval(recv, body); break; @@ -5217,8 +5220,8 @@ rb_load(fname, wrap) VALUE fname; int wrap; { + VALUE tmp; int state; - char *file; volatile ID last_func; volatile VALUE wrapper = 0; volatile VALUE self = ruby_top_self; @@ -5231,10 +5234,11 @@ rb_load(fname, wrap) else { SafeStringValue(fname); } - file = rb_find_file(RSTRING(fname)->ptr); - if (!file) { + tmp = rb_find_file(fname); + if (!tmp) { rb_raise(rb_eLoadError, "No such file to load -- %s", RSTRING(fname)->ptr); } + fname = tmp; ruby_errinfo = Qnil; /* ensure */ PUSH_VARS(); @@ -5269,7 +5273,7 @@ rb_load(fname, wrap) DEFER_INTS; ruby_in_eval++; - rb_load_file(file); + rb_load_file(RSTRING(fname)->ptr); ruby_in_eval--; node = ruby_eval_tree; ALLOW_INTS; @@ -5382,33 +5386,39 @@ rb_provided(feature) return rb_feature_p(feature, Qfalse); } -void -rb_provide(feature) - const char *feature; +static void +rb_provide_feature(feature) + VALUE feature; { - char *buf, *ext; + char *ext; + char *f = RSTRING(feature)->ptr; - ext = strrchr(feature, '.'); + ext = strrchr(f, '.'); if (ext && (strcmp(DLEXT, ext) == 0 #ifdef DLEXT2 || strcmp(DLEXT2, ext) == 0 #endif )) { - buf = ALLOCA_N(char, strlen(feature)+4); - strcpy(buf, feature); - ext = strrchr(buf, '.'); - strcpy(ext, ".so"); - feature = buf; + feature = rb_str_new(RSTRING(feature)->ptr, ext-RSTRING(feature)->ptr); + rb_str_cat2(feature, ".so"); } - if (rb_feature_p(feature, Qtrue)) return; - rb_ary_push(rb_features, rb_str_new2(feature)); + if (rb_feature_p(RSTRING(feature)->ptr, Qtrue)) return; + rb_ary_push(rb_features, feature); +} + +void +rb_provide(feature) + const char *feature; +{ + rb_provide_feature(rb_str_new2(feature)); } VALUE rb_f_require(obj, fname) VALUE obj, fname; { - char *ext, *file, *feature, *buf; /* OK */ + VALUE feature, tmp; + char *ext, *ftptr; /* OK */ volatile VALUE load; int state; volatile int safe = ruby_safe_level; @@ -5418,68 +5428,70 @@ rb_f_require(obj, fname) return Qfalse; ext = strrchr(RSTRING(fname)->ptr, '.'); if (ext) { - feature = file = RSTRING(fname)->ptr; if (strcmp(".rb", ext) == 0) { - file = rb_find_file(file); - if (file) goto load_rb; + feature = rb_str_dup(fname); + tmp = rb_find_file(fname); + if (tmp) { + fname = tmp; + goto load_rb; + } } else if (strcmp(".so", ext) == 0 || strcmp(".o", ext) == 0) { - if (strcmp(ext, DLEXT) != 0) { - buf = ALLOCA_N(char, strlen(file)+sizeof(DLEXT)+4); - strcpy(buf, feature); - ext = strrchr(buf, '.'); - strcpy(ext, DLEXT); - file = feature = buf; + fname = rb_str_new(RSTRING(fname)->ptr, ext-RSTRING(fname)->ptr); + tmp = rb_str_dup(fname); + rb_str_cat2(tmp, DLEXT); + tmp = rb_find_file(tmp); + if (tmp) { + feature = fname = tmp; + goto load_dyna; } - file = rb_find_file(file); - if (file) goto load_dyna; #ifdef DLEXT2 - file = feature = RSTRING(fname)->ptr; - if (strcmp(ext, DLEXT2) != 0) { - buf = ALLOCA_N(char, strlen(file)+sizeof(DLEXT2)+4); - strcpy(buf, feature); - ext = strrchr(buf, '.'); - strcpy(ext, DLEXT2); - file = feature = buf; + tmp = rb_str_dup(fname); + rb_str_cat2(tmp, DLEXT); + tmp = rb_find_file(tmp); + if (tmp) { + feature = fname = tmp; + goto load_dyna; } - file = rb_find_file(file); - if (file) goto load_dyna; #endif } else if (strcmp(DLEXT, ext) == 0) { - feature = RSTRING(fname)->ptr; - file = rb_find_file(feature); - if (file) goto load_dyna; + tmp = rb_find_file(fname); + if (tmp) { + feature = fname = tmp; + goto load_dyna; + } } #ifdef DLEXT2 else if (strcmp(DLEXT2, ext) == 0) { - feature = RSTRING(fname)->ptr; - file = rb_find_file(feature); - if (file) goto load_dyna; + tmp = rb_find_file(fname); + if (tmp) { + feature = fname = tmp; + goto load_dyna; + } } #endif } - buf = ALLOCA_N(char, strlen(RSTRING(fname)->ptr) + 5); - strcpy(buf, RSTRING(fname)->ptr); - switch (rb_find_file_noext(buf)) { + tmp = fname; + switch (rb_find_file_noext(&tmp)) { case 0: break; case 1: - fname = rb_str_new2(buf); - file = feature = buf; + feature = fname; + fname = tmp; goto load_rb; default: - feature = buf; - file = rb_find_file(buf); + feature = fname; + fname = rb_find_file(tmp); goto load_dyna; } rb_raise(rb_eLoadError, "No such file to load -- %s", RSTRING(fname)->ptr); load_dyna: - rb_provide(feature); + rb_provide_feature(feature); { int volatile old_vmode = scope_vmode; @@ -5488,9 +5500,7 @@ rb_f_require(obj, fname) void *handle; SCOPE_SET(SCOPE_PUBLIC); - load = rb_str_new2(file); - file = RSTRING(load)->ptr; - handle = dln_load(file); + handle = dln_load(RSTRING(fname)->ptr); rb_ary_push(ruby_dln_librefs, INT2NUM((long)handle)); } POP_TAG(); @@ -5502,21 +5512,22 @@ rb_f_require(obj, fname) load_rb: ruby_safe_level = 0; - rb_provide(feature); + rb_provide_feature(feature); /* loading ruby library should be serialized. */ if (!loading_tbl) { loading_tbl = st_init_strtable(); } /* partial state */ - st_insert(loading_tbl, strdup(feature), curr_thread); + ftptr = ruby_strdup(RSTRING(feature)->ptr); + st_insert(loading_tbl, ftptr, curr_thread); PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { rb_load(fname, 0); } POP_TAG(); - st_delete(loading_tbl, &feature, 0); /* loading done */ - free(feature); + st_delete(loading_tbl, &ftptr, 0); /* loading done */ + free(ftptr); ruby_safe_level = safe; if (state) JUMP_TAG(state); diff --git a/file.c b/file.c index 66f82bcc58..60cab5ba80 100644 --- a/file.c +++ b/file.c @@ -2202,26 +2202,27 @@ is_macos_native_path(path) } #endif -static char* +static int file_load_ok(file) char *file; { FILE *f; + if (!f) return 0; f = fopen(file, "r"); if (f == NULL) return 0; fclose(f); - return file; + return 1; } extern VALUE rb_load_path; int -rb_find_file_noext(file) - char *file; +rb_find_file_noext(filep) + VALUE *filep; { char *path, *e, *found; - char *fend = file + strlen(file); + char *f = RSTRING(*filep)->ptr; VALUE fname; int i, j; @@ -2233,16 +2234,22 @@ rb_find_file_noext(file) 0 }; - if (file[0] == '~') { - fname = rb_str_new2(file); + if (f[0] == '~') { + fname = *filep; fname = rb_file_s_expand_path(1, &fname); - file = StringValuePtr(fname); + if (rb_safe_level() >= 2 && OBJ_TAINTED(fname)) { + rb_raise(rb_eSecurityError, "loading from unsafe file %s", f); + } } - if (is_absolute_path(file)) { + if (is_absolute_path(f)) { for (i=0; ext[i]; i++) { - strcpy(fend, ext[i]); - if (file_load_ok(file)) return i+1; + fname = rb_str_dup(*filep); + rb_str_cat2(fname, ext[i]); + if (file_load_ok(RSTRING(fname)->ptr)) { + *filep = fname; + return i+1; + } } return 0; } @@ -2256,71 +2263,76 @@ rb_find_file_noext(file) SafeStringValue(str); path = RSTRING(str)->ptr; for (j=0; ext[j]; j++) { - strcpy(fend, ext[j]); - found = dln_find_file(file, path); - if (found && file_load_ok(found)) return j+1; + fname = rb_str_dup(*filep); + rb_str_cat2(fname, ext[j]); + found = dln_find_file(RSTRING(fname)->ptr, path); + if (found && file_load_ok(found)) { + *filep = fname; + return j+1; + } } } return 0; } -char* -rb_find_file(file) - char *file; +VALUE +rb_find_file(path) + VALUE path; { - VALUE vpath, fname; - char *path; + VALUE tmp, fname; + char *f = RSTRING(path)->ptr; + char *lpath; struct stat st; - if (file[0] == '~') { - fname = rb_str_new2(file); - fname = rb_file_s_expand_path(1, &fname); - if (rb_safe_level() >= 2 && OBJ_TAINTED(fname)) { - rb_raise(rb_eSecurityError, "loading from unsafe file %s", file); + if (f[0] == '~') { + tmp = rb_file_s_expand_path(1, &path); + if (rb_safe_level() >= 2 && OBJ_TAINTED(tmp)) { + rb_raise(rb_eSecurityError, "loading from unsafe file %s", f); } - file = StringValuePtr(fname); } #if defined(__MACOS__) || defined(riscos) - if (is_macos_native_path(file)) { - if (rb_safe_level() >= 2 && !rb_path_check(file)) { - rb_raise(rb_eSecurityError, "loading from unsafe file %s", file); + if (is_macos_native_path(f)) { + if (rb_safe_level() >= 2 && !rb_path_check(f)) { + rb_raise(rb_eSecurityError, "loading from unsafe file %s", f); } - return file_load_ok(file); + if (file_load_ok(f)) return path; } #endif - if (is_absolute_path(file)) { - if (rb_safe_level() >= 2 && !rb_path_check(file)) { - rb_raise(rb_eSecurityError, "loading from unsafe file %s", file); + if (is_absolute_path(f)) { + if (rb_safe_level() >= 2 && !rb_path_check(f)) { + rb_raise(rb_eSecurityError, "loading from unsafe file %s", f); } - return file_load_ok(file); + if (file_load_ok(f)) return path; } if (rb_load_path) { int i; Check_Type(rb_load_path, T_ARRAY); - vpath = rb_ary_new(); + tmp = rb_ary_new(); for (i=0;ilen;i++) { VALUE str = RARRAY(rb_load_path)->ptr[i]; SafeStringValue(str); if (RSTRING(str)->len > 0) { - rb_ary_push(vpath, str); + rb_ary_push(tmp, str); } } - vpath = rb_ary_join(vpath, rb_str_new2(PATH_SEP)); - path = StringValuePtr(vpath); - if (rb_safe_level() >= 2 && !rb_path_check(path)) { - rb_raise(rb_eSecurityError, "loading from unsafe path %s", path); + tmp = rb_ary_join(tmp, rb_str_new2(PATH_SEP)); + lpath = StringValuePtr(tmp); + if (rb_safe_level() >= 2 && !rb_path_check(lpath)) { + rb_raise(rb_eSecurityError, "loading from unsafe path %s", lpath); } } else { - path = 0; + lpath = 0; } - path = dln_find_file(file, path); - return file_load_ok(path); + f = dln_find_file(f, lpath); + if (file_load_ok(f)) { + return rb_str_new2(f); + } } static void diff --git a/intern.h b/intern.h index 7a837bea79..9f2793c9e8 100644 --- a/intern.h +++ b/intern.h @@ -27,6 +27,7 @@ VALUE rb_ary_new4 _((long, VALUE *)); VALUE rb_ary_freeze _((VALUE)); VALUE rb_ary_aref _((int, VALUE*, VALUE)); void rb_ary_store _((VALUE, long, VALUE)); +VALUE rb_ary_dup _((VALUE)); VALUE rb_ary_to_ary _((VALUE)); VALUE rb_ary_to_s _((VALUE)); VALUE rb_ary_push _((VALUE, VALUE)); @@ -181,8 +182,8 @@ void rb_thread_atfork _((void)); int eaccess _((const char*, int)); VALUE rb_file_s_expand_path _((int, VALUE *)); void rb_file_const _((const char*, VALUE)); -int rb_find_file_noext _((char*)); -char *rb_find_file _((char*)); +int rb_find_file_noext _((VALUE*)); +VALUE rb_find_file _((VALUE)); /* gc.c */ void rb_gc_mark_locations _((VALUE*, VALUE*)); void rb_mark_tbl _((struct st_table*)); @@ -240,6 +241,8 @@ VALUE rb_obj_tainted _((VALUE)); VALUE rb_obj_untaint _((VALUE)); VALUE rb_obj_freeze _((VALUE)); VALUE rb_obj_id _((VALUE)); +VALUE rb_obj_type _((VALUE)); +VALUE rb_class_real _((VALUE)); VALUE rb_convert_type _((VALUE,int,const char*,const char*)); VALUE rb_to_int _((VALUE)); VALUE rb_Integer _((VALUE)); @@ -364,7 +367,7 @@ VALUE rb_f_untrace_var _((int, VALUE*)); VALUE rb_f_global_variables _((void)); void rb_alias_variable _((ID, ID)); struct st_table* rb_generic_ivar_table _((VALUE)); -void rb_clone_generic_ivar _((VALUE,VALUE)); +void rb_copy_generic_ivar _((VALUE,VALUE)); void rb_mark_generic_ivar _((VALUE)); void rb_mark_generic_ivar_tbl _((void)); void rb_free_generic_ivar _((VALUE)); diff --git a/io.c b/io.c index 0fd059714a..2c51dec6e1 100644 --- a/io.c +++ b/io.c @@ -190,7 +190,7 @@ rb_read_check(fp) } static int -rb_dup(orig) +ruby_dup(orig) int orig; { int fd; @@ -329,7 +329,7 @@ rb_io_seek(io, offset, whence) long pos; GetOpenFile(io, fptr); - pos = fseek(fptr->f, NUM2INT(offset), whence); + pos = fseek(fptr->f, NUM2LONG(offset), whence); if (pos != 0) rb_sys_fail(fptr->path); clearerr(fptr->f); @@ -360,7 +360,7 @@ rb_io_set_pos(io, offset) long pos; GetOpenFile(io, fptr); - pos = fseek(fptr->f, NUM2INT(offset), SEEK_SET); + pos = fseek(fptr->f, NUM2LONG(offset), SEEK_SET); if (pos != 0) rb_sys_fail(fptr->path); clearerr(fptr->f); @@ -2042,11 +2042,11 @@ rb_io_clone(io) else mode = "r+"; break; } - fd = rb_dup(fileno(orig->f)); + fd = ruby_dup(fileno(orig->f)); fptr->f = rb_fdopen(fd, mode); if (fptr->f2) { if (fileno(orig->f) != fileno(orig->f2)) { - fd = rb_dup(fileno(orig->f2)); + fd = ruby_dup(fileno(orig->f2)); } fptr->f = rb_fdopen(fd, "w"); } diff --git a/object.c b/object.c index 2d70029f0b..e34bb23b1b 100644 --- a/object.c +++ b/object.c @@ -70,18 +70,23 @@ rb_obj_id(obj) return (VALUE)((long)obj|FIXNUM_FLAG); } -static VALUE -rb_obj_type(obj) - VALUE obj; +VALUE +rb_class_real(cl) + VALUE cl; { - VALUE cl = CLASS_OF(obj); - while (FL_TEST(cl, FL_SINGLETON) || TYPE(cl) == T_ICLASS) { cl = RCLASS(cl)->super; } return cl; } +VALUE +rb_obj_type(obj) + VALUE obj; +{ + return rb_class_real(CLASS_OF(obj)); +} + VALUE rb_obj_clone(obj) VALUE obj; @@ -113,6 +118,9 @@ rb_obj_dup(obj) if (!SPECIAL_CONST_P(dup)) { OBJSETUP(dup, rb_obj_type(obj), BUILTIN_TYPE(obj)); OBJ_INFECT(dup, obj); + if (FL_TEST(obj, FL_EXIVAR)) { + FL_SET(dup, FL_EXIVAR); + } } return dup; } @@ -866,7 +874,7 @@ rb_convert_type(val, type, tname, method) arg1.val = arg2.val = val; arg1.s = method; arg2.s = tname; - val = rb_rescue2(to_type, (VALUE)&arg1, fail_to_type, (VALUE)&arg2); + val = rb_rescue(to_type, (VALUE)&arg1, fail_to_type, (VALUE)&arg2); if (TYPE(val) != type) { rb_raise(rb_eTypeError, "%s#%s should return %s", rb_class2name(CLASS_OF(arg1.val)), method, tname); diff --git a/range.c b/range.c index fc02a69e0c..0b136f167a 100644 --- a/range.c +++ b/range.c @@ -45,7 +45,7 @@ range_init(obj, beg, end, exclude_end) args[0] = beg; args[1] = end; if (!FIXNUM_P(beg) || !FIXNUM_P(end)) { - rb_rescue2(range_check, (VALUE)args, range_failed, 0); + rb_rescue(range_check, (VALUE)args, range_failed, 0); } SET_EXCL(obj, exclude_end); diff --git a/regex.c b/regex.c index 0b7cd37254..df174328cb 100644 --- a/regex.c +++ b/regex.c @@ -3264,7 +3264,7 @@ re_search(bufp, string, size, startpos, range, regs) } if (startpos > size) return -1; - if ((anchor || !bufp->can_be_null) && size > 0 && startpos == size) + if ((anchor || !bufp->can_be_null) && range > 0 && size > 0 && startpos == size) return -1; val = re_match(bufp, string, size, startpos, regs); if (val >= 0) return startpos; @@ -4237,7 +4237,6 @@ re_match(bufp, string_arg, size, pos, regs) unsigned char c; PREFETCH; - c = *d++; if (*p == 0xff) { p++; if (!--mcnt @@ -4246,6 +4245,7 @@ re_match(bufp, string_arg, size, pos, regs) goto fail; continue; } + c = *d++; if (ismbchar(c)) { int n; diff --git a/ruby.c b/ruby.c index b5fdfb0c8e..a34c0a2974 100644 --- a/ruby.c +++ b/ruby.c @@ -770,7 +770,7 @@ load_file(fname, script) } if (script) { - VALUE c; + VALUE c = 1; /* something not nil */ VALUE line; char *p; diff --git a/ruby.h b/ruby.h index 57c676da49..bbd5819242 100644 --- a/ruby.h +++ b/ruby.h @@ -244,7 +244,7 @@ VALUE rb_newobj _((void)); #define CLONESETUP(clone,obj) do {\ OBJSETUP(clone,rb_singleton_class_clone(RBASIC(obj)->klass),RBASIC(obj)->flags);\ rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);\ - if (FL_TEST(obj, FL_EXIVAR)) rb_clone_generic_ivar((VALUE)clone,(VALUE)obj);\ + if (FL_TEST(obj, FL_EXIVAR)) rb_copy_generic_ivar((VALUE)clone,(VALUE)obj);\ } while (0) struct RBasic { diff --git a/string.c b/string.c index 5bf2c04398..9982e561b7 100644 --- a/string.c +++ b/string.c @@ -100,11 +100,7 @@ rb_str_new4(orig) { VALUE klass; - klass = CLASS_OF(orig); - while (TYPE(klass) == T_ICLASS || FL_TEST(klass, FL_SINGLETON)) { - klass = (VALUE)RCLASS(klass)->super; - } - + klass = rb_obj_type(orig); if (RSTRING(orig)->orig) { VALUE str; @@ -252,10 +248,7 @@ rb_str_dup(str) VALUE klass; StringValue(str); - klass = CLASS_OF(str); - while (TYPE(klass) == T_ICLASS || FL_TEST(klass, FL_SINGLETON)) { - klass = (VALUE)RCLASS(klass)->super; - } + klass = rb_obj_type(str); if (OBJ_FROZEN(str)) str2 = rb_str_new3(str); else if (FL_TEST(str, STR_NO_ORIG)) { @@ -267,6 +260,8 @@ rb_str_dup(str) else { str2 = rb_str_new3(rb_str_new4(str)); } + if (FL_TEST(str, FL_EXIVAR)) + rb_copy_generic_ivar(str2, str); OBJ_INFECT(str2, str); RBASIC(str2)->klass = klass; return str2; diff --git a/variable.c b/variable.c index 23b246da00..79a11b76fe 100644 --- a/variable.c +++ b/variable.c @@ -142,9 +142,6 @@ classname(klass) VALUE path = Qnil; ID classpath = rb_intern("__classpath__"); - while (TYPE(klass) == T_ICLASS || FL_TEST(klass, FL_SINGLETON)) { - klass = (VALUE)RCLASS(klass)->super; - } if (!klass) klass = rb_cObject; if (!ROBJECT(klass)->iv_tbl) ROBJECT(klass)->iv_tbl = st_init_numtable(); @@ -173,7 +170,7 @@ VALUE rb_mod_name(mod) VALUE mod; { - VALUE path = classname(mod); + VALUE path = classname(rb_obj_type(mod)); if (path) return rb_str_dup(path); return rb_str_new(0,0); @@ -183,7 +180,7 @@ VALUE rb_class_path(klass) VALUE klass; { - VALUE path = classname(klass); + VALUE path = classname(rb_class_real(klass)); if (path) return path; else { @@ -871,7 +868,7 @@ rb_free_generic_ivar(obj) } void -rb_clone_generic_ivar(clone, obj) +rb_copy_generic_ivar(clone, obj) VALUE clone, obj; { st_table *tbl; diff --git a/version.h b/version.h index 724f37e1df..2d668ccb83 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.7.1" -#define RUBY_RELEASE_DATE "2001-07-12" +#define RUBY_RELEASE_DATE "2001-07-15" #define RUBY_VERSION_CODE 171 -#define RUBY_RELEASE_CODE 20010712 +#define RUBY_RELEASE_CODE 20010715