mirror of https://git.wuffs.org/MWCC
50 lines
829 B
C
50 lines
829 B
C
#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;
|
|
}
|