includes: add strchra() and strchrnula() impls

Unfortunately GNU-EFI doesn't currently implement ascii versions of
strchr() or strchrnul(), and we kind of need them, so add an
implementation here for now.

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2021-02-09 13:39:48 -05:00 committed by Javier Martinez Canillas
parent 4a4d73f73a
commit 186595864c
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69

View File

@ -64,4 +64,30 @@ translate_slashes(CHAR8 *out, const char *str)
return out;
}
static inline UNUSED CHAR8 *
strchrnula(const CHAR8 *s, int c)
{
unsigned int i;
if (s == NULL)
return NULL;
for (i = 0; s[i] != '\000' && s[i] != c; i++)
;
return (CHAR8 *)&s[i];
}
static inline UNUSED CHAR8 *
strchra(const CHAR8 *s, int c)
{
const CHAR8 *s1;
s1 = strchrnula(s, c);
if (!s1 || s1[0] == '\000')
return NULL;
return (CHAR8 *)s1;
}
#endif /* SHIM_STR_H */