From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1DLykV-0003xL-OF for mharc-grub-devel@gnu.org; Thu, 14 Apr 2005 03:26:52 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DLykS-0003w1-3T for grub-devel@gnu.org; Thu, 14 Apr 2005 03:26:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DLykO-0003v1-VH for grub-devel@gnu.org; Thu, 14 Apr 2005 03:26:46 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DLye7-0002ZH-PO for grub-devel@gnu.org; Thu, 14 Apr 2005 03:20:16 -0400 Received: from [217.12.11.33] (helo=smtp002.mail.ukl.yahoo.com) by monty-python.gnu.org with smtp (Exim 4.34) id 1DLyYC-0001ky-0u for grub-devel@gnu.org; Thu, 14 Apr 2005 03:14:08 -0400 Received: from unknown (HELO ?192.168.0.2?) (subdino2004@83.194.41.32 with plain) by smtp002.mail.ukl.yahoo.com with SMTP; 14 Apr 2005 07:13:32 -0000 Message-ID: <425E181C.1000908@yahoo.fr> Date: Thu, 14 Apr 2005 09:13:32 +0200 From: Vincent Pelletier User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: The development of GRUB 2 References: <421A4CEA.5030603@yahoo.fr> <421F118C.5000504@yahoo.fr> <5118c6fb99a015e564cf60860935ce8d@penguinppc.org> <200502251812.04315.okuji@enbug.org> In-Reply-To: X-Enigmail-Version: 0.90.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [PATCHv2] dprintf implementation X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Apr 2005 07:26:49 -0000 Hollis Blanchard wrote: > int > grub_strword(const char *haystack, const char *needle) > { > char *match; > char *end; > > match = strstr (haystack, needle); > > if (match == NULL) > return 0; > if ((match > haystack) && (!grub_iswordseparator (match[-1]))) > return 0; > > end = match + strlen(needle)+1; > if (*end && !grub_iswordseparator (*end)) > return 0; > > return 1; > } I find a little problem (sorry :) ) : haystack = "filesystem file" needle = "file" won't match. A loop might do the trick, but after a short try I don't see how. Here is a new version of my strword. It should be easier to read. int grub_strword (const char *haystack, const char *needle) { const char *n_pos = needle; while (grub_iswordseparator (*haystack)) haystack++; while (*haystack) { /* Crawl both the needle and the haystack word we're on. */ while(*haystack && !grub_iswordseparator (*haystack) && *haystack == *n_pos) { haystack++; n_pos++; } /* If we reached the end of both words at the same time, the word is found. If not, eat everything in the haystack that isn't the next word (or the end of string) and "reset" the needle. */ if ( (!*haystack || grub_iswordseparator (*haystack)) && (!*n_pos || grub_iswordseparator (*n_pos))) return 1; else { n_pos = needle; while (*haystack && !grub_iswordseparator (*haystack)) haystack++; while (grub_iswordseparator (*haystack)) haystack++; } } return 0; } Vincent Pelletier