Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:54242 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48329 invoked from network); 29 Jul 2011 01:08:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jul 2011 01:08:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.170 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.220.170 mail-vx0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:45275] helo=mail-vx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9B/D0-35879-318023E4 for ; Thu, 28 Jul 2011 21:08:35 -0400 Received: by vxi39 with SMTP id 39so2624046vxi.29 for ; Thu, 28 Jul 2011 18:08:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=+7yaOM+27lqEDSIHNiONzKCb1iQE/GS7poGWkDriLT0=; b=pU7q1bV0Xr5mipyz0axscX/uPfKg1huLO8JfAu5qQF3aEWpAOyEWweG4BA/fA24TUI jSFtQygHaBQ9sQZo3fTgu8/20O9Onz6ozmxZuI92AhuNurbMj10L7b34CBs7xXZ4OkBi r9tyF19Z52wiuC6L/yh2c9G5Kzap9yZHmp8Co= MIME-Version: 1.0 Received: by 10.220.181.69 with SMTP id bx5mr177778vcb.235.1311901712219; Thu, 28 Jul 2011 18:08:32 -0700 (PDT) Sender: laruence@gmail.com Received: by 10.220.161.130 with HTTP; Thu, 28 Jul 2011 18:08:32 -0700 (PDT) In-Reply-To: <4E31A872.5030608@gmail.com> References: <4E31A872.5030608@gmail.com> Date: Fri, 29 Jul 2011 09:08:32 +0800 X-Google-Sender-Auth: NxHlZAkO1R8xY9eyM6uJvq1JydU Message-ID: To: =?UTF-8?B?w4FuZ2VsIEdvbnrDoWxleg==?= Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC]strn(case)cmp supporting negative length as third parameter From: laruence@php.net (Laruence) Hi: first of all, yes , you are right about the reverse order thing: and then, they are not equal: will output: strncmp: int(5) int(5) int(0) int(0) thanks 2011/7/29 =C3=81ngel Gonz=C3=A1lez : > Laruence wrote: >> >> Hi: >> >> =C2=A0 strn(case)cmp dosen't =C2=A0support a negative length as its thir= d >> paramter, =C2=A0while substr dose. > >> =C2=A0here is the rfc: https://wiki.php.net/rfc/strncmpnegativelen >> >> =C2=A0any question? plz worte me back. >> >> =C2=A0thanks > > What do you exactly mean by "in the reverse order" in >> >> if the abs of the negative length is greater than any strlen of the firs= t >> two parameters, then strn(case)cmp will work as strncmp in the reverse o= rder >> with the abs value: > > Looking at >> >> var_dump =C2=A0(strncmp >> =C2=A0("prefix_num", =C2=A0"num", =C2=A0-10)= ); >> =C2=A0 //outpu: int(7) > > it seems to mean that it would be equivalent to >> >> var_dump(strncmp("mun_xiferp", "mun", 10)); > > However, if I'm reading the patch correctly, it would > be taking the smaller string. Ie. it would be equivalent > to > >> var_dump =C2=A0(strncmp >> =C2=A0("prefix_num", =C2=A0"num", =C2=A0-3))= ; > > Seems an implementation bug. > > --=20 Laruence =C2=A0Xinchen Hui http://www.laruence.com/