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>
* version 1.3.5 - version 1.4 alpha

View file

@ -32,7 +32,6 @@ file.c
gc.c
hash.c
inits.c
install-sh
instruby.rb
intern.h
io.c
@ -89,21 +88,6 @@ ext/extmk.rb.nt
lib/CGI.rb
lib/English.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/base64.rb
lib/cgi-lib.rb

8
ToDo
View file

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

View file

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

592
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_SUBST(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_MAKE_SET
@ -324,6 +321,9 @@ AC_ARG_WITH(dln-a-out,
*) with_dln_a_out=no;;
esac], [with_dln_a_out=no])
AC_EXEEXT
AC_OBJEXT
AC_SUBST(XLDFLAGS)dnl
case "$host_os" in
@ -781,7 +781,9 @@ AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH}/${arch}")
AC_ARG_WITH(search-path,
[--with-search-path specify the additional search path],
[search_path=$withval])
if test "$search_path" != ""; then
AC_DEFINE_UNQUOTED(RUBY_SEARCH_PATH,"$search_path")
fi
echo "creating config.h"
cat confdefs.h > config.h

21
eval.c
View file

@ -4490,10 +4490,15 @@ find_file(file)
int i;
Check_Type(rb_load_path, T_ARRAY);
vpath = rb_ary_new();
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);
if (safe_level >= 2 && !rb_path_check(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) {
fd_set readfds, writefds, exceptfds;
fd_set readfds;
struct timeval delay_tv, *delay_ptr;
double delay, now; /* OK */
@ -6574,7 +6579,9 @@ rb_thread_join(thread)
VALUE oldbt = get_backtrace(th->errinfo);
VALUE errat = make_backtrace();
if (TYPE(oldbt) == T_ARRAY) {
rb_ary_unshift(errat, rb_ary_entry(oldbt, 0));
}
set_backtrace(th->errinfo, errat);
rb_exc_raise(th->errinfo);
}
@ -6707,19 +6714,19 @@ rb_thread_sleep_forever()
rb_thread_schedule();
}
static int rb_thread_abort;
static int thread_abort;
static VALUE
rb_thread_s_abort_exc()
{
return rb_thread_abort?Qtrue:Qfalse;
return thread_abort?Qtrue:Qfalse;
}
static VALUE
rb_thread_s_abort_exc_set(self, val)
VALUE self, val;
{
rb_thread_abort = RTEST(val);
thread_abort = RTEST(val);
return val;
}
@ -6898,7 +6905,7 @@ rb_thread_create_0(fn, arg, klass)
/* delegate exception to main_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);
error_print();
/* exit on main_thread */

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -135,7 +135,9 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
int family, len, i;
char *addr, *p;
u_long v4a;
#ifdef INET6
u_char pfx;
#endif
int h_error;
char numserv[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
#include "sockport.h"
static int do_not_reverse_lookup = 0;
VALUE rb_cBasicSocket;
VALUE rb_cIPSocket;
VALUE rb_cTCPSocket;
@ -423,6 +425,19 @@ bsock_recv(argc, argv, sock)
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
mkipaddr0(addr, buf, len)
struct sockaddr *addr;
@ -476,7 +491,6 @@ ip_addrsetup(host, port)
hostp = NULL;
}
else if (rb_obj_is_kind_of(host, rb_cInteger)) {
struct sockaddr_in sin;
long i = NUM2LONG(host);
mkinetaddr(htonl(i), hbuf, sizeof(hbuf));
@ -535,7 +549,6 @@ ipaddr(sockaddr)
{
VALUE family, port, addr1, addr2;
VALUE ary;
struct addrinfo hints, *res;
int error;
char hbuf[1024], pbuf[1024];
@ -552,18 +565,23 @@ ipaddr(sockaddr)
family = 0;
break;
}
if (!do_not_reverse_lookup) {
error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf),
NULL, 0, 0);
if (error) {
rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
addr1 = rb_str_new2(hbuf);
}
error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV);
if (error) {
rb_raise(rb_eSocket, "%s", gai_strerror(error));
}
addr2 = rb_str_new2(hbuf);
if (do_not_reverse_lookup) {
addr1 = addr2;
}
port = INT2FIX(atoi(pbuf));
ary = rb_ary_new3(4, family, port, addr1, addr2);
@ -665,7 +683,6 @@ open_inet(class, h, serv, type)
struct addrinfo hints, *res, *res0;
int fd, status;
char *syscall;
VALUE sock;
char pbuf[1024], *portp;
char *host;
int error;
@ -1434,7 +1451,7 @@ sock_accept(sock)
VALUE sock;
{
OpenFile *fptr;
VALUE addr, sock2;
VALUE sock2;
char buf[1024];
int len = sizeof buf;
@ -1519,7 +1536,6 @@ static VALUE
mkaddrinfo(res0)
struct addrinfo *res0;
{
char **pch;
VALUE base, ary;
struct addrinfo *res;
@ -1817,6 +1833,7 @@ sock_define_const(name, value)
rb_define_const(mConst, name, INT2FIX(value));
}
void
Init_socket()
{
rb_eSocket = rb_define_class("SocketError", rb_eStandardError);
@ -1824,6 +1841,12 @@ Init_socket()
rb_cBasicSocket = rb_define_class("BasicSocket", rb_cIO);
rb_undef_method(CLASS_OF(rb_cBasicSocket), "new");
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_write", bsock_close_write, 0);
rb_define_method(rb_cBasicSocket, "shutdown", bsock_shutdown, -1);

View file

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

View file

@ -52,7 +52,11 @@ File.makedirs archdir, true
File.makedirs pkglibdir+"/site_ruby", 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
end

26
io.c
View file

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

View file

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

View file

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

View file

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

View file

@ -67,7 +67,7 @@ class << File
to = catname(from, to)
$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
end
fstat = stat(from)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

1
time.c
View file

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