From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LQImw-0007pO-IK for mharc-grub-devel@gnu.org; Fri, 23 Jan 2009 04:57:22 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LQImu-0007ok-Br for grub-devel@gnu.org; Fri, 23 Jan 2009 04:57:20 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LQImt-0007oP-FW for grub-devel@gnu.org; Fri, 23 Jan 2009 04:57:19 -0500 Received: from [199.232.76.173] (port=53064 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LQImt-0007oM-A0 for grub-devel@gnu.org; Fri, 23 Jan 2009 04:57:19 -0500 Received: from eta-ori.net ([91.121.142.51]:36952 helo=orion.eta-ori.net) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LQIms-0007EO-ON for grub-devel@gnu.org; Fri, 23 Jan 2009 04:57:19 -0500 Received: by orion.eta-ori.net (Postfix, from userid 1006) id 5249A2EEDBB; Fri, 23 Jan 2009 10:57:10 +0100 (CET) Received: from [IPv6:2001:6f8:10ae:0:217:31ff:fe81:8c8] (istari.kleinerfeigling.org [IPv6:2001:6f8:10ae:0:217:31ff:fe81:8c8]) by orion.eta-ori.net (Postfix) with ESMTPSA id B35A52EED9E for ; Fri, 23 Jan 2009 10:57:07 +0100 (CET) Message-ID: <49799320.1000300@impulze.org> Date: Fri, 23 Jan 2009 10:51:28 +0100 From: Daniel Mierswa User-Agent: Thunderbird 2.0.0.19 (X11/20090121) MIME-Version: 1.0 To: grub-devel@gnu.org References: <49771040.7010509@impulze.org> <1232559057.17462.2.camel@dv> In-Reply-To: <1232559057.17462.2.camel@dv> X-Enigmail-Version: 0.95.7 OpenPGP: id=ADF32F97 Content-Type: multipart/mixed; boundary="------------060408080907040502080206" X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [PATCH] caseless uuid detection, fixed wrong behaviour for strncasecmp, added strcasecmp 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: Fri, 23 Jan 2009 09:57:20 -0000 This is a multi-part message in MIME format. --------------060408080907040502080206 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Am 01/21/09 18:30, Pavel Roskin schrieb: > The patch looks good to me. I would split changes to commands/search.c > into a separate commit. > > Please provide ChangeLog entries for the patches. > I will comply. Thanks for your quick response. -- Mierswa, Daniel If you still don't like it, that's ok: that's why I'm boss. I simply know better than you do. --- Linus Torvalds, comp.os.linux.advocacy, 1996/07/22 --------------060408080907040502080206 Content-Type: text/plain; name="ChangeLog" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ChangeLog" 2009-01-23 Daniel Mierswa * kern/misc.c: add strcasecmp for consistency reasons, use grub_size_t instead of int for strfuncs, fix strncasecmp return values, use the same algorithm in str*casecmp and str*cmp * include/grub/misc.h: add str{,n}casecmp, use grub_size_t for strncasecmp 2009-01-23 Daniel Mierswa * commands/search.c: caseless UUID comparing --------------060408080907040502080206 Content-Type: text/plain; name="grub2_strfuncs.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="grub2_strfuncs.patch" Index: kern/misc.c =================================================================== --- kern/misc.c (revision 1952) +++ kern/misc.c (working copy) @@ -194,7 +194,7 @@ while (*s1 && *s2) { if (*s1 != *s2) - return (int) *s1 - (int) *s2; + break; s1++; s2++; @@ -212,7 +212,7 @@ while (*s1 && *s2 && --n) { if (*s1 != *s2) - return (int) *s1 - (int) *s2; + break; s1++; s2++; @@ -222,21 +222,36 @@ } int -grub_strncasecmp (const char *s1, const char *s2, int c) +grub_strcasecmp (const char *s1, const char *s2) { - int p = 1; + while (*s1 && *s2) + { + if (grub_tolower (*s1) != grub_tolower (*s2)) + break; + + s1++; + s2++; + } - while (grub_tolower (*s1) && grub_tolower (*s2) && p < c) + return (int) grub_tolower (*s1) - (int) grub_tolower (*s2); +} + +int +grub_strncasecmp (const char *s1, const char *s2, grub_size_t n) +{ + if (n == 0) + return 0; + + while (*s1 && *s2 && --n) { if (grub_tolower (*s1) != grub_tolower (*s2)) - return (int) grub_tolower (*s1) - (int) grub_tolower (*s2); + break; s1++; s2++; - p++; } - return (int) *s1 - (int) *s2; + return (int) grub_tolower (*s1) - (int) grub_tolower (*s2); } char * Index: include/grub/misc.h =================================================================== --- include/grub/misc.h (revision 1952) +++ include/grub/misc.h (working copy) @@ -45,7 +45,8 @@ int EXPORT_FUNC(grub_memcmp) (const void *s1, const void *s2, grub_size_t n); int EXPORT_FUNC(grub_strcmp) (const char *s1, const char *s2); int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, grub_size_t n); -int EXPORT_FUNC(grub_strncasecmp) (const char *s1, const char *s2, int c); +int EXPORT_FUNC(grub_strcasecmp) (const char *s1, const char *s2); +int EXPORT_FUNC(grub_strncasecmp) (const char *s1, const char *s2, grub_size_t n); char *EXPORT_FUNC(grub_strchr) (const char *s, int c); char *EXPORT_FUNC(grub_strrchr) (const char *s, int c); int EXPORT_FUNC(grub_strword) (const char *s, const char *w); --------------060408080907040502080206 Content-Type: text/plain; name="grub2_caseless_uuid.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="grub2_caseless_uuid.patch" Index: commands/search.c =================================================================== --- commands/search.c (revision 1952) +++ commands/search.c (working copy) @@ -115,7 +115,7 @@ (fs->uuid) (dev, &uuid); if (grub_errno == GRUB_ERR_NONE && uuid) { - if (grub_strcmp (uuid, key) == 0) + if (grub_strcasecmp (uuid, key) == 0) { /* Found! */ count++; --------------060408080907040502080206--