mirror of
https://github.com/omar-polo/gmid.git
synced 2024-09-28 05:21:48 +02:00
add ends_with
This commit is contained in:
parent
d1ca3911d2
commit
f77a8c867e
18
gmid.c
18
gmid.c
@ -162,6 +162,24 @@ starts_with(const char *str, const char *prefix)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
ends_with(const char *str, const char *sufx)
|
||||
{
|
||||
size_t i, j;
|
||||
|
||||
i = strlen(str);
|
||||
j = strlen(sufx);
|
||||
|
||||
if (j > i)
|
||||
return 0;
|
||||
|
||||
i -= j;
|
||||
for (j = 0; str[i] != '\0'; i++, j++)
|
||||
if (str[i] != sufx[j])
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
filesize(int fd)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user