From: Decklin Foster <fosterd@hartwick.edu>
To: rc@hawkwind.utcs.toronto.edu
Subject: oops, let's try that one again
Date: Tue, 18 Apr 2000 00:45:10 -0400 [thread overview]
Message-ID: <20000418004510.A794@photek.dhs.org> (raw)
In-Reply-To: <20000417155937.A29462@photek.dhs.org>; from fosterd@hartwick.edu on Mon, Apr 17, 2000 at 03:59:37PM -0400
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
prev parent reply other threads:[~2000-04-18 21:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Pine.LNX.3.96.1000425010821.264C-100000@dwarf>
[not found] ` <QDwAALDY+jgTYAcA@ltsun0.star.le.ac.uk>
2000-04-17 19:59 ` Bug#62339: rc bug Decklin Foster
2000-04-18 4:45 ` Decklin Foster [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20000418004510.A794@photek.dhs.org \
--to=fosterd@hartwick.edu \
--cc=rc@hawkwind.utcs.toronto.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).