add StrRChr, fix BaseName

This commit is contained in:
Jōshin 2023-12-04 19:23:28 -05:00
parent 3fd424bf0d
commit 5554f32559
No known key found for this signature in database

View file

@ -239,12 +239,11 @@ static int StrCmp(const char *l, const char *r) {
return (l[i] & 255) - (r[i] & 255);
}
static const char *BaseName(const char *s) {
int c;
const char *b = "";
static const char *StrRChr(const char *s, int c) {
const char *b = 0;
if (s) {
while ((c = *s++)) {
if (c == '/') {
for (; *s; ++s) {
if (*s == c) {
b = s;
}
}
@ -252,6 +251,11 @@ static const char *BaseName(const char *s) {
return b;
}
static const char *BaseName(const char *s) {
const char *b = StrRChr(s, '/');
return b ? b + 1 : s;
}
static void Bzero(void *a, unsigned long n) {
long z;
char *p, *e;