r60274 - in /branches/upstream/libsocket-getaddrinfo-perl/current: Build.PL Changes META.yml Makefile.PL lib/Socket/GetAddrInfo.pm lib/Socket/GetAddrInfo.xs t/01getaddrinfo.t

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Wed Jul 14 02:29:01 UTC 2010


Author: ansgar-guest
Date: Wed Jul 14 02:28:52 2010
New Revision: 60274

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=60274
Log:
[svn-upgrade] new version libsocket-getaddrinfo-perl (0.16)

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/Makefile.PL
    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=60274&op=diff
==============================================================================
--- branches/upstream/libsocket-getaddrinfo-perl/current/Build.PL (original)
+++ branches/upstream/libsocket-getaddrinfo-perl/current/Build.PL Wed Jul 14 02:28:52 2010
@@ -5,21 +5,26 @@
 
 eval { require ExtUtils::CChecker; 1 } or
    die "OS unsupported - missing ExtUtils::CChecker";
+eval { ExtUtils::CChecker->VERSION( 0.04 ) } or
+   die "OS unsupported - ExtUtils::CChecker too old; need at least 0.04";
 
+my $cc = ExtUtils::CChecker->new();
+
+my $CAN_XS = 0;
 my $HAVE_SOCKADDR_SA_LEN;
 
-sub Configure
-{
+TRY_XS: {
    if( $ENV{NO_XS} ) {
       print "\$ENV{NO_XS} is set - XS code will be disabled\n";
-      return 0;
+      last TRY_XS;
    }
-
-   my $cc = ExtUtils::CChecker->new();
 
    print "\nDetecting if libc supports getaddrinfo()...\n";
 
-   my $gai_test = <<EOF;
+   last TRY_XS unless $cc->try_find_libs_for(
+      # Solaris et.al. use -lsocket or -lsocket -lnsl
+      libs => [ "", "socket", "socket nsl" ],
+      source => <<'EOF' );
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -35,13 +40,15 @@
 }
 EOF
 
-   return 0 unless $cc->try_compile_run( source => $gai_test );
+   $CAN_XS = 1;
 
    print "\nLooks like the libc supports getaddrinfo()\n";
 
    print "Detecting if sockaddr has sa_len field...\n";
 
-   my $sa_len_test = <<EOF;
+   $cc->try_compile_run(
+      define => "HAVE_SOCKADDR_SA_LEN",
+      source => <<'EOF' );
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -51,27 +58,19 @@
    return 0;
 }
 EOF
-
-   $HAVE_SOCKADDR_SA_LEN = $cc->try_compile_run( source => $sa_len_test );
-
-   return 1;
 }
 
-my $CAN_XS = Configure();
-
-my $build = Module::Build->new
-  (
+my $build = $cc->new_module_build(
    module_name => 'Socket::GetAddrInfo',
    dist_version_from => 'lib/Socket/GetAddrInfo.pm',
-   extra_compiler_flags => [ "-DHAVE_SOCKADDR_SA_LEN=$HAVE_SOCKADDR_SA_LEN" ],
    requires => {
       'XSLoader' => 0,
    },
    configure_requires => {
-      'ExtUtils::CChecker' => 0,
+      'ExtUtils::CChecker' => '0.04',
    },
    build_requires => {
-      'ExtUtils::CChecker' => 0,
+      'ExtUtils::CChecker' => '0.04',
       'Module::Build' => 0,
       'Module::Build::Compat' => 0,
       'Scalar::Util' => 0,
@@ -85,6 +84,6 @@
    create_readme  => 1,
 
    $CAN_XS ? () : ( xs_files => {} ),
-  );
+);
 
 $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=60274&op=diff
==============================================================================
--- branches/upstream/libsocket-getaddrinfo-perl/current/Changes (original)
+++ branches/upstream/libsocket-getaddrinfo-perl/current/Changes Wed Jul 14 02:28:52 2010
@@ -1,4 +1,10 @@
 Revision history for Socket-GetAddrInfo
+
+0.16    CHANGES:
+         * Accept undef as absent host/service name, as well as ""
+
+        BUGFIXES:
+         * Need -lsocket on some OSes; hunt it using ExtUtils::CChecker
 
 0.15    CHANGES:
          * Use XSLoader instead of DynaLoader

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=60274&op=diff
==============================================================================
--- branches/upstream/libsocket-getaddrinfo-perl/current/META.yml (original)
+++ branches/upstream/libsocket-getaddrinfo-perl/current/META.yml Wed Jul 14 02:28:52 2010
@@ -4,7 +4,7 @@
   - 'Paul Evans <leonerd at leonerd.org.uk>'
 build_requires:
   ExtUtils::CBuilder: 0
-  ExtUtils::CChecker: 0
+  ExtUtils::CChecker: 0.04
   Module::Build: 0
   Module::Build::Compat: 0
   Scalar::Util: 0
@@ -12,9 +12,9 @@
   Test::More: 0
   Test::Warn: 0
 configure_requires:
-  ExtUtils::CChecker: 0
+  ExtUtils::CChecker: 0.04
   Module::Build: 0.36
-generated_by: 'Module::Build version 0.3601'
+generated_by: 'Module::Build version 0.3607'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -23,9 +23,9 @@
 provides:
   Socket::GetAddrInfo:
     file: lib/Socket/GetAddrInfo.pm
-    version: 0.15
+    version: 0.16
 requires:
   XSLoader: 0
 resources:
   license: http://dev.perl.org/licenses/
-version: 0.15
+version: 0.16

Modified: branches/upstream/libsocket-getaddrinfo-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsocket-getaddrinfo-perl/current/Makefile.PL?rev=60274&op=diff
==============================================================================
--- branches/upstream/libsocket-getaddrinfo-perl/current/Makefile.PL (original)
+++ branches/upstream/libsocket-getaddrinfo-perl/current/Makefile.PL Wed Jul 14 02:28:52 2010
@@ -1,4 +1,4 @@
-# Note: this file was auto-generated by Module::Build::Compat version 0.3601
+# Note: this file was auto-generated by Module::Build::Compat version 0.3607
     use Module::Build::Compat 0.02;
     
     Module::Build::Compat->run_build_pl(args => \@ARGV);

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=60274&op=diff
==============================================================================
--- branches/upstream/libsocket-getaddrinfo-perl/current/lib/Socket/GetAddrInfo.pm (original)
+++ branches/upstream/libsocket-getaddrinfo-perl/current/lib/Socket/GetAddrInfo.pm Wed Jul 14 02:28:52 2010
@@ -1,7 +1,7 @@
 #  You may distribute under the terms of either the GNU General Public License
 #  or the Artistic License (the same terms as Perl itself)
 #
-#  (C) Paul Evans, 2007-2009 -- leonerd at leonerd.org.uk
+#  (C) Paul Evans, 2007-2010 -- leonerd at leonerd.org.uk
 
 package Socket::GetAddrInfo;
 
@@ -15,7 +15,7 @@
 my %errstr;
 
 BEGIN {
-   our $VERSION = "0.15";
+   our $VERSION = "0.16";
 
    our @EXPORT = qw(
       getaddrinfo

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=60274&op=diff
==============================================================================
--- branches/upstream/libsocket-getaddrinfo-perl/current/lib/Socket/GetAddrInfo.xs (original)
+++ branches/upstream/libsocket-getaddrinfo-perl/current/lib/Socket/GetAddrInfo.xs Wed Jul 14 02:28:52 2010
@@ -1,7 +1,7 @@
 /*  You may distribute under the terms of either the GNU General Public License
  *  or the Artistic License (the same terms as Perl itself)
  *
- *  (C) Paul Evans, 2008,2009 -- leonerd at leonerd.org.uk
+ *  (C) Paul Evans, 2008-2010 -- leonerd at leonerd.org.uk
  */
 
 #include "EXTERN.h"
@@ -111,12 +111,14 @@
   setup_constants();
 
 void
-getaddrinfo(host, service, hints=NULL)
-    char *host
-    char *service
+getaddrinfo(host=NULL, service=NULL, hints=NULL)
+    SV   *host
+    SV   *service
     SV   *hints
 
   PREINIT:
+    char *hostname = NULL;
+    char *servicename = NULL;
     struct addrinfo hints_s = { 0 };
     struct addrinfo *res;
     struct addrinfo *res_iter;
@@ -124,6 +126,12 @@
     int n_res;
 
   PPCODE:
+    if(SvOK(host) && SvCUR(host))
+      hostname = SvPV_nolen(host);
+
+    if(SvOK(service) && SvCUR(service))
+      servicename = SvPV_nolen(service);
+
     if(hints && SvOK(hints)) {
       HV *hintshash;
       SV **valp;
@@ -143,7 +151,7 @@
         hints_s.ai_protocol = SvIV(*valp);
     }
 
-    err = getaddrinfo(host[0] ? host : NULL, service[0] ? service : NULL, &hints_s, &res);
+    err = getaddrinfo(hostname, servicename, &hints_s, &res);
 
     XPUSHs(err_to_SV(err));
 
@@ -195,7 +203,7 @@
      * not be due to SvOOK */
     Newx(sa, addr_len, char);
     Copy(SvPV_nolen(addr), sa, addr_len, char);
-#if HAVE_SOCKADDR_SA_LEN
+#ifdef HAVE_SOCKADDR_SA_LEN
     ((struct sockaddr *)sa)->sa_len = addr_len;
 #endif
 

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=60274&op=diff
==============================================================================
--- branches/upstream/libsocket-getaddrinfo-perl/current/t/01getaddrinfo.t (original)
+++ branches/upstream/libsocket-getaddrinfo-perl/current/t/01getaddrinfo.t Wed Jul 14 02:28:52 2010
@@ -2,7 +2,7 @@
 
 use strict;
 
-use Test::More tests => 24;
+use Test::More tests => 28;
 use Test::Exception;
 
 use Socket::GetAddrInfo qw( :newapi getaddrinfo AI_NUMERICHOST );
@@ -97,10 +97,19 @@
 is_sinaddr( $res[0]->{addr}, 80, inet_aton( "127.0.0.1" ),
    '$res[0] addr is {"127.0.0.1", 0}' );
 
+# Check actual IV integers work just as well as PV strings
+( $err, @res ) = getaddrinfo( "127.0.0.1", 80, { socktype => SOCK_STREAM } );
+is_err( $err, 0,  '$err == 0 for host=127.0.0.1/service=80/socktype=STREAM' );
+is_sinaddr( $res[0]->{addr}, 80, inet_aton( "127.0.0.1" ),
+   '$res[0] addr is {"127.0.0.1", 0}' );
+
 ( $err, @res ) = getaddrinfo( "127.0.0.1", "" );
 is_err( $err, 0,  '$err == 0 for host=127.0.0.1' );
 # Might get more than one; e.g. different socktypes
 ok( scalar @res > 0, '@res has results' );
+
+( $err, @res ) = getaddrinfo( "127.0.0.1", undef );
+is_err( $err, 0,  '$err == 0 for host=127.0.0.1' );
 
 # Just pick the first one
 is( $res[0]->{family}, AF_INET,
@@ -119,6 +128,9 @@
    '$res[0] socktype is SOCK_STREAM' );
 ok( $res[0]->{protocol} == 0 || $res[0]->{protocol} == IPPROTO_TCP,
    '$res[0] protocol is 0 or IPPROTO_TCP' );
+
+( $err, @res ) = getaddrinfo( undef, "80", { family => AF_INET, socktype => SOCK_STREAM } );
+is_err( $err, 0,  '$err == 0 for service=80/family=AF_INET/socktype=STREAM' );
 
 # Now some tests of a few well-known internet hosts
 




More information about the Pkg-perl-cvs-commits mailing list