[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCHv2] dprintf implementation
From: |
Hollis Blanchard |
Subject: |
Re: [PATCHv2] dprintf implementation |
Date: |
Fri, 25 Feb 2005 10:02:36 -0600 |
On Feb 25, 2005, at 5:52 AM, Vincent Pelletier wrote:
grub_strword (string, word) : searches for word (a serie of
non-word-separators eventualy ended by word-separators) in string (a
succession of 0 or more words which can begin by word-separator(s))
grub_strword looks a little overcomplicated; would something like this
work?
int
grub_strword (const char *haystack, const char *needle)
{
int pos = 0;
int found = 0;
while (haystack[pos]) {
/* Advance to next word. */
while (grub_iswordseparator (haystack[pos]))
pos++;
if (0 == grub_strcmp (&haystack[pos], needle))
{
found = 1;
break;
}
}
return found;
}
That assumes 'needle' contains no separator characters. I think that's
a safe assumption, given that 'needle' should come from a list of
#defines. Or we could even sanity-check that in grub_strword, which
IMHO would still be simpler than your earlier code.
Also, don't forget to add double spaces after periods in comments;
otherwise the emacs^W"style" police will kick in your door and make you
write 500 ChangeLog entries as punishment.
-Hollis
- [PATCH] dprintf implementation, Vincent Pelletier, 2005/02/21
- Re: [PATCH] dprintf implementation, Hollis Blanchard, 2005/02/23
- Re: [PATCH] dprintf implementation, Vincent Pelletier, 2005/02/24
- Re: [PATCH] dprintf implementation, Aki Tossavainen, 2005/02/24
- Re: [PATCH] dprintf implementation, Yoshinori K. Okuji, 2005/02/24
- Re: [PATCH] dprintf implementation, Vincent Pelletier, 2005/02/24
- Re: [PATCH] dprintf implementation, Hollis Blanchard, 2005/02/24
- Re: [PATCH] dprintf implementation, Aki Tossavainen, 2005/02/25
- [PATCHv2] dprintf implementation, Vincent Pelletier, 2005/02/25
- Re: [PATCHv2] dprintf implementation,
Hollis Blanchard <=
- Re: [PATCHv2] dprintf implementation, Aki Tossavainen, 2005/02/25
- Re: [PATCHv2] dprintf implementation, Hollis Blanchard, 2005/02/25
- Re: [PATCHv2] dprintf implementation, Yoshinori K. Okuji, 2005/02/25
- Re: [PATCHv2] dprintf implementation, Vincent Pelletier, 2005/02/25
- Re: [PATCHv2] dprintf implementation, Yoshinori K. Okuji, 2005/02/25