From: Daniel Mierswa <impulze@impulze.org>
To: grub-devel@gnu.org
Subject: Re: [PATCH] caseless uuid detection, fixed wrong behaviour for strncasecmp, added strcasecmp
Date: Fri, 23 Jan 2009 10:51:28 +0100 [thread overview]
Message-ID: <49799320.1000300@impulze.org> (raw)
In-Reply-To: <1232559057.17462.2.camel@dv>
[-- Attachment #1: Type: text/plain, Size: 433 bytes --]
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
[-- Attachment #2: ChangeLog --]
[-- Type: text/plain, Size: 435 bytes --]
2009-01-23 Daniel Mierswa <impulze@impulze.org>
* 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 <impulze@impulze.org>
* commands/search.c: caseless UUID comparing
[-- Attachment #3: grub2_strfuncs.patch --]
[-- Type: text/plain, Size: 2150 bytes --]
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);
[-- Attachment #4: grub2_caseless_uuid.patch --]
[-- Type: text/plain, Size: 407 bytes --]
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++;
next prev parent reply other threads:[~2009-01-23 9:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-21 12:08 [PATCH] caseless uuid detection, fixed wrong behaviour for strncasecmp, added strcasecmp Daniel Mierswa
2009-01-21 17:30 ` Pavel Roskin
2009-01-23 9:51 ` Daniel Mierswa [this message]
2009-01-26 4:41 ` Pavel Roskin
2009-01-26 18:28 ` Daniel Mierswa
2009-01-28 1:49 ` Pavel Roskin
2009-01-28 4:02 ` Pavel Roskin
2009-01-28 8:31 ` ebik
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=49799320.1000300@impulze.org \
--to=impulze@impulze.org \
--cc=grub-devel@gnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.