diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-07-22 10:37:27 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-07-22 10:37:27 +0000 |
commit | a1530c751e6c484b6217565f3db2b0614735710c (patch) | |
tree | bfb9cae2410306cc39845fa836c44f546034290b /ext | |
parent | 86307f52ee1b3c5aa76e2fd6ee118e681dd76905 (diff) |
backtrace may be Qnil
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/extmk.rb.in | 110 | ||||
-rw-r--r-- | ext/nkf/nkf1.7/nkf.c | 2 | ||||
-rw-r--r-- | ext/pty/pty.c | 1 | ||||
-rw-r--r-- | ext/readline/readline.c | 2 | ||||
-rw-r--r-- | ext/sdbm/_sdbm.c | 2 | ||||
-rw-r--r-- | ext/socket/getaddrinfo.c | 9 | ||||
-rw-r--r-- | ext/socket/getnameinfo.c | 2 | ||||
-rw-r--r-- | ext/socket/socket.c | 43 | ||||
-rw-r--r-- | ext/tcltklib/tcltklib.c | 4 |
9 files changed, 86 insertions, 89 deletions
diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in index 0d1d5af276..30cff493a8 100644 --- a/ext/extmk.rb.in +++ b/ext/extmk.rb.in @@ -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 + $libs = "-l" + lib + " " + $libs 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 + libs = "-l" + lib + " " + $libs 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 + libs = "-l" + lib + " " + $libs 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 - $libs = $libs + " -lruby" - else - $libs = "-lruby" - end + if RUBY_PLATFORM =~ /beos/ + $libs = $libs + " -lruby" $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 + $libs = $libs + " @LIBRUBYARG@" $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,20 +381,18 @@ 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) mfile.printf "\n" if $static - mfile.printf "\ + mfile.printf "\ $(DLLIB): $(OBJS) @AR@ cru $(DLLIB) $(OBJS) @-@RANLIB@ $(DLLIB) 2> /dev/null || true @@ -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) diff --git a/ext/nkf/nkf1.7/nkf.c b/ext/nkf/nkf1.7/nkf.c index cfc699e096..26ef657021 100644 --- a/ext/nkf/nkf1.7/nkf.c +++ b/ext/nkf/nkf1.7/nkf.c @@ -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; diff --git a/ext/pty/pty.c b/ext/pty/pty.c index 2cd8d6f9a4..98be9044b7 100644 --- a/ext/pty/pty.c +++ b/ext/pty/pty.c @@ -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(); diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 60d45bf56b..02b29796af 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -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 diff --git a/ext/sdbm/_sdbm.c b/ext/sdbm/_sdbm.c index 8a40fb372d..a07cc55f6b 100644 --- a/ext/sdbm/_sdbm.c +++ b/ext/sdbm/_sdbm.c @@ -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 { /* diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c index aab7207cdf..d09d726516 100644 --- a/ext/socket/getaddrinfo.c +++ b/ext/socket/getaddrinfo.c @@ -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,8 +523,11 @@ 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); #else diff --git a/ext/socket/getnameinfo.c b/ext/socket/getnameinfo.c index 5af329225c..fbb39e059e 100644 --- a/ext/socket/getnameinfo.c +++ b/ext/socket/getnameinfo.c @@ -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]; diff --git a/ext/socket/socket.c b/ext/socket/socket.c index f4ee19e11e..90964663d1 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -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; } - error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf), - NULL, 0, 0); - if (error) { - rb_raise(rb_eSocket, "%s", gai_strerror(error)); + 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); } - 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); diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c index 352b0778db..314246869e 100644 --- a/ext/tcltklib/tcltklib.c +++ b/ext/tcltklib/tcltklib.c @@ -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> |