Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45662 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11930 invoked from network); 5 Oct 2009 14:45:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Oct 2009 14:45:30 -0000 Authentication-Results: pb1.pair.com header.from=ilia@prohost.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=ilia@prohost.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain prohost.org from 209.85.221.200 cause and error) X-PHP-List-Original-Sender: ilia@prohost.org X-Host-Fingerprint: 209.85.221.200 mail-qy0-f200.google.com Received: from [209.85.221.200] ([209.85.221.200:50310] helo=mail-qy0-f200.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 08/A4-21466-8860ACA4 for ; Mon, 05 Oct 2009 10:45:29 -0400 Received: by qyk38 with SMTP id 38so2828514qyk.27 for ; Mon, 05 Oct 2009 07:45:25 -0700 (PDT) Received: by 10.224.22.5 with SMTP id l5mr82317qab.380.1254753925775; Mon, 05 Oct 2009 07:45:25 -0700 (PDT) Received: from paulalaptop.centah.local (dev.centah.com [67.215.199.37]) by mx.google.com with ESMTPS id 6sm5202qwk.31.2009.10.05.07.45.22 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 05 Oct 2009 07:45:23 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v1076) Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes In-Reply-To: <4AC77E69.4010501@anderiasch.de> Date: Mon, 5 Oct 2009 10:45:20 -0400 Cc: internals@lists.php.net Content-Transfer-Encoding: 7bit Message-ID: <75FD67B9-1A31-4DA2-AD90-764D72A0B5FA@prohost.org> References: <4AC77E69.4010501@anderiasch.de> To: Florian Anderiasch X-Mailer: Apple Mail (2.1076) Subject: Re: [PHP-DEV] Patch for Bug #49757 From: ilia@prohost.org (Ilia Alshanetsky) Thanks for the patch, a patch closely based on your was just applied to SVN. On 2009-10-03, at 12:40 PM, Florian Anderiasch wrote: > Hello, > I've tried to fix http://bugs.php.net/bug.php?id=49757 > > As it's my first patch in c, any reviews and suggestions would be very > welcome. > > Greetings, > Florian > > Index: ext/standard/basic_functions.c > =================================================================== > --- ext/standard/basic_functions.c (revision 289129) > +++ ext/standard/basic_functions.c (working copy) > @@ -3932,6 +3932,7 @@ > int ip_len; > unsigned long n; > struct in_addr myaddr; > + char str[INET_ADDRSTRLEN]; > > if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &ip, > &ip_len) == FAILURE) { > return; > @@ -3940,7 +3941,14 @@ > n = strtoul(ip, NULL, 0); > > myaddr.s_addr = htonl(n); > - RETURN_STRING(inet_ntoa(myaddr), 1); > + > +#ifdef HAVE_INET_NTOP > + inet_ntop(AF_INET, &myaddr, str, INET_ADDRSTRLEN); > +#else > + str = inet_ntoa(myaddr); > +#endif > + > + RETURN_STRING(str, 1); > } > /* }}} */ > > Index: ext/standard/basic_functions.h > =================================================================== > --- ext/standard/basic_functions.h (revision 289129) > +++ ext/standard/basic_functions.h (working copy) > @@ -59,6 +59,7 @@ > #endif > PHP_FUNCTION(ip2long); > PHP_FUNCTION(long2ip); > +#define INET_ADDRSTRLEN 16 > > /* system functions */ > PHP_FUNCTION(getenv); > Index: ext/standard/basic_functions.c > =================================================================== > --- ext/standard/basic_functions.c (revision 289129) > +++ ext/standard/basic_functions.c (working copy) > @@ -3923,6 +3923,7 @@ > int ip_len; > unsigned long n; > struct in_addr myaddr; > + char str[INET_ADDRSTRLEN]; > > if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &ip, > &ip_len) == FAILURE) { > return; > @@ -3931,7 +3932,14 @@ > n = strtoul(ip, NULL, 0); > > myaddr.s_addr = htonl(n); > - RETURN_RT_STRING(inet_ntoa(myaddr), ZSTR_DUPLICATE); > + > +#ifdef HAVE_INET_NTOP > + inet_ntop(AF_INET, &myaddr, str, INET_ADDRSTRLEN); > +#else > + str = inet_ntoa(myaddr); > +#endif > + > + RETURN_RT_STRING(str, ZSTR_DUPLICATE); > } > /* }}} */ > > Index: ext/standard/basic_functions.h > =================================================================== > --- ext/standard/basic_functions.h (revision 289129) > +++ ext/standard/basic_functions.h (working copy) > @@ -59,6 +59,7 @@ > #endif > PHP_FUNCTION(ip2long); > PHP_FUNCTION(long2ip); > +#define INET_ADDRSTRLEN 16 > > /* system functions */ > PHP_FUNCTION(getenv); > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php