From e44f985bd4f796d4c4b11eb3555436dbaa2d163b Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 18 Oct 1999 18:03:37 +0000 Subject: Further development; mid-end index handling pretty much there! [originally from svn r238] --- ustring.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'ustring.c') diff --git a/ustring.c b/ustring.c index 42c5683..17ef3bd 100644 --- a/ustring.c +++ b/ustring.c @@ -57,12 +57,31 @@ int ustrcmp(wchar_t *lhs, wchar_t *rhs) { return 0; } +wchar_t utolower(wchar_t c) { + if (c == L'\0') + return c; /* this property needed by ustricmp */ + /* FIXME: this doesn't even come close */ + if (c >= 'A' && c <= 'Z') + c += 'a'-'A'; + return c; +} + +int ustricmp(wchar_t *lhs, wchar_t *rhs) { + wchar_t lc, rc; + while ((lc = utolower(*lhs)) == (rc = utolower(*rhs)) && lc && rc) + lhs++, rhs++; + if (!lc && !rc) + return 0; + if (lc < rc) + return -1; + else + return 1; +} + wchar_t *ustrlow(wchar_t *s) { wchar_t *p = s; while (*p) { - /* FIXME: this doesn't even come close */ - if (*p >= 'A' && *p <= 'Z') - *p += 'a'-'A'; + *p = utolower(*p); p++; } return s; -- cgit v1.1