diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-06-01 21:34:49 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-06-01 21:34:49 -0700 |
commit | 6ecc159a54c643a46c5682fd9245601c252924f5 (patch) | |
tree | 19ee83dab5cca46eb0840a6d1fcf92f7eaa907ac /nasmlib.c | |
parent | 8cad14bbcf0b8c056e6f81dccf4af38537e0bac6 (diff) | |
download | nasm-6ecc159a54c643a46c5682fd9245601c252924f5.tar.gz nasm-6ecc159a54c643a46c5682fd9245601c252924f5.tar.bz2 nasm-6ecc159a54c643a46c5682fd9245601c252924f5.zip |
qstring: backquoted strings seem to work now...
Hopefully backquoted strings should work correctly now.
Diffstat (limited to 'nasmlib.c')
-rw-r--r-- | nasmlib.c | 63 |
1 files changed, 45 insertions, 18 deletions
@@ -149,31 +149,58 @@ char *nasm_strndup(char *s, size_t len) #ifndef nasm_stricmp int nasm_stricmp(const char *s1, const char *s2) { - while (*s1 && tolower(*s1) == tolower(*s2)) - s1++, s2++; - if (!*s1 && !*s2) - return 0; - else if (tolower(*s1) < tolower(*s2)) - return -1; - else - return 1; + unsigned char c1, c2; + int d; + + while (1) { + c1 = *s1++; + c2 = *s2++; + d = c1-c2; + + if (d) + return d; + if (!c1) + break; + } + return 0; } #endif #ifndef nasm_strnicmp -int nasm_strnicmp(const char *s1, const char *s2, int n) -{ - while (n > 0 && *s1 && tolower(*s1) == tolower(*s2)) - s1++, s2++, n--; - if ((!*s1 && !*s2) || n == 0) - return 0; - else if (tolower(*s1) < tolower(*s2)) - return -1; - else - return 1; +int nasm_strnicmp(const char *s1, const char *s2, size_t n) +{ + unsigned char c1, c2; + int d; + + while (n--) { + c1 = *s1++; + c2 = *s2++; + d = c1-c2; + + if (d) + return d; + if (!c1) + break; + } + return 0; } #endif +int nasm_memicmp(const char *s1, const char *s2, size_t n) +{ + unsigned char c1, c2; + int d; + + while (n--) { + c1 = tolower(*s1++); + c2 = tolower(*s2++); + d = c1-c2; + if (d) + return d; + } + return 0; +} + #ifndef nasm_strsep char *nasm_strsep(char **stringp, const char *delim) { |