summaryrefslogtreecommitdiff
path: root/nasmlib.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-06-01 21:34:49 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-06-01 21:34:49 -0700
commit6ecc159a54c643a46c5682fd9245601c252924f5 (patch)
tree19ee83dab5cca46eb0840a6d1fcf92f7eaa907ac /nasmlib.c
parent8cad14bbcf0b8c056e6f81dccf4af38537e0bac6 (diff)
downloadnasm-6ecc159a54c643a46c5682fd9245601c252924f5.tar.gz
qstring: backquoted strings seem to work now...
Hopefully backquoted strings should work correctly now.
Diffstat (limited to 'nasmlib.c')
-rw-r--r--nasmlib.c63
1 files changed, 45 insertions, 18 deletions
diff --git a/nasmlib.c b/nasmlib.c
index d74b8acf..a4e7915e 100644
--- a/nasmlib.c
+++ b/nasmlib.c
@@ -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)
{