summaryrefslogtreecommitdiff
path: root/command_line/CmdLine/Src/OSLib/StringExtras.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--command_line/CmdLine/Src/OSLib/StringExtras.c32
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;
}