From 529bc6166cb3e6083678c278d8a871e803420804 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 8 Apr 1999 10:14:35 +0000 Subject: 1.2.4 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile.in | 4 +++- array.c | 2 +- bignum.c | 4 ++-- configure | 57 ++++++++++++++++++++++++++++++++---------------------- configure.in | 20 ++++++++++++++----- dln.c | 4 ++-- eval.c | 53 ++++++++++++++++++++++++++++++++++---------------- ext/extmk.rb.in | 19 ++++++++++-------- ext/tk/tkutil.c | 2 +- instruby.rb | 47 +++++++++++++++++++++++--------------------- intern.h | 2 +- io.c | 21 +++++++++----------- parse.y | 38 ++++++++++++++++++++++++++++-------- regex.c | 48 +++++++++++++++------------------------------ ruby.c | 4 ++-- sprintf.c | 2 +- string.c | 14 +++++++++----- time.c | 15 +++++++++++++++ 19 files changed, 273 insertions(+), 143 deletions(-) diff --git a/ChangeLog b/ChangeLog index 163aadc75c..093461db4e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,63 @@ +Fri Mar 12 12:27:55 1999 Yukihiro Matsumoto + + * string.c (str_index): negative offset. + + * regex.c (re_match): begline should not match at the point + between a newline and end-of-string. endline neither. + + * regex.c (re_compile_pattern): context_indep_anchors. + + * parse.y (parse_regx): need not to push backslashes before + escaped characters. + +Sun Mar 7 14:21:32 1999 IKARASHI Akira + + * string.c (rb_str_index): wrong end point calculation. + +Thu Mar 4 14:23:11 1999 Yukihiro Matsumoto + + * array.c (ary_replace_method): should replace original array + +Fri Mar 19 11:26:45 1999 WATANABE Hirofumi + + * eval.c (ruby_run): needed to eval END{} on exit. + + * eval.c (rb_exit): ditto. + +Thu Mar 18 15:47:18 1999 Yukihiro Matsumoto + + * bignum.c (rb_big_and): bug in sign calculation. + + * bignum.c (rb_big_or): ditto. + + * io.c (rb_f_select): forgot to use to_io to retrieve IO, after + calling select(2). + +Tue Mar 16 10:23:05 1999 Yukihiro Matsumoto + + * time.c (time_clone): Time object can be cloned. + +Tue Mar 16 03:13:10 1999 Koji Arai + + * ruby.c (load_file): argv[argc] should be NULL. + +Mon Mar 15 22:12:08 1999 Tadayoshi Funaba + + * sprintf.c (rb_f_sprintf): type in arg_num check at exit. + +Wed Feb 17 01:12:22 1999 Hirotaka Ichikawa + + * configure.in: BeOS patch. + +Wed Feb 17 01:25:26 1999 Yukihiro Matsumoto + + * eval.c (error_print): exception in rb_obj_as_string() caused + SEGV. protect it by PUSH_TAG/POP_TAG. + +Tue Feb 16 23:42:51 1999 Yasuhiro Fukuma + + * configure.in: FreeBSD objformat patch + Tue Feb 16 12:40:55 1999 Yukihiro Matsumoto * version 1.2.3 (stable) released. diff --git a/Makefile.in b/Makefile.in index 9f476166e9..2ced030e9e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -20,7 +20,9 @@ LDSHARED = @LDSHARED@ DLDFLAGS = @DLDFLAGS@ SOLIBS = @SOLIBS@ +RUBY_INSTALL_NAME = @RUBY_INSTALL_NAME@ binsuffix = @binsuffix@ +PROGRAM = $(RUBY_INSTALL_NAME)$(binsuffix) #### End of system configuration section. #### @@ -78,7 +80,7 @@ miniruby$(binsuffix): libruby.a $(MAINOBJ) dmyext.o @rm -f $@ $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) dmyext.o libruby.a $(LIBS) -o $@ -ruby$(binsuffix): $(LIBRUBY) $(MAINOBJ) $(EXTOBJS) +$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(EXTOBJS) @rm -f $@ $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@ diff --git a/array.c b/array.c index ca24daa16c..50f63924a1 100644 --- a/array.c +++ b/array.c @@ -893,7 +893,7 @@ ary_replace_method(ary, ary2) VALUE ary, ary2; { ary2 = to_ary(ary2); - ary_replace(ary, 0, RARRAY(ary2)->len, ary2); + ary_replace(ary, 0, RARRAY(ary)->len, ary2); return ary; } diff --git a/bignum.c b/bignum.c index 170055d912..5b19cd4516 100644 --- a/bignum.c +++ b/bignum.c @@ -983,7 +983,7 @@ big_and(x, y) ds2 = BDIGITS(y); sign = RBIGNUM(x)->sign; } - z = bignew(l2, RBIGNUM(x)->sign && RBIGNUM(y)->sign); + z = bignew(l2, RBIGNUM(x)->sign || RBIGNUM(y)->sign); zds = BDIGITS(z); for (i=0; isign; } - z = bignew(l2, RBIGNUM(x)->sign || RBIGNUM(y)->sign); + z = bignew(l2, RBIGNUM(x)->sign && RBIGNUM(y)->sign); zds = BDIGITS(z); for (i=0; i&5 linux*) LDSHARED="gcc -shared" rb_cv_dlopen=yes ;; freebsd*) LDSHARED="gcc -shared" - if test -x /usr/bin/objformat -a \ - `/usr/bin/objformat` = "elf" ; then + if test -x /usr/bin/objformat && \ + test `/usr/bin/objformat` = "elf" ; then LDFLAGS="-rdynamic" + 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 -Bshareable" @@ -3506,11 +3508,15 @@ echo "configure:3439: checking whether OS depend dynamic link works" >&5 human*) DLDFLAGS='' LDSHARED='' LDFLAGS='' ;; - beos*) LDSHARED="ld -xms" - case "$host_cpu" in + beos*) case "$host_cpu" in powerpc*) + LDSHARED="ld -xms" DLDFLAGS="-f ruby.exp -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o" ;; + i586*) + LDSHARED="ld -shared" + DLDFLAGS="-L/boot/develop/lib/x86 -lbe -lroot" + ;; *) DLDFLAGS="ruby.def -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o" ;; @@ -3526,13 +3532,13 @@ dln_a_out_works=no if test "$ac_cv_header_a_out_h" = yes; then if test "$with_dln_a_out" = yes || test "$rb_cv_dlopen" = unknown; then echo $ac_n "checking whether matz's dln works""... $ac_c" 1>&6 -echo "configure:3530: checking whether matz's dln works" >&5 +echo "configure:3536: checking whether matz's dln works" >&5 cat confdefs.h > config.h if eval "test \"`echo '$''{'rb_cv_dln_a_out'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3552: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* rb_cv_dln_a_out=yes else @@ -3644,7 +3650,7 @@ fi case "$host_os" in human*) echo $ac_n "checking for _harderr in -lsignal""... $ac_c" 1>&6 -echo "configure:3648: checking for _harderr in -lsignal" >&5 +echo "configure:3654: 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 @@ -3652,7 +3658,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsignal $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:3673: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3691,7 +3697,7 @@ else fi echo $ac_n "checking for hmemset in -lhmem""... $ac_c" 1>&6 -echo "configure:3695: checking for hmemset in -lhmem" >&5 +echo "configure:3701: 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 @@ -3699,7 +3705,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lhmem $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:3720: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3740,12 +3746,12 @@ fi for ac_func in select do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3744: checking for $ac_func" >&5 +echo "configure:3750: 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; then +if { (eval echo configure:3778: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3793,7 +3799,7 @@ fi done echo $ac_n "checking whether PD libc _dtos18 fail to convert big number""... $ac_c" 1>&6 -echo "configure:3797: checking whether PD libc _dtos18 fail to convert big number" >&5 +echo "configure:3803: 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 @@ -3801,7 +3807,7 @@ else { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < @@ -3813,7 +3819,7 @@ main () } EOF -if { (eval echo configure:3817: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3823: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then rb_cv_missing__dtos18=yes else @@ -3835,7 +3841,7 @@ EOF fi echo $ac_n "checking whether PD libc fconvert fail to round""... $ac_c" 1>&6 -echo "configure:3839: checking whether PD libc fconvert fail to round" >&5 +echo "configure:3845: 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 @@ -3843,7 +3849,7 @@ else { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < @@ -3856,7 +3862,7 @@ main () } EOF -if { (eval echo configure:3860: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3866: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then rb_cv_missing_fconvert=yes else @@ -3909,7 +3915,6 @@ LIBRUBY='libruby.a' LIBRUBYARG='libruby.a' SOLIBS= if test "$host_os" = "beos"; then - CFLAGS="$CFLAGS -relax_pointers" LIBRUBY='libruby.so' LIBRUBYARG='-lruby' SOLIBS='-lnet' @@ -3917,6 +3922,10 @@ if test "$host_os" = "beos"; then case "$host_cpu" in powerpc*) cp beos/ruby.def.in ruby.exp + CFLAGS="$CFLAGS -relax_pointers" + ;; + i586*) + LDFLAGS="$LDFLAGS -L." ;; *) echo EXPORTS > ruby.def @@ -3949,6 +3958,7 @@ esac + ri_prefix= test "$program_prefix" != NONE && ri_prefix=$program_prefix @@ -4178,6 +4188,7 @@ s%@STRIP@%$STRIP%g s%@EXTSTATIC@%$EXTSTATIC%g s%@binsuffix@%$binsuffix%g s%@setup@%$setup%g +s%@RUBY_INSTALL_NAME@%$RUBY_INSTALL_NAME%g s%@LIBRUBY@%$LIBRUBY%g s%@LIBRUBYARG@%$LIBRUBYARG%g s%@SOLIBS@%$SOLIBS%g diff --git a/configure.in b/configure.in index 1c3874c204..6f5b89166b 100644 --- a/configure.in +++ b/configure.in @@ -376,9 +376,11 @@ if test "$with_dln_a_out" != yes; then linux*) LDSHARED="gcc -shared" rb_cv_dlopen=yes ;; freebsd*) LDSHARED="gcc -shared" - if test -x /usr/bin/objformat -a \ - `/usr/bin/objformat` = "elf" ; then + if test -x /usr/bin/objformat && \ + test `/usr/bin/objformat` = "elf" ; then LDFLAGS="-rdynamic" + 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 -Bshareable" @@ -409,11 +411,15 @@ if test "$with_dln_a_out" != yes; then human*) DLDFLAGS='' LDSHARED='' LDFLAGS='' ;; - beos*) LDSHARED="ld -xms" - case "$host_cpu" in + beos*) case "$host_cpu" in powerpc*) + LDSHARED="ld -xms" DLDFLAGS="-f ruby.exp -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o" ;; + i586*) + LDSHARED="ld -shared" + DLDFLAGS="-L/boot/develop/lib/x86 -lbe -lroot" + ;; *) DLDFLAGS="ruby.def -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o" ;; @@ -576,7 +582,6 @@ LIBRUBY='libruby.a' LIBRUBYARG='libruby.a' SOLIBS= if test "$host_os" = "beos"; then - CFLAGS="$CFLAGS -relax_pointers" LIBRUBY='libruby.so' LIBRUBYARG='-lruby' SOLIBS='-lnet' @@ -584,6 +589,10 @@ if test "$host_os" = "beos"; then case "$host_cpu" in powerpc*) cp beos/ruby.def.in ruby.exp + CFLAGS="$CFLAGS -relax_pointers" + ;; + i586*) + LDFLAGS="$LDFLAGS -L." ;; *) echo EXPORTS > ruby.def @@ -612,6 +621,7 @@ case "$host_os" in esac +AC_SUBST(RUBY_INSTALL_NAME) AC_SUBST(LIBRUBY) AC_SUBST(LIBRUBYARG) AC_SUBST(SOLIBS) diff --git a/dln.c b/dln.c index ff671bf737..8668200c0a 100644 --- a/dln.c +++ b/dln.c @@ -1411,14 +1411,14 @@ dln_load(file) /* strcat(init_fct_symname, "__Fv"); */ /* parameter nothing. */ /* "__Fv" dont need! The Be Book Bug ? */ err_stat = get_image_symbol(img_id, buf, - B_SYMBOL_TYPE_TEXT, &init_fct); + B_SYMBOL_TYPE_TEXT, (void **)&init_fct); if (err_stat != B_NO_ERROR) { char real_name[1024]; strcpy(real_name, buf); strcat(real_name, "__Fv"); err_stat = get_image_symbol(img_id, real_name, - B_SYMBOL_TYPE_TEXT, &init_fct); + B_SYMBOL_TYPE_TEXT, (void **)&init_fct); } if ((B_BAD_IMAGE_ID == err_stat) || (B_BAD_INDEX == err_stat)) { diff --git a/eval.c b/eval.c index 5df59dc92b..d6b801fcfd 100644 --- a/eval.c +++ b/eval.c @@ -754,11 +754,20 @@ error_print() { VALUE errat; VALUE eclass; - VALUE einfo; + char *einfo; + int elen; if (NIL_P(errinfo)) return; - errat = get_backtrace(errinfo); + PUSH_TAG(PROT_NONE); + if (EXEC_TAG() == 0) { + errat = get_backtrace(errinfo); + } + else { + errat = Qnil; + } + POP_TAG(); + if (!NIL_P(errat)) { VALUE mesg = RARRAY(errat)->ptr[0]; @@ -769,37 +778,45 @@ error_print() } eclass = CLASS_OF(errinfo); - einfo = obj_as_string(errinfo); - if (eclass == eRuntimeError && RSTRING(einfo)->len == 0) { + PUSH_TAG(PROT_NONE); + if (EXEC_TAG() == 0) { + einfo = str2cstr(obj_as_string(errinfo), &elen); + } + else { + einfo = ""; + elen = 0; + } + POP_TAG(); + if (eclass == eRuntimeError && elen == 0) { fprintf(stderr, ": unhandled exception\n"); } else { VALUE epath; epath = rb_class_path(eclass); - if (RSTRING(einfo)->len == 0) { + if (elen == 0) { fprintf(stderr, ": "); fwrite(RSTRING(epath)->ptr, 1, RSTRING(epath)->len, stderr); putc('\n', stderr); } else { char *tail = 0; - int len = RSTRING(einfo)->len; + int len = elen; if (RSTRING(epath)->ptr[0] == '#') epath = 0; - if (tail = strchr(RSTRING(einfo)->ptr, '\n')) { - len = tail - RSTRING(einfo)->ptr; + if (tail = strchr(einfo, '\n')) { + len = tail - einfo; tail++; /* skip newline */ } fprintf(stderr, ": "); - fwrite(RSTRING(einfo)->ptr, 1, len, stderr); + fwrite(einfo, 1, elen, stderr); if (epath) { fprintf(stderr, " ("); fwrite(RSTRING(epath)->ptr, 1, RSTRING(epath)->len, stderr); fprintf(stderr, ")\n"); } if (tail) { - fwrite(tail, 1, RSTRING(einfo)->len-len-1, stderr); + fwrite(tail, 1, elen-len-1, stderr); putc('\n', stderr); } } @@ -1016,6 +1033,7 @@ ruby_run() } static void + exec_end_proc(); compile_error(at) char *at; { @@ -1079,7 +1097,6 @@ rb_eval_cmd(cmd, arg) } the_scope = saved_scope; - safe_level = safe; POP_TAG(); POP_CLASS(); @@ -1850,7 +1867,7 @@ rb_eval(self, node) break; case NODE_YIELD: - result = rb_yield_0(rb_eval(self, node->nd_stts), 0); + result = rb_yield_0(rb_eval(self, node->nd_stts), 0, 0); break; case NODE_RESCUE: @@ -2322,6 +2339,7 @@ rb_eval(self, node) str2 = list->nd_head->nd_lit; break; case NODE_EVSTR: + sourceline = nd_line(node); rb_in_eval++; list->nd_head = compile(list->nd_head->nd_lit,0); eval_tree = 0; @@ -2723,6 +2741,7 @@ rb_exit(status) exit_status = status; rb_raise(exc_new(eSystemExit, 0, 0)); } + exec_end_proc(); exit(status); } @@ -2876,9 +2895,9 @@ f_iterator_p() } VALUE -rb_yield_0(val, self) +rb_yield_0(val, self, klass) VALUE val; - volatile VALUE self; + volatile VALUE self, klass; { NODE *node; volatile VALUE result = Qnil; @@ -2902,7 +2921,7 @@ rb_yield_0(val, self) the_scope = block->scope; the_block = block->prev; mark_dvar(block->d_vars); - the_class = block->klass; + the_class = klass?klass:block->klass; if (!self) self = block->self; node = block->body; if (block->var) { @@ -2959,7 +2978,7 @@ VALUE rb_yield(val) VALUE val; { - return rb_yield_0(val, 0); + return rb_yield_0(val, 0, 0); } static VALUE @@ -4041,7 +4060,7 @@ static VALUE yield_under_i(self) VALUE self; { - return rb_yield_0(self, self); + return rb_yield_0(self, self, the_class); } static VALUE diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in index bb0e042371..2eb6cadf2c 100644 --- a/ext/extmk.rb.in +++ b/ext/extmk.rb.in @@ -286,8 +286,7 @@ LDSHARED = @LDSHARED@ mfile.printf "\ -program_transform_name = -e @program_transform_name@ -RUBY_INSTALL_NAME = `t='$(program_transform_name)'; echo ruby | sed $$t` +RUBY_INSTALL_NAME = @RUBY_INSTALL_NAME@ prefix = @prefix@ exec_prefix = @exec_prefix@ @@ -505,6 +504,10 @@ end exit if $install or $clean $extinit = "" unless $extinit + +ruby = "@RUBY_INSTALL_NAME@@binsuffix@" +miniruby = "miniruby@binsuffix@" + if $extlist.size > 0 for s,t in $extlist f = format("%s/%s.a", s, t) @@ -537,8 +540,8 @@ if $extlist.size > 0 Dir.chdir ".." - if older("ruby@binsuffix@", "#{$top_srcdir}/ext/@setup@") or older("ruby@binsuffix@", "miniruby@binsuffix@") - `rm -f ruby@binsuffix@` + if older(ruby, "#{$top_srcdir}/ext/@setup@") or older(ruby, miniruby) + `rm -f #{ruby}` end if $extobjs @@ -549,12 +552,12 @@ if $extlist.size > 0 if PLATFORM =~ /m68k-human|beos/ $extlibs.gsub!("-L/usr/local/lib", "") if $extlibs end - system format('make ruby@binsuffix@ EXTOBJS="%s" EXTLIBS="%s"', $extobjs, $extlibs) + system format('make #{ruby} EXTOBJS="%s" EXTLIBS="%s"', $extobjs, $extlibs) else Dir.chdir ".." - if older("ruby@binsuffix@", "miniruby@binsuffix@") - `rm -f ruby@binsuffix@` - system("make ruby@binsuffix@") + if older(ruby, miniruby) + system("rm -f #{ruby}") + system("make #{ruby}") end end diff --git a/ext/tk/tkutil.c b/ext/tk/tkutil.c index 58a382a41b..f87b674c6f 100644 --- a/ext/tk/tkutil.c +++ b/ext/tk/tkutil.c @@ -30,7 +30,7 @@ tk_s_new(argc, argv, class) VALUE obj = obj_alloc(class); rb_funcall2(obj, rb_intern("initialize"), argc, argv); - if (iterator_p()) rb_yield_0(obj, obj); + if (iterator_p()) rb_yield_0(obj, obj, 0); return obj; } diff --git a/instruby.rb b/instruby.rb index c02f48cc4e..d29e8b14f8 100644 --- a/instruby.rb +++ b/instruby.rb @@ -3,6 +3,8 @@ require "rbconfig.rb" include Config +destdir = ARGV[0] || '' + $:.unshift CONFIG["srcdir"]+"/lib" require "ftools" @@ -13,41 +15,42 @@ else prefix = CONFIG["prefix"] end ruby_install_name = CONFIG["ruby_install_name"] -bindir = CONFIG["bindir"] -libdir = CONFIG["libdir"] +bindir = destdir+CONFIG["bindir"] +libdir = destdir+CONFIG["libdir"] pkglibdir = libdir + "/" + ruby_install_name archdir = pkglibdir + "/" + CONFIG["arch"] -mandir = CONFIG["mandir"] + "/man1" +mandir = destdir+CONFIG["mandir"] + "/man1" wdir = Dir.getwd -File.makedirs bindir, TRUE -File.install "ruby#{binsuffix}", - "#{bindir}/#{ruby_install_name}#{binsuffix}", 0755, TRUE +File.makedirs bindir, true +File.install ruby_install_name+binsuffix, + "#{bindir}/#{ruby_install_name}#{binsuffix}", 0755, true for dll in Dir['*.dll'] - File.install dll, "#{bindir}/#{dll}", 0755, TRUE + File.install dll, "#{bindir}/#{dll}", 0755, true end File.makedirs libdir, TRUE for lib in ["libruby.so", "libruby.so.LIB"] if File.exist? lib - File.install lib, "#{libdir}", 0644, TRUE + File.install lib, libdir, 0644, true end end -File.makedirs pkglibdir, TRUE -File.makedirs archdir, TRUE +File.makedirs pkglibdir, true +File.makedirs archdir, true Dir.chdir "ext" -system "../miniruby#{binsuffix} extmk.rb install" +system "../miniruby#{binsuffix} extmk.rb install #{destdir}" Dir.chdir CONFIG["srcdir"] -IO.foreach 'MANIFEST' do |$_| - $_.chop! - if /^lib/ - File.install $_, "#{pkglibdir}", 0644, TRUE - elsif /^[a-z]+\.h$/ - File.install $_, "#{archdir}", 0644, TRUE - end +for f in Dir["lib/*.rb"] + File.install f, pkglibdir, 0644, true end -File.makedirs mandir, TRUE -File.install "ruby.1", "#{mandir}", 0644, TRUE + +for f in Dir["*.h"] + File.install f, archdir, 0644, true +end +File.install "#{wdir}/lib#{ruby_install_name}.a", archdir, 0644, true + +File.makedirs mandir, true +File.install "ruby.1", mandir, 0644, true Dir.chdir wdir -File.install "config.h", "#{archdir}", 0644, TRUE -File.install "rbconfig.rb", "#{archdir}", 0644, TRUE +File.install "config.h", archdir, 0644, true +File.install "rbconfig.rb", archdir, 0644, true # vi:set sw=2: diff --git a/intern.h b/intern.h index 2af9d24e8d..b0fe82cd82 100644 --- a/intern.h +++ b/intern.h @@ -111,7 +111,7 @@ void rb_raise _((VALUE)); void rb_fatal _((VALUE)); void rb_interrupt _((void)); int iterator_p _((void)); -VALUE rb_yield_0 _((VALUE, volatile VALUE)); +VALUE rb_yield_0 _((VALUE, volatile VALUE, volatile VALUE)); VALUE rb_apply _((VALUE, ID, VALUE)); VALUE rb_funcall2 _((VALUE, ID, int, VALUE*)); void rb_backtrace _((void)); diff --git a/io.c b/io.c index fd74c450e2..8a2a5bc3a9 100644 --- a/io.c +++ b/io.c @@ -58,6 +58,9 @@ struct timeval { #endif #ifdef __BEOS__ +# ifdef _X86_ +# define NOFILE (OPEN_MAX) +# endif #include #endif @@ -2010,9 +2013,7 @@ f_select(argc, argv, obj) rp = &rset; FD_ZERO(rp); for (i=0; ilen; i++) { - VALUE io = io_get_io(RARRAY(read)->ptr[i]); - - GetOpenFile(io, fptr); + GetOpenFile(io_get_io(RARRAY(read)->ptr[i]), fptr); FD_SET(fileno(fptr->f), rp); if (READ_DATA_PENDING(fptr->f)) { /* check for buffered data */ pending++; @@ -2033,9 +2034,7 @@ f_select(argc, argv, obj) wp = &wset; FD_ZERO(wp); for (i=0; ilen; i++) { - VALUE io = io_get_io(RARRAY(write)->ptr[i]); - - GetOpenFile(io, fptr); + GetOpenFile(io_get_io(RARRAY(write)->ptr[i]), fptr); FD_SET(fileno(fptr->f), wp); if (max < fileno(fptr->f)) max = fileno(fptr->f); if (fptr->f2) { @@ -2052,9 +2051,7 @@ f_select(argc, argv, obj) ep = &eset; FD_ZERO(ep); for (i=0; ilen; i++) { - VALUE io = io_get_io(RARRAY(except)->ptr[i]); - - GetOpenFile(io, fptr); + GetOpenFile(io_get_io(RARRAY(except)->ptr[i]), fptr); FD_SET(fileno(fptr->f), ep); if (max < fileno(fptr->f)) max = fileno(fptr->f); if (fptr->f2) { @@ -2097,7 +2094,7 @@ f_select(argc, argv, obj) if (rp) { list = RARRAY(res)->ptr[0]; for (i=0; i< RARRAY(read)->len; i++) { - GetOpenFile(RARRAY(read)->ptr[i], fptr); + GetOpenFile(io_get_io(RARRAY(read)->ptr[i]), fptr); if (FD_ISSET(fileno(fptr->f), rp) || FD_ISSET(fileno(fptr->f), &pset)) { ary_push(list, RARRAY(read)->ptr[i]); @@ -2108,7 +2105,7 @@ f_select(argc, argv, obj) if (wp) { list = RARRAY(res)->ptr[1]; for (i=0; i< RARRAY(write)->len; i++) { - GetOpenFile(RARRAY(write)->ptr[i], fptr); + GetOpenFile(io_get_io(RARRAY(write)->ptr[i]), fptr); if (FD_ISSET(fileno(fptr->f), wp)) { ary_push(list, RARRAY(write)->ptr[i]); } @@ -2121,7 +2118,7 @@ f_select(argc, argv, obj) if (ep) { list = RARRAY(res)->ptr[2]; for (i=0; i< RARRAY(except)->len; i++) { - GetOpenFile(RARRAY(except)->ptr[i], fptr); + GetOpenFile(io_get_io(RARRAY(except)->ptr[i]), fptr); if (FD_ISSET(fileno(fptr->f), ep)) { ary_push(list, RARRAY(except)->ptr[i]); } diff --git a/parse.y b/parse.y index 5d5ade2eb5..ea0976dfef 100644 --- a/parse.y +++ b/parse.y @@ -1708,7 +1708,9 @@ nextc() } while (RSTRING(v)->len >= 2 && RSTRING(v)->ptr[RSTRING(v)->len-1] == '\n' && - RSTRING(v)->ptr[RSTRING(v)->len-2] == '\\') { + RSTRING(v)->ptr[RSTRING(v)->len-2] == '\\' && + (RSTRING(v)->len == 2 || + RSTRING(v)->ptr[RSTRING(v)->len-2] != '\\')) { VALUE v2 = io_gets(lex_input); if (!NIL_P(v2)) { @@ -1964,9 +1966,17 @@ parse_regx(term, paren) tokadd(c); } else { + int c1; + pushback(c); - tokadd('\\'); - tokadd(read_escape()); + c1 = read_escape(); + if (c1 != c) { + tokadd(c1); + } + else { + tokadd('\\'); + tokadd(c); + } } } continue; @@ -2013,6 +2023,7 @@ parse_regx(term, paren) tokfix(); lex_state = EXPR_END; if (list) { + nd_set_line(list, re_start); if (toklen() > 0) { VALUE ss = str_new(tok(), toklen()); list_append(list, NEW_STR(ss)); @@ -2091,6 +2102,7 @@ parse_string(func, term, paren) tokfix(); lex_state = EXPR_END; if (list) { + nd_set_line(list, strstart); if (toklen() > 0) { VALUE ss = str_new(tok(), toklen()); list_append(list, NEW_STR(ss)); @@ -2229,14 +2241,15 @@ here_document(term) return 0; } sourceline++; - if (strncmp(eos, RSTRING(line)->ptr, len) == 0 && - (RSTRING(line)->ptr[len] == '\n' || - RSTRING(line)->ptr[len] == '\r')) { - break; - } lex_pbeg = lex_p = RSTRING(line)->ptr; lex_pend = lex_p + RSTRING(line)->len; + retry: + if (strncmp(eos, lex_p, len) == 0 && + (lex_p[len] == '\n' || lex_p[len] == '\r')) { + break; + } + switch (parse_string(term, '\n', '\n')) { case tSTRING: case tXSTRING: @@ -2261,6 +2274,9 @@ here_document(term) case 0: goto error; } + if (lex_p != lex_pend) { + goto retry; + } } free(eos); lex_lastline = lastline_save; @@ -2273,6 +2289,7 @@ here_document(term) sourceline = linesave; if (list) { + nd_set_line(list, linesave+1); yylval.node = list; } switch (term) { @@ -3230,6 +3247,8 @@ str_extend(list, term) newtok(); return list; } + case '\n': + sourceline++; default: tokadd(c); break; @@ -3551,6 +3570,9 @@ aryset(recv, idx, val) idx = arg_add(idx, val); } } + else { + idx = val; + } return NEW_CALL(recv, tASET, idx); } diff --git a/regex.c b/regex.c index 5d93c47811..50bcd6a6d1 100644 --- a/regex.c +++ b/regex.c @@ -1100,26 +1100,10 @@ re_compile_pattern(pattern, size, bufp) else break; } - /* $ means succeed if at end of line, but only in special contexts. - If validly in the middle of a pattern, it is a normal character. */ - - if (p0 == pend || *p0 == '\n' - || *p0 == ')' - || *p0 == '|') - { - BUFPUSH(endline); - break; - } - goto normal_char; + BUFPUSH(endline); + break; } case '^': - /* ^ means succeed if at beg of line, but only if no preceding - pattern. */ - - if (laststart) - goto invalid_pattern; - if (laststart && p - 2 >= pattern && p[-2] != '\n') - goto normal_char; BUFPUSH(begline); break; @@ -2857,12 +2841,6 @@ re_search(bufp, string, size, startpos, range, regs) if (startpos > size) return -1; if (anchor && size > 0 && startpos == size) return -1; - if (fastmap && startpos == size && range >= 0 - && (bufp->can_be_null == 0 || - (bufp->can_be_null && size > 0 - && string[startpos-1] == '\n'))) - return -1; - val = re_match(bufp, string, size, startpos, regs); if (val >= 0) return startpos; @@ -3262,8 +3240,11 @@ re_match(bufp, string_arg, size, pos, regs) /* If not end of string, try backtracking. Otherwise done. */ if (d != dend) { - while (stackp != stackb && (int)stackp[-1] == 1) + while (stackp != stackb && (int)stackp[-1] == 1) { + if (best_regs_set) + goto restore_best_regs; POP_FAILURE_POINT(); + } if (stackp != stackb) { /* More failure points to try. */ @@ -3548,15 +3529,18 @@ re_match(bufp, string_arg, size, pos, regs) } case begline: - if (size == 0 - || AT_STRINGS_BEG(d) - || (d && d[-1] == '\n')) - break; - else - goto fail; + if (size == 0 || AT_STRINGS_BEG(d)) + break; + if (d[-1] == '\n' && !AT_STRINGS_END(d)) + break; + goto fail; case endline: - if (AT_STRINGS_END(d) || *d == '\n') + if (AT_STRINGS_END(d)) { + if (size == 0 || d[-1] != '\n') + break; + } + else if (*d == '\n') break; goto fail; diff --git a/ruby.c b/ruby.c index f80873eb1a..1b7c03e9c5 100644 --- a/ruby.c +++ b/ruby.c @@ -560,10 +560,10 @@ load_file(fname, script) if (RSTRING(line)->ptr[RSTRING(line)->len-2] == '\r') RSTRING(line)->ptr[RSTRING(line)->len-2] = '\0'; if (p = strstr(p, " -")) { - int argc; char *argv[2]; char **argvp = argv; + int argc; char *argv[3]; char **argvp = argv; char *s = ++p; - argc = 2; argv[0] = 0; + argc = 2; argv[0] = argv[2] = 0; while (*p == '-') { while (*s && !ISSPACE(*s)) s++; diff --git a/sprintf.c b/sprintf.c index 9a05d78335..3331fab03a 100644 --- a/sprintf.c +++ b/sprintf.c @@ -585,7 +585,7 @@ f_sprintf(argc, argv) } sprint_exit: - if (RTEST(verbose) && argc > 1) { + if (RTEST(verbose) && argc > 0) { ArgError("too many argument for format string"); } result = str_new(buf, blen); diff --git a/string.c b/string.c index b57c7175e7..5e00b20e59 100644 --- a/string.c +++ b/string.c @@ -574,11 +574,15 @@ str_index(str, sub, offset) char *s, *e, *p; int len; + if (offset < 0) { + offset += RSTRING(str)->len; + if (offset < 0) return -1; + } if (RSTRING(str)->len - offset < RSTRING(sub)->len) return -1; s = RSTRING(str)->ptr+offset; p = RSTRING(sub)->ptr; len = RSTRING(sub)->len; - e = s + RSTRING(str)->len - len + 1; + e = RSTRING(str)->ptr + RSTRING(str)->len - len + 1; while (s < e) { if (*s == *(RSTRING(sub)->ptr) && memcmp(s, p, len) == 0) { return (s-(RSTRING(str)->ptr)); @@ -1474,7 +1478,7 @@ str_inspect(str) return str_new(buf, b - buf); } -VALUE +static VALUE str_dump(str) VALUE str; { @@ -1488,7 +1492,7 @@ str_dump(str) while (p < pend) { char c = *p++; switch (c) { - case '"': case '\'': + case '"': case '\\': case '\n': case '\r': case '\t': case '\f': case '\013': case '\007': case '\033': @@ -1537,7 +1541,7 @@ str_dump(str) *q++ = '\\'; *q++ = 'f'; } - else if (c == '\13') { + else if (c == '\013') { *q++ = '\\'; *q++ = 'v'; } @@ -1545,7 +1549,7 @@ str_dump(str) *q++ = '\\'; *q++ = 'a'; } - else if (c == 033) { + else if (c == '\033') { *q++ = '\\'; *q++ = 'e'; } diff --git a/time.c b/time.c index bceb0854dc..25c953e12e 100644 --- a/time.c +++ b/time.c @@ -396,6 +396,21 @@ time_hash(time) return INT2FIX(hash); } +static VALUE +time_clone(time) + VALUE time; +{ + VALUE obj; + struct time_object *tobj, *newtobj; + + GetTimeval(time, tobj); + obj = Data_Make_Struct(0, struct time_object, 0, free, newtobj); + CLONESETUP(obj, time); + MEMCPY(newtobj, tobj, struct time_object, 1); + + return obj; +} + static VALUE time_localtime(time) VALUE time; -- cgit v1.2.3