From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from newton.hartwick.edu ([147.205.85.10]) by hawkwind.utcs.toronto.edu with SMTP id <25603>; Tue, 18 Apr 2000 17:10:38 -0400 Received: from c26469-a.clnvl1.ct.home.com (147.205.111.20 [147.205.111.20]) by newton.hartwick.edu with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2448.0) id HRZAWJK2; Tue, 18 Apr 2000 00:43:10 -0400 Received: by c26469-a.clnvl1.ct.home.com (sSMTP sendmail emulation); Tue, 18 Apr 2000 00:45:10 -0400 Date: Tue, 18 Apr 2000 00:45:10 -0400 From: Decklin Foster To: rc@hawkwind.utcs.toronto.edu Subject: oops, let's try that one again Message-ID: <20000418004510.A794@photek.dhs.org> References: <20000417155937.A29462@photek.dhs.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Mutt/1.0.1i In-Reply-To: <20000417155937.A29462@photek.dhs.org>; from fosterd@hartwick.edu on Mon, Apr 17, 2000 at 03:59:37PM -0400 Organization: Society for the Prevention of Cruelty to Vermin Decklin Foster writes: > if (p->w && strspn(p->w, "*") == strlen(p->w) && > p->m && strspn(p->m, "\001") == strlen(p->m)) > return TRUE; OK, raise your hand if you can spot the bug here. The test case I came up with after posting this code, which breaks it, is: ~ () *'*' (any number of quoted stars will do.) Not a crasher, but still obviously wrong. Thankfully, the fix involves changing only one character: if (p->w && strspn(p->w, "*") == strlen(p->w) && p->m && strspn(p->m, "\001") == strlen(p->w)) return TRUE; But this of course can be simplified to if (p->w && p->m && strspn(p->w, "*") == strspn(p->m, "\001") == strlen(p->w)) return TRUE; Which is somewhat more efficient, anyway. If you would like me to stop thinking aloud, just speak up, but I don't think this list is suffering from too much traffic ;-) [Note: my normal style would be to pull "== strlen(p->w))" back to the first tab stop and then put "return TRUE;" after it on the same line, but the rc Way seems to be to use if (foo) bar; instead of if (foo) bar; which is what I do for short statements. In short, reformat as you see fit.] -- Written with 100% free software. Please support the following websites: www.debian.org www.noamazon.com www.gnu.org www.opendvd.org lpf.ai.mit.edu