Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29733 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42516 invoked by uid 1010); 25 May 2007 00:03:24 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 42501 invoked from network); 25 May 2007 00:03:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 May 2007 00:03:24 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 204.11.219.139 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 204.11.219.139 mail.lerdorf.com Received: from [204.11.219.139] ([204.11.219.139:33360] helo=mail.lerdorf.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C7/DF-57693-7C726564 for ; Thu, 24 May 2007 20:03:24 -0400 Received: from trainburn-lm.corp.yahoo.com (trainburn-lm.corp.yahoo.com [207.126.233.11]) (authenticated bits=0) by mail.lerdorf.com (8.14.1/8.14.1/Debian-4) with ESMTP id l4P03DXP028540 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 24 May 2007 17:03:13 -0700 Message-ID: <465627BE.5070603@lerdorf.com> Date: Thu, 24 May 2007 17:03:10 -0700 User-Agent: Thunderbird 2.0.0.0 (Macintosh/20070326) MIME-Version: 1.0 To: Martin Majlis CC: internals@lists.php.net References: <717e56840705241650p3210b76do1e1a0ae28e7aad3d@mail.gmail.com> In-Reply-To: <717e56840705241650p3210b76do1e1a0ae28e7aad3d@mail.gmail.com> X-Enigmail-Version: 0.95.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.90.2/3292/Thu May 24 16:04:26 2007 on colo.lerdorf.com X-Virus-Status: Clean Subject: Re: [PHP-DEV] [PATCH] JSON_parser From: rasmus@lerdorf.com (Rasmus Lerdorf) What prompted this? I'm not keen on changing the parser unless there is some benefit. Speed, portability, fixing a reported issue, etc. The one risk I see here is that isxdigit() is a LOCALE-aware function, so first, it is likely slower than what it replaces here, and second, a messed up LOCALE could potentially cause it to misbehave. -Rasmus Martin Majlis wrote: > Just small refactoring. Replacing self-made function with functions > from standard headers. > > Index: JSON_parser.c > =================================================================== > RCS file: /repository/php-src/ext/json/JSON_parser.c,v > retrieving revision 1.1.2.8 > diff -u -u -r1.1.2.8 JSON_parser.c > --- JSON_parser.c 24 May 2007 22:37:59 -0000 1.1.2.8 > +++ JSON_parser.c 24 May 2007 23:41:11 -0000 > @@ -29,6 +29,8 @@ > > #include "JSON_parser.h" > #include > +#include > +#include > > #define true 1 > #define false 0 > @@ -259,18 +261,10 @@ > > static int dehexchar(char c) > { > - if (c >= '0' && c <= '9') > - { > - return c - '0'; > - } > - else if (c >= 'A' && c <= 'F') > - { > - return c - ('A' - 10); > - } > - else if (c >= 'a' && c <= 'f') > - { > - return c - ('a' - 10); > - } > + if (isxdigit(c)) > + { > + return strtol(&c, NULL, 16); > + } > else > { > return -1; >