diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-03-06 10:31:23 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-03-06 10:31:23 +0000 |
commit | 4596752b8da44c630264e094a6e4a95082f0b07a (patch) | |
tree | ba0d09ffb1f6564f0bed552eac48b39fdad8ef02 /ext | |
parent | 013e295df0c07448c793c2b6d60b0a2400261e88 (diff) | |
download | perl-4596752b8da44c630264e094a6e4a95082f0b07a.tar.gz |
A clearer layout for the fall-through logic of Socket::inet_aton()
Diffstat (limited to 'ext')
-rw-r--r-- | ext/Socket/Socket.xs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ext/Socket/Socket.xs b/ext/Socket/Socket.xs index 3e81105e0c..9214fc15bb 100644 --- a/ext/Socket/Socket.xs +++ b/ext/Socket/Socket.xs @@ -423,15 +423,19 @@ inet_aton(host) { struct in_addr ip_address; struct hostent * phe; - int ok = (*host != '\0') && inet_aton(host, &ip_address); - if (!ok && (phe = gethostbyname(host)) && - phe->h_addrtype == AF_INET && phe->h_length == 4) { - Copy( phe->h_addr, &ip_address, phe->h_length, char ); - ok = 1; + if ((*host != '\0') && inet_aton(host, &ip_address)) { + ST(0) = newSVpvn_flags((char *)&ip_address, sizeof ip_address, SVs_TEMP); + XSRETURN(1); + } + + phe = gethostbyname(host); + if (phe && phe->h_addrtype == AF_INET && phe->h_length == 4) { + ST(0) = newSVpvn_flags((char *)phe->h_addr, phe->h_length, SVs_TEMP); + XSRETURN(1); } - ST(0) = newSVpvn_flags(ok ? (char *)&ip_address : NULL, sizeof ip_address, SVs_TEMP); + XSRETURN_UNDEF; } void |