diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-05-25 08:26:20 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-05-25 08:26:20 +0000 |
commit | 1307f8d555235116f0f0c79b9902df9cfd4bff12 (patch) | |
tree | faf8962d1f1fcdb54db653b4a99b148fdecea7e6 /ext | |
parent | 1aba398e29bd9134f83c165a2495883f72cbbb3d (diff) |
regexp null pattern
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/Win32API/Win32API.c | 4 | ||||
-rw-r--r-- | ext/extmk.rb.in | 18 | ||||
-rw-r--r-- | ext/pty/expect_sample.rb | 2 | ||||
-rw-r--r-- | ext/pty/extconf.rb | 1 | ||||
-rw-r--r-- | ext/pty/pty.c | 4 | ||||
-rw-r--r-- | ext/pty/script.rb | 2 | ||||
-rw-r--r-- | ext/socket/extconf.rb | 1 | ||||
-rw-r--r-- | ext/socket/getaddrinfo.c | 15 | ||||
-rw-r--r-- | ext/socket/socket.c | 31 |
9 files changed, 51 insertions, 27 deletions
diff --git a/ext/Win32API/Win32API.c b/ext/Win32API/Win32API.c index b57cf8101f..9f75653132 100644 --- a/ext/Win32API/Win32API.c +++ b/ext/Win32API/Win32API.c @@ -111,8 +111,8 @@ Win32API_initialize(self, dllname, proc, import, export) static VALUE Win32API_Call(argc, argv, obj) - VALUE argc; - VALUE argv; + int argc; + VALUE *argv; VALUE obj; { VALUE args; diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in index f98ca4dc2b..c564b59b70 100644 --- a/ext/extmk.rb.in +++ b/ext/extmk.rb.in @@ -14,6 +14,7 @@ elsif ARGV[0] == 'clean' ARGV.shift end +SRC_EXT = ["c", "cc", "cxx", "C"] $extlist = [] $cache_mod = FALSE; @@ -27,7 +28,6 @@ if $top_srcdir !~ "^/" end # get absolute path $topdir = File.expand_path("..") -$ruby_inc = $top_srcdir load "#{$top_srcdir}/lib/find.rb" @@ -355,7 +355,6 @@ libdir = @libdir@ #pkglibdir = $(libdir)/$(RUBY_INSTALL_NAME)/@MAJOR@.@MINOR@ pkglibdir = $(libdir)/ruby/@MAJOR@.@MINOR@ archdir = $(pkglibdir)/@arch@ -ruby_inc = #{$ruby_inc} @SET_MAKE@ #### End of system configuration section. #### @@ -366,7 +365,7 @@ ruby_inc = #{$ruby_inc} mfile.printf "OBJS = " if !$objs then $objs = [] - for f in Dir["#{$top_srcdir}/ext/#{$mdir}/*.{c,cc}"] + for f in Dir["#{$top_srcdir}/ext/#{$mdir}/*.{#{SRC_EXT.join(%q{,})}}"] f = File.basename(f) f.sub!(/\.(c|cc)$/, ".o") $objs.push f @@ -419,7 +418,7 @@ $(DLLIB): $(OBJS) $(DLLIB): $(OBJS) $(LDSHARED) $(DLDFLAGS) -o $(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS) " - elsif not File.exist?(target + ".c") and not File.exist?(target + ".cc") + elsif not SRC_EXT.detect{|ext| File.exist?(target + ext)} if PLATFORM == "m68k-human" mfile.printf "\ $(DLLIB): $(OBJS) @@ -499,11 +498,11 @@ def extmake(target) $extlist.push [$static,target] end if $install - system "make install DESTDIR=#{$destdir}" + system "#{$make} install DESTDIR=#{$destdir}" elsif $clean - system "make clean" + system "#{$make} clean" else - system "make all" or exit + system "#{$make} all" or exit end end if $static @@ -518,6 +517,9 @@ def extmake(target) end end +$make = ENV["MAKE"] +$make ||= with_config("make-prog", "make") + # get static-link modules $static_ext = {} for setup in ["@setup@", "#{$top_srcdir}/ext/@setup@"] @@ -620,7 +622,7 @@ if $extlist.size > 0 if PLATFORM =~ /m68k-human|beos/ $extlibs.gsub!("-L/usr/local/lib", "") if $extlibs end - system format(%[make #{ruby} EXTOBJS="%s" EXTLIBS="%s"], $extobjs, $extlibs) + system format(%[#{$make} #{ruby} EXTOBJS="%s" EXTLIBS="%s"], $extobjs, $extlibs) else Dir.chdir ".." if older(ruby, miniruby) diff --git a/ext/pty/expect_sample.rb b/ext/pty/expect_sample.rb index c71adcb220..1311476c5d 100644 --- a/ext/pty/expect_sample.rb +++ b/ext/pty/expect_sample.rb @@ -11,7 +11,7 @@ require 'expect' fnames = [] PTY.spawn("ftp ftp.netlab.co.jp") do - |r_f,w_f| + |r_f,w_f,pid| w_f.sync = true $expect_verbose = true diff --git a/ext/pty/extconf.rb b/ext/pty/extconf.rb index de9517ec0c..63383f7faf 100644 --- a/ext/pty/extconf.rb +++ b/ext/pty/extconf.rb @@ -2,6 +2,7 @@ require 'mkmf' have_header("sys/stropts.h") have_func("setresuid") +$CFLAGS << "-DHAVE_DEV_PTMX" if /cygwin/ === PLATFORM if have_func("openpty") or have_func("_getpty") or have_func("ioctl") diff --git a/ext/pty/pty.c b/ext/pty/pty.c index 8184b90185..0d3ba7f060 100644 --- a/ext/pty/pty.c +++ b/ext/pty/pty.c @@ -365,14 +365,18 @@ getDevice(master,slave) if(unlockpt(i) != -1) { if((pn = ptsname(i)) != NULL) { if((j = open(pn, O_RDWR, 0)) != -1) { +#if defined I_PUSH if(ioctl(j, I_PUSH, "ptem") != -1) { if(ioctl(j, I_PUSH, "ldterm") != -1) { +#endif *master = i; *slave = j; strcpy(SlaveName, pn); return; +#if defined I_PUSH } } +#endif } } } diff --git a/ext/pty/script.rb b/ext/pty/script.rb index 6c4027e6b3..6aaafec061 100644 --- a/ext/pty/script.rb +++ b/ext/pty/script.rb @@ -11,7 +11,7 @@ logfile = File.open(ofile,"a") system "stty -echo raw lnext ^_" PTY.spawn("/bin/csh") do - |r_pty,w_pty| + |r_pty,w_pty,pid| Thread.new do while true diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index 0526e319ec..37d8de5cbb 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -251,7 +251,6 @@ end if have_getaddrinfo $CFLAGS="-DHAVE_GETADDRINFO "+$CFLAGS else - sockaddr_storage=true $CFLAGS="-I. "+$CFLAGS $objs += "getaddrinfo.o" $objs += "getnameinfo.o" diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c index cdc3de52e4..e9ff9235e1 100644 --- a/ext/socket/getaddrinfo.c +++ b/ext/socket/getaddrinfo.c @@ -160,7 +160,10 @@ if (pai->ai_flags & AI_CANONNAME) {\ char *p;\ if (((ai) = (struct addrinfo *)malloc(sizeof(struct addrinfo) +\ ((afd)->a_socklen)))\ - == NULL) goto free;\ + == NULL) {\ + error = EAI_MEMORY;\ + goto free;\ + }\ memcpy(ai, pai, sizeof(struct addrinfo));\ (ai)->ai_addr = (struct sockaddr *)((ai) + 1);\ memset((ai)->ai_addr, 0, (afd)->a_socklen);\ @@ -394,6 +397,7 @@ getaddrinfo(hostname, servname, hints, res) */ if (hostname == NULL) { struct afd *afd; + int s; for (afd = &afdl[0]; afd->a_af; afd++) { if (!(pai->ai_family == PF_UNSPEC @@ -401,6 +405,15 @@ getaddrinfo(hostname, servname, hints, res) continue; } + /* + * filter out AFs that are not supported by the kernel + * XXX errno? + */ + s = socket(afd->a_af, SOCK_DGRAM, 0); + if (s < 0) + continue; + close(s); + if (pai->ai_flags & AI_PASSIVE) { GET_AI(cur->ai_next, afd, afd->a_addrany, port); /* xxx meaningless? diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 1f19b05d26..980c00bb01 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -72,6 +72,12 @@ int Rconnect(); #define INET_SERVER 1 #define INET_SOCKS 2 +#ifndef INET6 +# undef ss_family +# define sockaddr_storage sockaddr +# define ss_family sa_family +#endif + #ifdef NT static void sock_finalize(fptr) @@ -692,7 +698,7 @@ static VALUE tcp_s_gethostbyname(obj, host) VALUE obj, host; { - struct sockaddr addr; + struct sockaddr_storage addr; struct hostent *h; char **pch; VALUE ary, names; @@ -709,7 +715,7 @@ tcp_s_gethostbyname(obj, host) else { setipaddr(STR2CSTR(host), (struct sockaddr *)&addr); } - switch (addr.sa_family) { + switch (addr.ss_family) { case AF_INET: { struct sockaddr_in *sin; @@ -752,7 +758,7 @@ tcp_s_gethostbyname(obj, host) rb_ary_push(ary, INT2NUM(h->h_addrtype)); #ifdef h_addr for (pch = h->h_addr_list; *pch; pch++) { - switch (addr.sa_family) { + switch (addr.ss_family) { case AF_INET: { struct sockaddr_in sin; @@ -787,7 +793,7 @@ tcp_s_gethostbyname(obj, host) } #else memcpy((char *)&addr.sin_addr, h->h_addr, h->h_length); - rb_ary_push(ary, mkipaddr(addr.sin_addr.s_addr)); + rb_ary_push(ary, mkipaddr((struct sockaddr *)&addr)); #endif return ary; @@ -844,7 +850,7 @@ tcp_accept(sock) VALUE sock; { OpenFile *fptr; - struct sockaddr from; + struct sockaddr_storage from; int fromlen; GetOpenFile(sock, fptr); @@ -910,7 +916,7 @@ ip_addr(sock) VALUE sock; { OpenFile *fptr; - struct sockaddr addr; + struct sockaddr_storage addr; int len = sizeof addr; GetOpenFile(sock, fptr); @@ -925,7 +931,7 @@ ip_peeraddr(sock) VALUE sock; { OpenFile *fptr; - struct sockaddr addr; + struct sockaddr_storage addr; int len = sizeof addr; GetOpenFile(sock, fptr); @@ -939,7 +945,7 @@ static VALUE ip_s_getaddress(obj, host) VALUE obj, host; { - struct sockaddr addr; + struct sockaddr_storage addr; if (rb_obj_is_kind_of(host, rb_cInteger)) { long i = NUM2LONG(host); @@ -1049,7 +1055,6 @@ static VALUE udp_bind(sock, host, port) VALUE sock, host, port; { - struct sockaddr addr; OpenFile *fptr; struct addrinfo *res0, *res; @@ -1514,7 +1519,7 @@ static VALUE sock_s_gethostbyname(obj, host) VALUE obj, host; { - struct sockaddr addr; + struct sockaddr_storage addr; struct hostent *h; if (rb_obj_is_kind_of(host, rb_cInteger)) { @@ -1529,7 +1534,7 @@ sock_s_gethostbyname(obj, host) else { setipaddr(STR2CSTR(host), (struct sockaddr *)&addr); } - switch (addr.sa_family) { + switch (addr.ss_family) { case AF_INET: { struct sockaddr_in *sin; @@ -1685,7 +1690,7 @@ sock_s_getnameinfo(argc, argv) int fl; struct addrinfo hints, *res = NULL; int error; - struct sockaddr ss; + struct sockaddr_storage ss; struct sockaddr *sap; sa = flags = Qnil; @@ -1696,7 +1701,7 @@ sock_s_getnameinfo(argc, argv) rb_raise(rb_eTypeError, "sockaddr length too big"); } memcpy(&ss, RSTRING(sa)->ptr, RSTRING(sa)->len); - if (RSTRING(sa)->len != SA_LEN(&ss)) { + if (RSTRING(sa)->len != SA_LEN((struct sockaddr *)&ss)) { rb_raise(rb_eTypeError, "sockaddr size differs - should not happen"); } sap = (struct sockaddr *)&ss; |