Add has_extension()

The little helper has_extension() documents through its name what we are
trying to do and makes sure we don't forget the underrun check.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Rene Scharfe
2006-08-10 17:02:30 +02:00
committed by Junio C Hamano
parent 242abf106c
commit 83a2b841d6
8 changed files with 14 additions and 8 deletions

View File

@ -139,6 +139,12 @@ static inline ssize_t xwrite(int fd, const void *buf, size_t len)
}
}
static inline int has_extension(const char *filename, int len, const char *ext)
{
int extlen = strlen(ext);
return len > extlen && !memcmp(filename + len - extlen, ext, extlen);
}
/* Sane ctype - no locale, and works with signed chars */
#undef isspace
#undef isdigit