diff options
| author | Simon Tatham <anakin@pobox.com> | 1999-10-18 18:03:37 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 1999-10-18 18:03:37 +0000 |
| commit | e44f985bd4f796d4c4b11eb3555436dbaa2d163b (patch) | |
| tree | 8e037d5b32c5349760277e79ac53993b34035885 /ustring.c | |
| parent | 00f6e0ee13c753d98e8665ad1ff2e992f43ef6e4 (diff) | |
| download | halibut-e44f985bd4f796d4c4b11eb3555436dbaa2d163b.zip halibut-e44f985bd4f796d4c4b11eb3555436dbaa2d163b.tar.gz halibut-e44f985bd4f796d4c4b11eb3555436dbaa2d163b.tar.bz2 halibut-e44f985bd4f796d4c4b11eb3555436dbaa2d163b.tar.xz | |
Further development; mid-end index handling pretty much there!
[originally from svn r238]
Diffstat (limited to 'ustring.c')
| -rw-r--r-- | ustring.c | 25 |
1 files changed, 22 insertions, 3 deletions
@@ -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; |