[chora] problem when 0 is the name of a directory

Jon Parise jon@csh.rit.edu
Tue, 6 Mar 2001 23:08:32 -0500


On Wed, Mar 07, 2001 at 04:03:33AM -0000, Pixel Date wrote:

> Line 91 of chora/lib/CVSLib/Directory.php should be changed from
> 
>         while ($name = readdir($DIR)) {
> 
> to
> 
>         while (($name = readdir($DIR)) != '') {

I usually prefer to use empty() for cases like this, but I don't know
which method is better (in terms of performance or readability).

Thanks for all of the suggestions you've been making.  However, do you
think you could start submitting your changes as diffs (preferably
unified)?

-- 
Jon Parise (jon@csh.rit.edu)  .  Rochester Inst. of Technology
http://www.csh.rit.edu/~jon/  :  Computer Science House Member


>From chuck@horde.org Date: Tue,  6 Mar 2001 23:14:16 -0500
Return-Path: <chuck@horde.org>
Mailing-List: contact chora-help@lists.horde.org; run by ezmlm
Delivered-To: mailing list chora@lists.horde.org
Received: (qmail 87036 invoked from network); 7 Mar 2001 04:15:18 -0000
Received: from 208-59-250-206.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com (HELO marina.horde.org) (208.59.250.206)
  by horde.org with SMTP; 7 Mar 2001 04:15:18 -0000
Received: by marina.horde.org (Postfix, from userid 33)
	id DC8F43CA6; Tue,  6 Mar 2001 23:14:16 -0500 (EST)
Received: from 192.168.0.110 ( [192.168.0.110])
	as user chuck@localhost by marina.your.mom with HTTP;
	Tue,  6 Mar 2001 23:14:16 -0500
Message-ID: <983938456.3aa5b59881b95@marina.your.mom>
Date: Tue,  6 Mar 2001 23:14:16 -0500
From: Chuck Hagenbuch <chuck@horde.org>
To: chora@lists.horde.org
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 8bit
User-Agent: Internet Messaging Program (IMP) 2.3.7-cvs
Subject: Re: [chora] problem when 0 is the name of a directory

Quoting Jon Parise <jon@csh.rit.edu>:

> >         while (($name = readdir($DIR)) != '') {
> 
> I usually prefer to use empty() for cases like this, but I don't know
> which method is better (in terms of performance or readability).

In this case, I think the preferred way to write it would be:

while (($name = readdir($DIR)) !== false)

empty would still return true on 0 as the directory name, and there's no way to 
apply empty() directly within the while loop above without adding an extra step.

I'll commit this in a moment - I just reproduced the revs problem, or something 
suspiciously similar, so I'm trying to track it down.

-chuck

--
Charles Hagenbuch, <chuck@horde.org>
"Live, from Washington, where the doctors were telling us what they did, and
 did not, do with Vice President Cheney." -Dan Rather