diff options
author | Ash Wolf <ninji@wuffs.org> | 2022-10-12 18:07:57 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2022-10-12 18:07:57 +0100 |
commit | 945f73751630db0420522b5d6af0629d90376a45 (patch) | |
tree | 4b374c13d61dd0f54abefa49c6c348d6a56c6a52 /command_line/CmdLine/Src/OSLib/StringExtras.c | |
parent | f080c0e765878ae91949d91a0bc10b87e6c8269b (diff) | |
download | MWCC-945f73751630db0420522b5d6af0629d90376a45.tar.gz MWCC-945f73751630db0420522b5d6af0629d90376a45.zip |
almost finished OSLib
Diffstat (limited to '')
-rw-r--r-- | command_line/CmdLine/Src/OSLib/StringExtras.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/command_line/CmdLine/Src/OSLib/StringExtras.c b/command_line/CmdLine/Src/OSLib/StringExtras.c index 04ef6b4..a4415ee 100644 --- a/command_line/CmdLine/Src/OSLib/StringExtras.c +++ b/command_line/CmdLine/Src/OSLib/StringExtras.c @@ -1,17 +1,49 @@ #include "oslib.h" char *strcatn(char *d, const char *s, SInt32 max) { + char *p; + p = d + strlen(d); + while (*s && (p - d) + 1 < max) + *(p++) = *(s++); + + *p = 0; + return d; } char *strcpyn(char *d, const char *s, SInt32 len, SInt32 max) { + char *p; + + p = d; + while (len-- && *s && (p - d) + 1 < max) + *(p++) = *(s++); + *p = 0; + return d; } int ustrcmp(const char *src, const char *dst) { + int x; + do { + x = tolower(*src) - tolower(*(dst++)); + if (x) + return x; + } while (*(src++)); + + return 0; } int ustrncmp(const char *src, const char *dst, UInt32 len) { + int x; + + while (len--) { + x = tolower(*src) - tolower(*(dst++)); + if (x) + return x; + if (!*(src++)) + return 0; + } + return 0; } |