diff options
author | Werner Koch <[email protected]> | 2002-09-10 08:27:38 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2002-09-10 08:27:38 +0000 |
commit | 075f8622776ff04e726e9eb5cef19eb86a92bde1 (patch) | |
tree | bfde95c8b7d8e8589cabc484b2cc01553f7f4b55 /util/strgutil.c | |
parent | * gpgkeys_ldap.c (get_key): Some compilers (RISC OS, HPUX c89) don't like (diff) | |
download | gnupg-075f8622776ff04e726e9eb5cef19eb86a92bde1.tar.gz gnupg-075f8622776ff04e726e9eb5cef19eb86a92bde1.zip |
* w32reg.c (read_w32_registry_string): Handle REG_EXPAND_SZ.
Suggested by Ryan Malayter.
* strgutil.c (ascii_strcasecmp): Replaced by code from gnulib.
(ascii_strncasecmp): New.
Diffstat (limited to 'util/strgutil.c')
-rw-r--r-- | util/strgutil.c | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/util/strgutil.c b/util/strgutil.c index 858d603e0..e793fc1ce 100644 --- a/util/strgutil.c +++ b/util/strgutil.c @@ -687,18 +687,58 @@ ascii_tolower (int c) int -ascii_strcasecmp( const char *a, const char *b ) +ascii_strcasecmp (const char *a, const char *b) { - if (a == b) - return 0; + const unsigned char *p1 = (const unsigned char *)a; + const unsigned char *p2 = (const unsigned char *)b; + unsigned char c1, c2; - for (; *a && *b; a++, b++) { - if (*a != *b && ascii_toupper(*a) != ascii_toupper(*b)) - break; + if (p1 == p2) + return 0; + + do + { + c1 = ascii_tolower (*p1); + c2 = ascii_tolower (*p2); + + if (c1 == '\0') + break; + + ++p1; + ++p2; } - return *a == *b? 0 : (ascii_toupper (*a) - ascii_toupper (*b)); + while (c1 == c2); + + return c1 - c2; } +int +ascii_strncasecmp (const char *a, const char *b, size_t n) +{ + const unsigned char *p1 = (const unsigned char *)a; + const unsigned char *p2 = (const unsigned char *)b; + unsigned char c1, c2; + + if (p1 == p2 || !n ) + return 0; + + do + { + c1 = ascii_tolower (*p1); + c2 = ascii_tolower (*p2); + + if ( !--n || c1 == '\0') + break; + + ++p1; + ++p2; + } + while (c1 == c2); + + return c1 - c2; +} + + int ascii_memcasecmp( const char *a, const char *b, size_t n ) { @@ -712,6 +752,7 @@ ascii_memcasecmp( const char *a, const char *b, size_t n ) } + /********************************************* ********** missing string functions ********* *********************************************/ |