diff --git a/ChangeLog b/ChangeLog index becc4e7db8..82c45c3ac4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,82 @@ +Mon Jan 31 15:24:58 2000 Yukihiro Matsumoto + + * string.c (rb_str_sub): no bang method returns original string if + no change is made. + + * string.c (str_sub_bang): bang method returns string always. + experimental. + +Sun Jan 30 17:58:09 2000 WATANABE Hirofumi + + * eval.c: arrange to use setitimer(2) for BOW, DJGPP + + * defines.h: ditto. use random(3) on cygwin b20.1. + +Sun Jan 30 17:20:16 2000 WATANABE Hirofumi + + * eval.c: use getrlimit(2) on DJGPP. + +Thu Jan 27 01:27:10 2000 GOTO Kentaro + + * dir.c (glob): glob pattern "/*" did not match. + +Wed Jan 26 22:30:47 2000 Shigeo Kobayashi + + * numeric.c (flo_modulo): wrong result for negative modulo. + +Wed Jan 26 02:01:57 2000 Yukihiro Matsumoto + + * file.c (test_c): should use S_ISCHR. + + * file.c (rb_stat_c): ditto. + + * string.c (rb_str_each_line): should propagate tainting. + +Tue Jan 25 04:01:34 2000 Yukihiro Matsumoto + + * object.c (rb_obj_freeze): all objects made freezable. + +Tue Jan 25 00:37:01 2000 WATANABE Hirofumi + + * configure.in: use AC_CHECK_TOOL for cross compiling. + +Mon Jan 24 19:01:54 2000 Nobuyoshi Nakada + + * array.c (rb_protect_inspect): should be checked by id of + objects; not by object themselves. + +Mon Jan 24 18:48:08 2000 Minero Aoki + + * eval.c (rb_eval): too many warnings; warned on every method + overriding. should be on method discarding. + +Mon Jan 24 02:56:44 2000 Yukihiro Matsumoto + + * parse.y (yylex): -2.abs should be `(-2).abs' to accomplish the + principle of less surprise. `+2' too. + + * eval.c (rb_eval): when defining class is already there, and + superclass differ, throw away the old class. + + * variable.c (rb_const_set): gives warining again on constant + redefinition. + + * error.c (Init_Exception): SyntaxError, NameError, LoadError and + NotImplementError are subclasses of ScriptError + + * parse.y (parse_quotedwords): no longer use `String#split'. + and enable space escape within quoted word list. + e.g. %w(a\ b\ c abc) => ["a b c", "abc"]. + + * string.c (rb_str_slice_bang): new method `slice!'. + +Fri Jan 21 16:15:59 2000 Yukihiro Matsumoto + + * eval.c (thgroup_s_new): new class ThreadGroup. + Tue Jan 18 12:24:28 2000 Yukihiro Matsumoto * struct.c (Init_Struct): remove Struct's own hash and eql?. @@ -68,8 +147,8 @@ Tue Jan 4 06:04:14 2000 WATANABE Hirofumi Sat Jan 1 13:26:14 2000 Yukihiro Matsumoto - * eval.c (rb_yield_0): force_recycle ruby_dyna_vars to performance - gain. + * eval.c (rb_yield_0): force_recycle ruby_dyna_vars to gain + performance. * array.c (rb_ary_delete_at_m): takes same argument pattern with rb_ary_aref. @@ -85,8 +164,8 @@ Sat Jan 1 10:12:26 2000 Nobuyoshi Nakada * ruby.h (FL_ABLE, FL_SET, FL_UNSET, FL_REVERSE): made expressions not statements. - * ruby.h (OBJ_INFECT): newly added which copies taint from `s' to - `x'. + * ruby.h (OBJ_INFECT): newly added macro which copies taint from + `s' to `x'. Sat Jan 1 02:04:18 2000 Yukihiro Matsumoto @@ -202,7 +281,7 @@ Mon Dec 13 15:15:31 1999 Yukihiro Matsumoto because of major performace drawback. * class.c (rb_singleton_class): tainted status of the singleton - class must synchronize with the object. + class must be synchronized with the object. * eval.c (rb_thread_schedule): implement thread priority. @@ -404,7 +483,7 @@ Mon Nov 15 04:50:33 1999 Koji Arai Sat Nov 13 07:34:18 1999 Yukihiro Matsumoto * variable.c (rb_mod_constants): traverse superclasses to collect - constants (shared variables). + constants. * eval.c (assign): modified for shared variables. diff --git a/ToDo b/ToDo index dfd9a16cb1..aeddb5d036 100644 --- a/ToDo +++ b/ToDo @@ -2,31 +2,32 @@ Language Spec. - def foo; .. rescue .. end - compile time string concatenation, "hello" "world" => "helloworld" -- assignable constant, which now should be called shared variable. -- class variable (prefix?) -- done by shared variable - rescue modifier; a rescue b => begin a rescue; b end -* operator !! for rescue. +- %w(a\ b\ c abc) => ["a b c", "abc"] +* class variable (prefix @@?) ?? +* operator !! for rescue. ??? * objectify symbols * objectify characters * ../... outside condition invokes operator method too. * ... inside condition turns off just before right condition.??? -* %w(a\ b\ c abc) => ["a b c", "abc"] * package or access control for global variables?? * named arguments like foo(nation:="german") or foo(nation: "german"). -* method to retrieve argument information (need new C API) +* method to retrieve argument information (needs new C API) * multiple return values, yield values. maybe incompatible ??? * cascading method invocation ??? * def Class#method .. end ?? * class Foo::Bar -* retrieve STACK_LEVEL_MAX from users' limit. -* remove end_proc registered out of require only +- retrieve STACK_LEVEL_MAX from users' limit. +- remove end_proc registered out of require only +- all object made freezable * non-blocking open (e.g. for named pipe) for thread * avoid blocking with gethostbyname/gethostbyaddr * objectify interpreters @@ -34,7 +35,6 @@ Hacking Interpreter * syntax tree -> bytecode ??? * scrambled script, or script filter * setuid ruby -* freeze all object Standard Libraries @@ -45,9 +45,12 @@ Standard Libraries - sprintf/printf's $ to specify argument order - Dir.glob("**/*.c") ala zsh - Remove Enumerable#{size,length} -* Marshal should handle generic instance variables. -* SyntaxError and NameError should not be subclasses of StandardError, maybe. -* debugger for thread programming +- Array#slice, Array#slice! +- String#slice, String#slice! +- Marshal should handle generic instance variables. +- debugger for thread programming +- SyntaxError, NameError, LoadError and NotImplementError are subclasses of + ScriptError= 4) rb_raise(rb_eSecurityError, "Insecure: can't modify array"); } -VALUE -rb_ary_freeze(ary) - VALUE ary; -{ - if (rb_safe_level() >= 4 && !OBJ_TAINTED(ary)) - rb_raise(rb_eSecurityError, "Insecure: can't freeze array"); - - FL_SET(ary, ARY_FREEZE); - return ary; -} - static VALUE rb_ary_frozen_p(ary) VALUE ary; { - if (FL_TEST(ary, ARY_FREEZE|ARY_TMPLOCK)) + if (FL_TEST(ary, FL_FREEZE|ARY_TMPLOCK)) return Qtrue; return Qfalse; } @@ -355,7 +342,7 @@ rb_ary_entry(ary, offset) } static VALUE -rb_ary_subary(ary, beg, len) +rb_ary_subseq(ary, beg, len) VALUE ary; long beg, len; { @@ -397,7 +384,7 @@ rb_ary_aref(argc, argv, ary) if (beg < 0) { beg = RARRAY(ary)->len + beg; } - return rb_ary_subary(ary, beg, len); + return rb_ary_subseq(ary, beg, len); } /* special case - speeding up */ @@ -415,7 +402,7 @@ rb_ary_aref(argc, argv, ary) case Qnil: return Qnil; default: - return rb_ary_subary(ary, beg, len); + return rb_ary_subseq(ary, beg, len); } } return rb_ary_entry(ary, NUM2LONG(arg1)); @@ -790,8 +777,8 @@ rb_protect_inspect(func, obj, arg) VALUE obj, arg; { struct inspect_arg iarg; - VALUE inspect_tbl; + VALUE id; if (!inspect_key) { inspect_key = rb_intern("__inspect_key__"); @@ -801,10 +788,11 @@ rb_protect_inspect(func, obj, arg) inspect_tbl = rb_ary_new(); rb_thread_local_aset(rb_thread_current(), inspect_key, inspect_tbl); } - if (rb_ary_includes(inspect_tbl, obj)) { + id = rb_obj_id(obj); + if (rb_ary_includes(inspect_tbl, id)) { return (*func)(obj, arg); } - rb_ary_push(inspect_tbl, obj); + rb_ary_push(inspect_tbl, id); iarg.func = func; iarg.arg1 = obj; iarg.arg2 = arg; @@ -821,7 +809,7 @@ rb_inspecting_p(obj) if (!inspect_key) return Qfalse; inspect_tbl = rb_thread_local_aref(rb_thread_current(), inspect_key); if (NIL_P(inspect_tbl)) return Qfalse; - return rb_ary_includes(inspect_tbl, obj); + return rb_ary_includes(inspect_tbl, rb_obj_id(obj)); } static VALUE @@ -1040,7 +1028,7 @@ rb_ary_delete_at_m(argc, argv, ary) if (pos < 0) { pos = RARRAY(ary)->len + pos; } - arg2 = rb_ary_subary(ary, pos, len); + arg2 = rb_ary_subseq(ary, pos, len); rb_ary_replace(ary, pos, len, Qnil); /* Qnil/rb_ary_new2(0) */ return arg2; } @@ -1064,6 +1052,7 @@ rb_ary_delete_at_m(argc, argv, ary) return arg2; } + static VALUE rb_ary_delete_if(ary) VALUE ary; @@ -1500,11 +1489,26 @@ rb_ary_flatten_bang(ary) { long i; int mod = 0; + VALUE flattening = Qnil; rb_ary_modify(ary); for (i=0; ilen; i++) { VALUE ary2 = RARRAY(ary)->ptr[i]; if (TYPE(ary2) == T_ARRAY) { + if (ary == ary2) { + ary2 = Qnil; + } else { + VALUE id; + + if (NIL_P(flattening)) { + flattening = rb_ary_new(); + } + id = rb_obj_id(ary2); + if (rb_ary_includes(flattening, id)) { + rb_raise(rb_eArgError, "tryed to flatten recursive array"); + } + rb_ary_push(flattening, id); + } rb_ary_replace(ary, i--, 1, ary2); mod = 1; } @@ -1534,8 +1538,6 @@ Init_Array() rb_define_method(rb_cArray, "inspect", rb_ary_inspect, 0); rb_define_method(rb_cArray, "to_a", rb_ary_to_a, 0); rb_define_method(rb_cArray, "to_ary", rb_ary_to_a, 0); - - rb_define_method(rb_cArray, "freeze", rb_ary_freeze, 0); rb_define_method(rb_cArray, "frozen?", rb_ary_frozen_p, 0); rb_define_method(rb_cArray, "==", rb_ary_equal, 1); @@ -1583,6 +1585,9 @@ Init_Array() rb_define_method(rb_cArray, "include?", rb_ary_includes, 1); rb_define_method(rb_cArray, "<=>", rb_ary_cmp, 1); + rb_define_method(rb_cArray, "slice", rb_ary_aref, -1); + rb_define_method(rb_cArray, "slice!", rb_ary_delete_at_m, -1); + rb_define_method(rb_cArray, "assoc", rb_ary_assoc, 1); rb_define_method(rb_cArray, "rassoc", rb_ary_rassoc, 1); diff --git a/configure b/configure index 5e6ca7405c..681d65554a 100644 --- a/configure +++ b/configure @@ -693,10 +693,69 @@ test "$program_suffix" != NONE && test "$program_transform_name" = "" && program_transform_name="s,x,x," + +if test x"${build}" != x"${host}"; then + echo $ac_n "checking build system type""... $ac_c" 1>&6 +echo "configure:700: checking build system type" >&5 + +build_alias=$build +case "$build_alias" in +NONE) + case $nonopt in + NONE) build_alias=$host_alias ;; + *) build_alias=$nonopt ;; + esac ;; +esac + +build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` +build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$build" 1>&6 + +if test $host != $build; then + ac_tool_prefix=${host_alias}- +else + ac_tool_prefix= +fi + +# Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:726: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_CC" && ac_cv_prog_CC="gcc" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + + +fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:700: checking for $ac_word" >&5 +echo "configure:759: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -726,7 +785,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:730: checking for $ac_word" >&5 +echo "configure:789: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -777,7 +836,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:781: checking for $ac_word" >&5 +echo "configure:840: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -809,7 +868,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:813: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:872: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -820,12 +879,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 824 "configure" +#line 883 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:829: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:888: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -851,12 +910,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:855: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:914: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:860: checking whether we are using GNU C" >&5 +echo "configure:919: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -865,7 +924,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:869: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:928: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -884,7 +943,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:888: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:947: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -916,7 +975,7 @@ else fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:920: checking how to run the C preprocessor" >&5 +echo "configure:979: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -931,13 +990,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:941: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1000: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -948,13 +1007,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:958: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1017: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -965,13 +1024,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:975: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1034: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -997,13 +1056,13 @@ echo "$ac_t""$CPP" 1>&6 if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:1001: checking whether ${CC-cc} needs -traditional" >&5 +echo "configure:1060: checking whether ${CC-cc} needs -traditional" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_pattern="Autoconf.*'x'" cat > conftest.$ac_ext < Autoconf TIOCGETP @@ -1021,7 +1080,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext < Autoconf TCGETA @@ -1042,12 +1101,13 @@ echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6 fi fi + for ac_prog in 'bison -y' byacc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1051: checking for $ac_word" >&5 +echo "configure:1111: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1077,10 +1137,42 @@ test -n "$YACC" && break done test -n "$YACC" || YACC="yacc" -# Extract the first word of "ranlib", so it can be a program name with args. +# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1144: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +if test -z "$ac_cv_prog_RANLIB"; then +if test -n "$ac_tool_prefix"; then + # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1084: checking for $ac_word" >&5 +echo "configure:1176: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1107,13 +1199,49 @@ else echo "$ac_t""no" 1>&6 fi +else + RANLIB=":" +fi +fi + +# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1211: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_AR" && ac_cv_prog_AR="ar" +fi +fi +AR="$ac_cv_prog_AR" +if test -n "$AR"; then + echo "$ac_t""$AR" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + for ac_prog in ar aal do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1117: checking for $ac_word" >&5 +echo "configure:1245: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1144,8 +1272,141 @@ done test -n "$AR" || AR="ar" +case "$target_os" in + cygwin*) + # Extract the first word of "${ac_tool_prefix}nm", so it can be a program name with args. +set dummy ${ac_tool_prefix}nm; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1281: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_NM'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$NM"; then + ac_cv_prog_NM="$NM" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_NM="${ac_tool_prefix}nm" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_NM" && ac_cv_prog_NM="nm" +fi +fi +NM="$ac_cv_prog_NM" +if test -n "$NM"; then + echo "$ac_t""$NM" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + + + # Extract the first word of "${ac_tool_prefix}dllwrap", so it can be a program name with args. +set dummy ${ac_tool_prefix}dllwrap; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1313: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_DLLWRAP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$DLLWRAP"; then + ac_cv_prog_DLLWRAP="$DLLWRAP" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_DLLWRAP="${ac_tool_prefix}dllwrap" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_DLLWRAP" && ac_cv_prog_DLLWRAP="dllwrap" +fi +fi +DLLWRAP="$ac_cv_prog_DLLWRAP" +if test -n "$DLLWRAP"; then + echo "$ac_t""$DLLWRAP" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + + + # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. +set dummy ${ac_tool_prefix}as; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1345: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$AS"; then + ac_cv_prog_AS="$AS" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_AS="${ac_tool_prefix}as" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_AS" && ac_cv_prog_AS="as" +fi +fi +AS="$ac_cv_prog_AS" +if test -n "$AS"; then + echo "$ac_t""$AS" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + + + # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. +set dummy ${ac_tool_prefix}dlltool; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1377: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$DLLTOOL"; then + ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_DLLTOOL" && ac_cv_prog_DLLTOOL="dlltool" +fi +fi +DLLTOOL="$ac_cv_prog_DLLTOOL" +if test -n "$DLLTOOL"; then + echo "$ac_t""$DLLTOOL" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + + + ;; +esac + echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:1149: checking whether ln -s works" >&5 +echo "configure:1410: checking whether ln -s works" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1166,7 +1427,7 @@ else fi echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:1170: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:1431: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1196,17 +1457,17 @@ fi # checks for UNIX variants that set C preprocessor variables ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6 -echo "configure:1200: checking for minix/config.h" >&5 +echo "configure:1461: checking for minix/config.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1210: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1471: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1245,12 +1506,12 @@ fi echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:1249: checking for Cygwin environment" >&5 +echo "configure:1510: checking for Cygwin environment" >&5 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1526: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -1278,19 +1539,19 @@ echo "$ac_t""$ac_cv_cygwin" 1>&6 CYGWIN= test "$ac_cv_cygwin" = yes && CYGWIN=yes echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:1282: checking for mingw32 environment" >&5 +echo "configure:1543: checking for mingw32 environment" >&5 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1555: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -1309,7 +1570,7 @@ test "$ac_cv_mingw32" = yes && MINGW32=yes echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:1313: checking for executable suffix" >&5 +echo "configure:1574: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1319,7 +1580,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:1323: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:1584: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.o | *.obj) ;; @@ -1340,13 +1601,13 @@ echo "$ac_t""${ac_cv_exeext}" 1>&6 ac_exeext=$EXEEXT echo $ac_n "checking for object suffix""... $ac_c" 1>&6 -echo "configure:1344: checking for object suffix" >&5 +echo "configure:1605: checking for object suffix" >&5 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftest* echo 'int i = 1;' > conftest.$ac_ext -if { (eval echo configure:1350: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1611: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then for ac_file in conftest.*; do case $ac_file in *.c) ;; @@ -1365,7 +1626,7 @@ ac_objext=$ac_cv_objext echo $ac_n "checking size of int""... $ac_c" 1>&6 -echo "configure:1369: checking size of int" >&5 +echo "configure:1630: checking size of int" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1373,7 +1634,7 @@ else ac_cv_sizeof_int=4 else cat > conftest.$ac_ext < main() @@ -1384,7 +1645,7 @@ main() exit(0); } EOF -if { (eval echo configure:1388: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1649: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_int=`cat conftestval` else @@ -1404,7 +1665,7 @@ EOF echo $ac_n "checking size of short""... $ac_c" 1>&6 -echo "configure:1408: checking size of short" >&5 +echo "configure:1669: checking size of short" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1412,7 +1673,7 @@ else ac_cv_sizeof_short=2 else cat > conftest.$ac_ext < main() @@ -1423,7 +1684,7 @@ main() exit(0); } EOF -if { (eval echo configure:1427: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1688: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_short=`cat conftestval` else @@ -1443,7 +1704,7 @@ EOF echo $ac_n "checking size of long""... $ac_c" 1>&6 -echo "configure:1447: checking size of long" >&5 +echo "configure:1708: checking size of long" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1451,7 +1712,7 @@ else ac_cv_sizeof_long=4 else cat > conftest.$ac_ext < main() @@ -1462,7 +1723,7 @@ main() exit(0); } EOF -if { (eval echo configure:1466: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1727: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_long=`cat conftestval` else @@ -1482,7 +1743,7 @@ EOF echo $ac_n "checking size of void*""... $ac_c" 1>&6 -echo "configure:1486: checking size of void*" >&5 +echo "configure:1747: checking size of void*" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_voidp'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1490,7 +1751,7 @@ else ac_cv_sizeof_voidp=4 else cat > conftest.$ac_ext < main() @@ -1501,7 +1762,7 @@ main() exit(0); } EOF -if { (eval echo configure:1505: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1766: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_voidp=`cat conftestval` else @@ -1521,7 +1782,7 @@ EOF echo $ac_n "checking size of float""... $ac_c" 1>&6 -echo "configure:1525: checking size of float" >&5 +echo "configure:1786: checking size of float" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_float'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1529,7 +1790,7 @@ else ac_cv_sizeof_float=4 else cat > conftest.$ac_ext < main() @@ -1540,7 +1801,7 @@ main() exit(0); } EOF -if { (eval echo configure:1544: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1805: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_float=`cat conftestval` else @@ -1560,7 +1821,7 @@ EOF echo $ac_n "checking size of double""... $ac_c" 1>&6 -echo "configure:1564: checking size of double" >&5 +echo "configure:1825: checking size of double" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_double'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1568,7 +1829,7 @@ else ac_cv_sizeof_double=8 else cat > conftest.$ac_ext < main() @@ -1579,7 +1840,7 @@ main() exit(0); } EOF -if { (eval echo configure:1583: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1844: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_double=`cat conftestval` else @@ -1600,19 +1861,19 @@ EOF echo $ac_n "checking for prototypes""... $ac_c" 1>&6 -echo "configure:1604: checking for prototypes" >&5 +echo "configure:1865: checking for prototypes" >&5 if eval "test \"`echo '$''{'rb_cv_have_prototypes'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1877: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* rb_cv_have_prototypes=yes else @@ -1633,19 +1894,19 @@ EOF fi echo $ac_n "checking token paste string""... $ac_c" 1>&6 -echo "configure:1637: checking token paste string" >&5 +echo "configure:1898: checking token paste string" >&5 if eval "test \"`echo '$''{'rb_cv_tokenpaste'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1910: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* rb_cv_tokenpaste=ansi else @@ -1671,12 +1932,12 @@ EOF fi echo $ac_n "checking for variable length prototypes and stdarg.h""... $ac_c" 1>&6 -echo "configure:1675: checking for variable length prototypes and stdarg.h" >&5 +echo "configure:1936: checking for variable length prototypes and stdarg.h" >&5 if eval "test \"`echo '$''{'rb_cv_stdarg'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -1693,7 +1954,7 @@ int main() { return foo(10, "", 3.14); ; return 0; } EOF -if { (eval echo configure:1697: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1958: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* rb_cv_stdarg=yes else @@ -1714,19 +1975,19 @@ EOF fi echo $ac_n "checking for gcc attribute noreturn""... $ac_c" 1>&6 -echo "configure:1718: checking for gcc attribute noreturn" >&5 +echo "configure:1979: checking for gcc attribute noreturn" >&5 if eval "test \"`echo '$''{'rb_cv_have_attr_noreturn'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1991: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* rb_cv_have_attr_noreturn=yes else @@ -1756,7 +2017,7 @@ cygwin*) ;; *) LIBS="-lm $LIBS";; esac echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6 -echo "configure:1760: checking for crypt in -lcrypt" >&5 +echo "configure:2021: checking for crypt in -lcrypt" >&5 ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1764,7 +2025,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lcrypt $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2040: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1803,7 +2064,7 @@ else fi echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 -echo "configure:1807: checking for dlopen in -ldl" >&5 +echo "configure:2068: checking for dlopen in -ldl" >&5 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1811,7 +2072,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2087: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1850,7 +2111,7 @@ else fi # Dynamic linking for SunOS/Solaris and SYSV echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6 -echo "configure:1854: checking for shl_load in -ldld" >&5 +echo "configure:2115: checking for shl_load in -ldld" >&5 ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1858,7 +2119,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldld $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2134: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1897,7 +2158,7 @@ else fi # Dynamic linking for HP-UX echo $ac_n "checking for setlocale in -lxpg4""... $ac_c" 1>&6 -echo "configure:1901: checking for setlocale in -lxpg4" >&5 +echo "configure:2162: checking for setlocale in -lxpg4" >&5 ac_lib_var=`echo xpg4'_'setlocale | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1905,7 +2166,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lxpg4 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2181: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1949,12 +2210,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 -echo "configure:1953: checking for $ac_hdr that defines DIR" >&5 +echo "configure:2214: checking for $ac_hdr that defines DIR" >&5 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_hdr> @@ -1962,7 +2223,7 @@ int main() { DIR *dirp = 0; ; return 0; } EOF -if { (eval echo configure:1966: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2227: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "ac_cv_header_dirent_$ac_safe=yes" else @@ -1987,7 +2248,7 @@ done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 -echo "configure:1991: checking for opendir in -ldir" >&5 +echo "configure:2252: checking for opendir in -ldir" >&5 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1995,7 +2256,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldir $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2271: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2028,7 +2289,7 @@ fi else echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 -echo "configure:2032: checking for opendir in -lx" >&5 +echo "configure:2293: checking for opendir in -lx" >&5 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2036,7 +2297,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lx $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2312: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2070,12 +2331,12 @@ fi fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:2074: checking for ANSI C header files" >&5 +echo "configure:2335: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2083,7 +2344,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2087: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2348: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2100,7 +2361,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -2118,7 +2379,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -2139,7 +2400,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -2150,7 +2411,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:2154: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2415: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -2174,12 +2435,12 @@ EOF fi echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 -echo "configure:2178: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo "configure:2439: checking for sys/wait.h that is POSIX.1 compatible" >&5 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2195,7 +2456,7 @@ wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } EOF -if { (eval echo configure:2199: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2460: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_sys_wait_h=yes else @@ -2221,17 +2482,17 @@ for ac_hdr in stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h\ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2225: checking for $ac_hdr" >&5 +echo "configure:2486: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2235: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2496: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2259,12 +2520,12 @@ done echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6 -echo "configure:2263: checking for uid_t in sys/types.h" >&5 +echo "configure:2524: checking for uid_t in sys/types.h" >&5 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF @@ -2293,12 +2554,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:2297: checking for size_t" >&5 +echo "configure:2558: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -2326,12 +2587,12 @@ EOF fi echo $ac_n "checking for st_blksize in struct stat""... $ac_c" 1>&6 -echo "configure:2330: checking for st_blksize in struct stat" >&5 +echo "configure:2591: checking for st_blksize in struct stat" >&5 if eval "test \"`echo '$''{'ac_cv_struct_st_blksize'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2339,7 +2600,7 @@ int main() { struct stat s; s.st_blksize; ; return 0; } EOF -if { (eval echo configure:2343: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2604: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_st_blksize=yes else @@ -2361,12 +2622,12 @@ fi save_LIBOJBS="$LIBOBJS" echo $ac_n "checking for st_blocks in struct stat""... $ac_c" 1>&6 -echo "configure:2365: checking for st_blocks in struct stat" >&5 +echo "configure:2626: checking for st_blocks in struct stat" >&5 if eval "test \"`echo '$''{'ac_cv_struct_st_blocks'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2374,7 +2635,7 @@ int main() { struct stat s; s.st_blocks; ; return 0; } EOF -if { (eval echo configure:2378: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2639: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_st_blocks=yes else @@ -2398,12 +2659,12 @@ fi LIBOBJS="$save_LIBOBJS" echo $ac_n "checking for st_rdev in struct stat""... $ac_c" 1>&6 -echo "configure:2402: checking for st_rdev in struct stat" >&5 +echo "configure:2663: checking for st_rdev in struct stat" >&5 if eval "test \"`echo '$''{'ac_cv_struct_st_rdev'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2411,7 +2672,7 @@ int main() { struct stat s; s.st_rdev; ; return 0; } EOF -if { (eval echo configure:2415: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2676: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_st_rdev=yes else @@ -2433,7 +2694,7 @@ fi echo $ac_n "checking type of array argument to getgroups""... $ac_c" 1>&6 -echo "configure:2437: checking type of array argument to getgroups" >&5 +echo "configure:2698: checking type of array argument to getgroups" >&5 if eval "test \"`echo '$''{'ac_cv_type_getgroups'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2441,7 +2702,7 @@ else ac_cv_type_getgroups=cross else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2731: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_type_getgroups=gid_t else @@ -2480,7 +2741,7 @@ fi if test $ac_cv_type_getgroups = cross; then cat > conftest.$ac_ext < EOF @@ -2504,12 +2765,12 @@ EOF echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:2508: checking return type of signal handlers" >&5 +echo "configure:2769: checking return type of signal handlers" >&5 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2526,7 +2787,7 @@ int main() { int i; ; return 0; } EOF -if { (eval echo configure:2530: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2791: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else @@ -2547,19 +2808,19 @@ EOF # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 -echo "configure:2551: checking for working alloca.h" >&5 +echo "configure:2812: checking for working alloca.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:2563: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2824: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_header_alloca_h=yes else @@ -2580,12 +2841,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:2584: checking for alloca" >&5 +echo "configure:2845: checking for alloca" >&5 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_alloca_works=yes else @@ -2645,12 +2906,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:2649: checking whether alloca needs Cray hooks" >&5 +echo "configure:2910: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2679: checking for $ac_func" >&5 +echo "configure:2940: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2968: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2730,7 +2991,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:2734: checking stack direction for C alloca" >&5 +echo "configure:2995: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2738,7 +2999,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3022: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 else @@ -2779,12 +3040,12 @@ EOF fi echo $ac_n "checking for pid_t""... $ac_c" 1>&6 -echo "configure:2783: checking for pid_t" >&5 +echo "configure:3044: checking for pid_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -2813,17 +3074,17 @@ fi ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for vfork.h""... $ac_c" 1>&6 -echo "configure:2817: checking for vfork.h" >&5 +echo "configure:3078: checking for vfork.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2827: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3088: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2848,18 +3109,18 @@ else fi echo $ac_n "checking for working vfork""... $ac_c" 1>&6 -echo "configure:2852: checking for working vfork" >&5 +echo "configure:3113: checking for working vfork" >&5 if eval "test \"`echo '$''{'ac_cv_func_vfork_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then echo $ac_n "checking for vfork""... $ac_c" 1>&6 -echo "configure:2858: checking for vfork" >&5 +echo "configure:3119: checking for vfork" >&5 if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3147: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_vfork=yes" else @@ -2904,7 +3165,7 @@ fi ac_cv_func_vfork_works=$ac_cv_func_vfork else cat > conftest.$ac_ext < @@ -2999,7 +3260,7 @@ main() { } } EOF -if { (eval echo configure:3003: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3264: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_vfork_works=yes else @@ -3022,7 +3283,7 @@ EOF fi echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6 -echo "configure:3026: checking for 8-bit clean memcmp" >&5 +echo "configure:3287: checking for 8-bit clean memcmp" >&5 if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3030,7 +3291,7 @@ else ac_cv_func_memcmp_clean=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3305: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_memcmp_clean=yes else @@ -3062,12 +3323,12 @@ for ac_func in dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\ isinf isnan finite do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3066: checking for $ac_func" >&5 +echo "configure:3327: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3355: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3123,12 +3384,12 @@ for ac_func in fmod killpg drand48 random wait4 waitpid syscall getcwd\ dlopen sigprocmask sigaction _setjmp setsid getrlimit do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3127: checking for $ac_func" >&5 +echo "configure:3388: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3416: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3176,12 +3437,12 @@ fi done echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 -echo "configure:3180: checking whether struct tm is in sys/time.h or time.h" >&5 +echo "configure:3441: checking whether struct tm is in sys/time.h or time.h" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -3189,7 +3450,7 @@ int main() { struct tm *tp; tp->tm_sec; ; return 0; } EOF -if { (eval echo configure:3193: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3454: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm=time.h else @@ -3210,12 +3471,12 @@ EOF fi echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6 -echo "configure:3214: checking for tm_zone in struct tm" >&5 +echo "configure:3475: checking for tm_zone in struct tm" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm_zone'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_cv_struct_tm> @@ -3223,7 +3484,7 @@ int main() { struct tm tm; tm.tm_zone; ; return 0; } EOF -if { (eval echo configure:3227: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3488: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm_zone=yes else @@ -3243,12 +3504,12 @@ EOF else echo $ac_n "checking for tzname""... $ac_c" 1>&6 -echo "configure:3247: checking for tzname" >&5 +echo "configure:3508: checking for tzname" >&5 if eval "test \"`echo '$''{'ac_cv_var_tzname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #ifndef tzname /* For SGI. */ @@ -3258,7 +3519,7 @@ int main() { atoi(*tzname); ; return 0; } EOF -if { (eval echo configure:3262: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3523: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_var_tzname=yes else @@ -3281,14 +3542,14 @@ fi if test "$ac_cv_func_strftime" = no; then cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3553: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_DAYLIGHT 1 @@ -3308,7 +3569,7 @@ EOF else echo $ac_n "checking for BSD signal semantics""... $ac_c" 1>&6 -echo "configure:3312: checking for BSD signal semantics" >&5 +echo "configure:3573: checking for BSD signal semantics" >&5 if eval "test \"`echo '$''{'rb_cv_bsd_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3316,7 +3577,7 @@ else rb_cv_bsd_signal=no else cat > conftest.$ac_ext < @@ -3338,7 +3599,7 @@ main() } EOF -if { (eval echo configure:3342: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3603: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then rb_cv_bsd_signal=yes else @@ -3362,7 +3623,7 @@ EOF fi echo $ac_n "checking whether getpgrp takes no argument""... $ac_c" 1>&6 -echo "configure:3366: checking whether getpgrp takes no argument" >&5 +echo "configure:3627: checking whether getpgrp takes no argument" >&5 if eval "test \"`echo '$''{'ac_cv_func_getpgrp_void'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3370,7 +3631,7 @@ else { echo "configure: error: cannot check getpgrp if cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3690: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_getpgrp_void=yes else @@ -3449,7 +3710,7 @@ EOF fi echo $ac_n "checking whether setpgrp takes no argument""... $ac_c" 1>&6 -echo "configure:3453: checking whether setpgrp takes no argument" >&5 +echo "configure:3714: checking whether setpgrp takes no argument" >&5 if eval "test \"`echo '$''{'ac_cv_func_setpgrp_void'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3457,7 +3718,7 @@ else { echo "configure: error: cannot check setpgrp if cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3742: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_setpgrp_void=no else @@ -3502,7 +3763,7 @@ fi echo $ac_n "checking for working strtod""... $ac_c" 1>&6 -echo "configure:3506: checking for working strtod" >&5 +echo "configure:3767: checking for working strtod" >&5 if eval "test \"`echo '$''{'rb_cv_func_strtod'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3510,7 +3771,7 @@ else rb_cv_func_strtod=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3805: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then rb_cv_func_strtod=yes else @@ -3558,14 +3819,14 @@ echo "$ac_t""$rb_cv_func_strtod" 1>&6 test $rb_cv_func_strtod = no && LIBOBJS="$LIBOBJS strtod.o" echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6 -echo "configure:3562: checking whether byte ordering is bigendian" >&5 +echo "configure:3823: checking whether byte ordering is bigendian" >&5 if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_bigendian=unknown # See if sys/param.h defines the BYTE_ORDER macro. cat > conftest.$ac_ext < #include @@ -3576,11 +3837,11 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:3580: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3841: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* # It does; now see whether it defined to BIG_ENDIAN or not. cat > conftest.$ac_ext < #include @@ -3591,7 +3852,7 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:3595: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3856: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_bigendian=yes else @@ -3611,7 +3872,7 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3889: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_bigendian=no else @@ -3648,12 +3909,12 @@ EOF fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:3652: checking for working const" >&5 +echo "configure:3913: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3967: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -3723,14 +3984,14 @@ EOF fi echo $ac_n "checking whether char is unsigned""... $ac_c" 1>&6 -echo "configure:3727: checking whether char is unsigned" >&5 +echo "configure:3988: checking whether char is unsigned" >&5 if eval "test \"`echo '$''{'ac_cv_c_char_unsigned'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$GCC" = yes; then # GCC predefines this symbol on systems where it applies. cat > conftest.$ac_ext <&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4027: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_char_unsigned=yes else @@ -3787,7 +4048,7 @@ fi echo $ac_n "checking whether right shift preserve sign bit""... $ac_c" 1>&6 -echo "configure:3791: checking whether right shift preserve sign bit" >&5 +echo "configure:4052: checking whether right shift preserve sign bit" >&5 if eval "test \"`echo '$''{'rb_cv_rshift_sign'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3795,7 +4056,7 @@ else rb_cv_rshift_sign=yes else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4072: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then rb_cv_rshift_sign=yes else @@ -3835,19 +4096,19 @@ EOF fi echo $ac_n "checking count field in FILE structures""... $ac_c" 1>&6 -echo "configure:3839: checking count field in FILE structures" >&5 +echo "configure:4100: checking count field in FILE structures" >&5 if eval "test \"`echo '$''{'rb_cv_fcnt'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { FILE *f = stdin; f->_cnt = 0; ; return 0; } EOF -if { (eval echo configure:3851: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4112: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* rb_cv_fcnt="_cnt" else @@ -3857,14 +4118,14 @@ fi rm -f conftest* if test "$rb_cv_fcnt" = ""; then cat > conftest.$ac_ext < int main() { FILE *f = stdin; f->__cnt = 0; ; return 0; } EOF -if { (eval echo configure:3868: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4129: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* rb_cv_fcnt="__cnt" else @@ -3875,14 +4136,14 @@ rm -f conftest* fi if test "$rb_cv_fcnt" = ""; then cat > conftest.$ac_ext < int main() { FILE *f = stdin; f->_r = 0; ; return 0; } EOF -if { (eval echo configure:3886: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4147: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* rb_cv_fcnt="_r" else @@ -3893,14 +4154,14 @@ rm -f conftest* fi if test "$rb_cv_fcnt" = ""; then cat > conftest.$ac_ext < int main() { FILE *f = stdin; f->readCount = 0; ; return 0; } EOF -if { (eval echo configure:3904: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4165: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* rb_cv_fcnt="readCount" else @@ -3911,14 +4172,14 @@ rm -f conftest* fi if test "$rb_cv_fcnt" = ""; then cat > conftest.$ac_ext < int main() { FILE *f = stdin; f->_rcount = 0; ; return 0; } EOF -if { (eval echo configure:3922: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4183: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* rb_cv_fcnt="_rcount" else @@ -3949,19 +4210,23 @@ if test "${with_default_kcode+set}" = set; then utf8) cat >> confdefs.h <<\EOF #define DEFAULT_KCODE KCODE_UTF8 EOF -;; + + DEFAULT_KCODE="KCODE_UTF8";; euc) cat >> confdefs.h <<\EOF #define DEFAULT_KCODE KCODE_EUC EOF -;; + + DEFAULT_KCODE="KCODE_EUC";; sjis) cat >> confdefs.h <<\EOF #define DEFAULT_KCODE KCODE_SJIS EOF -;; + + DEFAULT_KCODE="KCODE_SJIS";; none) cat >> confdefs.h <<\EOF #define DEFAULT_KCODE KCODE_NONE EOF -;; + + DEFAULT_KCODE="KCODE_NONE";; *) echo "configure: warning: $withval is not valid kcode; ignored" 1>&2;; esac fi @@ -3981,10 +4246,8 @@ fi -case "$target_os" in - linux*) - echo $ac_n "checking whether ELF binaries are produced""... $ac_c" 1>&6 -echo "configure:3988: checking whether ELF binaries are produced" >&5 +echo $ac_n "checking whether ELF binaries are produced""... $ac_c" 1>&6 +echo "configure:4251: checking whether ELF binaries are produced" >&5 if eval "test \"`echo '$''{'rb_cv_binary_elf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3992,7 +4255,7 @@ else rb_cv_binary_elf=yes else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4279: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then rb_cv_binary_elf=yes else @@ -4027,12 +4290,30 @@ fi fi echo "$ac_t""$rb_cv_binary_elf" 1>&6 + +if test "$rb_cv_binary_elf" = yes; then + cat >> confdefs.h <<\EOF +#define USE_ELF 1 +EOF + +fi + +case "$target_os" in + linux*) if test "$rb_cv_binary_elf" = no; then with_dln_a_out=yes target_os=${target_os}-a_out else LDFLAGS="-rdynamic" fi;; +netbsd*) + if [ "`$CC -dM -E - &6 -echo "configure:4046: checking whether OS depend dynamic link works" >&5 +echo "configure:4327: checking whether OS depend dynamic link works" >&5 if test "$GCC" = yes; then case "$target_os" in nextstep*) ;; @@ -4093,20 +4374,17 @@ echo "configure:4046: checking whether OS depend dynamic link works" >&5 linux*) LDSHARED="$CC -shared" rb_cv_dlopen=yes ;; freebsd*) LDSHARED="$CC -shared" - if test -x /usr/bin/objformat && \ - test `/usr/bin/objformat` = "elf" ; then + if test "$rb_cv_binary_elf" = yes; then LDFLAGS="-rdynamic" DLDFLAGS='-Wl,-soname,$(.TARGET)' - rb_cv_freebsd_elf=yes else test "$GCC" = yes && `$CC --print-prog-name=ld` -v 2>&1 | grep "GNU ld" > /dev/null || LDSHARED="ld -Bshareable" fi rb_cv_dlopen=yes ;; - netbsd*) LDSHARED="ld -shared" - case "$target_cpu" in - alpha) - LDFLAGS="-export-dynamic" ;; - esac + netbsd*) LDSHARED="ld -shared" + if test "$rb_cv_binary_elf" = yes; then + LDFLAGS="-export-dynamic" + fi rb_cv_dlopen=yes ;; openbsd*) LDSHARED="ld -Bforcearchive -Bshareable" rb_cv_dlopen=yes ;; @@ -4151,7 +4429,7 @@ echo "configure:4046: checking whether OS depend dynamic link works" >&5 DLDFLAGS="ruby.def -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o" esac rb_cv_dlopen=yes ;; - cygwin*) : ${LDSHARED='dllwrap --export-all -s'} + cygwin*) : ${LDSHARED="${DLLWRAP} --as=${AS} --dlltool-name=${DLLTOOL} --driver-name=${CC} --export-all -s"} rb_cv_dlopen=yes ;; *) LDSHARED='ld' ;; esac @@ -4163,12 +4441,12 @@ if test "$ac_cv_header_a_out_h" = yes; then if test "$with_dln_a_out" = yes || test "$rb_cv_dlopen" = unknown; then cat confdefs.h > config.h echo $ac_n "checking whether matz's dln works""... $ac_c" 1>&6 -echo "configure:4167: checking whether matz's dln works" >&5 +echo "configure:4445: checking whether matz's dln works" >&5 if eval "test \"`echo '$''{'rb_cv_dln_a_out'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4460: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* rb_cv_dln_a_out=yes else @@ -4285,7 +4563,7 @@ fi case "$target_os" in human*) echo $ac_n "checking for _harderr in -lsignal""... $ac_c" 1>&6 -echo "configure:4289: checking for _harderr in -lsignal" >&5 +echo "configure:4567: checking for _harderr in -lsignal" >&5 ac_lib_var=`echo signal'_'_harderr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4293,7 +4571,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsignal $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4586: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4332,7 +4610,7 @@ else fi echo $ac_n "checking for hmemset in -lhmem""... $ac_c" 1>&6 -echo "configure:4336: checking for hmemset in -lhmem" >&5 +echo "configure:4614: checking for hmemset in -lhmem" >&5 ac_lib_var=`echo hmem'_'hmemset | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4340,7 +4618,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lhmem $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4633: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4381,12 +4659,12 @@ fi for ac_func in select gettimeofday do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4385: checking for $ac_func" >&5 +echo "configure:4663: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4691: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4434,7 +4712,7 @@ fi done echo $ac_n "checking whether PD libc _dtos18 fail to convert big number""... $ac_c" 1>&6 -echo "configure:4438: checking whether PD libc _dtos18 fail to convert big number" >&5 +echo "configure:4716: checking whether PD libc _dtos18 fail to convert big number" >&5 if eval "test \"`echo '$''{'rb_cv_missing__dtos18'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4442,7 +4720,7 @@ else rb_cv_missing__dtos18=no else cat > conftest.$ac_ext < @@ -4454,7 +4732,7 @@ main () } EOF -if { (eval echo configure:4458: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4736: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then rb_cv_missing__dtos18=yes else @@ -4476,7 +4754,7 @@ EOF fi echo $ac_n "checking whether PD libc fconvert fail to round""... $ac_c" 1>&6 -echo "configure:4480: checking whether PD libc fconvert fail to round" >&5 +echo "configure:4758: checking whether PD libc fconvert fail to round" >&5 if eval "test \"`echo '$''{'rb_cv_missing_fconvert'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4484,7 +4762,7 @@ else rb_cv_missing_fconvert=no else cat > conftest.$ac_ext < @@ -4497,7 +4775,7 @@ main () } EOF -if { (eval echo configure:4501: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4779: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then rb_cv_missing_fconvert=yes else @@ -4605,18 +4883,18 @@ if test "$enable_shared" = 'yes'; then ;; freebsd*) LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR)$(MINOR)' - if test "$rb_cv_freebsd_elf" != "yes" ; then + if test "$rb_cv_binary_elf" != "yes" ; then LIBRUBY_SO="$LIBRUBY_SO.\$(TEENY)" LIBRUBY_ALIASES='' fi ;; netbsd*) LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR)' - case "$target_cpu" in - alpha|mipsel|mipseb|powerpc|sparc64) # ELF platforms - LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR) lib$(RUBY_INSTALL_NAME).so' ;; - *) LIBRUBY_ALIASES= ;; # a.out platforms - esac + if test "$rb_cv_binary_elf" = yes; then # ELF platforms + LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR) lib$(RUBY_INSTALL_NAME).so' + else + LIBRUBY_ALIASES= # a.out platforms + fi ;; solaris*) XLDFLAGS='-R${prefix}/lib' @@ -4645,10 +4923,6 @@ if test "$enable_shared" = 'yes'; then FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in LIBOBJS="$LIBOBJS strftime.o" CCDLFLAGS=-DUSEIMPORTLIB - : ${NM=nm} - - : ${DLLWRAP=dllwrap} - ;; *) ;; @@ -4906,11 +5180,20 @@ s%@target_alias@%$target_alias%g s%@target_cpu@%$target_cpu%g s%@target_vendor@%$target_vendor%g s%@target_os@%$target_os%g +s%@build@%$build%g +s%@build_alias@%$build_alias%g +s%@build_cpu@%$build_cpu%g +s%@build_vendor@%$build_vendor%g +s%@build_os@%$build_os%g s%@CC@%$CC%g s%@CPP@%$CPP%g s%@YACC@%$YACC%g s%@RANLIB@%$RANLIB%g s%@AR@%$AR%g +s%@NM@%$NM%g +s%@DLLWRAP@%$DLLWRAP%g +s%@AS@%$AS%g +s%@DLLTOOL@%$DLLTOOL%g s%@LN_S@%$LN_S%g s%@SET_MAKE@%$SET_MAKE%g s%@EXEEXT@%$EXEEXT%g @@ -4929,8 +5212,6 @@ s%@EXTSTATIC@%$EXTSTATIC%g s%@setup@%$setup%g s%@MINIRUBY@%$MINIRUBY%g s%@PREP@%$PREP%g -s%@NM@%$NM%g -s%@DLLWRAP@%$DLLWRAP%g s%@LIBRUBY_LDSHARED@%$LIBRUBY_LDSHARED%g s%@LIBRUBY_DLDFLAGS@%$LIBRUBY_DLDFLAGS%g s%@RUBY_INSTALL_NAME@%$RUBY_INSTALL_NAME%g diff --git a/configure.in b/configure.in index 54cb416e4f..69ef552e44 100644 --- a/configure.in +++ b/configure.in @@ -68,13 +68,27 @@ fi AC_ARG_PROGRAM dnl Checks for programs. + +if test x"${build}" != x"${host}"; then + AC_CHECK_TOOL(CC, gcc) +fi AC_PROG_CC AC_PROG_GCC_TRADITIONAL + AC_PROG_YACC -AC_PROG_RANLIB -AC_SUBST(AR) +AC_CHECK_TOOL(RANLIB, ranlib, :) +AC_CHECK_TOOL(AR, ar) AC_CHECK_PROGS(AR, ar aal, ar) +case "$target_os" in + cygwin*) + AC_CHECK_TOOL(NM, nm) + AC_CHECK_TOOL(DLLWRAP, dllwrap) + AC_CHECK_TOOL(AS, as) + AC_CHECK_TOOL(DLLTOOL, dlltool) + ;; +esac + AC_PROG_LN_S AC_PROG_MAKE_SET @@ -310,10 +324,14 @@ AC_SUBST(DEFAULT_KCODE) AC_ARG_WITH(default-kcode, [--with-default-kcode=CODE specify default value for \$KCODE (utf8|euc|sjis|none)], [case $withval in - utf8) AC_DEFINE(DEFAULT_KCODE, KCODE_UTF8);; - euc) AC_DEFINE(DEFAULT_KCODE, KCODE_EUC);; - sjis) AC_DEFINE(DEFAULT_KCODE, KCODE_SJIS);; - none) AC_DEFINE(DEFAULT_KCODE, KCODE_NONE);; + utf8) AC_DEFINE(DEFAULT_KCODE, KCODE_UTF8) + DEFAULT_KCODE="KCODE_UTF8";; + euc) AC_DEFINE(DEFAULT_KCODE, KCODE_EUC) + DEFAULT_KCODE="KCODE_EUC";; + sjis) AC_DEFINE(DEFAULT_KCODE, KCODE_SJIS) + DEFAULT_KCODE="KCODE_SJIS";; + none) AC_DEFINE(DEFAULT_KCODE, KCODE_NONE) + DEFAULT_KCODE="KCODE_NONE";; *) AC_MSG_WARN($withval is not valid kcode; ignored);; esac]) @@ -327,10 +345,8 @@ AC_ARG_WITH(dln-a-out, AC_SUBST(XLDFLAGS)dnl -case "$target_os" in - linux*) - AC_CACHE_CHECK(whether ELF binaries are produced, rb_cv_binary_elf, - [AC_TRY_RUN([ +AC_CACHE_CHECK(whether ELF binaries are produced, rb_cv_binary_elf, +[AC_TRY_RUN([ /* Test for whether ELF binaries are produced */ #include #include @@ -347,15 +363,30 @@ main() { exit(0); /* succeed (yes, it's ELF) */ } ], - rb_cv_binary_elf=yes, - rb_cv_binary_elf=no, - rb_cv_binary_elf=yes)]) +rb_cv_binary_elf=yes, +rb_cv_binary_elf=no, +rb_cv_binary_elf=yes)]) + +if test "$rb_cv_binary_elf" = yes; then + AC_DEFINE(USE_ELF) +fi + +case "$target_os" in + linux*) if test "$rb_cv_binary_elf" = no; then with_dln_a_out=yes target_os=${target_os}-a_out else LDFLAGS="-rdynamic" fi;; +netbsd*) + if [[ "`$CC -dM -E - &1 | grep "GNU ld" > /dev/null || LDSHARED="ld -Bshareable" fi rb_cv_dlopen=yes ;; - netbsd*) LDSHARED="ld -shared" - case "$target_cpu" in - alpha) - LDFLAGS="-export-dynamic" ;; - esac + netbsd*) LDSHARED="ld -shared" + if test "$rb_cv_binary_elf" = yes; then + LDFLAGS="-export-dynamic" + fi rb_cv_dlopen=yes ;; openbsd*) LDSHARED="ld -Bforcearchive -Bshareable" rb_cv_dlopen=yes ;; @@ -478,7 +506,7 @@ if test "$with_dln_a_out" != yes; then DLDFLAGS="ruby.def -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o" esac rb_cv_dlopen=yes ;; - cygwin*) : ${LDSHARED='dllwrap --export-all -s'} + cygwin*) : ${LDSHARED="${DLLWRAP} --as=${AS} --dlltool-name=${DLLTOOL} --driver-name=${CC} --export-all -s"} rb_cv_dlopen=yes ;; *) LDSHARED='ld' ;; esac @@ -687,18 +715,18 @@ if test "$enable_shared" = 'yes'; then ;; freebsd*) LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR)$(MINOR)' - if test "$rb_cv_freebsd_elf" != "yes" ; then + if test "$rb_cv_binary_elf" != "yes" ; then LIBRUBY_SO="$LIBRUBY_SO.\$(TEENY)" LIBRUBY_ALIASES='' fi ;; netbsd*) LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR)' - case "$target_cpu" in - alpha|mipsel|mipseb|powerpc|sparc64) # ELF platforms - LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR) lib$(RUBY_INSTALL_NAME).so' ;; - *) LIBRUBY_ALIASES= ;; # a.out platforms - esac + if test "$rb_cv_binary_elf" = yes; then # ELF platforms + LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR) lib$(RUBY_INSTALL_NAME).so' + else + LIBRUBY_ALIASES= # a.out platforms + fi ;; solaris*) XLDFLAGS='-R${prefix}/lib' @@ -727,10 +755,6 @@ if test "$enable_shared" = 'yes'; then FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in LIBOBJS="$LIBOBJS strftime.o" CCDLFLAGS=-DUSEIMPORTLIB - : ${NM=nm} - AC_SUBST(NM) - : ${DLLWRAP=dllwrap} - AC_SUBST(DLLWRAP) ;; *) ;; diff --git a/defines.h b/defines.h index 5690eff34c..fc3994b67e 100644 --- a/defines.h +++ b/defines.h @@ -55,11 +55,15 @@ #endif #define PATH_SEP_CHAR PATH_SEP[0] -#if defined(__human68k__) || defined(__CYGWIN__) +#if defined(__human68k__) #undef HAVE_RANDOM #undef HAVE_SETITIMER #endif +#if defined(__CYGWIN__) || defined(DJGPP) || defined(__BOW__) +#undef HAVE_SETITIMER +#endif + #ifndef RUBY_PLATFORM #define RUBY_PLATFORM "unknown-unknown" #endif diff --git a/dir.c b/dir.c index 47c2de272e..f94ce60ed1 100644 --- a/dir.c +++ b/dir.c @@ -510,7 +510,7 @@ extract_path(p, pend) len = pend - p; alloc = ALLOC_N(char, len+1); memcpy(alloc, p, len); - if (len > 0 && pend[-1] == '/') { + if (len > 1 && pend[-1] == '/') { alloc[len-1] = 0; } else { @@ -584,19 +584,21 @@ glob(path, func, arg) free(base); break; } +#define BASE (*base && !(*base == '/' && !base[1])) + for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { if (recursive) { if (strcmp(".", dp->d_name) == 0 || strcmp("..", dp->d_name) == 0) continue; buf = ALLOC_N(char, strlen(base)+NAMLEN(dp)+strlen(m)+6); - sprintf(buf, "%s%s%s/**%s", base, (*base)?"/":"", dp->d_name, m); + sprintf(buf, "%s%s%s/**%s", base, (BASE)?"/":"", dp->d_name, m); glob(buf, func, arg); free(buf); continue; } if (fnmatch(magic, dp->d_name, FNM_PERIOD|FNM_PATHNAME) == 0) { buf = ALLOC_N(char, strlen(base)+NAMLEN(dp)+2); - sprintf(buf, "%s%s%s", base, (*base)?"/":"", dp->d_name); + sprintf(buf, "%s%s%s", base, (BASE)?"/":"", dp->d_name); if (!m) { (*func)(buf, arg); free(buf); diff --git a/dln.c b/dln.c index a30c7c1251..10ea423643 100644 --- a/dln.c +++ b/dln.c @@ -80,7 +80,7 @@ int eaccess(); #endif #ifndef FUNCNAME_PATTERN -# if defined(__hp9000s300) || (defined(__NetBSD__) && (!defined(__alpha__) && !defined(__mips__))) || defined(__BORLANDC__) || (defined(__FreeBSD__) && __FreeBSD__ < 3) || defined(__OpenBSD__) || defined(NeXT) || defined(__WATCOMC__) || defined(__APPLE__) +# if defined(__hp9000s300) || (defined(__NetBSD__) && !defined(__ELF__)) || defined(__BORLANDC__) || (defined(__FreeBSD__) && __FreeBSD__ < 3) || defined(__OpenBSD__) || defined(NeXT) || defined(__WATCOMC__) || defined(__APPLE__) # define FUNCNAME_PATTERN "_Init_%.200s" # else # define FUNCNAME_PATTERN "Init_%.200s" diff --git a/error.c b/error.c index 7959620d69..75b57ffb0e 100644 --- a/error.c +++ b/error.c @@ -239,16 +239,18 @@ VALUE rb_eSignal; VALUE rb_eFatal; VALUE rb_eStandardError; VALUE rb_eRuntimeError; -VALUE rb_eSyntaxError; VALUE rb_eTypeError; VALUE rb_eArgError; -VALUE rb_eNameError; VALUE rb_eIndexError; -VALUE rb_eLoadError; VALUE rb_eSecurityError; VALUE rb_eNotImpError; VALUE rb_eNoMemError; +VALUE rb_eScriptError; +VALUE rb_eNameError; +VALUE rb_eSyntaxError; +VALUE rb_eLoadError; + VALUE rb_eSystemCallError; VALUE rb_mErrno; @@ -533,16 +535,18 @@ Init_Exception() rb_eSignal = rb_define_class("SignalException", rb_eException); rb_eStandardError = rb_define_class("StandardError", rb_eException); - rb_eSyntaxError = rb_define_class("SyntaxError", rb_eStandardError); rb_eTypeError = rb_define_class("TypeError", rb_eStandardError); rb_eArgError = rb_define_class("ArgumentError", rb_eStandardError); - rb_eNameError = rb_define_class("NameError", rb_eStandardError); rb_eIndexError = rb_define_class("IndexError", rb_eStandardError); - rb_eLoadError = rb_define_class("LoadError", rb_eStandardError); + + rb_eScriptError = rb_define_class("ScriptError", rb_eException); + rb_eSyntaxError = rb_define_class("SyntaxError", rb_eScriptError); + rb_eNameError = rb_define_class("NameError", rb_eScriptError); + rb_eLoadError = rb_define_class("LoadError", rb_eScriptError); + rb_eNotImpError = rb_define_class("NotImplementError", rb_eScriptError); rb_eRuntimeError = rb_define_class("RuntimeError", rb_eStandardError); rb_eSecurityError = rb_define_class("SecurityError", rb_eStandardError); - rb_eNotImpError = rb_define_class("NotImplementError", rb_eException); rb_eNoMemError = rb_define_class("NoMemoryError", rb_eException); init_syserr(); @@ -672,6 +676,13 @@ rb_sys_fail(mesg) rb_exc_raise(ee); } +void +rb_error_frozen(what) + char *what; +{ + rb_raise(rb_eTypeError, "can't modify frozen %s", what); +} + static void init_syserr() { diff --git a/eval.c b/eval.c index cbf6d8ceaa..068e7e0ad4 100644 --- a/eval.c +++ b/eval.c @@ -90,7 +90,7 @@ static int scope_vmode; #define SCOPE_SET(f) do {scope_vmode=(f);} while(0) #define SCOPE_TEST(f) (scope_vmode&(f)) -static int safe_level = 0; +int ruby_safe_level = 0; /* safe-level: 0 - strings from streams/environment/ARGV are tainted (default) 1 - no dangerous operation by tainted string @@ -99,25 +99,19 @@ static int safe_level = 0; 4 - no global (non-tainted) variable modification/no direct output */ -int -rb_safe_level() -{ - return safe_level; -} - void rb_set_safe_level(level) int level; { - if (level > safe_level) { - safe_level = level; + if (level > ruby_safe_level) { + ruby_safe_level = level; } } static VALUE safe_getter() { - return INT2FIX(safe_level); + return INT2FIX(ruby_safe_level); } static void @@ -126,18 +120,18 @@ safe_setter(val) { int level = NUM2INT(val); - if (level < safe_level) { + if (level < ruby_safe_level) { rb_raise(rb_eSecurityError, "tried to downgrade safe level from %d to %d", - safe_level, level); + ruby_safe_level, level); } - safe_level = level; + ruby_safe_level = level; } void rb_check_safe_str(x) VALUE x; { - if (safe_level > 0 && OBJ_TAINTED(x)){ + if (ruby_safe_level > 0 && OBJ_TAINTED(x)){ rb_raise(rb_eSecurityError, "Insecure operation - %s", rb_id2name(ruby_frame->last_func)); } @@ -151,9 +145,9 @@ void rb_secure(level) int level; { - if (level <= safe_level) { + if (level <= ruby_safe_level) { rb_raise(rb_eSecurityError, "Insecure operation `%s' for level %d", - rb_id2name(ruby_frame->last_func), safe_level); + rb_id2name(ruby_frame->last_func), ruby_safe_level); } } @@ -225,9 +219,10 @@ rb_add_method(klass, mid, node, noex) if (klass == rb_cObject) { rb_secure(4); } - if (safe_level >= 4 && !OBJ_TAINTED(klass)) { + if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) { rb_raise(rb_eSecurityError, "Insecure: can't define method"); } + if (OBJ_FROZEN(klass)) rb_error_frozen("class/module"); body = NEW_METHOD(node, noex); st_insert(RCLASS(klass)->m_tbl, mid, body); } @@ -306,9 +301,10 @@ remove_method(klass, mid) if (klass == rb_cObject) { rb_secure(4); } - if (safe_level >= 4 && !OBJ_TAINTED(klass)) { + if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) { rb_raise(rb_eSecurityError, "Insecure: can't remove method"); } + if (OBJ_FROZEN(klass)) rb_error_frozen("class/module"); if (!st_delete(RCLASS(klass)->m_tbl, &mid, &body)) { rb_raise(rb_eNameError, "method `%s' not defined in %s", rb_id2name(mid), rb_class2name(klass)); @@ -567,7 +563,7 @@ struct RVarmap *ruby_dyna_vars; ruby_dyna_vars = _old; \ } -#define DVAR_DONT_RECYCLE FL_USER0 +#define DVAR_DONT_RECYCLE FL_USER2 static struct RVarmap* new_dvar(id, value, prev) @@ -597,6 +593,20 @@ rb_dvar_defined(id) return Qfalse; } +VALUE +rb_dvar_curr(id) + ID id; +{ + struct RVarmap *vars = ruby_dyna_vars; + + while (vars) { + if (vars->id == 0) break; + if (vars->id == id) return Qtrue; + vars = vars->next; + } + return Qfalse; +} + VALUE rb_dvar_ref(id) ID id; @@ -621,48 +631,48 @@ rb_dvar_push(id, value) } static void -dvar_asgn(id, value, push) +dvar_asgn_internal(id, value, curr) ID id; VALUE value; - int push; + int curr; { + int n = 0; struct RVarmap *vars = ruby_dyna_vars; while (vars) { - if (push && vars->id == 0) break; + if (curr && vars->id == 0) { + n++; + if (n == 2) break; + } if (vars->id == id) { vars->val = value; return; } vars = vars->next; } - rb_dvar_push(id, value); + if (!ruby_dyna_vars) { + ruby_dyna_vars = new_dvar(id, value, 0); + } + else { + vars = new_dvar(id, value, ruby_dyna_vars->next); + ruby_dyna_vars->next = vars; + } } void -rb_dvar_asgn(id, value) +dvar_asgn(id, value) ID id; VALUE value; { - dvar_asgn(id, value, 0); + dvar_asgn_internal(id, value, 0); } static void -dvar_asgn_push(id, value) +dvar_asgn_curr(id, value) ID id; VALUE value; { - struct RVarmap* vars = 0; - - if (ruby_dyna_vars && ruby_dyna_vars->id == 0) { - vars = ruby_dyna_vars; - ruby_dyna_vars = ruby_dyna_vars->next; - } - dvar_asgn(id, value, 1); - if (vars) { - vars->next = ruby_dyna_vars; - ruby_dyna_vars = vars; - } + dvar_asgn_internal(id, value, 1); } struct iter { @@ -1198,7 +1208,7 @@ rb_eval_cmd(cmd, arg) int state; VALUE val; /* OK */ struct SCOPE *saved_scope; - volatile int safe = safe_level; + volatile int safe = ruby_safe_level; if (TYPE(cmd) != T_STRING) { return rb_funcall2(cmd, rb_intern("call"), @@ -1212,7 +1222,7 @@ rb_eval_cmd(cmd, arg) ruby_class = rb_cObject; if (OBJ_TAINTED(cmd)) { - safe_level = 4; + ruby_safe_level = 4; } if ((state = EXEC_TAG()) == 0) { @@ -1222,7 +1232,7 @@ rb_eval_cmd(cmd, arg) if (FL_TEST(ruby_scope, SCOPE_DONT_RECYCLE)) FL_SET(saved_scope, SCOPE_DONT_RECYCLE); ruby_scope = saved_scope; - safe_level = safe; + ruby_safe_level = safe; POP_TAG(); POP_CLASS(); @@ -1405,9 +1415,10 @@ rb_undef(klass, id) if (ruby_class == rb_cObject) { rb_secure(4); } - if (safe_level >= 4 && !OBJ_TAINTED(klass)) { + if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) { rb_raise(rb_eSecurityError, "Insecure: can't undef"); } + if (OBJ_FROZEN(klass)) rb_error_frozen("class/module"); body = search_method(ruby_class, id, &origin); if (!body || !body->nd_body) { char *s0 = " class"; @@ -1429,7 +1440,6 @@ rb_undef(klass, id) rb_raise(rb_eNameError, "undefined method `%s' for%s `%s'", rb_id2name(id),s0,rb_class2name(c)); } - rb_clear_cache_by_id(id); rb_add_method(klass, id, 0, NOEX_PUBLIC); rb_clear_cache_by_id(id); } @@ -1653,7 +1663,7 @@ is_defined(self, node, buf) case NODE_MASGN: case NODE_LASGN: case NODE_DASGN: - case NODE_DASGN_PUSH: + case NODE_DASGN_CURR: case NODE_GASGN: case NODE_IASGN: case NODE_CASGN: @@ -2466,12 +2476,12 @@ rb_eval(self, node) case NODE_DASGN: result = rb_eval(self, node->nd_value); - rb_dvar_asgn(node->nd_vid, result); + dvar_asgn(node->nd_vid, result); break; - case NODE_DASGN_PUSH: + case NODE_DASGN_CURR: result = rb_eval(self, node->nd_value); - dvar_asgn_push(node->nd_vid, result); + dvar_asgn_curr(node->nd_vid, result); break; case NODE_GASGN: @@ -2709,7 +2719,7 @@ rb_eval(self, node) } body = search_method(ruby_class, node->nd_mid, &origin); if (body){ - if (RTEST(ruby_verbose)) { + if (RTEST(ruby_verbose) && ruby_class == origin) { rb_warning("discarding old %s", rb_id2name(node->nd_mid)); } rb_clear_cache_by_id(node->nd_mid); @@ -2760,12 +2770,13 @@ rb_eval(self, node) rb_class2name(CLASS_OF(recv))); } - if (safe_level >= 4 && !OBJ_TAINTED(recv)) { + if (rb_safe_level() >= 4 && !OBJ_TAINTED(recv)) { rb_raise(rb_eSecurityError, "can't define singleton method"); } + if (OBJ_FROZEN(recv)) rb_error_frozen("object"); klass = rb_singleton_class(recv); if (st_lookup(RCLASS(klass)->m_tbl, node->nd_mid, &body)) { - if (safe_level >= 4) { + if (rb_safe_level() >= 4) { rb_raise(rb_eSecurityError, "re-defining method prohibited"); } if (RTEST(ruby_verbose)) { @@ -2844,16 +2855,17 @@ rb_eval(self, node) tmp = RCLASS(tmp)->super; } if (tmp != super) { - rb_raise(rb_eTypeError, "superclass mismatch for %s", - rb_id2name(node->nd_cname)); + super = tmp; + goto override_class; } } - if (safe_level >= 4) { + if (rb_safe_level() >= 4) { rb_raise(rb_eSecurityError, "extending class prohibited"); } rb_clear_cache(); } else { + override_class: if (!super) super = rb_cObject; klass = rb_define_class_id(node->nd_cname, super); rb_const_set(ruby_class, node->nd_cname, klass); @@ -2892,7 +2904,7 @@ rb_eval(self, node) rb_raise(rb_eTypeError, "%s is not a module", rb_id2name(node->nd_cname)); } - if (safe_level >= 4) { + if (rb_safe_level() >= 4) { rb_raise(rb_eSecurityError, "extending module prohibited"); } } @@ -2919,8 +2931,9 @@ rb_eval(self, node) rb_raise(rb_eTypeError, "no virtual class for %s", rb_class2name(CLASS_OF(klass))); } - if (safe_level >= 4 && !OBJ_TAINTED(klass)) + if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) rb_raise(rb_eSecurityError, "Insecure: can't extend object"); + if (OBJ_FROZEN(klass)) rb_error_frozen("object"); if (FL_TEST(CLASS_OF(klass), FL_SINGLETON)) { rb_clear_cache(); } @@ -3221,10 +3234,13 @@ rb_f_raise(argc, argv) set_backtrace(mesg, (argc>2)?argv[2]:Qnil); } - PUSH_FRAME(); /* fake frame */ - *ruby_frame = *_frame.prev->prev; + if (ruby_frame != top_frame) { + PUSH_FRAME(); /* fake frame */ + *ruby_frame = *_frame.prev->prev; + rb_longjmp(TAG_RAISE, mesg); + POP_FRAME(); + } rb_longjmp(TAG_RAISE, mesg); - POP_FRAME(); return Qnil; /* not reached */ } @@ -3455,11 +3471,11 @@ assign(self, lhs, val, check) break; case NODE_DASGN: - rb_dvar_asgn(lhs->nd_vid, val); + dvar_asgn(lhs->nd_vid, val); break; - case NODE_DASGN_PUSH: - dvar_asgn_push(lhs->nd_vid, val); + case NODE_DASGN_CURR: + dvar_asgn_curr(lhs->nd_vid, val); break; case NODE_CASGN: @@ -3780,7 +3796,7 @@ rb_undefined(obj, id, argc, argv, call_status) } #ifdef DJGPP -# define STACK_LEVEL_MAX 65535 +static int STACK_LEVEL_MAX = 65535; #else #ifdef __human68k__ extern int _stacksize; @@ -4608,7 +4624,7 @@ static VALUE yield_under(under, self) VALUE under, self; { - if (safe_level >= 4 && !OBJ_TAINTED(self)) + if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) rb_raise(rb_eSecurityError, "Insecure: can't eval"); return exec_under(yield_under_i, under, self); } @@ -4842,7 +4858,7 @@ rb_f_require(obj, fname) char *ext, *file, *feature, *buf; /* OK */ volatile VALUE load; int state; - volatile int safe = safe_level; + volatile int safe = ruby_safe_level; Check_SafeStr(fname); if (rb_provided(RSTRING(fname)->ptr)) @@ -4910,7 +4926,7 @@ rb_f_require(obj, fname) return Qtrue; load_rb: - safe_level = 0; + ruby_safe_level = 0; if (rb_thread_loading(feature)) return Qfalse; rb_provide(feature); @@ -4920,7 +4936,7 @@ rb_f_require(obj, fname) } POP_TAG(); rb_thread_loading_done(feature); - safe_level = safe; + ruby_safe_level = safe; if (state) JUMP_TAG(state); return Qtrue; @@ -5588,7 +5604,7 @@ rb_f_binding(self) #define PROC_T3 FL_USER1 #define PROC_T4 FL_USER2 -#define PROC_T5 (FL_USER1|FL_USER2) +#define PROC_TMAX (FL_USER1|FL_USER2) #define PROC_TMASK (FL_USER1|FL_USER2) static void @@ -5596,15 +5612,17 @@ proc_save_safe_level(data) VALUE data; { if (OBJ_TAINTED(data)) { - switch (safe_level) { + switch (rb_safe_level()) { case 3: FL_SET(data, PROC_T3); break; case 4: FL_SET(data, PROC_T4); break; - case 5: - FL_SET(data, PROC_T5); + default: + if (rb_safe_level() > 4) { + FL_SET(data, PROC_TMAX); + } break; } } @@ -5617,13 +5635,13 @@ proc_set_safe_level(data) if (OBJ_TAINTED(data)) { switch (RBASIC(data)->flags & PROC_TMASK) { case PROC_T3: - safe_level = 3; + ruby_safe_level = 3; break; case PROC_T4: - safe_level = 4; + ruby_safe_level = 4; break; - case PROC_T5: - safe_level = 5; + case PROC_TMAX: + ruby_safe_level = 5; break; } } @@ -5695,7 +5713,7 @@ proc_call(proc, args) volatile VALUE result = Qnil; int state; volatile int orphan; - volatile int safe = safe_level; + volatile int safe = ruby_safe_level; Data_Get_Struct(proc, struct BLOCK, data); orphan = blk_orphan(data); @@ -5741,7 +5759,7 @@ proc_call(proc, args) state &= TAG_MASK; } ruby_block = old_block; - safe_level = safe; + ruby_safe_level = safe; if (state) { if (orphan) {/* orphan procedure */ @@ -5799,7 +5817,7 @@ block_pass(self, node) volatile VALUE result = Qnil; int state; volatile int orphan; - volatile int safe = safe_level; + volatile int safe = ruby_safe_level; if (NIL_P(block)) { return rb_eval(self, node->nd_iter); @@ -5836,7 +5854,7 @@ block_pass(self, node) orphan = 2; } ruby_block = old_block; - safe_level = safe; + ruby_safe_level = safe; if (state) { if (orphan == 2) {/* escape from orphan procedure */ @@ -5921,14 +5939,14 @@ method_call(argc, argv, method) VALUE result; struct METHOD *data; int state; - volatile int safe = safe_level; + volatile int safe = ruby_safe_level; Data_Get_Struct(method, struct METHOD, data); PUSH_ITER(rb_iterator_p()?ITER_PRE:ITER_NOT); PUSH_TAG(PROT_NONE); if (OBJ_TAINTED(data->recv) || OBJ_TAINTED(method)) { OBJ_TAINT(method); - if (safe_level < 4) safe_level = 4; + if (ruby_safe_level < 4) ruby_safe_level = 4; } if ((state = EXEC_TAG()) == 0) { result = rb_call0(data->klass, data->recv, data->id, @@ -5936,7 +5954,7 @@ method_call(argc, argv, method) } POP_TAG(); POP_ITER(); - safe_level = safe; + ruby_safe_level = safe; if (state) JUMP_TAG(state); return result; } @@ -6123,6 +6141,7 @@ struct thread { int abort; int priority; + int gid; st_table *locals; @@ -6274,7 +6293,7 @@ rb_thread_save_context(th) th->last_status = rb_last_status; th->last_line = rb_lastline_get(); th->last_match = rb_backref_get(); - th->safe = safe_level; + th->safe = ruby_safe_level; th->file = ruby_sourcefile; th->line = ruby_sourceline; @@ -6341,7 +6360,7 @@ rb_thread_restore_context(th, exit) tracing = th->tracing; ruby_errinfo = th->errinfo; rb_last_status = th->last_status; - safe_level = th->safe; + ruby_safe_level = th->safe; ruby_sourcefile = th->file; ruby_sourceline = th->line; @@ -6599,9 +6618,10 @@ rb_thread_schedule() curr_thread->file = ruby_sourcefile; curr_thread->line = ruby_sourceline; FOREACH_THREAD_FROM(curr, th) { - fprintf(stderr, "%s:%d:deadlock 0x%lx: %d:%d %s\n", - th->file, th->line, th->thread, th->status, - th->wait_for, th==main_thread?"(main)":""); + fprintf(stderr, "deadlock 0x%lx: %d:%d %s - %s:%d:\n", + th->thread, th->status, + th->wait_for, th==main_thread?"(main)":"", + th->file, th->line); if (th->status == THREAD_STOPPED) { next = th; } @@ -6610,6 +6630,7 @@ rb_thread_schedule() /* raise fatal error to main thread */ rb_thread_deadlock(); rb_thread_ready(next); + next->gid = 0; next->status = THREAD_TO_KILL; } if (next->status == THREAD_RUNNABLE && next == curr_thread) { @@ -6901,11 +6922,15 @@ rb_thread_kill(thread) { thread_t th = rb_thread_check(thread); + if (th != curr_thread && th->safe < 4) { + rb_secure(4); + } if (th->status == THREAD_TO_KILL || th->status == THREAD_KILLED) return thread; if (th == th->next || th == main_thread) rb_exit(0); rb_thread_ready(th); + th->gid = 0; th->status = THREAD_TO_KILL; rb_thread_schedule(); return Qnil; /* not reached */ @@ -6982,7 +7007,7 @@ rb_thread_priority(thread) { thread_t th = rb_thread_check(thread);; - if (safe_level >= 4 && th != curr_thread) { + if (rb_safe_level() >= 4 && th != curr_thread) { rb_raise(rb_eSecurityError, "Insecure: can't get priority"); } return INT2NUM(th->priority); @@ -7078,6 +7103,7 @@ rb_thread_abort_exc_set(thread, val) th->last_match = 0;\ th->abort = 0;\ th->priority = 0;\ + th->gid = 1;\ th->locals = 0;\ } while(0) @@ -7096,6 +7122,7 @@ rb_thread_alloc(klass) th->next = curr_thread->next; curr_thread->next = th; th->priority = curr_thread->priority; + th->gid = curr_thread->gid; } else { curr_thread = th->prev = th->next = th; @@ -7105,7 +7132,7 @@ rb_thread_alloc(klass) return th; } -#if defined(HAVE_SETITIMER) && !defined(__BOW__) +#if defined(HAVE_SETITIMER) static void catch_timer(sig) int sig; @@ -7128,7 +7155,7 @@ static VALUE rb_thread_raise _((int, VALUE*, VALUE)); #define SCOPE_SHARED FL_USER1 -#if defined(HAVE_SETITIMER) && !defined(__BOW__) +#if defined(HAVE_SETITIMER) static int thread_init = 0; void @@ -7167,7 +7194,7 @@ rb_thread_create_0(fn, arg, klass) enum thread_status status; int state; -#if defined(HAVE_SETITIMER) && !defined(__BOW__) +#if defined(HAVE_SETITIMER) if (!thread_init) { #ifdef POSIX_SIGNAL posix_signal(SIGVTALRM, catch_timer); @@ -7180,6 +7207,7 @@ rb_thread_create_0(fn, arg, klass) } #endif + scope_dup(ruby_scope); FL_SET(ruby_scope, SCOPE_SHARED); rb_thread_save_context(curr_thread); if (setjmp(curr_thread->context)) { @@ -7325,6 +7353,7 @@ rb_thread_cleanup() FOREACH_THREAD(th) { if (th != curr_thread && th->status != THREAD_KILLED) { rb_thread_ready(th); + th->gid = 0; th->status = THREAD_TO_KILL; } } @@ -7417,6 +7446,9 @@ rb_thread_raise(argc, argv, thread) if (curr_thread == th) { rb_f_raise(argc, argv); } + if (th->safe < 4) { + rb_secure(4); + } if (curr_thread->status != THREAD_KILLED) rb_thread_save_context(curr_thread); @@ -7473,7 +7505,7 @@ rb_thread_local_aref(thread, id) VALUE val; th = rb_thread_check(thread); - if (safe_level >= 4 && th != curr_thread) { + if (rb_safe_level() >= 4 && th != curr_thread) { rb_raise(rb_eSecurityError, "Insecure: thread locals"); } if (!th->locals) return Qnil; @@ -7498,9 +7530,10 @@ rb_thread_local_aset(thread, id, val) { thread_t th = rb_thread_check(thread); - if (safe_level >= 4 && th != curr_thread) { + if (rb_safe_level() >= 4 && th != curr_thread) { rb_raise(rb_eSecurityError, "Insecure: can't modify thread locals"); } + if (OBJ_FROZEN(thread)) rb_error_frozen("thread locals"); if (!th->locals) { th->locals = st_init_numtable(); @@ -7613,9 +7646,65 @@ rb_cont_call(argc, argv, cont) return Qnil; } +struct thgroup { + int gid; +}; + +static VALUE +thgroup_s_new(klass) + VALUE klass; +{ + VALUE group; + struct thgroup *data; + static int serial = 1; + + group = Data_Make_Struct(klass, struct thgroup, 0, free, data); + data->gid = serial++; + + return group; +} + +static VALUE +thgroup_list(group) + VALUE group; +{ + struct thgroup *data; + thread_t th; + VALUE ary; + + Data_Get_Struct(group, struct thgroup, data); + ary = rb_ary_new(); + + FOREACH_THREAD(th) { + if (th->gid == data->gid) { + rb_ary_push(ary, th->thread); + } + } + END_FOREACH(th); + + return ary; +} + +static VALUE +thgroup_add(group, thread) + VALUE group, thread; +{ + thread_t th; + struct thgroup *data; + + rb_secure(4); + th = rb_thread_check(thread); + Data_Get_Struct(group, struct thgroup, data); + + th->gid = data->gid; + return group; +} + void Init_Thread() { + VALUE cThGroup; + rb_eThreadError = rb_define_class("ThreadError", rb_eStandardError); rb_cThread = rb_define_class("Thread", rb_cObject); @@ -7669,6 +7758,12 @@ Init_Thread() rb_undef_method(CLASS_OF(rb_cCont), "new"); rb_define_method(rb_cCont, "call", rb_cont_call, -1); rb_define_global_function("callcc", rb_callcc, 0); + + cThGroup = rb_define_class("ThreadGroup", rb_cObject); + rb_define_singleton_method(cThGroup, "new", thgroup_s_new, 0); + rb_define_method(cThGroup, "list", thgroup_list, 0); + rb_define_method(cThGroup, "add", thgroup_add, 1); + rb_define_const(cThGroup, "Default", thgroup_s_new(cThGroup)); } static VALUE diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index 6975994ef8..b7aee1cc36 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -41,6 +41,7 @@ end $ipv6type = nil $ipv6lib = nil $ipv6libdir = nil +$ipv6trylibc = nil if $ipv6 if egrep_cpp("yes", < @@ -59,6 +60,7 @@ EOF $ipv6type = "kame" $ipv6lib="inet6" $ipv6libdir="/usr/local/v6/lib" + $ipv6trylibc=true $CFLAGS="-DINET6 "+$CFLAGS elsif File.directory? "/usr/inet6" $ipv6type = "linux" @@ -100,7 +102,7 @@ EOF if $ipv6lib if File.directory? $ipv6libdir and File.exist? "#{$ipv6libdir}/lib#{$ipv6lib}.a" $LOCAL_LIBS = " -L#$ipv6libdir -l#$ipv6lib" - else + elsif !$ipv6trylibc print < #include #include +int +main() +{ + struct sockaddr_storage ss; + + ss.ss_family; + return 0; +} +EOF + $CFLAGS="-DHAVE_SOCKADDR_STORAGE "+$CFLAGS +end + + if try_link(< +#include +#include +#include #include int main() diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 37094026e4..d680adc325 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -81,10 +81,27 @@ int Rconnect(); #define INET_SERVER 1 #define INET_SOCKS 2 -#ifndef INET6 -# undef ss_family -# define sockaddr_storage sockaddr -# define ss_family sa_family +#ifndef HAVE_SOCKADDR_STORAGE +/* + * RFC 2553: protocol-independent placeholder for socket addresses + */ +#define _SS_MAXSIZE 128 +#define _SS_ALIGNSIZE (sizeof(long long)) +#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) * 2) +#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) * 2 - \ + _SS_PAD1SIZE - _SS_ALIGNSIZE) + +struct sockaddr_storage { +#ifdef HAVE_SA_LEN + unsigned char ss_len; /* address length */ + unsigned char ss_family; /* address family */ +#else + unsigned short ss_family; +#endif + char __ss_pad1[_SS_PAD1SIZE]; + long long __ss_align; /* force desired structure storage alignment */ + char __ss_pad2[_SS_PAD2SIZE]; +}; #endif #ifdef NT diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c index 314246869e..e846e1f038 100644 --- a/ext/tcltklib/tcltklib.c +++ b/ext/tcltklib/tcltklib.c @@ -69,8 +69,7 @@ _timer_for_tcl(clientData) VALUE thread; Tk_DeleteTimerHandler(timer_token); - timer_token = Tk_CreateTimerHandler(100, _timer_for_tcl, - (ClientData)0); + timer_token = Tk_CreateTimerHandler(100, _timer_for_tcl, (ClientData)0); CHECK_INTS; q = iqueue; @@ -93,8 +92,7 @@ static VALUE lib_mainloop(self) VALUE self; { - timer_token = Tk_CreateTimerHandler(100, _timer_for_tcl, - (ClientData)0); + timer_token = Tk_CreateTimerHandler(100, _timer_for_tcl, (ClientData)0); DUMP1("start Tk_Mainloop"); Tk_MainLoop(); DUMP1("stop Tk_Mainloop"); diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 931cb90819..c344a2bf8e 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -196,7 +196,9 @@ module TkComm def _get_eval_string(str) return nil if str == None - if str.kind_of?(Hash) + if str.kind_of?(String) + # do nothing + elsif str.kind_of?(Hash) str = hash_kv(str).join(" ") elsif str.kind_of?(Array) str = array2tk_list(str) @@ -417,11 +419,11 @@ module TkCore INTERP._invoke("proc", "rb_out", "args", "if {[set st [catch {ruby [format \"TkCore.callback %%Q!%s!\" $args]} ret]] != 0} {if {[regsub -all {!} $args {\\!} newargs] == 0} {return -code $st $ret} {if {[set st [catch {ruby [format \"TkCore.callback %%Q!%s!\" $newargs]} ret]] != 0} {return -code $st $ret} {return $ret}}} {return $ret}") def callback_break - raise TkCallbackBreak, "Tk callback returns 'break' status" + fail TkCallbackBreak, "Tk callback returns 'break' status" end def callback_continue - raise TkCallbackContinue, "Tk callback returns 'continue' status" + fail TkCallbackContinue, "Tk callback returns 'continue' status" end def after(ms, cmd=Proc.new) @@ -527,8 +529,8 @@ module TkCore args.unshift "unknown" res = INTERP._invoke(*args) rescue - raise unless /^invalid command/ =~ $! - raise err + fail unless /^invalid command/ =~ $! + fail err end end if INTERP._return_value() != 0 @@ -583,6 +585,32 @@ module Tk def yscrollcommand(cmd=Proc.new) configure_cmd 'yscrollcommand', cmd end + def xview(*index) + v = tk_send('xview', *index) + list(v) if index.size == 0 + end + def yview(*index) + v = tk_send('yview', *index) + list(v) if index.size == 0 + end + def xscrollbar(bar=nil) + if bar + @xscrollbar = bar + @xscrollbar.orient 'horizontal' + self.xscrollcommand {|arg| @xscrollbar.set *arg} + @xscrollbar.command {|arg| self.xview *arg} + end + @xscrollbar + end + def yscrollbar(bar=nil) + if bar + @yscrollbar = bar + @yscrollbar.orient 'vertical' + self.yscrollcommand {|arg| @yscrollbar.set *arg} + @yscrollbar.command {|arg| self.yview *arg} + end + @yscrollbar + end end module Wm @@ -784,7 +812,7 @@ class TkVariable INTERP._eval(format('global %s; set %s', @id, @id)) rescue if INTERP._eval(format('global %s; array exists %s', @id, @id)) != "1" - raise + fail else Hash[*tk_split_simplelist(INTERP._eval(format('global %s; array get %s', @id, @id)))] @@ -798,7 +826,7 @@ class TkVariable INTERP._eval(format('global %s; set %s %s', @id, @id, s)) rescue if INTERP._eval(format('global %s; array exists %s', @id, @id)) != "1" - raise + fail else if val == [] INTERP._eval(format('global %s; unset %s; set %s(0) 0; unset %s(0)', @@ -815,7 +843,7 @@ class TkVariable INTERP._eval(format('global %s; unset %s; array set %s %s', @id, @id, @id, s)) else - raise + fail end end end @@ -2149,7 +2177,7 @@ end class TkTextWinst_mode)) return Qtrue; + if (S_ISCHR(get_stat(obj)->st_mode)) return Qtrue; return Qfalse; } diff --git a/gc.c b/gc.c index 6a0e7c527a..b20c84837b 100644 --- a/gc.c +++ b/gc.c @@ -492,7 +492,7 @@ rb_gc_mark(ptr) case NODE_GASGN: case NODE_LASGN: case NODE_DASGN: - case NODE_DASGN_PUSH: + case NODE_DASGN_CURR: case NODE_IASGN: case NODE_CASGN: case NODE_MODULE: diff --git a/hash.c b/hash.c index b6a1d507c0..77f7e3e6e2 100644 --- a/hash.c +++ b/hash.c @@ -23,39 +23,17 @@ char *strchr _((char*,char)); char* strdup(const char*); #endif -#define HASH_FREEZE FL_USER1 -#define HASH_DELETED FL_USER2 +#define HASH_DELETED FL_USER1 static void rb_hash_modify(hash) VALUE hash; { - if (FL_TEST(hash, HASH_FREEZE)) - rb_raise(rb_eTypeError, "can't modify frozen hash"); + if (OBJ_FROZEN(hash)) rb_error_frozen("hash"); if (!OBJ_TAINTED(hash) && rb_safe_level() >= 4) rb_raise(rb_eSecurityError, "Insecure: can't modify hash"); } -VALUE -rb_hash_freeze(hash) - VALUE hash; -{ - if (rb_safe_level() >= 4 && !OBJ_TAINTED(hash)) - rb_raise(rb_eSecurityError, "Insecure: can't freeze hash"); - - FL_SET(hash, HASH_FREEZE); - return hash; -} - -static VALUE -rb_hash_frozen_p(hash) - VALUE hash; -{ - if (FL_TEST(hash, HASH_FREEZE)) - return Qtrue; - return Qfalse; -} - VALUE rb_cHash; static VALUE envtbl; @@ -1387,9 +1365,6 @@ Init_Hash() rb_define_method(rb_cHash,"dup", rb_hash_dup, 0); rb_define_method(rb_cHash,"rehash", rb_hash_rehash, 0); - rb_define_method(rb_cHash,"freeze", rb_hash_freeze, 0); - rb_define_method(rb_cHash,"frozen?",rb_hash_frozen_p, 0); - rb_define_method(rb_cHash,"to_hash", rb_hash_to_hash, 0); rb_define_method(rb_cHash,"to_a", rb_hash_to_a, 0); rb_define_method(rb_cHash,"to_s", rb_hash_to_s, 0); diff --git a/intern.h b/intern.h index 14d2fdc452..7dfc9f3032 100644 --- a/intern.h +++ b/intern.h @@ -101,6 +101,7 @@ void rb_alias _((VALUE, ID, ID)); void rb_attr _((VALUE,ID,int,int,int)); int rb_method_boundp _((VALUE, ID, int)); VALUE rb_dvar_defined _((ID)); +VALUE rb_dvar_curr _((ID)); VALUE rb_dvar_ref _((ID)); void rb_dvar_asgn _((ID, VALUE)); void rb_dvar_push _((ID, VALUE)); diff --git a/io.c b/io.c index 6222d9047e..88c95a02c5 100644 --- a/io.c +++ b/io.c @@ -1576,7 +1576,12 @@ rb_io_s_popen(argc, argv, self) } Check_SafeStr(pname); port = pipe_open(RSTRING(pname)->ptr, mode); - if (NIL_P(port)) return Qnil; + if (NIL_P(port)) { + rb_yield(port); + } + else if (rb_iterator_p()) { + return rb_ensure(rb_yield, port, rb_io_close, port); + } return port; } @@ -1647,8 +1652,10 @@ rb_f_open(argc, argv) } port = pipe_open(RSTRING(pname)->ptr+1, mode); - if (NIL_P(port)) return Qnil; - if (rb_iterator_p()) { + if (NIL_P(port)) { + rb_yield(port); + } + else if (rb_iterator_p()) { return rb_ensure(rb_yield, port, rb_io_close, port); } @@ -3222,7 +3229,7 @@ Init_IO() rb_rs = rb_default_rs = rb_str_new2("\n"); rb_output_rs = Qnil; rb_global_variable(&rb_default_rs); - rb_str_freeze(rb_default_rs); /* avoid modifying RS_default */ + OBJ_FREEZE(rb_default_rs); /* avoid modifying RS_default */ rb_define_hooked_variable("$/", &rb_rs, 0, rb_str_setter); rb_define_hooked_variable("$-0", &rb_rs, 0, rb_str_setter); rb_define_hooked_variable("$\\", &rb_output_rs, 0, rb_str_setter); diff --git a/lib/getoptlong.rb b/lib/getoptlong.rb index 82cccf43b9..7b6d5cc671 100644 --- a/lib/getoptlong.rb +++ b/lib/getoptlong.rb @@ -35,7 +35,7 @@ class GetoptLong # # Status codes. # - STATUS_YET, STATUS_STARTED, STATUS_TERMINATED = 0..2 + STATUS_YET, STATUS_STARTED, STATUS_TERMINATED = 0, 1, 2 # # Error types. diff --git a/lib/observer.rb b/lib/observer.rb index 0c74b49750..a91c1e38c3 100644 --- a/lib/observer.rb +++ b/lib/observer.rb @@ -32,7 +32,7 @@ module Observable def notify_observers(*arg) if @observer_state if @observer_peers - for i in @observer_peers + for i in @observer_peers.dup i.update(*arg) end end diff --git a/lib/parsedate.rb b/lib/parsedate.rb index 7bf1affb42..35fffcfe98 100644 --- a/lib/parsedate.rb +++ b/lib/parsedate.rb @@ -27,7 +27,7 @@ module ParseDate if date.sub!(/(#{DAYPAT})[a-z]*,?/i, ' ') wday = DAYS[$1.downcase] end - if date.sub!(/(\d+):(\d+)(?::(\d+))?(?:\s*(am|pm))?(?:\s+([a-z]{1,4}(?:\s+[a-z]{1,4}|[-+]\d{4})?))?/i, ' ') + if date.sub!(/(\d+):(\d+)(?::(\d+))?(?:\s*(am|pm))?(?:\s+([a-z]{1,4}(?:\s+[a-z]{1,4}|[-+]\d{4})?|[-+]\d{4}))?/i, ' ') hour = $1.to_i min = $2.to_i if $3 diff --git a/marshal.c b/marshal.c index b83261bdf2..a2e6a0a40c 100644 --- a/marshal.c +++ b/marshal.c @@ -227,7 +227,7 @@ w_object(obj, arg, limit) st_table *ivtbl = 0; if (limit == 0) { - rb_raise(rb_eRuntimeError, "exceed depth limit"); + rb_raise(rb_eArgError, "exceed depth limit"); } if (obj == Qnil) { w_byte(TYPE_NIL, arg); diff --git a/node.h b/node.h index 46e9b1525a..f53a5c6610 100644 --- a/node.h +++ b/node.h @@ -45,7 +45,7 @@ enum node_type { NODE_MASGN, NODE_LASGN, NODE_DASGN, - NODE_DASGN_PUSH, + NODE_DASGN_CURR, NODE_GASGN, NODE_IASGN, NODE_CASGN, @@ -260,7 +260,7 @@ typedef struct RNode { #define NEW_GASGN(v,val) rb_node_newnode(NODE_GASGN,v,val,rb_global_entry(v)) #define NEW_LASGN(v,val) rb_node_newnode(NODE_LASGN,v,val,local_cnt(v)) #define NEW_DASGN(v,val) rb_node_newnode(NODE_DASGN,v,val,0); -#define NEW_DASGN_PUSH(v,val) rb_node_newnode(NODE_DASGN_PUSH,v,val,0); +#define NEW_DASGN_CURR(v,val) rb_node_newnode(NODE_DASGN_CURR,v,val,0); #define NEW_IASGN(v,val) rb_node_newnode(NODE_IASGN,v,val,0) #define NEW_CASGN(v,val) rb_node_newnode(NODE_CASGN,v,val,0) #define NEW_CDECL(v,val) rb_node_newnode(NODE_CDECL,v,val,0) diff --git a/numeric.c b/numeric.c index 20dff3a833..0169621623 100644 --- a/numeric.c +++ b/numeric.c @@ -331,8 +331,7 @@ flo_modulo(x, y, modulo) result = value1 - value2 * value; } #endif - if (modulo && - (RFLOAT(x)->value < 0.0) != (result < 0.0) && result != 0.0) { + if (modulo && value*result<0.0) { result += value; } return rb_float_new(result); @@ -352,6 +351,45 @@ flo_remainder(x, y) return flo_modulo(x,y,0); } +static VALUE +flo_divmod(x, y) + VALUE x, y; +{ + double value, div, mod; + + switch (TYPE(y)) { + case T_FIXNUM: + value = (double)FIX2LONG(y); + break; + case T_BIGNUM: + value = rb_big2dbl(y); + break; + case T_FLOAT: + value = RFLOAT(y)->value; + break; + default: + return rb_num_coerce_bin(x, y); + } + +#ifdef HAVE_FMOD + mod = fmod(RFLOAT(x)->value, value); +#else + { + double value1 = RFLOAT(x)->value; + double value2; + + modf(value1/value, &value2); + mod = value1 - value2 * value; + } +#endif + div = (RFLOAT(x)->value - mod) / value; + if (value*mod<0.0) { + mod += value; + div -= 1.0; + } + return rb_assoc_new(rb_float_new(div), rb_float_new(mod)); +} + static VALUE flo_pow(x, y) VALUE x, y; @@ -1517,6 +1555,7 @@ Init_Numeric() rb_define_method(rb_cFloat, "*", flo_mul, 1); rb_define_method(rb_cFloat, "/", flo_div, 1); rb_define_method(rb_cFloat, "%", flo_mod, 1); + rb_define_method(rb_cFloat, "divmod", flo_divmod, 1); rb_define_method(rb_cFloat, "remainder", flo_remainder, 1); rb_define_method(rb_cFloat, "**", flo_pow, 1); rb_define_method(rb_cFloat, "==", flo_eq, 1); diff --git a/object.c b/object.c index bf2ff5eed3..572c7406f7 100644 --- a/object.c +++ b/object.c @@ -297,6 +297,25 @@ rb_obj_untaint(obj) return obj; } +VALUE +rb_obj_freeze(obj) + VALUE obj; +{ + if (rb_safe_level() >= 4 && !OBJ_TAINTED(obj)) + rb_raise(rb_eSecurityError, "Insecure: can't freeze object"); + + OBJ_FREEZE(obj); + return obj; +} + +static VALUE +rb_obj_frozen_p(obj) + VALUE obj; +{ + if (OBJ_FROZEN(obj)) return Qtrue; + return Qfalse; +} + static VALUE nil_to_i(obj) VALUE obj; @@ -1004,6 +1023,8 @@ Init_Object() rb_define_method(rb_mKernel, "taint", rb_obj_taint, 0); rb_define_method(rb_mKernel, "tainted?", rb_obj_tainted, 0); rb_define_method(rb_mKernel, "untaint", rb_obj_untaint, 0); + rb_define_method(rb_mKernel, "freeze", rb_obj_freeze, 0); + rb_define_method(rb_mKernel, "frozen?", rb_obj_frozen_p, 0); rb_define_method(rb_mKernel, "to_a", rb_any_to_a, 0); rb_define_method(rb_mKernel, "to_s", rb_any_to_s, 0); diff --git a/pack.c b/pack.c index 0b0ebb0202..a26e14e301 100644 --- a/pack.c +++ b/pack.c @@ -305,7 +305,7 @@ static void pack_add_ptr(str, add) VALUE str, add; { -#define STR_NO_ORIG FL_USER3 /* copied from string.c */ +#define STR_NO_ORIG FL_USER2 /* copied from string.c */ if (!RSTRING(str)->orig) { RSTRING(str)->orig = rb_ary_new(); FL_SET(str, STR_NO_ORIG); diff --git a/parse.y b/parse.y index f15684fb99..8f88b978eb 100644 --- a/parse.y +++ b/parse.y @@ -532,6 +532,10 @@ mlhs_node : variable { $$ = attrset($1, $3); } + | primary tCOLON2 tIDENTIFIER + { + $$ = attrset($1, $3); + } | backref { rb_backref_error($1); @@ -550,6 +554,10 @@ lhs : variable { $$ = attrset($1, $3); } + | primary tCOLON2 tIDENTIFIER + { + $$ = attrset($1, $3); + } | backref { rb_backref_error($1); @@ -683,6 +691,17 @@ arg : lhs '=' arg $$ = NEW_OP_ASGN2($1, $3, $4, $5); fixpos($$, $1); } + | primary tCOLON2 tIDENTIFIER tOP_ASGN arg + { + if ($4 == tOROP) { + $4 = 0; + } + else if ($4 == tANDOP) { + $4 = 1; + } + $$ = NEW_OP_ASGN2($1, $3, $4, $5); + fixpos($$, $1); + } | backref tOP_ASGN arg { rb_backref_error($1); @@ -968,15 +987,6 @@ primary : literal { $$ = NEW_LIT($1); } - | primary tCOLON2 tCONSTANT - { - value_expr($1); - $$ = NEW_COLON2($1, $3); - } - | tCOLON3 cname - { - $$ = NEW_COLON3($2); - } | string | tXSTRING { @@ -986,6 +996,43 @@ primary : literal | tDREGEXP | var_ref | backref + | tFID + { + $$ = NEW_VCALL($1); + } + | kBEGIN + compstmt + rescue + opt_else + ensure + kEND + { + if (!$3 && !$4 && !$5) + $$ = NEW_BEGIN($2); + else { + if ($3) $2 = NEW_RESCUE($2, $3, $4); + else if ($4) { + rb_warn("else without rescue is useless"); + $2 = block_append($2, $4); + } + if ($5) $2 = NEW_ENSURE($2, $5); + $$ = $2; + } + fixpos($$, $2); + } + | tLPAREN compstmt ')' + { + $$ = $2; + } + | primary tCOLON2 tCONSTANT + { + value_expr($1); + $$ = NEW_COLON2($1, $3); + } + | tCOLON3 cname + { + $$ = NEW_COLON3($2); + } | primary '[' aref_args ']' { value_expr($1); @@ -1040,10 +1087,6 @@ primary : literal in_defined = 0; $$ = NEW_DEFINED($5); } - | tFID - { - $$ = NEW_VCALL($1); - } | operation brace_block { $2->nd_iter = NEW_FCALL($1, 0); @@ -1109,30 +1152,6 @@ primary : literal $$ = NEW_FOR($2, $5, $8); fixpos($$, $2); } - | kBEGIN - compstmt - rescue - opt_else - ensure - kEND - { - if (!$3 && !$4 && !$5) - $$ = NEW_BEGIN($2); - else { - if ($3) $2 = NEW_RESCUE($2, $3, $4); - else if ($4) { - rb_warn("else without rescue is useless"); - $2 = block_append($2, $4); - } - if ($5) $2 = NEW_ENSURE($2, $5); - $$ = $2; - } - fixpos($$, $2); - } - | tLPAREN compstmt ')' - { - $$ = $2; - } | kCLASS cname superclass { if (cur_mid || in_single) @@ -2400,11 +2419,80 @@ parse_qstring(term, paren) } static int -parse_quotedword(term, paren) +parse_quotedwords(term, paren) int term, paren; { - if (parse_qstring(term, paren) == 0) return 0; - yylval.node = NEW_CALL(NEW_STR(yylval.val), rb_intern("split"), 0); + NODE *qwords = 0; + int strstart; + int c; + int nest = 0; + + strstart = ruby_sourceline; + newtok(); + + while ((c = nextc()) == ' ') + ; /* skip preceding spaces */ + pushback(c); + while ((c = nextc()) != term || nest > 0) { + if (c == -1) { + ruby_sourceline = strstart; + rb_compile_error("unterminated string meets end of file"); + return 0; + } + if (ismbchar(c)) { + int i, len = mbclen(c)-1; + + for (i = 0; i < len; i++) { + tokadd(c); + c = nextc(); + } + } + else if (c == '\\') { + c = nextc(); + switch (c) { + case '\n': + continue; + case '\\': + c = '\\'; + break; + case ' ': + tokadd(' '); + break; + default: + tokadd('\\'); + } + } + else if (c == ' ') { + NODE *str; + + tokfix(); + str = NEW_STR(rb_str_new(tok(), toklen())); + newtok(); + if (!qwords) qwords = NEW_LIST(str); + else list_append(qwords, str); + while ((c = nextc()) == ' ') + ; /* skip continuous spaces */ + pushback(c); + continue; + } + if (paren) { + if (c == paren) nest++; + if (c == term && nest-- == 0) break; + } + tokadd(c); + } + + tokfix(); + if (toklen() > 0) { + NODE *str; + + str = NEW_STR(rb_str_new(tok(), toklen())); + if (!qwords) qwords = NEW_LIST(str); + else list_append(qwords, str); + } + if (!qwords) qwords = NEW_ZARRAY(); + yylval.node = qwords; + lex_state = EXPR_END; return tDSTRING; } @@ -2814,6 +2902,8 @@ yylex() if (lex_state == EXPR_BEG || lex_state == EXPR_MID || (lex_state == EXPR_ARG && space_seen && !ISSPACE(c))) { pushback(c); + if (lex_state == EXPR_ARG) arg_ambiguous(); + if (ISDIGIT(c)) goto start_num; lex_state = EXPR_BEG; return tUPLUS; } @@ -2837,8 +2927,13 @@ yylex() } if (lex_state == EXPR_BEG || lex_state == EXPR_MID || (lex_state == EXPR_ARG && space_seen && !ISSPACE(c))) { + if (lex_state == EXPR_ARG) arg_ambiguous(); lex_state = EXPR_BEG; pushback(c); + if (ISDIGIT(c)) { + c = '-'; + goto start_num; + } return tUMINUS; } lex_state = EXPR_BEG; @@ -3072,6 +3167,12 @@ yylex() lex_state = EXPR_BEG; } else { + if (lex_state == EXPR_ARG) { + if (space_seen) { + arg_ambiguous(); + c = tLPAREN; + } + } lex_state = EXPR_BEG; } return c; @@ -3147,7 +3248,7 @@ yylex() return parse_qstring(term, paren); case 'w': - return parse_quotedword(term, paren); + return parse_quotedwords(term, paren); case 'x': return parse_string('`', term, paren); @@ -3766,15 +3867,18 @@ assignable(id, val) yyerror("Can't assign to __LINE__"); } else if (is_local_id(id)) { - if (rb_dvar_defined(id)) { + if (rb_dvar_curr(id)) { + lhs = NEW_DASGN_CURR(id, val); + } + else if (rb_dvar_defined(id)) { lhs = NEW_DASGN(id, val); } else if (local_id(id) || !dyna_in_block()) { lhs = NEW_LASGN(id, val); } else{ - rb_dvar_push(id, 0); - lhs = NEW_DASGN_PUSH(id, val); + rb_dvar_push(id, Qnil); + lhs = NEW_DASGN_CURR(id, val); } } else if (is_global_id(id)) { @@ -3871,7 +3975,7 @@ node_assign(lhs, rhs) case NODE_IASGN: case NODE_LASGN: case NODE_DASGN: - case NODE_DASGN_PUSH: + case NODE_DASGN_CURR: case NODE_MASGN: case NODE_CASGN: case NODE_CDECL: @@ -4354,8 +4458,11 @@ top_local_setup() static struct RVarmap* dyna_push() { + struct RVarmap* vars = ruby_dyna_vars; + + rb_dvar_push(0, 0); lvtbl->dlev++; - return ruby_dyna_vars; + return vars; } static void diff --git a/ruby.h b/ruby.h index a5c9e39ad3..4d307c5880 100644 --- a/ruby.h +++ b/ruby.h @@ -160,11 +160,11 @@ VALUE rb_uint2inum _((unsigned long)); #define T_DATA 0x22 #define T_MATCH 0x23 -#define T_VARMAP 0x7d -#define T_SCOPE 0x7e -#define T_NODE 0x7f +#define T_VARMAP 0x3d +#define T_SCOPE 0x3e +#define T_NODE 0x3f -#define T_MASK 0x7f +#define T_MASK 0x3f #define BUILTIN_TYPE(x) (((struct RBasic*)(x))->flags & T_MASK) @@ -176,6 +176,10 @@ void rb_check_safe_str _((VALUE)); #define Check_SafeStr(v) rb_check_safe_str((VALUE)(v)) void rb_secure _((int)); +extern int ruby_safe_level; +#define rb_safe_level() (ruby_safe_level) +void rb_set_safe_level _((int)); + long rb_num2long _((VALUE)); unsigned long rb_num2ulong _((VALUE)); #define NUM2LONG(x) (FIXNUM_P(x)?FIX2LONG(x):rb_num2long((VALUE)x)) @@ -326,10 +330,11 @@ struct RBignum { #define RFILE(obj) (R_CAST(RFile)(obj)) #define FL_SINGLETON FL_USER0 -#define FL_MARK (1<<7) -#define FL_FINALIZE (1<<8) -#define FL_TAINT (1<<9) -#define FL_EXIVAR (1<<10) +#define FL_MARK (1<<6) +#define FL_FINALIZE (1<<7) +#define FL_TAINT (1<<8) +#define FL_EXIVAR (1<<9) +#define FL_FREEZE (1<<10) #define FL_USHIFT 11 @@ -356,6 +361,9 @@ struct RBignum { #define OBJ_TAINT(x) FL_SET((x), FL_TAINT) #define OBJ_INFECT(x,s) (FL_ABLE(x) && FL_ABLE(s) && (RBASIC(x)->flags |= RBASIC(s)->flags & FL_TAINT)) +#define OBJ_FROZEN(x) FL_TEST((x), FL_FREEZE) +#define OBJ_FREEZE(x) FL_SET((x), FL_FREEZE) + void *xmalloc _((size_t)); void *xcalloc _((size_t,size_t)); void *xrealloc _((void*,size_t)); @@ -417,9 +425,6 @@ VALUE rb_equal _((VALUE,VALUE)); EXTERN VALUE ruby_verbose, ruby_debug; -int rb_safe_level _((void)); -void rb_set_safe_level _((int)); - void rb_raise __((VALUE, const char*, ...)) NORETURN; void rb_fatal __((const char*, ...)) NORETURN; void rb_bug __((const char*, ...)) NORETURN; diff --git a/sample/test.rb b/sample/test.rb index 53783d145e..ac668172c7 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -137,7 +137,9 @@ tmp.close $bad = false tmp = open("while_tmp", "r") while tmp.gets() - if gsub!('vt100', 'VT100') + line = $_ + $_ = gsub(/vt100/, 'VT100') + if $_ != line gsub!('VT100', 'Vt100') redo; end @@ -677,7 +679,8 @@ ok("a".upcase![0] == ?A) ok("A".downcase![0] == ?a) ok("abc".tr!("a-z", "A-Z") == "ABC") ok("aabbcccc".tr_s!("a-z", "A-Z") == "ABC") -ok("abc".tr!("0-9", "A-Z") == nil) +$x = "abc" +ok($x.tr("0-9", "A-Z").equal?($x)) ok("abcc".squeeze!("a-z") == "abc") ok("abcd".delete!("bc") == "ad") @@ -965,6 +968,7 @@ File.unlink "script_tmp.bak" or `/bin/rm -f "script_tmp.bak"` $bad = false for script in Dir["{lib,sample}/*.rb"] unless `./miniruby -c #{script}`.chomp == "Syntax OK" + p `./miniruby -c #{script}`.chomp $bad = true end end @@ -1009,7 +1013,7 @@ ok(foo.test == "test") begin foo.test2 ok false -rescue +rescue NameError ok true end @@ -1061,7 +1065,7 @@ ok($$.instance_of?(Fixnum)) begin $$ = 5 ok false -rescue +rescue NameError ok true end diff --git a/string.c b/string.c index 635bbcf18f..b1288fee0f 100644 --- a/string.c +++ b/string.c @@ -24,8 +24,7 @@ VALUE rb_cString; -#define STR_FREEZE FL_USER1 -#define STR_NO_ORIG FL_USER3 +#define STR_NO_ORIG FL_USER2 VALUE rb_fs; @@ -94,11 +93,10 @@ VALUE rb_str_new4(orig) VALUE orig; { - if (FL_TEST(orig, STR_FREEZE)) { - return orig; - } - else if (RSTRING(orig)->orig && !FL_TEST(orig, STR_NO_ORIG)) { - return rb_str_freeze(RSTRING(orig)->orig); + if (OBJ_FROZEN(orig)) return orig; + if (RSTRING(orig)->orig && !FL_TEST(orig, STR_NO_ORIG)) { + OBJ_FREEZE(RSTRING(orig)->orig); + return RSTRING(orig)->orig; } else { NEWOBJ(str, struct RString); @@ -111,7 +109,8 @@ rb_str_new4(orig) if (OBJ_TAINTED(orig)) { OBJ_TAINT(str); } - FL_SET(str, STR_FREEZE); + OBJ_FREEZE(str); + return (VALUE)str; } } @@ -328,8 +327,7 @@ rb_str_modify(str) { char *ptr; - if (FL_TEST(str, STR_FREEZE)) - rb_raise(rb_eTypeError, "can't modify frozen string"); + if (OBJ_FROZEN(str)) rb_error_frozen("string"); if (!OBJ_TAINTED(str) && rb_safe_level() >= 4) rb_raise(rb_eSecurityError, "Insecure: can't modify string"); if (!RSTRING(str)->orig || FL_TEST(str, STR_NO_ORIG)) return; @@ -342,36 +340,18 @@ rb_str_modify(str) RSTRING(str)->orig = 0; } -VALUE -rb_str_freeze(str) - VALUE str; -{ - if (rb_safe_level() >= 4 && !OBJ_TAINTED(str)) - rb_raise(rb_eSecurityError, "Insecure: can't freeze string"); - - FL_SET(str, STR_FREEZE); - return str; -} - -static VALUE -rb_str_frozen_p(str) - VALUE str; -{ - if (FL_TEST(str, STR_FREEZE)) - return Qtrue; - return Qfalse; -} - VALUE rb_str_dup_frozen(str) VALUE str; { if (RSTRING(str)->orig && !FL_TEST(str, STR_NO_ORIG)) { - return rb_str_freeze(RSTRING(str)->orig); + OBJ_FREEZE(RSTRING(str)->orig); + return RSTRING(str)->orig; } - if (FL_TEST(str, STR_FREEZE)) - return str; - return rb_str_freeze(rb_str_dup(str)); + if (OBJ_FROZEN(str)) return str; + str = rb_str_dup(str); + OBJ_FREEZE(str); + return str; } VALUE @@ -966,6 +946,48 @@ rb_str_aset_m(argc, argv, str) return rb_str_aset(str, arg1, arg2); } +static VALUE +rb_str_slice_bang(argc, argv, str) + int argc; + VALUE *argv; + VALUE str; +{ + VALUE arg1, arg2; + long pos, len, i; + + rb_str_modify(str); + if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) { + pos = NUM2LONG(arg1); + len = NUM2LONG(arg2); + delete_pos_len: + if (pos < 0) { + pos = RSTRING(str)->len + pos; + } + arg2 = rb_str_substr(str, pos, len); + rb_str_replace(str, pos, len, rb_str_new(0,0)); + return arg2; + } + + if (!FIXNUM_P(arg1) && rb_range_beg_len(arg1, &pos, &len, RSTRING(str)->len, 0)) { + goto delete_pos_len; + } + + pos = NUM2LONG(arg1); + len = RSTRING(str)->len; + + if (pos >= len) return Qnil; + if (pos < 0) pos += len; + if (pos < 0) return Qnil; + + arg2 = INT2FIX(RSTRING(str)->ptr[pos] & 0xff); + memmove(RSTRING(str)->ptr + pos, + RSTRING(str)->ptr + pos + 1, + RSTRING(str)->len - (pos + 1)); + RSTRING(str)->len--; + + return arg2; +} + static VALUE get_pat(pat) VALUE pat; @@ -986,7 +1008,7 @@ get_pat(pat) } static VALUE -rb_str_sub_bang(argc, argv, str) +str_sub_bang(argc, argv, str) int argc; VALUE *argv; VALUE str; @@ -1040,19 +1062,33 @@ rb_str_sub_bang(argc, argv, str) return Qnil; } +static VALUE +rb_str_sub_bang(argc, argv, str) + int argc; + VALUE *argv; + VALUE str; +{ + str_sub_bang(argc, argv, str); + return str; +} + static VALUE rb_str_sub(argc, argv, str) int argc; VALUE *argv; VALUE str; { - str = rb_str_dup(str); - rb_str_sub_bang(argc, argv, str); - return str; + VALUE dup = rb_str_dup(str); + + if (NIL_P(str_sub_bang(argc, argv, dup))) { + rb_gc_force_recycle(dup); + return str; + } + return dup; } static VALUE -rb_str_gsub_bang(argc, argv, str) +str_gsub_bang(argc, argv, str) int argc; VALUE *argv; VALUE str; @@ -1150,15 +1186,29 @@ rb_str_gsub_bang(argc, argv, str) return str; } +static VALUE +rb_str_gsub_bang(argc, argv, str) + int argc; + VALUE *argv; + VALUE str; +{ + str_gsub_bang(argc, argv, str); + return str; +} + static VALUE rb_str_gsub(argc, argv, str) int argc; VALUE *argv; VALUE str; { - str = rb_str_dup(str); - rb_str_gsub_bang(argc, argv, str); - return str; + VALUE dup = rb_str_dup(str); + + if (NIL_P(str_gsub_bang(argc, argv, dup))) { + rb_gc_force_recycle(dup); + return str; + } + return dup; } static VALUE @@ -1200,13 +1250,15 @@ rb_f_sub(argc, argv) int argc; VALUE *argv; { - VALUE line; + VALUE line = uscore_get(); + VALUE dup = rb_str_dup(line); - line = rb_str_dup(uscore_get()); - if (!NIL_P(rb_str_sub_bang(argc, argv, line))) { - rb_lastline_set(line); + if (NIL_P(str_sub_bang(argc, argv, dup))) { + rb_gc_force_recycle(dup); + return line; } - return line; + rb_lastline_set(dup); + return dup; } static VALUE @@ -1222,13 +1274,15 @@ rb_f_gsub(argc, argv) int argc; VALUE *argv; { - VALUE line; + VALUE line = uscore_get(); + VALUE dup = rb_str_dup(line); - line = rb_str_dup(uscore_get()); - if (!NIL_P(rb_str_gsub_bang(argc, argv, line = rb_str_dup(line)))) { - rb_lastline_set(line); + if (NIL_P(str_gsub_bang(argc, argv, dup))) { + rb_gc_force_recycle(dup); + return line; } - return line; + rb_lastline_set(dup); + return dup; } static VALUE @@ -1496,7 +1550,7 @@ rb_str_dump(str) } static VALUE -rb_str_upcase_bang(str) +str_upcase_bang(str) VALUE str; { char *s, *send; @@ -1520,16 +1574,28 @@ rb_str_upcase_bang(str) } static VALUE -rb_str_upcase(str) +rb_str_upcase_bang(str) VALUE str; { - str = rb_str_dup(str); - rb_str_upcase_bang(str); + str_upcase_bang(str); return str; } static VALUE -rb_str_downcase_bang(str) +rb_str_upcase(str) + VALUE str; +{ + VALUE dup = rb_str_dup(str); + + if (NIL_P(str_upcase_bang(dup))) { + rb_gc_force_recycle(dup); + return str; + } + return dup; +} + +static VALUE +str_downcase_bang(str) VALUE str; { char *s, *send; @@ -1553,16 +1619,28 @@ rb_str_downcase_bang(str) } static VALUE -rb_str_downcase(str) +rb_str_downcase_bang(str) VALUE str; { - str = rb_str_dup(str); - rb_str_downcase_bang(str); + str_downcase_bang(str); return str; } static VALUE -rb_str_capitalize_bang(str) +rb_str_downcase(str) + VALUE str; +{ + VALUE dup = rb_str_dup(str); + + if (NIL_P(str_downcase_bang(dup))) { + rb_gc_force_recycle(dup); + return str; + } + return dup; +} + +static VALUE +str_capitalize_bang(str) VALUE str; { char *s, *send; @@ -1588,16 +1666,28 @@ rb_str_capitalize_bang(str) } static VALUE -rb_str_capitalize(str) +rb_str_capitalize_bang(str) VALUE str; { - str = rb_str_dup(str); - rb_str_capitalize_bang(str); + str_capitalize_bang(str); return str; } static VALUE -rb_str_swapcase_bang(str) +rb_str_capitalize(str) + VALUE str; +{ + VALUE dup = rb_str_dup(str); + + if (NIL_P(str_capitalize_bang(dup))) { + rb_gc_force_recycle(dup); + return str; + } + return dup; +} + +static VALUE +str_swapcase_bang(str) VALUE str; { char *s, *send; @@ -1624,13 +1714,25 @@ rb_str_swapcase_bang(str) return Qnil; } +static VALUE +rb_str_swapcase_bang(str) + VALUE str; +{ + str_swapcase_bang(str); + return str; +} + static VALUE rb_str_swapcase(str) VALUE str; { - str = rb_str_dup(str); - rb_str_swapcase_bang(str); - return str; + VALUE dup = rb_str_dup(str); + + if (NIL_P(str_swapcase_bang(dup))) { + rb_gc_force_recycle(dup); + return str; + } + return dup; } typedef unsigned char *USTR; @@ -1771,16 +1873,19 @@ static VALUE rb_str_tr_bang(str, src, repl) VALUE str, src, repl; { - return tr_trans(str, src, repl, 0); + tr_trans(str, src, repl, 0); + return str; } static VALUE rb_str_tr(str, src, repl) VALUE str, src, repl; { - str = rb_str_dup(str); - tr_trans(str, src, repl, 0); - return str; + VALUE dup = rb_str_dup(str); + + if (NIL_P(tr_trans(str, src, repl, 0))) + return str; + return dup; } static void @@ -1818,7 +1923,7 @@ tr_setup_table(str, table, init) } static VALUE -rb_str_delete_bang(argc, argv, str) +str_delete_bang(argc, argv, str) int argc; VALUE *argv; VALUE str; @@ -1855,19 +1960,33 @@ rb_str_delete_bang(argc, argv, str) return Qnil; } +static VALUE +rb_str_delete_bang(argc, argv, str) + int argc; + VALUE *argv; + VALUE str; +{ + str_delete_bang(argc, argv, str); + return str; +} + static VALUE rb_str_delete(argc, argv, str) int argc; VALUE *argv; VALUE str; { - str = rb_str_dup(str); - rb_str_delete_bang(argc, argv, str); - return str; + VALUE dup = rb_str_dup(str); + + if (NIL_P(str_delete_bang(argc, argv, dup))) { + rb_gc_force_recycle(dup); + return str; + } + return dup; } static VALUE -rb_str_squeeze_bang(argc, argv, str) +str_squeeze_bang(argc, argv, str) int argc; VALUE *argv; VALUE str; @@ -1915,31 +2034,48 @@ rb_str_squeeze_bang(argc, argv, str) return Qnil; } +static VALUE +rb_str_squeeze_bang(argc, argv, str) + int argc; + VALUE *argv; + VALUE str; +{ + str_squeeze_bang(argc, argv, str); + return str; +} + static VALUE rb_str_squeeze(argc, argv, str) int argc; VALUE *argv; VALUE str; { - str = rb_str_dup(str); - rb_str_squeeze_bang(argc, argv, str); - return str; + VALUE dup = rb_str_dup(str); + + if (NIL_P(str_squeeze_bang(argc, argv, dup))) { + rb_gc_force_recycle(dup); + return str; + } + return dup; } static VALUE rb_str_tr_s_bang(str, src, repl) VALUE str, src, repl; { - return tr_trans(str, src, repl, 1); + tr_trans(str, src, repl, 1); + return str; } static VALUE rb_str_tr_s(str, src, repl) VALUE str, src, repl; { - str = rb_str_dup(str); - tr_trans(str, src, repl, 1); - return str; + VALUE dup = rb_str_dup(str); + + if (NIL_P(tr_trans(str, src, repl, 1))) + return str; + return dup; } static VALUE @@ -2187,6 +2323,7 @@ rb_str_each_line(argc, argv, str) if (s != pend) { if (p > pend) p = pend; line = rb_str_new(s, p - s); + OBJ_INFECT(line, str); rb_yield(line); } @@ -2206,7 +2343,7 @@ rb_str_each_byte(str) } static VALUE -rb_str_chop_bang(str) +str_chop_bang(str) VALUE str; { if (RSTRING(str)->len > 0) { @@ -2224,13 +2361,25 @@ rb_str_chop_bang(str) return Qnil; } +static VALUE +rb_str_chop_bang(str) + VALUE str; +{ + str_chop_bang(str); + return str; +} + static VALUE rb_str_chop(str) VALUE str; { - str = rb_str_dup(str); - rb_str_chop_bang(str); - return str; + VALUE dup = rb_str_dup(str); + + if (NIL_P(str_chop_bang(dup))) { + rb_gc_force_recycle(dup); + return str; + } + return dup; } static VALUE @@ -2243,16 +2392,18 @@ rb_f_chop_bang(str) static VALUE rb_f_chop() { - VALUE str = rb_str_dup(uscore_get()); + VALUE line = uscore_get(); + VALUE dup = rb_str_dup(line); - if (!NIL_P(rb_str_chop_bang(str))) { - rb_lastline_set(str); + if (!NIL_P(str_chop_bang(dup))) { + rb_lastline_set(dup); + return dup; } - return str; + return line; } static VALUE -rb_str_chomp_bang(argc, argv, str) +str_chomp_bang(argc, argv, str) int argc; VALUE *argv; VALUE str; @@ -2294,15 +2445,29 @@ rb_str_chomp_bang(argc, argv, str) return Qnil; } +static VALUE +rb_str_chomp_bang(argc, argv, str) + int argc; + VALUE *argv; + VALUE str; +{ + str_chomp_bang(argc, argv, str); + return str; +} + static VALUE rb_str_chomp(argc, argv, str) int argc; VALUE *argv; VALUE str; { - str = rb_str_dup(str); - rb_str_chomp_bang(argc, argv, str); - return str; + VALUE dup = rb_str_dup(str); + + if (NIL_P(str_chomp_bang(argc, argv, dup))) { + rb_gc_force_recycle(dup); + return str; + } + return dup; } static VALUE @@ -2318,15 +2483,18 @@ rb_f_chomp(argc, argv) int argc; VALUE *argv; { - VALUE str = rb_str_dup(uscore_get()); - if (!NIL_P(rb_str_chomp_bang(argc, argv, str))) { - rb_lastline_set(str); + VALUE str = uscore_get(); + VALUE dup = rb_str_dup(str); + + if (!NIL_P(str_chomp_bang(argc, argv, dup))) { + rb_lastline_set(dup); + return dup; } return str; } static VALUE -rb_str_strip_bang(str) +str_strip_bang(str) VALUE str; { char *s, *t, *e; @@ -2361,13 +2529,25 @@ rb_str_strip_bang(str) return str; } +static VALUE +rb_str_strip_bang(str) + VALUE str; +{ + str_strip_bang(str); + return str; +} + static VALUE rb_str_strip(str) VALUE str; { - str = rb_str_dup(str); - rb_str_strip_bang(str); - return str; + VALUE dup = rb_str_dup(str); + + if (NIL_P(str_strip_bang(dup))) { + rb_gc_force_recycle(dup); + return str; + } + return dup; } static VALUE @@ -2621,9 +2801,6 @@ Init_String() rb_define_method(rb_cString, "rindex", rb_str_rindex, -1); rb_define_method(rb_cString, "replace", rb_str_replace_m, 1); - rb_define_method(rb_cString, "freeze", rb_str_freeze, 0); - rb_define_method(rb_cString, "frozen?", rb_str_frozen_p, 0); - rb_define_method(rb_cString, "to_i", rb_str_to_i, 0); rb_define_method(rb_cString, "to_f", rb_str_to_f, 0); rb_define_method(rb_cString, "to_s", rb_str_to_s, 0); @@ -2702,6 +2879,10 @@ Init_String() rb_define_global_function("split", rb_f_split, -1); + rb_define_method(rb_cString, "slice", rb_str_aref_m, -1); + rb_define_method(rb_cString, "slice!", rb_str_slice_bang, -1); + rb_define_method(rb_cString, "delete_at", rb_str_slice_bang, -1); + to_str = rb_intern("to_s"); rb_fs = Qnil; diff --git a/struct.c b/struct.c index 145c2e5b44..2fd7690039 100644 --- a/struct.c +++ b/struct.c @@ -474,6 +474,7 @@ rb_struct_aset_id(s, id, val) rb_bug("non-initialized struct"); } + if (OBJ_FROZEN(s)) rb_error_frozen("Struct"); len = RARRAY(member)->len; for (i=0; iptr[i]) == id) { @@ -502,6 +503,7 @@ rb_struct_aset(s, idx, val) if (RSTRUCT(s)->len <= i) rb_raise(rb_eIndexError, "offset %d too large for struct(size:%d)", i, RSTRUCT(s)->len); + if (OBJ_FROZEN(s)) rb_error_frozen("Struct"); return RSTRUCT(s)->ptr[i] = val; } diff --git a/time.c b/time.c index 65e479a5f6..5ea0f96f64 100644 --- a/time.c +++ b/time.c @@ -400,14 +400,12 @@ time_cmp(time1, time2) { double t; - if (tobj1->tv.tv_sec == (time_t)RFLOAT(time2)->value) - return INT2FIX(0); t = (double)tobj1->tv.tv_sec + (double)tobj1->tv.tv_usec*1e-6; - if (tobj1->tv.tv_sec == (time_t)RFLOAT(time2)->value) - return INT2FIX(0); - if (tobj1->tv.tv_sec > (time_t)RFLOAT(time2)->value) + if (t > RFLOAT(time2)->value) return INT2FIX(1); - return FIX2INT(-1); + if (t < RFLOAT(time2)->value) + return INT2FIX(-1); + return INT2FIX(0); } } diff --git a/variable.c b/variable.c index 176faac2f2..4d1ec0644c 100644 --- a/variable.c +++ b/variable.c @@ -898,6 +898,7 @@ rb_ivar_set(obj, id, val) { if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4) rb_raise(rb_eSecurityError, "Insecure: can't modify instance variable"); + if (OBJ_FROZEN(obj)) rb_error_frozen("object"); switch (TYPE(obj)) { case T_OBJECT: case T_CLASS: @@ -984,6 +985,7 @@ rb_obj_remove_instance_variable(obj, name) if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4) rb_raise(rb_eSecurityError, "Insecure: can't modify instance variable"); + if (OBJ_FROZEN(obj)) rb_error_frozen("object"); if (!rb_is_instance_id(id)) { rb_raise(rb_eNameError, "`%s' is not an instance variable", rb_id2name(id)); @@ -1099,11 +1101,12 @@ rb_mod_remove_const(mod, name) ID id = rb_to_id(name); VALUE val; - if (!OBJ_TAINTED(mod) && rb_safe_level() >= 4) - rb_raise(rb_eSecurityError, "Insecure: can't remove constant"); if (!rb_is_const_id(id)) { rb_raise(rb_eNameError, "`%s' is not constant", rb_id2name(id)); } + if (!OBJ_TAINTED(mod) && rb_safe_level() >= 4) + rb_raise(rb_eSecurityError, "Insecure: can't remove constant"); + if (OBJ_FROZEN(mod)) rb_error_frozen("class/module"); if (RCLASS(mod)->iv_tbl && st_delete(ROBJECT(mod)->iv_tbl, &id, &val)) { return val; @@ -1221,9 +1224,13 @@ rb_const_set(klass, id, val) { if (!OBJ_TAINTED(klass) && rb_safe_level() >= 4) rb_raise(rb_eSecurityError, "Insecure: can't set constant"); + if (OBJ_FROZEN(klass)) rb_error_frozen("class/module"); if (!RCLASS(klass)->iv_tbl) { RCLASS(klass)->iv_tbl = st_init_numtable(); } + else if (st_lookup(RCLASS(klass)->iv_tbl, id, 0)) { + rb_warn("already initialized constant %s", rb_id2name(id)); + } st_insert(RCLASS(klass)->iv_tbl, id, val); } diff --git a/version.h b/version.h index 6aa0d401f7..5445d7a1a8 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.5.2" -#define RUBY_RELEASE_DATE "2000-01-18" +#define RUBY_RELEASE_DATE "2000-02-01" #define RUBY_VERSION_CODE 152 -#define RUBY_RELEASE_CODE 20000118 +#define RUBY_RELEASE_CODE 20000201 diff --git a/win32/win32.c b/win32/win32.c index 412259211c..877978db58 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1619,7 +1619,8 @@ myfdopen (int fd, const char *mode) void myfdclose(FILE *fp) { - fclose(fp); + _free_osfhnd(fileno(fp)); + fclose(fp); }