summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9fe7a64)
raw | patch | inline | side by side (parent: 9fe7a64)
author | Alex Riesen <raa.lkml@gmail.com> | |
Sun, 26 Oct 2008 21:59:13 +0000 (22:59 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 27 Oct 2008 05:08:58 +0000 (22:08 -0700) |
This is just vsnprintf's but additionally calls cleanup_path() on the
result. To be used as alternatives to mkpath() where the buffer for the
created path may not be reused by subsequent calls of the same formatting
function.
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
result. To be used as alternatives to mkpath() where the buffer for the
created path may not be reused by subsequent calls of the same formatting
function.
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h | patch | blob | history | |
path.c | patch | blob | history |
index 884fae826cb8c296520aecbc8c23d9848dacb606..aea13b0822d56546f30a02eb366524e6993c55df 100644 (file)
--- a/cache.h
+++ b/cache.h
#define DATA_CHANGED 0x0020
#define TYPE_CHANGED 0x0040
+extern char *mksnpath(char *buf, size_t n, const char *fmt, ...)
+ __attribute__((format (printf, 3, 4)));
+
/* Return a statically allocated filename matching the sha1 signature */
extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
extern char *git_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
index 76e8872622e435b050f77198ef6eef6e6ff6869e..8b64878c2147825a3a7ce483e9e6f05a0570a751 100644 (file)
--- a/path.c
+++ b/path.c
return path;
}
+char *mksnpath(char *buf, size_t n, const char *fmt, ...)
+{
+ va_list args;
+ unsigned len;
+
+ va_start(args, fmt);
+ len = vsnprintf(buf, n, fmt, args);
+ va_end(args);
+ if (len >= n) {
+ snprintf(buf, n, bad_path);
+ return buf;
+ }
+ return cleanup_path(buf);
+}
+
char *mkpath(const char *fmt, ...)
{
va_list args;