Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRene Scharfe <rene.scharfe@lsrfire.ath.cx>2006-08-10 19:02:30 +0400
committerJunio C Hamano <junkio@cox.net>2006-08-11 01:13:53 +0400
commit83a2b841d6b90e6f4b797df40ed3a105364574b6 (patch)
tree06b21e14a70cde595570d2b7948245b26995dbb8 /git-compat-util.h
parent242abf106c6929028c2dc916504879885cd64d4d (diff)
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>
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index 3bcf5b13f2..dd92093652 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -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