1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

backtrace may be Qnil

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1999-07-22 10:37:27 +00:00
parent 86307f52ee
commit a1530c751e
39 changed files with 899 additions and 757 deletions

View file

@ -1,3 +1,80 @@
Tue Jul 20 02:28:34 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* io.c (rb_gets): $_ should be nil, when get returns nil.
* io.c (rb_f_gets): ditto.
Mon Jul 19 17:13:09 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* regex.c (re_compile_fastmap): should continue fastmap compile
for anychar_repeat, for it's repeat anyway.
Mon Jul 19 01:57:28 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* lib/mkmf.rb: no longer use install program.
* ext/extmk.rb.in: use miniruby to install programs.
Sat Jul 17 00:06:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* ext/socket/socket.c (ipaddr): don't do reverse lookup if
attribute do_not_reverse_lookup is set for socket classes.
Experimental. Note this is a global attribute.
Fri Jul 16 22:18:29 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* io.c (rb_io_eof): use feof() to check EOF already met.
* io.c (read_all): should return nil at EOF.
Fri Jul 16 13:39:42 1999 Wakou Aoyama <wakou@fsinet.or.jp>
* lib/telnet.rb: version 0.231.
Fri Jul 16 10:58:22 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
* regex.c (re_match): debug print removed.
Fri Jul 16 09:58:15 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
* many files: clean up unsed variables found by gcc -Wall.
* lib/mkmf.rb: better cygwin support etc.
* ext/extmk.rb.in: ditto.
* instruby.rb: ditto.
Fri Jul 16 01:37:50 1999 Koji Arai <JCA02266@nifty.ne.jp>
* string.c (rb_str_squeeze_bang): the type of local variable `c'
should be int, not char.
* string.c (rb_str_reverse): should always return copy.
Thu Jul 15 23:25:57 1999 NAKAMURA Hiroshi <nakahiro@sarion.co.jp>
* lib/debug.rb: better display & frame treatment.
Thu Jul 15 21:16:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* array.c (rb_ary_each): returns self for normal termination;
returns nil for break.
* string.c: non bang methods (e.g. String#sub) should always
return copy of the receiver.
Thu Jul 15 21:09:15 1999 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
* eval.c (find_file): do not add empty string to the path.
* configure.in (with-search-path): should not add empty string if
the option is not supplied.
Thu Jul 15 17:49:08 1999 Ryo HAYASAKA <hayasaka@univ21.u-aizu.ac.jp>
* ext/tcltklib/tcltklib.c: move `#include "ruby.h"' forward.
Thu Jul 15 16:54:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp> Thu Jul 15 16:54:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* version 1.3.5 - version 1.4 alpha * version 1.3.5 - version 1.4 alpha

View file

@ -32,7 +32,6 @@ file.c
gc.c gc.c
hash.c hash.c
inits.c inits.c
install-sh
instruby.rb instruby.rb
intern.h intern.h
io.c io.c
@ -89,21 +88,6 @@ ext/extmk.rb.nt
lib/CGI.rb lib/CGI.rb
lib/English.rb lib/English.rb
lib/Env.rb lib/Env.rb
lib/Mail/README
lib/Mail/README.jp
lib/Mail/doc.jp/changes.html
lib/Mail/doc.jp/index.html
lib/Mail/doc.jp/pop.html
lib/Mail/doc.jp/session.html
lib/Mail/doc.jp/smtp.html
lib/Mail/doc/changes.html
lib/Mail/doc/index.html
lib/Mail/doc/pop.html
lib/Mail/doc/session.html
lib/Mail/doc/smtp.html
lib/Mail/pop.rb
lib/Mail/session.rb
lib/Mail/smtp.rb
lib/README lib/README
lib/base64.rb lib/base64.rb
lib/cgi-lib.rb lib/cgi-lib.rb

8
ToDo
View file

@ -1,13 +1,16 @@
Language Spec. Language Spec.
* ../... outside condition invokes operator method too.
* %w(a\ b\ c abc) => ["a b c", "abc"] * %w(a\ b\ c abc) => ["a b c", "abc"]
* package or access control for global variables * package or access control for global variables
* class variable (prefix?)
* named arguments like foo(nation:="german") or foo(nation: "german"). * named arguments like foo(nation:="german") or foo(nation: "german").
* method to retrieve argument information (need new C API) * method to retrieve argument information (need new C API)
* multiple return values, yield values. maybe incompatible * multiple return values, yield values. maybe incompatible
* cascading method invocation ??? * cascading method invocation ???
* def Class#method .. end ?? * def Class#method .. end ??
* class Foo::Bar<Baz .. end, module Boo::Bar .. end * class Foo::Bar<Baz .. end, module Boo::Bar .. end
* def Foo::Bar::baz() .. end ??
Hacking Interpreter Hacking Interpreter
@ -23,7 +26,8 @@ Standard Libraries
* String#scanf(?) * String#scanf(?)
* Object#fmt(?) * Object#fmt(?)
* Integer[num], Float[num] (String[str]?, Array[obj]??) * Time::strptime
* Integer[num], Float[num]; Fixnum[num]?
* method to detect non-number trailer for to_i/to_f. * method to detect non-number trailer for to_i/to_f.
* Stream or Port, abstract superclass of IO ? * Stream or Port, abstract superclass of IO ?
* String#{pred,prev}, String#downto * String#{pred,prev}, String#downto
@ -36,7 +40,7 @@ Extension Libraries
Ruby Libraries Ruby Libraries
* maillib {pop3,smtp} * net/pop.rb net/smtp.rb
* httplib.rb, urllib.rb, nttplib.rb, etc. * httplib.rb, urllib.rb, nttplib.rb, etc.
* format like perl's * format like perl's

View file

@ -552,7 +552,7 @@ rb_ary_each(ary)
for (i=0; i<RARRAY(ary)->len; i++) { for (i=0; i<RARRAY(ary)->len; i++) {
rb_yield(RARRAY(ary)->ptr[i]); rb_yield(RARRAY(ary)->ptr[i]);
} }
return Qnil; return ary;
} }
static VALUE static VALUE
@ -564,7 +564,7 @@ rb_ary_each_index(ary)
for (i=0; i<RARRAY(ary)->len; i++) { for (i=0; i<RARRAY(ary)->len; i++) {
rb_yield(INT2NUM(i)); rb_yield(INT2NUM(i));
} }
return Qnil; return ary;
} }
static VALUE static VALUE
@ -576,7 +576,7 @@ rb_ary_reverse_each(ary)
while (len--) { while (len--) {
rb_yield(RARRAY(ary)->ptr[len]); rb_yield(RARRAY(ary)->ptr[len]);
} }
return Qnil; return ary;
} }
static VALUE static VALUE
@ -922,7 +922,7 @@ rb_ary_delete(ary, item)
if (rb_iterator_p()) { if (rb_iterator_p()) {
return rb_yield(item); return rb_yield(item);
} }
return Qnil; return ary;
} }
else { else {
RARRAY(ary)->len = i2; RARRAY(ary)->len = i2;

594
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -73,9 +73,6 @@ AC_PROG_YACC
AC_PROG_RANLIB AC_PROG_RANLIB
AC_SUBST(AR) AC_SUBST(AR)
AC_CHECK_PROGS(AR, ar aal, ar) AC_CHECK_PROGS(AR, ar aal, ar)
AC_PROG_INSTALL
test -z "$INSTALL_DLLIB" && INSTALL_DLLIB='${INSTALL} -m 555'
AC_SUBST(INSTALL_DLLIB)
AC_PROG_LN_S AC_PROG_LN_S
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
@ -324,6 +321,9 @@ AC_ARG_WITH(dln-a-out,
*) with_dln_a_out=no;; *) with_dln_a_out=no;;
esac], [with_dln_a_out=no]) esac], [with_dln_a_out=no])
AC_EXEEXT
AC_OBJEXT
AC_SUBST(XLDFLAGS)dnl AC_SUBST(XLDFLAGS)dnl
case "$host_os" in case "$host_os" in
@ -781,7 +781,9 @@ AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH}/${arch}")
AC_ARG_WITH(search-path, AC_ARG_WITH(search-path,
[--with-search-path specify the additional search path], [--with-search-path specify the additional search path],
[search_path=$withval]) [search_path=$withval])
AC_DEFINE_UNQUOTED(RUBY_SEARCH_PATH,"$search_path") if test "$search_path" != ""; then
AC_DEFINE_UNQUOTED(RUBY_SEARCH_PATH,"$search_path")
fi
echo "creating config.h" echo "creating config.h"
cat confdefs.h > config.h cat confdefs.h > config.h

23
eval.c
View file

@ -4490,10 +4490,15 @@ find_file(file)
int i; int i;
Check_Type(rb_load_path, T_ARRAY); Check_Type(rb_load_path, T_ARRAY);
vpath = rb_ary_new();
for (i=0;i<RARRAY(rb_load_path)->len;i++) { for (i=0;i<RARRAY(rb_load_path)->len;i++) {
Check_SafeStr(RARRAY(rb_load_path)->ptr[i]); VALUE str = RARRAY(rb_load_path)->ptr[i];
Check_SafeStr(str);
if (RSTRING(str)->len > 0) {
rb_ary_push(vpath, str);
}
} }
vpath = rb_ary_join(rb_load_path, rb_str_new2(RUBY_PATH_SEP)); vpath = rb_ary_join(vpath, rb_str_new2(RUBY_PATH_SEP));
path = STR2CSTR(vpath); path = STR2CSTR(vpath);
if (safe_level >= 2 && !rb_path_check(path)) { if (safe_level >= 2 && !rb_path_check(path)) {
rb_raise(rb_eSecurityError, "loading from unsefe path %s", path); rb_raise(rb_eSecurityError, "loading from unsefe path %s", path);
@ -6258,7 +6263,7 @@ rb_thread_schedule()
} }
if (num_waiting_on_fd > 0 || num_waiting_on_timer > 0) { if (num_waiting_on_fd > 0 || num_waiting_on_timer > 0) {
fd_set readfds, writefds, exceptfds; fd_set readfds;
struct timeval delay_tv, *delay_ptr; struct timeval delay_tv, *delay_ptr;
double delay, now; /* OK */ double delay, now; /* OK */
@ -6574,7 +6579,9 @@ rb_thread_join(thread)
VALUE oldbt = get_backtrace(th->errinfo); VALUE oldbt = get_backtrace(th->errinfo);
VALUE errat = make_backtrace(); VALUE errat = make_backtrace();
rb_ary_unshift(errat, rb_ary_entry(oldbt, 0)); if (TYPE(oldbt) == T_ARRAY) {
rb_ary_unshift(errat, rb_ary_entry(oldbt, 0));
}
set_backtrace(th->errinfo, errat); set_backtrace(th->errinfo, errat);
rb_exc_raise(th->errinfo); rb_exc_raise(th->errinfo);
} }
@ -6707,19 +6714,19 @@ rb_thread_sleep_forever()
rb_thread_schedule(); rb_thread_schedule();
} }
static int rb_thread_abort; static int thread_abort;
static VALUE static VALUE
rb_thread_s_abort_exc() rb_thread_s_abort_exc()
{ {
return rb_thread_abort?Qtrue:Qfalse; return thread_abort?Qtrue:Qfalse;
} }
static VALUE static VALUE
rb_thread_s_abort_exc_set(self, val) rb_thread_s_abort_exc_set(self, val)
VALUE self, val; VALUE self, val;
{ {
rb_thread_abort = RTEST(val); thread_abort = RTEST(val);
return val; return val;
} }
@ -6898,7 +6905,7 @@ rb_thread_create_0(fn, arg, klass)
/* delegate exception to main_thread */ /* delegate exception to main_thread */
rb_thread_raise(1, &ruby_errinfo, main_thread->thread); rb_thread_raise(1, &ruby_errinfo, main_thread->thread);
} }
else if (rb_thread_abort || curr_thread->abort || RTEST(ruby_debug)) { else if (thread_abort || curr_thread->abort || RTEST(ruby_debug)) {
VALUE err = rb_exc_new(rb_eSystemExit, 0, 0); VALUE err = rb_exc_new(rb_eSystemExit, 0, 0);
error_print(); error_print();
/* exit on main_thread */ /* exit on main_thread */

View file

@ -3,21 +3,21 @@
$".push 'mkmf.rb' $".push 'mkmf.rb'
if ARGV[0] == 'static' if ARGV[0] == 'static'
$force_static = TRUE $force_static = true
ARGV.shift ARGV.shift
elsif ARGV[0] == 'install' elsif ARGV[0] == 'install'
$install = TRUE $install = true
$destdir = ARGV[1] || '' $destdir = ARGV[1] || ''
ARGV.shift ARGV.shift
elsif ARGV[0] == 'clean' elsif ARGV[0] == 'clean'
$clean = TRUE $clean = true
ARGV.shift ARGV.shift
end end
SRC_EXT = ["c", "cc", "cxx", "C"] SRC_EXT = ["c", "cc", "cxx", "C"]
$extlist = [] $extlist = []
$cache_mod = FALSE; $cache_mod = false
$lib_cache = {} $lib_cache = {}
$func_cache = {} $func_cache = {}
$hdr_cache = {} $hdr_cache = {}
@ -31,13 +31,6 @@ $topdir = File.expand_path("..")
load "#{$top_srcdir}/lib/find.rb" load "#{$top_srcdir}/lib/find.rb"
## drive letter
if PLATFORM == "i386-os2_emx" then
$dots = ""
else
$dots = if "@INSTALL@" =~ /^\// then "" else "#{$topdir}/ext/" end
end
if File.exist?("config.cache") then if File.exist?("config.cache") then
f = open("config.cache", "r") f = open("config.cache", "r")
while f.gets while f.gets
@ -66,7 +59,7 @@ def older(file1, file2)
return false return false
end end
if PLATFORM == "m68k-human" if RUBY_PLATFORM == "m68k-human"
CFLAGS = "@CFLAGS@".gsub(/-c..-stack=[0-9]+ */, '') CFLAGS = "@CFLAGS@".gsub(/-c..-stack=[0-9]+ */, '')
else else
CFLAGS = "@CFLAGS@" CFLAGS = "@CFLAGS@"
@ -74,7 +67,7 @@ end
LINK = "@CC@ -o conftest -I#$topdir -I#$top_srcdir -I@includedir@ #{CFLAGS} @LDFLAGS@ %s %s conftest.c %s %s @LIBS@" LINK = "@CC@ -o conftest -I#$topdir -I#$top_srcdir -I@includedir@ #{CFLAGS} @LDFLAGS@ %s %s conftest.c %s %s @LIBS@"
CPP = "@CPP@ @CPPFLAGS@ -I#$topdir -I#$top_srcdir -I@includedir@ #{CFLAGS} %s %s conftest.c" CPP = "@CPP@ @CPPFLAGS@ -I#$topdir -I#$top_srcdir -I@includedir@ #{CFLAGS} %s %s conftest.c"
if /cygwin|mswin32|djgpp|mingw32|m68k-human|i386-os2_emx/i =~ PLATFORM if /cygwin|mswin32|djgpp|mingw32|m68k-human|i386-os2_emx/i =~ RUBY_PLATFORM
$null = open("nul", "w") $null = open("nul", "w")
else else
$null = open("/dev/null", "w") $null = open("/dev/null", "w")
@ -147,8 +140,9 @@ def try_run(src, opt="")
end end
end end
def install_rb(mfile, srcdir) def install_rb(mfile, srcdir = nil)
libdir = srcdir + "/lib" libdir = "lib"
libdir = srcdir + "/" + libdir if srcdir
path = [] path = []
dir = [] dir = []
Find.find(libdir) do |f| Find.find(libdir) do |f|
@ -159,21 +153,17 @@ def install_rb(mfile, srcdir)
end end
for f in dir for f in dir
next if f == "." next if f == "."
mfile.printf "\t@test -d $(DESTDIR)$(pkglibdir)/%s || mkdir $(DESTDIR)$(pkglibdir)/%s\n", f, f mfile.printf "\t@$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(DESTDIR)$(pkglibdir)/%s\n", f
end end
for f in path for f in path
mfile.printf "\t$(INSTALL_DATA) $(srcdir)/lib/%s $(DESTDIR)$(pkglibdir)/%s\n", f, f mfile.printf "\t@$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0644, true)' $(srcdir)/lib/%s $(DESTDIR)$(pkglibdir)/%s\n", f, f
end end
end end
def have_library(lib, func="main") def have_library(lib, func="main")
if $lib_cache[lib] if $lib_cache[lib]
if $lib_cache[lib] == "yes" if $lib_cache[lib] == "yes"
if $libs $libs = "-l" + lib + " " + $libs
$libs = "-l" + lib + " " + $libs
else
$libs = "-l" + lib
end
return true return true
else else
return false return false
@ -181,11 +171,7 @@ def have_library(lib, func="main")
end end
if func && func != "" if func && func != ""
if $libs libs = "-l" + lib + " " + $libs
libs = "-l" + lib + " " + $libs
else
libs = "-l" + lib
end
unless try_link(<<"SRC", libs) unless try_link(<<"SRC", libs)
int main() { return 0; } int main() { return 0; }
int t() { #{func}(); return 0; } int t() { #{func}(); return 0; }
@ -195,11 +181,7 @@ SRC
return false return false
end end
else else
if $libs libs = "-l" + lib + " " + $libs
libs = "-l" + lib + " " + $libs
else
libs = "-l" + lib
end
end end
$libs = libs $libs = libs
@ -219,7 +201,6 @@ def have_func(func)
end end
libs = $libs libs = $libs
libs = "" if libs == nil
unless try_link(<<"SRC", libs) unless try_link(<<"SRC", libs)
char #{func}(); char #{func}();
@ -306,7 +287,7 @@ end
def create_makefile(target) def create_makefile(target)
system "rm -f conftest*" system "rm -f conftest*"
if $libs and "@DLEXT@" == "o" if "@DLEXT@" == "o"
libs = $libs.split libs = $libs.split
for lib in libs for lib in libs
lib.sub!(/-l(.*)/, '"lib\1.a"') lib.sub!(/-l(.*)/, '"lib\1.a"')
@ -316,25 +297,17 @@ def create_makefile(target)
$DLDFLAGS = '@DLDFLAGS@' $DLDFLAGS = '@DLDFLAGS@'
if PLATFORM =~ /beos/ if RUBY_PLATFORM =~ /beos/
if $libs $libs = $libs + " -lruby"
$libs = $libs + " -lruby"
else
$libs = "-lruby"
end
$DLDFLAGS = $DLDFLAGS + " -L" + $topdir $DLDFLAGS = $DLDFLAGS + " -L" + $topdir
end end
defflag = '' defflag = ''
if PLATFORM =~ /cygwin/ and not $static if RUBY_PLATFORM =~ /cygwin/ and not $static
if File.exist? target + ".def" if File.exist? target + ".def"
defflag = "--def=" + target + ".def" defflag = "--def=" + target + ".def"
end end
if $libs $libs = $libs + " @LIBRUBYARG@"
$libs = $libs + " @LIBRUBYARG@"
else
$libs = "@LIBRUBYARG@"
end
$DLDFLAGS = $DLDFLAGS + " -L" + $topdir $DLDFLAGS = $DLDFLAGS + " -L" + $topdir
end end
@ -354,7 +327,6 @@ DESTDIR =
CC = @CC@ CC = @CC@
prefix = @prefix@
CFLAGS = %s -I$(topdir) -I$(hdrdir) -I@includedir@ #{CFLAGS} #$CFLAGS %s CFLAGS = %s -I$(topdir) -I$(hdrdir) -I@includedir@ #{CFLAGS} #$CFLAGS %s
DLDFLAGS = #$DLDFLAGS #$LDFLAGS DLDFLAGS = #$DLDFLAGS #$LDFLAGS
LDSHARED = @LDSHARED@ #{defflag} LDSHARED = @LDSHARED@ #{defflag}
@ -393,15 +365,13 @@ archdir = $(pkglibdir)/@arch@
TARGET = #{target} TARGET = #{target}
DLLIB = $(TARGET).#{$static ? "a" : "@DLEXT@"} DLLIB = $(TARGET).#{$static ? "a" : "@DLEXT@"}
INSTALL = #{$dots}@INSTALL@ RUBY = ../../miniruby@binsuffix@
INSTALL_DLLIB = @INSTALL_DLLIB@
INSTALL_DATA = @INSTALL_DATA@
binsuffix = @binsuffix@ binsuffix = @binsuffix@
all: $(DLLIB) all: $(DLLIB)
clean:; @rm -f *.o *.a *.so *.sl *.a clean:; @rm -f *.o *.so *.sl *.a $(DLLIB)
@rm -f Makefile extconf.h conftest.* @rm -f Makefile extconf.h conftest.*
@rm -f core ruby$(binsuffix) *~ @rm -f core ruby$(binsuffix) *~
@ -411,20 +381,18 @@ EOS
mfile.printf <<EOS mfile.printf <<EOS
install: install:
@test -d $(DESTDIR)$(libdir) || mkdir $(DESTDIR)$(libdir) @$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(DESTDIR)$(libdir) $(DESTDIR)$(pkglibdir) $(DESTDIR)$(archdir)
@test -d $(DESTDIR)$(pkglibdir) || mkdir $(DESTDIR)$(pkglibdir)
@test -d $(DESTDIR)$(archdir) || mkdir $(DESTDIR)$(archdir)
EOS EOS
if !$static unless $static
mfile.printf "\ mfile.printf "\
$(INSTALL_DLLIB) $(DLLIB) $(DESTDIR)$(archdir)/$(DLLIB) @$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0555, true)' $(DLLIB) $(DESTDIR)$(archdir)/$(DLLIB)
" "
end end
install_rb(mfile, $srcdir) install_rb(mfile, $srcdir)
mfile.printf "\n" mfile.printf "\n"
if $static if $static
mfile.printf "\ mfile.printf "\
$(DLLIB): $(OBJS) $(DLLIB): $(OBJS)
@AR@ cru $(DLLIB) $(OBJS) @AR@ cru $(DLLIB) $(OBJS)
@-@RANLIB@ $(DLLIB) 2> /dev/null || true @-@RANLIB@ $(DLLIB) 2> /dev/null || true
@ -434,7 +402,7 @@ $(DLLIB): $(OBJS)
$(DLLIB): $(OBJS) $(DLLIB): $(OBJS)
$(LDSHARED) $(DLDFLAGS) -o $(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS) $(LDSHARED) $(DLDFLAGS) -o $(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)
" "
elsif PLATFORM == "m68k-human" elsif RUBY_PLATFORM == "m68k-human"
mfile.printf "\ mfile.printf "\
$(DLLIB): $(OBJS) $(DLLIB): $(OBJS)
ar cru $(DLLIB) $(OBJS) ar cru $(DLLIB) $(OBJS)
@ -456,15 +424,15 @@ $(DLLIB): $(OBJS)
end end
mfile.close mfile.close
if PLATFORM =~ /beos/ if RUBY_PLATFORM =~ /beos/
if PLATFORM =~ /^powerpc/ then if RUBY_PLATFORM =~ /^powerpc/ then
deffilename = "ruby.exp" deffilename = "ruby.exp"
else else
deffilename = "ruby.def" deffilename = "ruby.def"
end end
print "creating ruby.def\n" print "creating #{deffilename}\n"
open(deffilename, "w") do |file| open(deffilename, "w") do |file|
file.print("EXPORTS\n") if PLATFORM =~ /^i/ file.print("EXPORTS\n") if RUBY_PLATFORM =~ /^i/
file.print("Init_#{target}\n") file.print("Init_#{target}\n")
end end
end end
@ -474,13 +442,13 @@ def extmake(target)
if $force_static or $static_ext[target] if $force_static or $static_ext[target]
$static = target $static = target
else else
$static = FALSE $static = false
end end
return if $nodynamic and not $static return if $nodynamic and not $static
$objs = nil $objs = nil
$libs = PLATFORM =~ /cygwin|beos|openstep|nextstep|rhapsody/ ? nil : "-lc" $libs = RUBY_PLATFORM =~ /cygwin|beos|openstep|nextstep|rhapsody/ ? "" : "-lc"
$LOCAL_LIBS = "" # to be assigned in extconf.rb $LOCAL_LIBS = "" # to be assigned in extconf.rb
$CFLAGS = "" $CFLAGS = ""
$LDFLAGS = "" $LDFLAGS = ""
@ -499,7 +467,7 @@ def extmake(target)
if File.exist?("#{$top_srcdir}/ext/#{target}/extconf.rb") if File.exist?("#{$top_srcdir}/ext/#{target}/extconf.rb")
load "#{$top_srcdir}/ext/#{target}/extconf.rb" load "#{$top_srcdir}/ext/#{target}/extconf.rb"
else else
create_makefile(target); create_makefile(target)
end end
end end
if File.exist?("./Makefile") if File.exist?("./Makefile")
@ -517,7 +485,7 @@ def extmake(target)
if $static if $static
$extlibs ||= "" $extlibs ||= ""
$extlibs += " " + $LDFLAGS unless $LDFLAGS == "" $extlibs += " " + $LDFLAGS unless $LDFLAGS == ""
$extlibs += " " + $libs if $libs $extlibs += " " + $libs unless $libs == ""
$extlibs += " " + $LOCAL_LIBS unless $LOCAL_LIBS == "" $extlibs += " " + $LOCAL_LIBS unless $LOCAL_LIBS == ""
end end
ensure ensure
@ -539,10 +507,10 @@ for setup in ["@setup@", "#{$top_srcdir}/ext/@setup@"]
sub!(/#.*$/, '') sub!(/#.*$/, '')
next if /^\s*$/ next if /^\s*$/
if /^option +nodynamic/ if /^option +nodynamic/
$nodynamic = TRUE $nodynamic = true
next next
end end
$static_ext[$_.split[0]] = TRUE $static_ext[$_.split[0]] = true
end end
f.close f.close
break break
@ -560,7 +528,7 @@ for d in Dir["#{$top_srcdir}/ext/*"]
print "cleaning ", d, "\n" print "cleaning ", d, "\n"
else else
print "compiling ", d, "\n" print "compiling ", d, "\n"
if PLATFORM =~ /-aix/ and older("../ruby.imp", "../miniruby") if RUBY_PLATFORM =~ /-aix/ and older("../ruby.imp", "../miniruby")
load "#{$top_srcdir}/ext/aix_mksym.rb" load "#{$top_srcdir}/ext/aix_mksym.rb"
end end
end end
@ -600,7 +568,7 @@ if $extlist.size > 0
$extobjs += f $extobjs += f
$extobjs += " " $extobjs += " "
else else
FALSE false
end end
end end
@ -628,7 +596,7 @@ if $extlist.size > 0
else else
$extobjs = "ext/extinit.o " $extobjs = "ext/extinit.o "
end end
if PLATFORM =~ /m68k-human|beos/ if RUBY_PLATFORM =~ /m68k-human|beos/
$extlibs.gsub!("-L/usr/local/lib", "") if $extlibs $extlibs.gsub!("-L/usr/local/lib", "") if $extlibs
end end
system format(%[#{$make} #{ruby} EXTOBJS="%s" EXTLIBS="%s"], $extobjs, $extlibs) system format(%[#{$make} #{ruby} EXTOBJS="%s" EXTLIBS="%s"], $extobjs, $extlibs)

View file

@ -1571,7 +1571,7 @@ mime_begin(f)
FILE *f; FILE *f;
{ {
int c1; int c1;
int i,j,k; int i,j;
int r[MAXRECOVER]; /* recovery buffer, max mime pattern lenght */ int r[MAXRECOVER]; /* recovery buffer, max mime pattern lenght */
mime_mode = FALSE; mime_mode = FALSE;

View file

@ -208,7 +208,6 @@ establishShell(shellname, info)
struct pty_info *info; struct pty_info *info;
{ {
static int i,j,master,slave,currentPid; static int i,j,master,slave,currentPid;
static char procName[32];
char *p,*getenv(); char *p,*getenv();
struct passwd *pwent; struct passwd *pwent;
RETSIGTYPE chld_changed(); RETSIGTYPE chld_changed();

View file

@ -268,7 +268,7 @@ hist_each(self)
for (i = 0; i < state->length; i++) { for (i = 0; i < state->length; i++) {
rb_yield(rb_str_new2(state->entries[i]->line)); rb_yield(rb_str_new2(state->entries[i]->line));
} }
return Qnil; return self;
} }
static VALUE static VALUE

View file

@ -363,11 +363,11 @@ int need;
char twin[PBLKSIZ]; char twin[PBLKSIZ];
#ifdef MSDOS #ifdef MSDOS
char zer[PBLKSIZ]; char zer[PBLKSIZ];
long oldtail;
#endif #endif
char *pag = db->pagbuf; char *pag = db->pagbuf;
char *new = twin; char *new = twin;
register int smax = SPLTMAX; register int smax = SPLTMAX;
long oldtail;
do { do {
/* /*

View file

@ -446,7 +446,9 @@ getaddrinfo(hostname, servname, hints, res)
for (i = 0; afdl[i].a_af; i++) { for (i = 0; afdl[i].a_af; i++) {
if (inet_pton(afdl[i].a_af, hostname, pton)) { if (inet_pton(afdl[i].a_af, hostname, pton)) {
u_long v4a; u_long v4a;
#ifdef INET6
u_char pfx; u_char pfx;
#endif
switch (afdl[i].a_af) { switch (afdl[i].a_af) {
case AF_INET: case AF_INET:
@ -521,8 +523,11 @@ get_name(addr, afd, res, numaddr, pai, port0)
u_short port = port0 & 0xffff; u_short port = port0 & 0xffff;
struct hostent *hp; struct hostent *hp;
struct addrinfo *cur; struct addrinfo *cur;
int error = 0, h_error; int error = 0;
#ifdef INET6
int h_error;
#endif
#ifdef INET6 #ifdef INET6
hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error); hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
#else #else

View file

@ -135,7 +135,9 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
int family, len, i; int family, len, i;
char *addr, *p; char *addr, *p;
u_long v4a; u_long v4a;
#ifdef INET6
u_char pfx; u_char pfx;
#endif
int h_error; int h_error;
char numserv[512]; char numserv[512];
char numaddr[512]; char numaddr[512];

View file

@ -46,6 +46,8 @@ extern int rb_thread_select(int, fd_set*, fd_set*, fd_set*, struct timeval*); /*
#endif #endif
#include "sockport.h" #include "sockport.h"
static int do_not_reverse_lookup = 0;
VALUE rb_cBasicSocket; VALUE rb_cBasicSocket;
VALUE rb_cIPSocket; VALUE rb_cIPSocket;
VALUE rb_cTCPSocket; VALUE rb_cTCPSocket;
@ -423,6 +425,19 @@ bsock_recv(argc, argv, sock)
return s_recv(sock, argc, argv, RECV_RECV); return s_recv(sock, argc, argv, RECV_RECV);
} }
static VALUE
bsock_do_not_rev_lookup()
{
return do_not_reverse_lookup?Qtrue:Qfalse;
}
static VALUE
bsock_do_not_rev_lookup_set(self, val)
{
do_not_reverse_lookup = RTEST(val);
return val;
}
static void static void
mkipaddr0(addr, buf, len) mkipaddr0(addr, buf, len)
struct sockaddr *addr; struct sockaddr *addr;
@ -476,7 +491,6 @@ ip_addrsetup(host, port)
hostp = NULL; hostp = NULL;
} }
else if (rb_obj_is_kind_of(host, rb_cInteger)) { else if (rb_obj_is_kind_of(host, rb_cInteger)) {
struct sockaddr_in sin;
long i = NUM2LONG(host); long i = NUM2LONG(host);
mkinetaddr(htonl(i), hbuf, sizeof(hbuf)); mkinetaddr(htonl(i), hbuf, sizeof(hbuf));
@ -535,7 +549,6 @@ ipaddr(sockaddr)
{ {
VALUE family, port, addr1, addr2; VALUE family, port, addr1, addr2;
VALUE ary; VALUE ary;
struct addrinfo hints, *res;
int error; int error;
char hbuf[1024], pbuf[1024]; char hbuf[1024], pbuf[1024];
@ -552,18 +565,23 @@ ipaddr(sockaddr)
family = 0; family = 0;
break; break;
} }
error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf), if (!do_not_reverse_lookup) {
NULL, 0, 0); error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf),
if (error) { NULL, 0, 0);
rb_raise(rb_eSocket, "%s", gai_strerror(error)); if (error) {
rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
addr1 = rb_str_new2(hbuf);
} }
addr1 = rb_str_new2(hbuf);
error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf), error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV); pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV);
if (error) { if (error) {
rb_raise(rb_eSocket, "%s", gai_strerror(error)); rb_raise(rb_eSocket, "%s", gai_strerror(error));
} }
addr2 = rb_str_new2(hbuf); addr2 = rb_str_new2(hbuf);
if (do_not_reverse_lookup) {
addr1 = addr2;
}
port = INT2FIX(atoi(pbuf)); port = INT2FIX(atoi(pbuf));
ary = rb_ary_new3(4, family, port, addr1, addr2); ary = rb_ary_new3(4, family, port, addr1, addr2);
@ -665,7 +683,6 @@ open_inet(class, h, serv, type)
struct addrinfo hints, *res, *res0; struct addrinfo hints, *res, *res0;
int fd, status; int fd, status;
char *syscall; char *syscall;
VALUE sock;
char pbuf[1024], *portp; char pbuf[1024], *portp;
char *host; char *host;
int error; int error;
@ -1434,7 +1451,7 @@ sock_accept(sock)
VALUE sock; VALUE sock;
{ {
OpenFile *fptr; OpenFile *fptr;
VALUE addr, sock2; VALUE sock2;
char buf[1024]; char buf[1024];
int len = sizeof buf; int len = sizeof buf;
@ -1519,7 +1536,6 @@ static VALUE
mkaddrinfo(res0) mkaddrinfo(res0)
struct addrinfo *res0; struct addrinfo *res0;
{ {
char **pch;
VALUE base, ary; VALUE base, ary;
struct addrinfo *res; struct addrinfo *res;
@ -1817,6 +1833,7 @@ sock_define_const(name, value)
rb_define_const(mConst, name, INT2FIX(value)); rb_define_const(mConst, name, INT2FIX(value));
} }
void
Init_socket() Init_socket()
{ {
rb_eSocket = rb_define_class("SocketError", rb_eStandardError); rb_eSocket = rb_define_class("SocketError", rb_eStandardError);
@ -1824,6 +1841,12 @@ Init_socket()
rb_cBasicSocket = rb_define_class("BasicSocket", rb_cIO); rb_cBasicSocket = rb_define_class("BasicSocket", rb_cIO);
rb_undef_method(CLASS_OF(rb_cBasicSocket), "new"); rb_undef_method(CLASS_OF(rb_cBasicSocket), "new");
rb_undef_method(CLASS_OF(rb_cBasicSocket), "open"); rb_undef_method(CLASS_OF(rb_cBasicSocket), "open");
rb_define_singleton_method(rb_cBasicSocket, "do_not_reverse_lookup",
bsock_do_not_rev_lookup, 0);
rb_define_singleton_method(rb_cBasicSocket, "do_not_reverse_lookup=",
bsock_do_not_rev_lookup_set, 1);
rb_define_method(rb_cBasicSocket, "close_read", bsock_close_read, 0); rb_define_method(rb_cBasicSocket, "close_read", bsock_close_read, 0);
rb_define_method(rb_cBasicSocket, "close_write", bsock_close_write, 0); rb_define_method(rb_cBasicSocket, "close_write", bsock_close_write, 0);
rb_define_method(rb_cBasicSocket, "shutdown", bsock_shutdown, -1); rb_define_method(rb_cBasicSocket, "shutdown", bsock_shutdown, -1);

View file

@ -4,12 +4,12 @@
* Oct. 24, 1997 Y. Matsumoto * Oct. 24, 1997 Y. Matsumoto
*/ */
#include "ruby.h"
#include "rubysig.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <tcl.h> #include <tcl.h>
#include <tk.h> #include <tk.h>
#include "ruby.h"
#include "rubysig.h"
#ifdef __MACOS__ #ifdef __MACOS__
# include <tkMac.h> # include <tkMac.h>

View file

@ -52,7 +52,11 @@ File.makedirs archdir, true
File.makedirs pkglibdir+"/site_ruby", true File.makedirs pkglibdir+"/site_ruby", true
File.makedirs pkglibdir+"/site_ruby/"+CONFIG["arch"], true File.makedirs pkglibdir+"/site_ruby/"+CONFIG["arch"], true
if PLATFORM =~ /-aix/ if RUBY_PLATFORM =~ /cygwin/ and File.exist? "import.h"
File.install "import.h", archdir, 0644, true
end
if RUBY_PLATFORM =~ /-aix/
File.install "ruby.imp", archdir, 0644, true File.install "ruby.imp", archdir, 0644, true
end end

26
io.c
View file

@ -317,6 +317,7 @@ rb_io_eof(io)
GetOpenFile(io, fptr); GetOpenFile(io, fptr);
rb_io_check_readable(fptr); rb_io_check_readable(fptr);
if (feof(fptr->f)) return Qtrue;
if (READ_DATA_PENDING(fptr->f)) return Qfalse; if (READ_DATA_PENDING(fptr->f)) return Qfalse;
READ_CHECK(fptr->f); READ_CHECK(fptr->f);
TRAP_BEG; TRAP_BEG;
@ -397,13 +398,17 @@ read_all(port)
GetOpenFile(port, fptr); GetOpenFile(port, fptr);
rb_io_check_readable(fptr); rb_io_check_readable(fptr);
if (feof(fptr->f)) return Qnil;
if (fstat(fileno(fptr->f), &st) == 0 && S_ISREG(st.st_mode) if (fstat(fileno(fptr->f), &st) == 0 && S_ISREG(st.st_mode)
#ifdef __BEOS__ #ifdef __BEOS__
&& (st.st_dev > 3) && (st.st_dev > 3)
#endif #endif
) )
{ {
if (st.st_size == 0) return rb_str_new(0, 0); if (st.st_size == 0) {
getc(fptr->f); /* force EOF */
return rb_str_new(0, 0);
}
else { else {
long pos = ftell(fptr->f); long pos = ftell(fptr->f);
if (st.st_size > pos && pos >= 0) { if (st.st_size > pos && pos >= 0) {
@ -417,9 +422,8 @@ read_all(port)
TRAP_BEG; TRAP_BEG;
n = fread(RSTRING(str)->ptr+bytes, 1, siz-bytes, fptr->f); n = fread(RSTRING(str)->ptr+bytes, 1, siz-bytes, fptr->f);
TRAP_END; TRAP_END;
if (n <= 0) { if (n < 0) {
if (ferror(fptr->f)) rb_sys_fail(fptr->path); rb_sys_fail(fptr->path);
return rb_str_new(0,0);
} }
bytes += n; bytes += n;
if (bytes < siz) break; if (bytes < siz) break;
@ -452,15 +456,15 @@ io_read(argc, argv, io)
GetOpenFile(io, fptr); GetOpenFile(io, fptr);
rb_io_check_readable(fptr); rb_io_check_readable(fptr);
if (feof(fptr->f)) return Qtrue;
str = rb_str_new(0, len); str = rb_str_new(0, len);
READ_CHECK(fptr->f); READ_CHECK(fptr->f);
TRAP_BEG; TRAP_BEG;
n = fread(RSTRING(str)->ptr, 1, len, fptr->f); n = fread(RSTRING(str)->ptr, 1, len, fptr->f);
TRAP_END; TRAP_END;
if (n <= 0) { if (n < 0) {
if (ferror(fptr->f)) rb_sys_fail(fptr->path); rb_sys_fail(fptr->path);
return Qnil;
} }
RSTRING(str)->len = n; RSTRING(str)->len = n;
RSTRING(str)->ptr[n] = '\0'; RSTRING(str)->ptr[n] = '\0';
@ -767,7 +771,7 @@ rb_io_each_line(argc, argv, io)
while (!NIL_P(str = rb_io_gets_internal(argc, argv, io))) { while (!NIL_P(str = rb_io_gets_internal(argc, argv, io))) {
rb_yield(str); rb_yield(str);
} }
return Qnil; return io;
} }
static VALUE static VALUE
@ -2319,7 +2323,7 @@ rb_f_gets(argc, argv)
{ {
VALUE line = rb_f_gets_internal(argc, argv); VALUE line = rb_f_gets_internal(argc, argv);
if (!NIL_P(line)) rb_lastline_set(line); rb_lastline_set(line);
return line; return line;
} }
@ -2340,8 +2344,8 @@ rb_gets()
next_p = 1; next_p = 1;
goto retry; goto retry;
} }
rb_lastline_set(line);
if (!NIL_P(line)) { if (!NIL_P(line)) {
rb_lastline_set(line);
gets_lineno++; gets_lineno++;
lineno = INT2FIX(gets_lineno); lineno = INT2FIX(gets_lineno);
} }
@ -2997,7 +3001,7 @@ argf_each_line(argc, argv)
while (RTEST(str = rb_f_gets_internal(argc, argv))) { while (RTEST(str = rb_f_gets_internal(argc, argv))) {
rb_yield(str); rb_yield(str);
} }
return Qnil; return argf;
} }
static VALUE static VALUE

View file

@ -246,7 +246,7 @@ class CGI < SimpleDelegator
CGI::tag("BODY"){ message } CGI::tag("BODY"){ message }
} }
} }
TRUE true
end end
# print error message to $> and exit # print error message to $> and exit

View file

@ -1,22 +1,12 @@
class DEBUGGER__ class DEBUGGER__
def max(a,b)
if (a<b); b; else a; end
end
def min(a,b)
if (a<=b); a; else b; end
end
trap("INT") { DEBUGGER__::CONTEXT.interrupt } trap("INT") { DEBUGGER__::CONTEXT.interrupt }
$DEBUG = TRUE $DEBUG = true
def initialize def initialize
@break_points = [] @break_points = []
@stop_next = 1 @stop_next = 1
@frames = [nil] @frames = [nil]
@frame_pos = nil # nil means not '0' but `unknown'.
@last_file = nil @last_file = nil
@last = [nil, nil]
@scripts = {} @scripts = {}
end end
@ -41,16 +31,17 @@ class DEBUGGER__
end end
def debug_command(file, line, id, binding) def debug_command(file, line, id, binding)
frame_pos = 0
binding_file = file binding_file = file
binding_line = line binding_line = line
debug_line = {} previus_line = nil
if (ENV['EMACS'] == 't') if (ENV['EMACS'] == 't')
STDOUT.printf "\032\032%s:%d:\n", binding_file, binding_line STDOUT.printf "\032\032%s:%d:\n", binding_file, binding_line
else else
STDOUT.printf "%s:%d:%s", binding_file, binding_line, STDOUT.printf "%s:%d:%s", binding_file, binding_line,
line_at(binding_file, binding_line) line_at(binding_file, binding_line)
end end
@frames[-1] = binding @frames[0] = binding
STDOUT.print "(rdb:-) " STDOUT.print "(rdb:-) "
STDOUT.flush STDOUT.flush
while input = STDIN.gets while input = STDIN.gets
@ -60,10 +51,10 @@ class DEBUGGER__
else else
DEBUG_LAST_CMD[0] = input DEBUG_LAST_CMD[0] = input
end end
case input
when /^b(reak)?\s+(([^:\n]+:)?.+)/ case input
pos = $2 when /^b(?:reak)?\s+((?:[^:\n]+:)?.+)/
pos = $1
if pos.index ":" if pos.index ":"
file, pos = pos.split(":") file, pos = pos.split(":")
end end
@ -78,15 +69,15 @@ class DEBUGGER__
pname pname
@break_points.push [file, pos] @break_points.push [file, pos]
when /^b(reak)?$/ when /^b(?:reak)?$/, /^i(?:nfo) b(?:reak)?$/
n = 0 n = 0
for f, p in @break_points for f, p in @break_points
STDOUT.printf "%d %s:%s\n", n, f, p STDOUT.printf "%d %s:%s\n", n, f, p
n += 1 n += 1
end end
when /^del(ete)?(\s+(\d+))?$/ when /^del(?:ete)?(?:\s+(\d+))?$/
pos = $3 pos = $1
unless pos unless pos
STDOUT.print "clear all breakpoints? (y/n) " STDOUT.print "clear all breakpoints? (y/n) "
STDOUT.flush STDOUT.flush
@ -107,99 +98,111 @@ class DEBUGGER__
end end
end end
when /^c(ont)?$/ when /^c(?:ont)?$/
return return
when /^s(tep)?\s*(\d+)?$/ when /^s(?:tep)?\s*(\d+)?$/
if $2 if $1
lev = Integer($2) lev = Integer($1)
else else
lev = 1 lev = 1
end end
@stop_next = lev @stop_next = lev
return return
when /^n(ext)?\s*(\d+)?$/ when /^n(?:ext)?\s*(\d+)?$/
if $2 if $1
lev = Integer($2) lev = Integer($1)
else else
lev = 1 lev = 1
end end
@stop_next = lev @stop_next = lev
@no_step = @frames.size @no_step = @frames.size - frame_pos
return return
when /^i(?:nfo)?/, /^w(?:here)?/ when /^w(?:here)?$/, /^f(?:rame)?$/
fs = @frames.size at = caller(0)
tb = caller(0)[-fs..-1].reverse 0.upto( @frames.size - 1 ) do |n|
unless @frame_pos; @frame_pos = fs - 1; end if ( frame_pos == n )
STDOUT.printf "--> #%d %s\n", n, at[-(@frames.size - n)]
(fs-1).downto(0){ |i|
if (@frame_pos == i)
STDOUT.printf "--> frame %d:%s\n", i, tb[i]
else else
STDOUT.printf " frame %d:%s\n", i, tb[i] STDOUT.printf " #%d %s\n", n, at[-(@frames.size - n)]
end end
}
when /^l(ist)?$/
fs = @frames.size
tb = caller(0)[-fs..-1].reverse
unless @frame_pos; @frame_pos = fs - 1; end
file, line, func = tb[@frame_pos].split(":")
line = line.to_i
b = line - 1
e = line + 9
line_at(file, line)
if lines = @scripts[file] and lines != TRUE
lines = [0] + lines # Simple offset adjust
b = max(0, b); e = min(lines.size-1, e)
for l in b..e
if (l == line)
STDOUT.printf "--> %5d %s", l, lines[l]
else
STDOUT.printf " %5d %s", l, lines[l]
end
end
else
STDOUT.printf "no sourcefile available for %s\n", file
end end
when /^d(?:own)?\s*(\d+)??$/ when /^l(?:ist)?(?:\s+(.+))?$/
if $1; lev = Integer($1); else lev = 1; end if !$1
unless @frame_pos; @frame_pos = 0; end b = previus_line ? previus_line + 10 : binding_line - 5
@frame_pos -= lev e = b + 9
if @frame_pos < 0 elsif $1 == '-'
STDOUT.print "at stack bottom\n" b = previus_line ? previus_line - 10 : binding_line - 5
@frame_pos = 0 e = b + 9
else else
STDOUT.printf "at level %d\n", @frame_pos b, e = $1.split(/[-,]/)
end if e
binding = @frames[@frame_pos] b = Integer(b)
e = Integer(e)
else
b = Integer(b) - 5
e = b + 9
end
end
previus_line = b
STDOUT.printf "[%d, %d] in %s\n", b, e, binding_file
line_at(binding_file, binding_line)
if lines = @scripts[binding_file] and lines != true
n = 0
b.upto(e) do |n|
if n > 0 && lines[n-1]
if ( n == binding_line )
STDOUT.printf "=> %d %s\n", n, lines[n-1].chomp
else
STDOUT.printf " %d %s\n", n, lines[n-1].chomp
end
end
end
else
STDOUT.printf "no sourcefile available for %s\n", binding_file
end
when /^u(?:p)?\s*(\d+)?$/ when /^up\s*(\d+)?$/
if $1; lev = Integer($1); else lev = 1; end previus_line = nil
unless @frame_pos; @frame_pos = @frames.size - 1; end if $1
@frame_pos += lev lev = Integer($1)
p @frame_pos else
if @frame_pos >= @frames.size lev = 1
STDOUT.print "at toplevel\n" end
@frame_pos = nil frame_pos += lev
else if frame_pos >= @frames.size
binding = @frames[@frame_pos] frame_pos = @frames.size - 1
frame_info = caller(4)[-(@frame_pos+1)] STDOUT.print "at toplevel\n"
STDOUT.print "at #{frame_info}\n"
frame_info.sub( /:in `.*'$/, '' ) =~ /^(.*):(\d+)$/ #`
binding_file, binding_line = $1, $2.to_i
binding = @frames[@frame_pos]
end end
binding = @frames[frame_pos]
info, binding_file, binding_line = frame_info(frame_pos)
STDOUT.printf "#%d %s\n", frame_pos, info
when /^f(inish)?/ when /^down\s*(\d+)?$/
@finish_pos = @frames.size previus_line = nil
if $1
lev = Integer($1)
else
lev = 1
end
frame_pos -= lev
if frame_pos < 0
frame_pos = 0
STDOUT.print "at stack bottom\n"
end
binding = @frames[frame_pos]
info, binding_file, binding_line = frame_info(frame_pos)
STDOUT.printf "#%d %s\n", frame_pos, info
when /^fi(?:nish)?$/
@finish_pos = @frames.size - frame_pos
frame_pos = 0
return return
when /^q(uit)?$/ when /^q(?:uit)?$/
STDOUT.print "really quit? (y/n) " STDOUT.print "really quit? (y/n) "
STDOUT.flush STDOUT.flush
input = STDIN.gets.chop! input = STDIN.gets.chop!
@ -217,22 +220,28 @@ class DEBUGGER__
end end
end end
def frame_info(pos = 0)
info = caller(0)[-(@frames.size - pos)]
info.sub( /:in `.*'$/, '' ) =~ /^(.*):(\d+)$/ #`
[info, $1, $2.to_i]
end
def line_at(file, line) def line_at(file, line)
lines = @scripts[file] lines = @scripts[file]
if lines if lines
return "\n" if lines == TRUE return "\n" if lines == true
line = lines[line-1] line = lines[line-1]
return "\n" unless line return "\n" unless line
return line return line
end end
save = $DEBUG save = $DEBUG
begin begin
$DEBUG = FALSE $DEBUG = false
f = open(file) f = open(file)
lines = @scripts[file] = f.readlines lines = @scripts[file] = f.readlines
rescue rescue
$DEBUG = save $DEBUG = save
@scripts[file] = TRUE @scripts[file] = true
return "\n" return "\n"
end end
line = lines[line-1] line = lines[line-1]
@ -254,15 +263,14 @@ class DEBUGGER__
index = @break_points.index([file, pos]) index = @break_points.index([file, pos])
STDOUT.printf "Breakpoint %d, %s at %s:%s\n", STDOUT.printf "Breakpoint %d, %s at %s:%s\n",
index, debug_funcname(id), file, pos index, debug_funcname(id), file, pos
return TRUE return true
end end
return FALSE return false
end end
def excn_handle(file, line, id, binding) def excn_handle(file, line, id, binding)
fs = @frames.size fs = @frames.size
tb = caller(0)[-fs..-1] tb = caller(0)[-fs..-1]
unless @frame_pos; @frame_pos = fs - 1; end
STDOUT.printf "%s\n", $! STDOUT.printf "%s\n", $!
for i in tb for i in tb
@ -271,11 +279,15 @@ class DEBUGGER__
debug_command(file, line, id, binding) debug_command(file, line, id, binding)
end end
def trace_func(event, file, line, id, binding) def trace_func(event, file, line, id, binding)
if event == 'line' case event
if @no_step == nil or @no_step >= @frames.size when 'line'
if !@no_step or @frames.size == @no_step
@stop_next -= 1 @stop_next -= 1
elsif @frames.size < @no_step
@stop_next = 0 # break here before leaving...
else
# nothing to do. skipped.
end end
if @stop_next == 0 if @stop_next == 0
if [file, line] == @last if [file, line] == @last
@ -289,31 +301,26 @@ class DEBUGGER__
if check_break_points(file, line, binding, id) if check_break_points(file, line, binding, id)
debug_command(file, line, id, binding) debug_command(file, line, id, binding)
end end
end
if event == 'call' when 'call'
@frames.push binding @frames.unshift binding
if check_break_points(file, id.id2name, binding, id) if check_break_points(file, id.id2name, binding, id)
debug_command(file, line, id, binding) debug_command(file, line, id, binding)
end end
end
if event == 'class' when 'class'
@frames.push binding @frames.unshift binding
end
if event == 'return' or event == 'end' when 'return', 'end'
if @finish_pos == @frames.size if @frames.size == @finish_pos
@stop_next = 1 @stop_next = 1
end end
@frames.pop @frames.shift
end
if event == 'raise' when 'raise'
# @frames.push binding
excn_handle(file, line, id, binding) excn_handle(file, line, id, binding)
end
end
@last_file = file @last_file = file
end end

View file

@ -157,7 +157,7 @@ module Finalizer
# method to call finalize_* safely. # method to call finalize_* safely.
def safe def safe
old_status = Thread.critical old_status = Thread.critical
Thread.critical = TRUE Thread.critical = true
ObjectSpace.remove_finalizer(@proc) ObjectSpace.remove_finalizer(@proc)
yield yield
ObjectSpace.add_finalizer(@proc) ObjectSpace.add_finalizer(@proc)

View file

@ -67,7 +67,7 @@ class << File
to = catname(from, to) to = catname(from, to)
$stderr.print from, " -> ", to, "\n" if verbose $stderr.print from, " -> ", to, "\n" if verbose
if PLATFORM =~ /djgpp|cygwin|mswin32/ and FileTest.file? to if RUBY_PLATFORM =~ /djgpp|cygwin|mswin32/ and FileTest.file? to
unlink to unlink to
end end
fstat = stat(from) fstat = stat(from)

View file

@ -15,7 +15,7 @@ $RCS_ID=%q$Header$
def isSingle(lopt) def isSingle(lopt)
if lopt.index(":") if lopt.index(":")
if lopt.split(":")[0].length == 1 if lopt.split(":")[0].length == 1
return TRUE return true
end end
end end
return nil return nil
@ -87,13 +87,13 @@ def getopts(single_opts, *options)
return nil return nil
end end
setOption(compare, ARGV[1]) setOption(compare, ARGV[1])
opts[compare] = TRUE opts[compare] = true
ARGV.shift ARGV.shift
count += 1 count += 1
break break
elsif lo == compare elsif lo == compare
setOption(compare, TRUE) setOption(compare, true)
opts[compare] = TRUE opts[compare] = true
count += 1 count += 1
break break
end end
@ -106,19 +106,19 @@ def getopts(single_opts, *options)
for idx in 1..(ARGV[0].length - 1) for idx in 1..(ARGV[0].length - 1)
compare = ARGV[0][idx, 1] compare = ARGV[0][idx, 1]
if single_opts && compare =~ "[" + single_opts + "]" if single_opts && compare =~ "[" + single_opts + "]"
setOption(compare, TRUE) setOption(compare, true)
opts[compare] = TRUE opts[compare] = true
count += 1 count += 1
elsif single_colon != "" && compare =~ "[" + single_colon + "]" elsif single_colon != "" && compare =~ "[" + single_colon + "]"
if ARGV[0][idx..-1].length > 1 if ARGV[0][idx..-1].length > 1
setOption(compare, ARGV[0][(idx + 1)..-1]) setOption(compare, ARGV[0][(idx + 1)..-1])
opts[compare] = TRUE opts[compare] = true
count += 1 count += 1
elsif ARGV.length <= 1 elsif ARGV.length <= 1
return nil return nil
else else
setOption(compare, ARGV[1]) setOption(compare, ARGV[1])
opts[compare] = TRUE opts[compare] = true
ARGV.shift ARGV.shift
count += 1 count += 1
end end
@ -127,7 +127,7 @@ def getopts(single_opts, *options)
end end
else else
compare = ARGV[0] compare = ARGV[0]
opts[compare] = TRUE opts[compare] = true
newargv << ARGV[0] newargv << ARGV[0]
end end

View file

@ -1,6 +1,6 @@
# jcode.rb - ruby code to handle japanese (EUC/SJIS) string # jcode.rb - ruby code to handle japanese (EUC/SJIS) string
$vsave, $VERBOSE = $VERBOSE, FALSE $vsave, $VERBOSE = $VERBOSE, false
class String class String
printf STDERR, "feel free for some warnings:\n" if $VERBOSE printf STDERR, "feel free for some warnings:\n" if $VERBOSE
@ -58,7 +58,10 @@ class String
return nil return nil
end end
ExpandChCache = {}
def _expand_ch def _expand_ch
return ExpandChCache[self] if ExpandChCache.key? self
a = [] a = []
self.scan(/(.|\n)-(.|\n)|(.|\n)/) do |r| self.scan(/(.|\n)-(.|\n)|(.|\n)/) do |r|
if $3 if $3
@ -71,6 +74,7 @@ class String
$1.upto($2) { |c| a.push c } $1.upto($2) { |c| a.push c }
end end
end end
ExpandChCache[self] = a
a a
end end
@ -78,7 +82,7 @@ class String
return self.delete!(from) if to.length == 0 return self.delete!(from) if to.length == 0
if from =~ /^\^/ if from =~ /^\^/
comp=TRUE comp=true
from = $' from = $'
end end
afrom = from._expand_ch afrom = from._expand_ch
@ -109,7 +113,7 @@ class String
def delete!(del) def delete!(del)
if del =~ /^\^/ if del =~ /^\^/
comp=TRUE comp=true
del = $' del = $'
end end
adel = del._expand_ch adel = del._expand_ch
@ -133,7 +137,7 @@ class String
def squeeze!(del=nil) def squeeze!(del=nil)
if del if del
if del =~ /^\^/ if del =~ /^\^/
comp=TRUE comp=true
del = $' del = $'
end end
adel = del._expand_ch adel = del._expand_ch
@ -161,7 +165,7 @@ class String
def tr_s!(from, to) def tr_s!(from, to)
return self.delete!(from) if to.length == 0 return self.delete!(from) if to.length == 0
if from =~ /^\^/ if from =~ /^\^/
comp=TRUE comp=true
from = $' from = $'
end end
afrom = from._expand_ch afrom = from._expand_ch

View file

@ -121,7 +121,7 @@ class Bignum
end end
class Rational class Rational
Unify = TRUE Unify = true
alias power! ** alias power! **
@ -304,6 +304,6 @@ module Math
end end
class Complex class Complex
Unify = TRUE Unify = true
end end

View file

@ -39,7 +39,7 @@
# creates a matrix where `rows' indicates rows. # creates a matrix where `rows' indicates rows.
# `rows' is an array of arrays, # `rows' is an array of arrays,
# e.g, Matrix[[11, 12], [21, 22]] # e.g, Matrix[[11, 12], [21, 22]]
# Matrix.rows(rows, copy = TRUE) # Matrix.rows(rows, copy = true)
# creates a matrix where `rows' indicates rows. # creates a matrix where `rows' indicates rows.
# if optional argument `copy' is false, use the array as # if optional argument `copy' is false, use the array as
# internal structure of the metrix without copying. # internal structure of the metrix without copying.
@ -145,7 +145,7 @@
# #
# INSTANCE CREATION: # INSTANCE CREATION:
# Vector.[](*array) # Vector.[](*array)
# Vector.elements(array, copy = TRUE) # Vector.elements(array, copy = true)
# ACCSESSING: # ACCSESSING:
# [](i) # [](i)
# size # size
@ -195,10 +195,10 @@ class Matrix
private_class_method :new private_class_method :new
def Matrix.[](*rows) def Matrix.[](*rows)
new(:init_rows, rows, FALSE) new(:init_rows, rows, false)
end end
def Matrix.rows(rows, copy = TRUE) def Matrix.rows(rows, copy = true)
new(:init_rows, rows, copy) new(:init_rows, rows, copy)
end end
@ -210,7 +210,7 @@ class Matrix
columns[j][i] columns[j][i]
} }
} }
Matrix.rows(rows, FALSE) Matrix.rows(rows, false)
end end
def Matrix.diagonal(*values) def Matrix.diagonal(*values)
@ -221,7 +221,7 @@ class Matrix
row[j] = values[j] row[j] = values[j]
row row
} }
rows(rows, FALSE) rows(rows, false)
end end
def Matrix.scalar(n, value) def Matrix.scalar(n, value)
@ -243,11 +243,11 @@ class Matrix
def Matrix.row_vector(row) def Matrix.row_vector(row)
case row case row
when Vector when Vector
Matrix.rows([row.to_a], FALSE) Matrix.rows([row.to_a], false)
when Array when Array
Matrix.rows([row.dup], FALSE) Matrix.rows([row.dup], false)
else else
Matrix.row([[row]], FALSE) Matrix.row([[row]], false)
end end
end end
@ -312,13 +312,13 @@ class Matrix
|i| |i|
@rows[i][j] @rows[i][j]
} }
Vector.elements(col, FALSE) Vector.elements(col, false)
end end
end end
def collect def collect
rows = @rows.collect{|row| row.collect{|e| yield e}} rows = @rows.collect{|row| row.collect{|e| yield e}}
Matrix.rows(rows, FALSE) Matrix.rows(rows, false)
end end
alias map collect alias map collect
@ -346,7 +346,7 @@ class Matrix
|row| |row|
row[from_col, size_col] row[from_col, size_col]
} }
Matrix.rows(rows, FALSE) Matrix.rows(rows, false)
end end
# TESTING # TESTING
@ -364,20 +364,20 @@ class Matrix
# COMPARING # COMPARING
def ==(other) def ==(other)
return FALSE unless Matrix === other return false unless Matrix === other
other.compare_by_row_vectors(@rows) other.compare_by_row_vectors(@rows)
end end
alias eql? == alias eql? ==
def compare_by_row_vectors(rows) def compare_by_row_vectors(rows)
return FALSE unless @rows.size == rows.size return false unless @rows.size == rows.size
0.upto(@rows.size - 1) do 0.upto(@rows.size - 1) do
|i| |i|
return FALSE unless @rows[i] == rows[i] return false unless @rows[i] == rows[i]
end end
TRUE true
end end
def clone def clone
@ -406,7 +406,7 @@ class Matrix
e * m e * m
} }
} }
return Matrix.rows(rows, FALSE) return Matrix.rows(rows, false)
when Vector when Vector
m = Matrix.column_vector(m) m = Matrix.column_vector(m)
r = self * m r = self * m
@ -426,7 +426,7 @@ class Matrix
vij vij
} }
} }
return Matrix.rows(rows, FALSE) return Matrix.rows(rows, false)
else else
x, y = m.coerce(self) x, y = m.coerce(self)
return x * y return x * y
@ -454,7 +454,7 @@ class Matrix
self[i, j] + m[i, j] self[i, j] + m[i, j]
} }
} }
Matrix.rows(rows, FALSE) Matrix.rows(rows, false)
end end
def -(m) def -(m)
@ -478,7 +478,7 @@ class Matrix
self[i, j] - m[i, j] self[i, j] - m[i, j]
} }
} }
Matrix.rows(rows, FALSE) Matrix.rows(rows, false)
end end
def /(other) def /(other)
@ -491,7 +491,7 @@ class Matrix
e / other e / other
} }
} }
return Matrix.rows(rows, FALSE) return Matrix.rows(rows, false)
when Matrix when Matrix
return self * other.inverse return self * other.inverse
else else
@ -620,10 +620,10 @@ class Matrix
begin begin
if (akk = a[k][k]) == 0 if (akk = a[k][k]) == 0
i = -1 i = -1
nothing = FALSE nothing = false
begin begin
if (i += 1) > column_size - 1 if (i += 1) > column_size - 1
nothing = TRUE nothing = true
break break
end end
end while a[i][k] == 0 end while a[i][k] == 0
@ -806,10 +806,10 @@ class Vector
private_class_method :new private_class_method :new
def Vector.[](*array) def Vector.[](*array)
new(:init_elements, array, copy = FALSE) new(:init_elements, array, copy = false)
end end
def Vector.elements(array, copy = TRUE) def Vector.elements(array, copy = true)
new(:init_elements, array, copy) new(:init_elements, array, copy)
end end
@ -854,7 +854,7 @@ class Vector
# COMPARING # COMPARING
def ==(other) def ==(other)
return FALSE unless Vector === other return false unless Vector === other
other.compare_by(@elements) other.compare_by(@elements)
end end
@ -878,7 +878,7 @@ class Vector
case x case x
when Numeric when Numeric
els = @elements.collect{|e| e * x} els = @elements.collect{|e| e * x}
Vector.elements(els, FALSE) Vector.elements(els, false)
when Matrix when Matrix
self.covector * x self.covector * x
else else
@ -895,7 +895,7 @@ class Vector
|v1, v2| |v1, v2|
v1 + v2 v1 + v2
} }
Vector.elements(els, FALSE) Vector.elements(els, false)
when Matrix when Matrix
Matrix.column_vector(self) + v Matrix.column_vector(self) + v
else else
@ -912,7 +912,7 @@ class Vector
|v1, v2| |v1, v2|
v1 - v2 v1 - v2
} }
Vector.elements(els, FALSE) Vector.elements(els, false)
when Matrix when Matrix
Matrix.column_vector(self) - v Matrix.column_vector(self) - v
else else
@ -939,7 +939,7 @@ class Vector
|v| |v|
yield v yield v
} }
Vector.elements(els, FALSE) Vector.elements(els, false)
end end
alias map collect alias map collect
@ -948,7 +948,7 @@ class Vector
|v1, v2| |v1, v2|
yield v1, v2 yield v1, v2
} }
Vector.elements(els, FALSE) Vector.elements(els, false)
end end
def r def r

View file

@ -6,7 +6,7 @@ require 'find'
include Config include Config
$found = false; $cache_mod = false
$lib_cache = {} $lib_cache = {}
$lib_found = {} $lib_found = {}
$func_cache = {} $func_cache = {}
@ -33,14 +33,6 @@ end
$srcdir = CONFIG["srcdir"] $srcdir = CONFIG["srcdir"]
$libdir = CONFIG["libdir"]+"/ruby/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"] $libdir = CONFIG["libdir"]+"/ruby/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
$archdir = $libdir+"/"+CONFIG["arch"] $archdir = $libdir+"/"+CONFIG["arch"]
$install = CONFIG["INSTALL_PROGRAM"]
$install_dllib = CONFIG["INSTALL_DLLIB"]
$install_data = CONFIG["INSTALL_DATA"]
if $install =~ %r!^[^\s/]+/! then
$install = CONFIG["compile_dir"]+"/"+$install
$install_dllib = CONFIG["compile_dir"]+"/"+$install_dllib
$install_data = CONFIG["compile_dir"]+"/"+$install_data
end
if File.exist? $archdir + "/ruby.h" if File.exist? $archdir + "/ruby.h"
$hdrdir = $archdir $hdrdir = $archdir
@ -52,12 +44,12 @@ else
end end
CFLAGS = CONFIG["CFLAGS"] CFLAGS = CONFIG["CFLAGS"]
if PLATFORM == "m68k-human" if RUBY_PLATFORM == "m68k-human"
CFLAGS.gsub!(/-c..-stack=[0-9]+ */, '') CFLAGS.gsub!(/-c..-stack=[0-9]+ */, '')
elsif PLATFORM =~ /-nextstep|-rhapsody/ elsif RUBY_PLATFORM =~ /-nextstep|-rhapsody/
CFLAGS.gsub!( /-arch\s\w*/, '' ); CFLAGS.gsub!( /-arch\s\w*/, '' )
end end
if /win32|djgpp|mingw32|m68k-human|i386-os2_emx/i =~ PLATFORM if /win32|djgpp|mingw32|m68k-human|i386-os2_emx/i =~ RUBY_PLATFORM
$null = open("nul", "w") $null = open("nul", "w")
else else
$null = open("/dev/null", "w") $null = open("/dev/null", "w")
@ -100,7 +92,6 @@ def try_cpp(src, opt="")
cfile.print src cfile.print src
cfile.close cfile.close
begin begin
xsystem(format(CPP, $CFLAGS, opt)) xsystem(format(CPP, $CFLAGS, opt))
ensure ensure
system "rm -f conftest*" system "rm -f conftest*"
@ -134,21 +125,23 @@ def try_run(src, opt="")
end end
end end
def install_rb(mfile) def install_rb(mfile, srcdir = nil)
libdir = "lib"
libdir = srcdir + "/" + libdir if srcdir
path = [] path = []
dir = [] dir = []
Find.find("lib") do |f| Find.find(libdir) do |f|
next unless /\.rb$/ =~ f next unless /\.rb$/ =~ f
f = f[4..-1] f = f[libdir.length+1..-1]
path.push f path.push f
dir |= File.dirname(f) dir |= File.dirname(f)
end end
for f in dir for f in dir
next if f == "." next if f == "."
mfile.printf "\t@test -d $(libdir)/%s || mkdir $(libdir)/%s\n", f, f mfile.printf "\t@$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(libdir)/%s\n", f
end end
for f in path for f in path
mfile.printf "\t$(INSTALL_DATA) lib/%s $(libdir)/%s\n", f, f mfile.printf "\t@$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0644, true)' lib/%s $(libdir)/%s\n", f, f
end end
end end
@ -157,54 +150,35 @@ def have_library(lib, func="main")
STDOUT.flush STDOUT.flush
if $lib_cache[lib] if $lib_cache[lib]
if $lib_cache[lib] == "yes" if $lib_cache[lib] == "yes"
if $libs $libs = "-l" + lib + " " + $libs
$libs = "-l" + lib + " " + $libs
else
$libs = "-l" + lib
end
print "(cached) yes\n" print "(cached) yes\n"
return TRUE return true
else else
print "(cached) no\n" print "(cached) no\n"
return FALSE return false
end end
end end
if func && func != "" if func && func != ""
cfile = open("conftest.c", "w") libs = "-l" + lib + " " + $libs
cfile.printf "\
int main() { return 0; }
int t() { %s(); return 0; }
", func
cfile.close
if $libs
libs = "-l" + lib + " " + $libs
else
libs = "-l" + lib
end
unless try_link(<<"SRC", libs) unless try_link(<<"SRC", libs)
int main() { return 0; } int main() { return 0; }
int t() { #{func}(); return 0; } int t() { #{func}(); return 0; }
SRC SRC
$lib_cache[lib] = 'no' $lib_cache[lib] = 'no'
$cache_mod = TRUE $cache_mod = true
print "no\n" print "no\n"
return FALSE return false
end end
else else
if $libs libs = "-l" + lib + " " + $libs
libs = "-l" + lib + " " + $libs
else
libs = "-l" + lib
end
end end
$libs = libs $libs = libs
$lib_cache[lib] = 'yes' $lib_cache[lib] = 'yes'
$cache_mod = TRUE $cache_mod = true
print "yes\n" print "yes\n"
return TRUE return true
end end
def have_func(func) def have_func(func)
@ -214,15 +188,14 @@ def have_func(func)
if $func_cache[func] == "yes" if $func_cache[func] == "yes"
$defs.push(format("-DHAVE_%s", func.upcase)) $defs.push(format("-DHAVE_%s", func.upcase))
print "(cached) yes\n" print "(cached) yes\n"
return TRUE return true
else else
print "(cached) no\n" print "(cached) no\n"
return FALSE return false
end end
end end
libs = $libs libs = $libs
libs = "" if libs == nil
unless try_link(<<"SRC", libs) unless try_link(<<"SRC", libs)
char #{func}(); char #{func}();
@ -230,15 +203,15 @@ int main() { return 0; }
int t() { #{func}(); return 0; } int t() { #{func}(); return 0; }
SRC SRC
$func_found[func] = 'no' $func_found[func] = 'no'
$found = TRUE $cache_mod = true
print "no\n" print "no\n"
return FALSE return false
end end
$defs.push(format("-DHAVE_%s", func.upcase)) $defs.push(format("-DHAVE_%s", func.upcase))
$func_found[func] = 'yes' $func_found[func] = 'yes'
$found = TRUE $cache_mod = true
print "yes\n" print "yes\n"
return TRUE return true
end end
def have_header(header) def have_header(header)
@ -249,10 +222,10 @@ def have_header(header)
header.tr!("a-z./\055", "A-Z___") header.tr!("a-z./\055", "A-Z___")
$defs.push(format("-DHAVE_%s", header)) $defs.push(format("-DHAVE_%s", header))
print "(cached) yes\n" print "(cached) yes\n"
return TRUE return true
else else
print "(cached) no\n" print "(cached) no\n"
return FALSE return false
end end
end end
@ -260,20 +233,20 @@ def have_header(header)
#include <#{header}> #include <#{header}>
SRC SRC
$hdr_found[header] = 'no' $hdr_found[header] = 'no'
$found = TRUE $cache_mod = true
print "no\n" print "no\n"
return FALSE return false
end end
$hdr_found[header] = 'yes' $hdr_found[header] = 'yes'
header.tr!("a-z./\055", "A-Z___") header.tr!("a-z./\055", "A-Z___")
$defs.push(format("-DHAVE_%s", header)) $defs.push(format("-DHAVE_%s", header))
$found = TRUE $cache_mod = true
print "yes\n" print "yes\n"
return TRUE return true
end end
def arg_config(config, default=nil) def arg_config(config, default=nil)
return default if /mswin32/i =~ PLATFORM return default if /mswin32/i =~ RUBY_PLATFORM
unless defined? $configure_args unless defined? $configure_args
$configure_args = {} $configure_args = {}
for arg in CONFIG["configure_args"].split + ARGV for arg in CONFIG["configure_args"].split + ARGV
@ -318,25 +291,33 @@ def create_header()
end end
end end
def create_makefile(target) def create_makefile(target, installpos = "")
print "creating Makefile\n" print "creating Makefile\n"
system "rm -f conftest*" system "rm -f conftest*"
STDOUT.flush STDOUT.flush
if $libs and CONFIG["DLEXT"] == "o" if CONFIG["DLEXT"] == "o"
libs = $libs.split libs = $libs.split
for lib in libs for lib in libs
lib.sub!(/-l(.*)/, '"lib\1.a"') lib.sub!(/-l(.*)/, '"lib\1.a"')
end end
$defs.push(format("-DEXTLIB='%s'", libs.join(","))) $defs.push(format("-DEXTLIB='%s'", libs.join(",")))
end end
$libs = "" unless $libs
$DLDFLAGS = CONFIG["DLDFLAGS"] $DLDFLAGS = CONFIG["DLDFLAGS"]
if PLATFORM =~ /beos/ if RUBY_PLATFORM =~ /beos/
$libs = $libs + " -lruby" $libs = $libs + " -lruby"
$DLDFLAGS = $DLDFLAGS + " -L" + CONFIG["prefix"] + "/lib" $DLDFLAGS = $DLDFLAGS + " -L" + CONFIG["prefix"] + "/lib"
end end
defflag = ''
if RUBY_PLATFORM =~ /cygwin/
if File.exist? target + ".def"
defflag = "--def=" + target + ".def"
end
$libs = $libs + " " + CONFIG["LIBRUBYARG"]
$DLDFLAGS = $DLDFLAGS + " -L$(topdir)"
end
unless $objs then unless $objs then
$objs = Dir["*.{c,cc,m}"] $objs = Dir["*.{c,cc,m}"]
for f in $objs for f in $objs
@ -360,7 +341,7 @@ CC = #{CONFIG["CC"]}
CFLAGS = #{CONFIG["CCDLFLAGS"]} -I$(hdrdir) -I#{CONFIG["includedir"]} #{CFLAGS} #{$CFLAGS} #{$defs.join(" ")} CFLAGS = #{CONFIG["CCDLFLAGS"]} -I$(hdrdir) -I#{CONFIG["includedir"]} #{CFLAGS} #{$CFLAGS} #{$defs.join(" ")}
CXXFLAGS = $(CFLAGS) CXXFLAGS = $(CFLAGS)
DLDFLAGS = #{$DLDFLAGS} #{$LDFLAGS} DLDFLAGS = #{$DLDFLAGS} #{$LDFLAGS}
LDSHARED = #{CONFIG["LDSHARED"]} LDSHARED = #{CONFIG["LDSHARED"]} #{defflag}
prefix = #{CONFIG["prefix"]} prefix = #{CONFIG["prefix"]}
exec_prefix = #{CONFIG["exec_prefix"]} exec_prefix = #{CONFIG["exec_prefix"]}
@ -376,15 +357,13 @@ OBJS = #{$objs}
TARGET = #{target} TARGET = #{target}
DLLIB = $(TARGET).#{CONFIG["DLEXT"]} DLLIB = $(TARGET).#{CONFIG["DLEXT"]}
INSTALL = #{$install} RUBY = #{CONFIG["ruby_install_name"]}
INSTALL_DLLIB = #{$install_dllib}
INSTALL_DATA = #{$install_data}
binsuffix = #{CONFIG["binsuffix"]} binsuffix = #{CONFIG["binsuffix"]}
all: $(DLLIB) all: $(DLLIB)
clean:; @rm -f *.o *.so *.sl *.a clean:; @rm -f *.o *.so *.sl *.a $(DLLIB)
@rm -f Makefile extconf.h conftest.* @rm -f Makefile extconf.h conftest.*
@rm -f core ruby$(binsuffix) *~ @rm -f core ruby$(binsuffix) *~
@ -393,9 +372,8 @@ realclean: clean
install: $(archdir)/$(DLLIB) install: $(archdir)/$(DLLIB)
$(archdir)/$(DLLIB): $(DLLIB) $(archdir)/$(DLLIB): $(DLLIB)
@test -d $(libdir) || mkdir $(libdir) @$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(libdir) $(archdir)
@test -d $(archdir) || mkdir $(archdir) @$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0555, true)' $(DLLIB) $(archdir)/$(DLLIB)
$(INSTALL_DLLIB) $(DLLIB) $(archdir)/$(DLLIB)
EOMF EOMF
install_rb(mfile) install_rb(mfile)
mfile.printf "\n" mfile.printf "\n"
@ -407,7 +385,7 @@ $(DLLIB): $(OBJS)
EOMF EOMF
elsif not File.exist?(target + ".c") and not File.exist?(target + ".cc") elsif not File.exist?(target + ".c") and not File.exist?(target + ".cc")
mfile.print "$(DLLIB): $(OBJS)\n" mfile.print "$(DLLIB): $(OBJS)\n"
case PLATFORM case RUBY_PLATFORM
when "m68k-human" when "m68k-human"
mfile.printf "ar cru $(DLLIB) $(OBJS)\n" mfile.printf "ar cru $(DLLIB) $(OBJS)\n"
else else
@ -425,7 +403,7 @@ EOMF
end end
mfile.close mfile.close
if $found if $cache_mod
begin begin
f = open($config_cache, "w") f = open($config_cache, "w")
for k,v in $lib_cache for k,v in $lib_cache
@ -451,16 +429,21 @@ EOMF
end end
end end
if PLATFORM =~ /beos/ if RUBY_PLATFORM =~ /beos/
print "creating ruby.def\n" if RUBY_PLATFORM =~ /^powerpc/ then
open("ruby.def", "w") do |file| deffilename = "ruby.exp"
file.print("EXPORTS\n") if PLATFORM =~ /^i/ else
deffilename = "ruby.def"
end
print "creating #{deffilename}\n"
open(deffilename, "w") do |file|
file.print("EXPORTS\n") if RUBY_PLATFORM =~ /^i/
file.print("Init_#{target}\n") file.print("Init_#{target}\n")
end end
end end
end end
$libs = PLATFORM =~ /cygwin32|beos|rhapsody|nextstep/ ? nil : "-lc" $libs = RUBY_PLATFORM =~ /cygwin|beos|openstep|nextstep|rhapsody/ ? "" : "-lc"
$objs = nil $objs = nil
$LOCAL_LIBS = "" $LOCAL_LIBS = ""
$CFLAGS = "" $CFLAGS = ""

View file

@ -67,33 +67,33 @@ module Mutex_m
end end
def mu_try_lock def mu_try_lock
result = FALSE result = false
Thread.critical = TRUE Thread.critical = true
unless @mu_locked unless @mu_locked
@mu_locked = TRUE @mu_locked = true
result = TRUE result = true
end end
Thread.critical = FALSE Thread.critical = false
result result
end end
def mu_lock def mu_lock
while (Thread.critical = TRUE; @mu_locked) while (Thread.critical = true; @mu_locked)
@mu_waiting.push Thread.current @mu_waiting.push Thread.current
Thread.stop Thread.stop
end end
@mu_locked = TRUE @mu_locked = true
Thread.critical = FALSE Thread.critical = false
self self
end end
def mu_unlock def mu_unlock
return unless @mu_locked return unless @mu_locked
Thread.critical = TRUE Thread.critical = true
wait = @mu_waiting wait = @mu_waiting
@mu_waiting = [] @mu_waiting = []
@mu_locked = FALSE @mu_locked = false
Thread.critical = FALSE Thread.critical = false
for w in wait for w in wait
w.run w.run
end end
@ -105,7 +105,7 @@ module Mutex_m
def initialize(*args) def initialize(*args)
ret = super ret = super
@mu_waiting = [] @mu_waiting = []
@mu_locked = FALSE; @mu_locked = false;
return ret return ret
end end
end end

View file

@ -23,7 +23,7 @@ module Observable
0 0
end end
end end
def changed(state=TRUE) def changed(state=true)
@observer_state = state @observer_state = state
end end
def changed? def changed?
@ -36,7 +36,7 @@ module Observable
i.update(*arg) i.update(*arg)
end end
end end
@observer_state = FALSE @observer_state = false
end end
end end
end end

View file

@ -17,7 +17,7 @@ module Shellwords
words = [] words = []
while line != '' while line != ''
field = '' field = ''
while TRUE while true
if line.sub! /^"(([^"\\]|\\.)*)"/, '' then #" if line.sub! /^"(([^"\\]|\\.)*)"/, '' then #"
snippet = $1 snippet = $1
snippet.gsub! /\\(.)/, '\1' snippet.gsub! /\\(.)/, '\1'

View file

@ -1,33 +1,33 @@
=begin =begin
$Date: 1999/06/29 09:08:51 $ $Date: 1999/07/16 13:39:42 $
== SIMPLE TELNET CLIANT LIBRARY == SIMPLE TELNET CLIANT LIBRARY
telnet.rb telnet.rb
Version 0.22 Version 0.231
Wakou Aoyama <wakou@fsinet.or.jp> Wakou Aoyama <wakou@fsinet.or.jp>
=== MAKE NEW TELNET OBJECT === MAKE NEW TELNET OBJECT
host = Telnet.new({"Binmode" => FALSE, # default: FALSE host = Telnet.new({"Binmode" => false, # default: false
"Host" => "localhost", # default: "localhost" "Host" => "localhost", # default: "localhost"
"Output_log" => "output_log", # default: not output "Output_log" => "output_log", # default: not output
"Dump_log" => "dump_log", # default: not output "Dump_log" => "dump_log", # default: not output
"Port" => 23, # default: 23 "Port" => 23, # default: 23
"Prompt" => /[$%#>] \z/n, # default: /[$%#>] \z/n "Prompt" => /[$%#>] \z/n, # default: /[$%#>] \z/n
"Telnetmode" => TRUE, # default: TRUE "Telnetmode" => true, # default: true
"Timeout" => 10, # default: 10 "Timeout" => 10, # default: 10
# if ignore timeout then set "Timeout" to FALSE. # if ignore timeout then set "Timeout" to false.
"Waittime" => 0, # default: 0 "Waittime" => 0, # default: 0
"Proxy" => proxy}) # default: nil "Proxy" => proxy}) # default: nil
# proxy is Telnet or TCPsocket object # proxy is Telnet or TCPsocket object
Telnet object has socket class methods. Telnet object has socket class methods.
if set "Telnetmode" option FALSE. not TELNET command interpretation. if set "Telnetmode" option to false. not telnet command interpretation.
"Waittime" is time to confirm "Prompt". There is a possibility that "Waittime" is time to confirm "Prompt". There is a possibility that
the same character as "Prompt" is included in the data, and, when the same character as "Prompt" is included in the data, and, when
the network or the host is very heavy, the value is enlarged. the network or the host is very heavy, the value is enlarged.
@ -50,9 +50,9 @@ example
line = host.waitfor({"Match" => /match/, line = host.waitfor({"Match" => /match/,
"String" => "string", "String" => "string",
"Timeout" => secs}) "Timeout" => secs})
# if ignore timeout then set "Timeout" to FALSE. # if ignore timeout then set "Timeout" to false.
if set "String" option. Match = Regexp.new(quote(string)) if set "String" option, then Match == Regexp.new(quote("string"))
==== REALTIME OUTPUT ==== REALTIME OUTPUT
@ -62,7 +62,7 @@ if set "String" option. Match = Regexp.new(quote(string))
"String" => "string", "String" => "string",
"Timeout" => secs}){|c| print c} "Timeout" => secs}){|c| print c}
of cource, set sync=TRUE or flush is necessary. of cource, set sync=true or flush is necessary.
=== SEND STRING AND WAIT PROMPT === SEND STRING AND WAIT PROMPT
@ -80,7 +80,7 @@ of cource, set sync=TRUE or flush is necessary.
"Prompt" => /[$%#>] \z/n, "Prompt" => /[$%#>] \z/n,
"Timeout" => 10}){|c| print c } "Timeout" => 10}){|c| print c }
of cource, set sync=TRUE or flush is necessary. of cource, set sync=true or flush is necessary.
=== SEND STRING === SEND STRING
@ -91,15 +91,15 @@ of cource, set sync=TRUE or flush is necessary.
=== TURN TELNET COMMAND INTERPRETATION === TURN TELNET COMMAND INTERPRETATION
host.telnetmode # turn on/off host.telnetmode # turn on/off
host.telnetmode(TRUE) # on host.telnetmode(true) # on
host.telnetmode(FALSE) # off host.telnetmode(false) # off
=== TOGGLE NEWLINE TRANSLATION === TOGGLE NEWLINE TRANSLATION
host.binmode # turn TRUE/FALSE host.binmode # turn true/false
host.binmode(TRUE) # no translate newline host.binmode(true) # no translate newline
host.binmode(FALSE) # translate newline host.binmode(false) # translate newline
=== LOGIN === LOGIN
@ -119,7 +119,7 @@ of cource, set sync=TRUE or flush is necessary.
"Prompt" => /[$%#>] \z/n, "Prompt" => /[$%#>] \z/n,
"Timeout" => 10}){|c| print c } "Timeout" => 10}){|c| print c }
of cource, set sync=TRUE or flush is necessary. of cource, set sync=true or flush is necessary.
== EXAMPLE == EXAMPLE
@ -138,7 +138,7 @@ of cource, set sync=TRUE or flush is necessary.
pop = Telnet.new({"Host" => "your_destination_host_here", pop = Telnet.new({"Host" => "your_destination_host_here",
"Port" => 110, "Port" => 110,
"Telnetmode" => FALSE, "Telnetmode" => false,
"Prompt" => /^\+OK/n}) "Prompt" => /^\+OK/n})
pop.cmd("user " + "your_username_here"){|c| print c} pop.cmd("user " + "your_username_here"){|c| print c}
pop.cmd("pass " + "your_password_here"){|c| print c} pop.cmd("pass " + "your_password_here"){|c| print c}
@ -147,11 +147,23 @@ of cource, set sync=TRUE or flush is necessary.
== HISTORY == HISTORY
=== Version 0.231
1999/07/16 13:39:42
- TRUE --> true, FALSE --> false
=== Version 0.23
1999/07/15 22:32:09
- waitfor: if end of file reached, then return nil.
=== Version 0.22 === Version 0.22
1999/06/29 09:08:51 1999/06/29 09:08:51
- new, waitfor, cmd: {"Timeout" => FALSE} # ignore timeout - new, waitfor, cmd: {"Timeout" => false} # ignore timeout
=== Version 0.21 === Version 0.21
@ -350,31 +362,31 @@ class Telnet < SimpleDelegator
EOL = CR + LF EOL = CR + LF
v = $-v v = $-v
$-v = false $-v = false
VERSION = "0.22" VERSION = "0.231"
RELEASE_DATE = "$Date: 1999/06/29 09:08:51 $" RELEASE_DATE = "$Date: 1999/07/16 13:39:42 $"
$-v = v $-v = v
def initialize(options) def initialize(options)
@options = options @options = options
@options["Binmode"] = FALSE unless @options.key?("Binmode") @options["Binmode"] = false unless @options.key?("Binmode")
@options["Host"] = "localhost" unless @options.key?("Host") @options["Host"] = "localhost" unless @options.key?("Host")
@options["Port"] = 23 unless @options.key?("Port") @options["Port"] = 23 unless @options.key?("Port")
@options["Prompt"] = /[$%#>] \z/n unless @options.key?("Prompt") @options["Prompt"] = /[$%#>] \z/n unless @options.key?("Prompt")
@options["Telnetmode"] = TRUE unless @options.key?("Telnetmode") @options["Telnetmode"] = true unless @options.key?("Telnetmode")
@options["Timeout"] = 10 unless @options.key?("Timeout") @options["Timeout"] = 10 unless @options.key?("Timeout")
@options["Waittime"] = 0 unless @options.key?("Waittime") @options["Waittime"] = 0 unless @options.key?("Waittime")
@telnet_option = { "SGA" => FALSE, "BINARY" => FALSE } @telnet_option = { "SGA" => false, "BINARY" => false }
if @options.key?("Output_log") if @options.key?("Output_log")
@log = File.open(@options["Output_log"], 'a+') @log = File.open(@options["Output_log"], 'a+')
@log.sync = TRUE @log.sync = true
@log.binmode @log.binmode
end end
if @options.key?("Dump_log") if @options.key?("Dump_log")
@dumplog = File.open(@options["Dump_log"], 'a+') @dumplog = File.open(@options["Dump_log"], 'a+')
@dumplog.sync = TRUE @dumplog.sync = true
@dumplog.binmode @dumplog.binmode
end end
@ -393,7 +405,7 @@ $-v = v
@dumplog.write(message) if @options.key?("Dump_log") @dumplog.write(message) if @options.key?("Dump_log")
begin begin
if @options["Timeout"] == FALSE if @options["Timeout"] == false
@sock = TCPsocket.open(@options["Host"], @options["Port"]) @sock = TCPsocket.open(@options["Host"], @options["Port"])
else else
timeout(@options["Timeout"]){ timeout(@options["Timeout"]){
@ -407,7 +419,7 @@ $-v = v
@dumplog.write($!.to_s + "\n") if @options.key?("Dump_log") @dumplog.write($!.to_s + "\n") if @options.key?("Dump_log")
raise raise
end end
@sock.sync = TRUE @sock.sync = true
@sock.binmode @sock.binmode
message = "Connected to " + @options["Host"] + ".\n" message = "Connected to " + @options["Host"] + ".\n"
@ -423,17 +435,17 @@ $-v = v
def telnetmode(mode = 'turn') def telnetmode(mode = 'turn')
if 'turn' == mode if 'turn' == mode
@options["Telnetmode"] = @options["Telnetmode"] ? FALSE : TRUE @options["Telnetmode"] = @options["Telnetmode"] ? false : true
else else
@options["Telnetmode"] = mode ? TRUE : FALSE @options["Telnetmode"] = mode ? true : false
end end
end end
def binmode(mode = 'turn') def binmode(mode = 'turn')
if 'turn' == mode if 'turn' == mode
@options["Binmode"] = @options["Binmode"] ? FALSE : TRUE @options["Binmode"] = @options["Binmode"] ? false : true
else else
@options["Binmode"] = mode ? TRUE : FALSE @options["Binmode"] = mode ? true : false
end end
end end
@ -449,7 +461,7 @@ $-v = v
# respond to "IAC DO x" # respond to "IAC DO x"
str.gsub!(/([^#{IAC}]?)#{IAC}#{DO}([#{OPT_BINARY}-#{OPT_NEW_ENVIRON}#{OPT_EXOPL}])/no){ str.gsub!(/([^#{IAC}]?)#{IAC}#{DO}([#{OPT_BINARY}-#{OPT_NEW_ENVIRON}#{OPT_EXOPL}])/no){
if OPT_BINARY == $2 if OPT_BINARY == $2
@telnet_option["BINARY"] = TRUE @telnet_option["BINARY"] = true
@sock.write(IAC + WILL + OPT_BINARY) @sock.write(IAC + WILL + OPT_BINARY)
else else
@sock.write(IAC + WONT + $2) @sock.write(IAC + WONT + $2)
@ -468,7 +480,7 @@ $-v = v
if OPT_ECHO == $2 if OPT_ECHO == $2
@sock.write(IAC + DO + OPT_ECHO) @sock.write(IAC + DO + OPT_ECHO)
elsif OPT_SGA == $2 elsif OPT_SGA == $2
@telnet_option["SGA"] = TRUE @telnet_option["SGA"] = true
@sock.write(IAC + DO + OPT_SGA) @sock.write(IAC + DO + OPT_SGA)
end end
$1 $1
@ -479,7 +491,7 @@ $-v = v
if OPT_ECHO == $2 if OPT_ECHO == $2
@sock.write(IAC + DONT + OPT_ECHO) @sock.write(IAC + DONT + OPT_ECHO)
elsif OPT_SGA == $2 elsif OPT_SGA == $2
@telnet_option["SGA"] = FALSE @telnet_option["SGA"] = false
@sock.write(IAC + DONT + OPT_SGA) @sock.write(IAC + DONT + OPT_SGA)
end end
$1 $1
@ -514,7 +526,7 @@ $-v = v
prompt = options prompt = options
end end
if time_out == FALSE if time_out == false
time_out = nil time_out = nil
end end
@ -524,19 +536,27 @@ $-v = v
unless IO::select([@sock], nil, nil, time_out) unless IO::select([@sock], nil, nil, time_out)
raise TimeOut, "timed-out; wait for the next data" raise TimeOut, "timed-out; wait for the next data"
end end
c = @sock.sysread(1024 * 1024) begin
@dumplog.print(c) if @options.key?("Dump_log") c = @sock.sysread(1024 * 1024)
buf.concat c @dumplog.print(c) if @options.key?("Dump_log")
if @options["Telnetmode"] buf.concat c
buf = preprocess(buf) if @options["Telnetmode"]
if /#{IAC}.?\z/no === buf buf = preprocess(buf)
next if /#{IAC}.?\z/no === buf
next
end
end end
end @log.print(buf) if @options.key?("Output_log")
@log.print(buf) if @options.key?("Output_log") yield buf if iterator?
yield buf if iterator? line.concat(buf)
line.concat(buf) buf = ''
buf = '' rescue EOFError # End of file reached
if line == ''
line = nil
yield nil if iterator?
end
break
end
end end
line line
end end
@ -575,7 +595,7 @@ $-v = v
end end
IO::select(nil, [@sock]) IO::select(nil, [@sock])
print(string) self.print(string)
if iterator? if iterator?
waitfor({"Prompt" => match, "Timeout" => time_out}){|c| yield c } waitfor({"Prompt" => match, "Timeout" => time_out}){|c| yield c }
else else

View file

@ -62,10 +62,10 @@ class Mutex
def unlock def unlock
return unless @locked return unless @locked
Thread.critical = TRUE Thread.critical = true
t = @waiting.shift t = @waiting.shift
@locked = FALSE @locked = false
Thread.critical = FALSE Thread.critical = false
t.run if t t.run if t
self self
end end
@ -192,14 +192,14 @@ class SizedQueue<Queue
end end
def max=(max) def max=(max)
Thread.critical = TRUE Thread.critical = true
if @max >= max if @max >= max
@max = max @max = max
Thread.critical = FALSE Thread.critical = false
else else
diff = max - @max diff = max - @max
@max = max @max = max
Thread.critical = FALSE Thread.critical = false
diff.times do diff.times do
t = @queue_wait.shift t = @queue_wait.shift
t.run if t t.run if t

View file

@ -223,9 +223,7 @@ static BSD__sfvwrite(fp, uio)
register size_t len; register size_t len;
register char *p; register char *p;
register struct __siov *iov; register struct __siov *iov;
register int w, s; register int w;
char *nl;
int nlknown, nldist;
if ((len = uio->uio_resid) == 0) if ((len = uio->uio_resid) == 0)
return (0); return (0);

View file

@ -148,7 +148,7 @@ range_each(range)
} }
} }
return Qnil; return range;
} }
static VALUE static VALUE

View file

@ -2746,6 +2746,9 @@ re_compile_fastmap(bufp)
} }
/* Don't return; check the alternative paths /* Don't return; check the alternative paths
so we can set can_be_null if appropriate. */ so we can set can_be_null if appropriate. */
if ((enum regexpcode)p[-1] == anychar_repeat) {
continue;
}
break; break;
case wordchar: case wordchar:
@ -2852,7 +2855,7 @@ re_compile_fastmap(bufp)
} }
{ {
unsigned short size; unsigned short size;
unsigned long c, beg, end; unsigned long c, beg;
p += p[-1] + 2; p += p[-1] + 2;
size = EXTRACT_UNSIGNED(&p[-2]); size = EXTRACT_UNSIGNED(&p[-2]);
@ -3539,7 +3542,6 @@ re_match(bufp, string_arg, size, pos, regs)
} }
EXTRACT_NUMBER_AND_INCR(mcnt, p); EXTRACT_NUMBER_AND_INCR(mcnt, p);
STORE_NUMBER(p+mcnt, stackp - stackb); STORE_NUMBER(p+mcnt, stackp - stackb);
printf("%d\n", stackp - stackb);
continue; continue;
case stop_nowidth: case stop_nowidth:

View file

@ -140,8 +140,8 @@ gsub!(/\beof_error\b/,"rb_eof_error")
gsub!(/\bf_gets\b/,"rb_f_gets") gsub!(/\bf_gets\b/,"rb_f_gets")
gsub!(/\bio_binmode\b/,"rb_io_binmode") gsub!(/\bio_binmode\b/,"rb_io_binmode")
gsub!(/\bio_check_closed\b/,"rb_io_check_closed") gsub!(/\bio_check_closed\b/,"rb_io_check_closed")
gsub!(/\bio_check_readable\b/,"rb_io_check_readable") gsub!(/\bio_readable\b/,"rb_io_check_readable")
gsub!(/\bio_check_writable\b/,"rb_io_check_writable") gsub!(/\bio_writable\b/,"rb_io_check_writable")
gsub!(/\bio_close\b/,"rb_io_close") gsub!(/\bio_close\b/,"rb_io_close")
gsub!(/\bio_fptr_finalize\b/,"rb_io_fptr_finalize") gsub!(/\bio_fptr_finalize\b/,"rb_io_fptr_finalize")
gsub!(/\bio_getc\b/,"rb_io_getc") gsub!(/\bio_getc\b/,"rb_io_getc")

View file

@ -769,7 +769,7 @@ rb_str_upto(beg, end, excl)
break; break;
} }
return Qnil; return beg;
} }
static VALUE static VALUE
@ -1041,7 +1041,7 @@ rb_str_sub(argc, argv, str)
VALUE *argv; VALUE *argv;
VALUE str; VALUE str;
{ {
VALUE val = rb_str_sub_bang(argc, argv, rb_str_dup(str)); VALUE val = rb_str_sub_bang(argc, argv, str = rb_str_dup(str));
if (NIL_P(val)) return str; if (NIL_P(val)) return str;
return val; return val;
@ -1148,7 +1148,7 @@ rb_str_gsub(argc, argv, str)
VALUE *argv; VALUE *argv;
VALUE str; VALUE str;
{ {
VALUE val = rb_str_gsub_bang(argc, argv, rb_str_dup(str)); VALUE val = rb_str_gsub_bang(argc, argv, str = rb_str_dup(str));
if (NIL_P(val)) return str; if (NIL_P(val)) return str;
return val; return val;
@ -1196,7 +1196,7 @@ rb_f_sub(argc, argv)
VALUE line, v; VALUE line, v;
line = uscore_get(); line = uscore_get();
v = rb_str_sub_bang(argc, argv, rb_str_dup(line)); v = rb_str_sub_bang(argc, argv, line = rb_str_dup(line));
if (NIL_P(v)) return line; if (NIL_P(v)) return line;
rb_lastline_set(v); rb_lastline_set(v);
return v; return v;
@ -1218,7 +1218,7 @@ rb_f_gsub(argc, argv)
VALUE line, v; VALUE line, v;
line = uscore_get(); line = uscore_get();
v = rb_str_gsub_bang(argc, argv, rb_str_dup(line)); v = rb_str_gsub_bang(argc, argv, line = rb_str_dup(line));
if (NIL_P(v)) return line; if (NIL_P(v)) return line;
rb_lastline_set(v); rb_lastline_set(v);
return v; return v;
@ -1249,7 +1249,7 @@ rb_str_reverse(str)
VALUE obj; VALUE obj;
char *s, *e, *p; char *s, *e, *p;
if (RSTRING(str)->len <= 1) return str; if (RSTRING(str)->len <= 1) return rb_str_dup(str);
obj = rb_str_new(0, RSTRING(str)->len); obj = rb_str_new(0, RSTRING(str)->len);
s = RSTRING(str)->ptr; e = s + RSTRING(str)->len - 1; s = RSTRING(str)->ptr; e = s + RSTRING(str)->len - 1;
@ -1522,7 +1522,7 @@ static VALUE
rb_str_upcase(str) rb_str_upcase(str)
VALUE str; VALUE str;
{ {
VALUE val = rb_str_upcase_bang(rb_str_dup(str)); VALUE val = rb_str_upcase_bang(str = rb_str_dup(str));
if (NIL_P(val)) return str; if (NIL_P(val)) return str;
return val; return val;
@ -1556,7 +1556,7 @@ static VALUE
rb_str_downcase(str) rb_str_downcase(str)
VALUE str; VALUE str;
{ {
VALUE val = rb_str_downcase_bang(rb_str_dup(str)); VALUE val = rb_str_downcase_bang(str = rb_str_dup(str));
if (NIL_P(val)) return str; if (NIL_P(val)) return str;
return val; return val;
@ -1592,7 +1592,7 @@ static VALUE
rb_str_capitalize(str) rb_str_capitalize(str)
VALUE str; VALUE str;
{ {
VALUE val = rb_str_capitalize_bang(rb_str_dup(str)); VALUE val = rb_str_capitalize_bang(str = rb_str_dup(str));
if (NIL_P(val)) return str; if (NIL_P(val)) return str;
return val; return val;
@ -1630,7 +1630,7 @@ static VALUE
rb_str_swapcase(str) rb_str_swapcase(str)
VALUE str; VALUE str;
{ {
VALUE val = rb_str_swapcase_bang(rb_str_dup(str)); VALUE val = rb_str_swapcase_bang(str = rb_str_dup(str));
if (NIL_P(val)) return str; if (NIL_P(val)) return str;
return val; return val;
@ -1781,7 +1781,7 @@ static VALUE
rb_str_tr(str, src, repl) rb_str_tr(str, src, repl)
VALUE str, src, repl; VALUE str, src, repl;
{ {
VALUE val = tr_trans(rb_str_dup(str), src, repl, 0); VALUE val = tr_trans(str = rb_str_dup(str), src, repl, 0);
if (NIL_P(val)) return str; if (NIL_P(val)) return str;
return val; return val;
@ -1865,7 +1865,7 @@ rb_str_delete(argc, argv, str)
VALUE *argv; VALUE *argv;
VALUE str; VALUE str;
{ {
VALUE val = rb_str_delete_bang(argc, argv, rb_str_dup(str)); VALUE val = rb_str_delete_bang(argc, argv, str = rb_str_dup(str));
if (NIL_P(val)) return str; if (NIL_P(val)) return str;
return val; return val;
@ -1879,7 +1879,7 @@ rb_str_squeeze_bang(argc, argv, str)
{ {
char squeez[256]; char squeez[256];
char *s, *send, *t; char *s, *send, *t;
char c, save, modify = 0; int c, save, modify = 0;
int init = 1; int init = 1;
int i; int i;
@ -1906,7 +1906,7 @@ rb_str_squeeze_bang(argc, argv, str)
save = -1; save = -1;
while (s < send) { while (s < send) {
c = *s++ & 0xff; c = *s++ & 0xff;
if (c != save || !squeez[c & 0xff]) { if (c != save || !squeez[c]) {
*t++ = save = c; *t++ = save = c;
} }
} }
@ -1926,7 +1926,7 @@ rb_str_squeeze(argc, argv, str)
VALUE *argv; VALUE *argv;
VALUE str; VALUE str;
{ {
VALUE val = rb_str_squeeze_bang(argc, argv, rb_str_dup(str)); VALUE val = rb_str_squeeze_bang(argc, argv, str = rb_str_dup(str));
if (NIL_P(val)) return str; if (NIL_P(val)) return str;
return val; return val;
@ -1943,7 +1943,7 @@ static VALUE
rb_str_tr_s(str, src, repl) rb_str_tr_s(str, src, repl)
VALUE str, src, repl; VALUE str, src, repl;
{ {
VALUE val = tr_trans(rb_str_dup(str), src, repl, 1); VALUE val = tr_trans(str = rb_str_dup(str), src, repl, 1);
if (NIL_P(val)) return str; if (NIL_P(val)) return str;
return val; return val;
@ -2160,9 +2160,11 @@ rb_str_each_line(argc, argv, str)
if (NIL_P(rs)) { if (NIL_P(rs)) {
rb_yield(str); rb_yield(str);
return Qnil; return str;
}
if (TYPE(rs) != T_STRING) {
rs = rb_str_to_str(rs);
} }
if (TYPE(rs) != T_STRING) rs = rb_str_to_str(rs);
rslen = RSTRING(rs)->len; rslen = RSTRING(rs)->len;
if (rslen == 0) { if (rslen == 0) {
@ -2194,19 +2196,19 @@ rb_str_each_line(argc, argv, str)
rb_yield(line); rb_yield(line);
} }
return Qnil; return str;
} }
static VALUE static VALUE
rb_str_each_byte(str) rb_str_each_byte(str)
struct RString* str; VALUE str;
{ {
int i; int i;
for (i=0; i<RSTRING(str)->len; i++) { for (i=0; i<RSTRING(str)->len; i++) {
rb_yield(INT2FIX(RSTRING(str)->ptr[i] & 0xff)); rb_yield(INT2FIX(RSTRING(str)->ptr[i] & 0xff));
} }
return Qnil; return str;
} }
static VALUE static VALUE
@ -2232,7 +2234,7 @@ static VALUE
rb_str_chop(str) rb_str_chop(str)
VALUE str; VALUE str;
{ {
VALUE val = rb_str_chop_bang(rb_str_dup(str)); VALUE val = rb_str_chop_bang(str = rb_str_dup(str));
if (NIL_P(val)) return str; if (NIL_P(val)) return str;
return val; return val;
@ -2249,7 +2251,7 @@ static VALUE
rb_f_chop() rb_f_chop()
{ {
VALUE str = uscore_get(); VALUE str = uscore_get();
VALUE val = rb_str_chop_bang(rb_str_dup(str)); VALUE val = rb_str_chop_bang(str = rb_str_dup(str));
if (NIL_P(val)) return str; if (NIL_P(val)) return str;
rb_lastline_set(val); rb_lastline_set(val);
@ -2305,7 +2307,7 @@ rb_str_chomp(argc, argv, str)
VALUE *argv; VALUE *argv;
VALUE str; VALUE str;
{ {
VALUE val = rb_str_chomp_bang(argc, argv, rb_str_dup(str)); VALUE val = rb_str_chomp_bang(argc, argv, str = rb_str_dup(str));
if (NIL_P(val)) return str; if (NIL_P(val)) return str;
return val; return val;
@ -2325,7 +2327,7 @@ rb_f_chomp(argc, argv)
VALUE *argv; VALUE *argv;
{ {
VALUE str = uscore_get(); VALUE str = uscore_get();
VALUE val = rb_str_chomp_bang(argc, argv, rb_str_dup(str)); VALUE val = rb_str_chomp_bang(argc, argv, str = rb_str_dup(str));
if (NIL_P(val)) return str; if (NIL_P(val)) return str;
rb_lastline_set(val); rb_lastline_set(val);
@ -2372,7 +2374,7 @@ static VALUE
rb_str_strip(str) rb_str_strip(str)
VALUE str; VALUE str;
{ {
VALUE val = rb_str_strip_bang(rb_str_dup(str)); VALUE val = rb_str_strip_bang(str = rb_str_dup(str));
if (NIL_P(val)) return str; if (NIL_P(val)) return str;
return val; return val;
@ -2432,7 +2434,7 @@ rb_str_scan(str, pat)
while (!NIL_P(result = scan_once(str, pat, &start))) { while (!NIL_P(result = scan_once(str, pat, &start))) {
rb_yield(result); rb_yield(result);
} }
return Qnil; return str;
} }
static VALUE static VALUE

View file

@ -325,7 +325,7 @@ rb_struct_each(s)
for (i=0; i<RSTRUCT(s)->len; i++) { for (i=0; i<RSTRUCT(s)->len; i++) {
rb_yield(RSTRUCT(s)->ptr[i]); rb_yield(RSTRUCT(s)->ptr[i]);
} }
return Qnil; return s;
} }
static VALUE static VALUE

1
time.c
View file

@ -104,7 +104,6 @@ struct timeval
rb_time_interval(time) rb_time_interval(time)
VALUE time; VALUE time;
{ {
struct time_object *tobj;
struct timeval t; struct timeval t;
switch (TYPE(time)) { switch (TYPE(time)) {