r63778 - in /branches/upstream/libsocket-getaddrinfo-perl/current: Build.PL Changes META.yml README lib/Socket/GetAddrInfo.pm lib/Socket/GetAddrInfo.xs t/01getaddrinfo.t
periapt-guest at users.alioth.debian.org
periapt-guest at users.alioth.debian.org
Fri Oct 15 21:26:52 UTC 2010
Author: periapt-guest
Date: Fri Oct 15 21:26:45 2010
New Revision: 63778
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=63778
Log:
[svn-upgrade] new version libsocket-getaddrinfo-perl (0.19)
Modified:
branches/upstream/libsocket-getaddrinfo-perl/current/Build.PL
branches/upstream/libsocket-getaddrinfo-perl/current/Changes
branches/upstream/libsocket-getaddrinfo-perl/current/META.yml
branches/upstream/libsocket-getaddrinfo-perl/current/README
branches/upstream/libsocket-getaddrinfo-perl/current/lib/Socket/GetAddrInfo.pm
branches/upstream/libsocket-getaddrinfo-perl/current/lib/Socket/GetAddrInfo.xs
branches/upstream/libsocket-getaddrinfo-perl/current/t/01getaddrinfo.t
Modified: branches/upstream/libsocket-getaddrinfo-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsocket-getaddrinfo-perl/current/Build.PL?rev=63778&op=diff
==============================================================================
--- branches/upstream/libsocket-getaddrinfo-perl/current/Build.PL (original)
+++ branches/upstream/libsocket-getaddrinfo-perl/current/Build.PL Fri Oct 15 21:26:45 2010
@@ -23,18 +23,37 @@
last TRY_XS unless $cc->try_find_libs_for(
# Solaris et.al. use -lsocket or -lsocket -lnsl
- libs => [ "", "socket", "socket nsl" ],
+ libs => [ "", "socket", "socket nsl", "ws2_32" ],
source => <<'EOF' );
#include <stdlib.h>
+#include <stdio.h>
+#ifdef _WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
+#endif
+
int main(int argc, char *argv[]) {
struct addrinfo hints = { 0 };
struct addrinfo *res;
+ int rc;
+#ifdef _WIN32
+ WSADATA wsadata;
+ rc = WSAStartup(MAKEWORD(2, 0), &wsadata);
+ if (rc != 0) {
+ printf("WSAStartup() failed: %d\n", rc);
+ return 1;
+ }
+#endif
hints.ai_socktype = SOCK_STREAM;
- if(getaddrinfo("127.0.0.1", "80", &hints, &res))
+ rc = getaddrinfo("127.0.0.1", "80", &hints, &res);
+ if (rc != 0) {
+ printf("getaddrinfo() failed: %d\n", rc);
return 1;
+ }
freeaddrinfo(res);
return 0;
}
@@ -50,8 +69,14 @@
define => "HAVE_SOCKADDR_SA_LEN",
source => <<'EOF' );
#include <stdlib.h>
+#ifdef _WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#else
#include <sys/types.h>
#include <sys/socket.h>
+#include <netdb.h>
+#endif
int main(int argc, char *argv[]) {
struct sockaddr sa;
sa.sa_len = 0;
@@ -82,8 +107,7 @@
create_makefile_pl => 'small',
create_license => 1,
create_readme => 1,
-
- $CAN_XS ? () : ( xs_files => {} ),
+ xs_files => $CAN_XS ? { ('lib/Socket/GetAddrInfo.xs') x 2 } : {},
);
$build->create_build_script;
Modified: branches/upstream/libsocket-getaddrinfo-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsocket-getaddrinfo-perl/current/Changes?rev=63778&op=diff
==============================================================================
--- branches/upstream/libsocket-getaddrinfo-perl/current/Changes (original)
+++ branches/upstream/libsocket-getaddrinfo-perl/current/Changes Fri Oct 15 21:26:45 2010
@@ -1,4 +1,9 @@
Revision history for Socket-GetAddrInfo
+
+0.19 BUGFIXES:
+ * Can't store &PL_sv_undef in an HV; store newSV(0) instead
+ * Handle magic in getaddrinfo() args [chansen]
+ * Win32 build fixes [chansen]
0.18 BUGFIXES:
* Fix plain number passing for getaddrinfo()'s service on perl
Modified: branches/upstream/libsocket-getaddrinfo-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsocket-getaddrinfo-perl/current/META.yml?rev=63778&op=diff
==============================================================================
--- branches/upstream/libsocket-getaddrinfo-perl/current/META.yml (original)
+++ branches/upstream/libsocket-getaddrinfo-perl/current/META.yml Fri Oct 15 21:26:45 2010
@@ -23,9 +23,9 @@
provides:
Socket::GetAddrInfo:
file: lib/Socket/GetAddrInfo.pm
- version: 0.18
+ version: 0.19
requires:
XSLoader: 0
resources:
license: http://dev.perl.org/licenses/
-version: 0.18
+version: 0.19
Modified: branches/upstream/libsocket-getaddrinfo-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsocket-getaddrinfo-perl/current/README?rev=63778&op=diff
==============================================================================
--- branches/upstream/libsocket-getaddrinfo-perl/current/README (original)
+++ branches/upstream/libsocket-getaddrinfo-perl/current/README Fri Oct 15 21:26:45 2010
@@ -195,8 +195,11 @@
Extensions for IPv6
ACKNOWLEDGEMENTS
- With thanks to Zefram <zefram at fysh.org> for help with fixing some bugs
- in the XS code.
+ Christian Hansen <chansen at cpan.org> - for help with some XS features and
+ Win32 build fixes.
+
+ Zefram <zefram at fysh.org> - for help with fixing some bugs in the XS
+ code.
AUTHOR
Paul Evans <leonerd at leonerd.org.uk>
Modified: branches/upstream/libsocket-getaddrinfo-perl/current/lib/Socket/GetAddrInfo.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsocket-getaddrinfo-perl/current/lib/Socket/GetAddrInfo.pm?rev=63778&op=diff
==============================================================================
--- branches/upstream/libsocket-getaddrinfo-perl/current/lib/Socket/GetAddrInfo.pm (original)
+++ branches/upstream/libsocket-getaddrinfo-perl/current/lib/Socket/GetAddrInfo.pm Fri Oct 15 21:26:45 2010
@@ -15,7 +15,7 @@
my %errstr;
BEGIN {
- our $VERSION = "0.18";
+ our $VERSION = "0.19";
our @EXPORT = qw(
getaddrinfo
@@ -553,8 +553,10 @@
=head1 ACKNOWLEDGEMENTS
-With thanks to Zefram <zefram at fysh.org> for help with fixing some bugs in the
-XS code.
+Christian Hansen <chansen at cpan.org> - for help with some XS features and Win32
+build fixes.
+
+Zefram <zefram at fysh.org> - for help with fixing some bugs in the XS code.
=head1 AUTHOR
Modified: branches/upstream/libsocket-getaddrinfo-perl/current/lib/Socket/GetAddrInfo.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsocket-getaddrinfo-perl/current/lib/Socket/GetAddrInfo.xs?rev=63778&op=diff
==============================================================================
--- branches/upstream/libsocket-getaddrinfo-perl/current/lib/Socket/GetAddrInfo.xs (original)
+++ branches/upstream/libsocket-getaddrinfo-perl/current/lib/Socket/GetAddrInfo.xs Fri Oct 15 21:26:45 2010
@@ -8,9 +8,14 @@
#include "perl.h"
#include "XSUB.h"
+#ifdef _WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
+#endif
// Newx was new in 5.9.3
#ifndef Newx
@@ -111,7 +116,7 @@
setup_constants();
void
-getaddrinfo(host=NULL, service=NULL, hints=NULL)
+getaddrinfo(host=&PL_sv_undef, service=&PL_sv_undef, hints=NULL)
SV *host
SV *service
SV *hints
@@ -127,12 +132,19 @@
int n_res;
PPCODE:
- if(SvOK(host) && SvCUR(host))
- hostname = SvPV_nolen(host);
-
- /* This might be numeric so we may have to stringify it */
- if(SvOK(service) && (SvCUR(service) || SvPV(service, len) && len))
- servicename = SvPV_nolen(service);
+ SvGETMAGIC(host);
+ if(SvOK(host)) {
+ hostname = SvPV_nomg(host, len);
+ if (!len)
+ hostname = NULL;
+ }
+
+ SvGETMAGIC(service);
+ if(SvOK(service)) {
+ servicename = SvPV_nomg(service, len);
+ if (!len)
+ servicename = NULL;
+ }
if(hints && SvOK(hints)) {
HV *hintshash;
@@ -173,7 +185,7 @@
if(res_iter->ai_canonname)
hv_store(res_hv, "canonname", 9, newSVpv(res_iter->ai_canonname, 0), 0);
else
- hv_store(res_hv, "canonname", 9, &PL_sv_undef, 0);
+ hv_store(res_hv, "canonname", 9, newSV(0), 0);
XPUSHs(sv_2mortal(newRV_noinc((SV*)res_hv)));
n_res++;
Modified: branches/upstream/libsocket-getaddrinfo-perl/current/t/01getaddrinfo.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsocket-getaddrinfo-perl/current/t/01getaddrinfo.t?rev=63778&op=diff
==============================================================================
--- branches/upstream/libsocket-getaddrinfo-perl/current/t/01getaddrinfo.t (original)
+++ branches/upstream/libsocket-getaddrinfo-perl/current/t/01getaddrinfo.t Fri Oct 15 21:26:45 2010
@@ -2,7 +2,7 @@
use strict;
-use Test::More tests => 28;
+use Test::More tests => 39;
use Test::Exception;
use Socket::GetAddrInfo qw( :newapi getaddrinfo AI_NUMERICHOST );
@@ -24,7 +24,7 @@
return;
}
- if( $port != $expect_port ) {
+ if( defined $expect_port && $port != $expect_port ) {
diag( "Expected port $expect_port, got $port" );
fail( $message );
return;
@@ -110,6 +110,40 @@
( $err, @res ) = getaddrinfo( "127.0.0.1", undef );
is_err( $err, 0, '$err == 0 for host=127.0.0.1' );
+
+{
+ "127.0.0.1" =~ /(.+)/;
+ ( $err, @res ) = getaddrinfo($1, undef);
+ is_err( $err, 0, '$err == 0 for host=$1' );
+ ok( scalar @res > 0, '@res has results' );
+ is_sinaddr( $res[0]->{addr}, undef, inet_aton( "127.0.0.1" ),
+ '$res[0] addr is "127.0.0.1"');
+}
+
+{
+ package MyString;
+ use overload '""' => sub { ${ $_[0] } }, fallback => 1;
+ sub new {
+ my ($class, $string) = @_;
+ return bless \$string, $class;
+ }
+}
+
+{
+ ( $err, @res ) = getaddrinfo(MyString->new("127.0.0.1"), undef);
+ is_err( $err, 0, '$err == 0 for host=MyString->new("127.0.0.1")' );
+ ok( scalar @res > 0, '@res has results' );
+ is_sinaddr( $res[0]->{addr}, undef, inet_aton( "127.0.0.1" ),
+ '$res[0] addr is "127.0.0.1"');
+}
+
+{
+ ( $err, @res ) = getaddrinfo(substr("127.0.0.1", 0, 9), undef);
+ is_err( $err, 0, '$err == 0 for host=substr("127.0.0.1", 0, 9)' );
+ ok( scalar @res > 0, '@res has results' );
+ is_sinaddr( $res[0]->{addr}, undef, inet_aton( "127.0.0.1" ),
+ '$res[0] addr is "127.0.0.1"');
+}
# Just pick the first one
is( $res[0]->{family}, AF_INET,
@@ -186,3 +220,11 @@
'getaddrinfo() with string hints dies' );
dies_ok( sub { getaddrinfo( "127.0.0.1", "80", [] ) },
'getaddrinfo() with ARRAY hints dies' );
+
+# Ensure it doesn't segfault if args are missing
+
+( $err, @res ) = getaddrinfo();
+ok( defined $err, '$err defined for getaddrinfo()' );
+
+( $err, @res ) = getaddrinfo( "127.0.0.1" );
+ok( defined $err, '$err defined for getaddrinfo("127.0.0.1")' );
More information about the Pkg-perl-cvs-commits
mailing list