diff options
| author | Simon Rettberg | 2021-07-22 14:36:35 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2021-07-22 14:36:35 +0200 |
| commit | fc21afb08c7b827b3cd4a77618f36a7abdc13494 (patch) | |
| tree | f7909726a1d49cb834bfa9647621b29cb15caea4 /src/core/string.c | |
| parent | Merge branch 'master' into openslx (diff) | |
| parent | [cloud] Retry DHCP aggressively in AWS EC2 (diff) | |
| download | ipxe-fc21afb08c7b827b3cd4a77618f36a7abdc13494.tar.gz ipxe-fc21afb08c7b827b3cd4a77618f36a7abdc13494.tar.xz ipxe-fc21afb08c7b827b3cd4a77618f36a7abdc13494.zip | |
Merge branch 'master' into openslx
Diffstat (limited to 'src/core/string.c')
| -rw-r--r-- | src/core/string.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/core/string.c b/src/core/string.c index 188fe0864..9a1b9b72a 100644 --- a/src/core/string.c +++ b/src/core/string.c @@ -27,6 +27,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include <stdint.h> #include <stdlib.h> #include <string.h> +#include <strings.h> #include <ctype.h> /** @file @@ -205,11 +206,24 @@ int strncmp ( const char *first, const char *second, size_t max ) { * @ret diff Difference */ int strcasecmp ( const char *first, const char *second ) { + + return strncasecmp ( first, second, ~( ( size_t ) 0 ) ); +} + +/** + * Compare case-insensitive strings + * + * @v first First string + * @v second Second string + * @v max Maximum length to compare + * @ret diff Difference + */ +int strncasecmp ( const char *first, const char *second, size_t max ) { const uint8_t *first_bytes = ( ( const uint8_t * ) first ); const uint8_t *second_bytes = ( ( const uint8_t * ) second ); int diff; - for ( ; ; first_bytes++, second_bytes++ ) { + for ( ; max-- ; first_bytes++, second_bytes++ ) { diff = ( toupper ( *first_bytes ) - toupper ( *second_bytes ) ); if ( diff ) @@ -217,6 +231,7 @@ int strcasecmp ( const char *first, const char *second ) { if ( ! *first_bytes ) return 0; } + return 0; } /** |
