summaryrefslogtreecommitdiff
path: root/usage.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2016-05-08 16:47:22 +0700
committerJunio C Hamano <gitster@pobox.com>2016-05-09 12:29:08 -0700
commitfd1d672300f36b2b06c2951ec450de0cf8f17797 (patch)
tree41ed0d3c4b16ac0afcd2e00b9e2f7f0f18d87433 /usage.c
parent58e4e5118ae3707b417a19e8dc9224ac25c3f32f (diff)
downloadgit-fd1d672300f36b2b06c2951ec450de0cf8f17797.tar.gz
usage.c: add warning_errno() and error_errno()
Similar to die_errno(), these functions will append strerror() automatically. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'usage.c')
-rw-r--r--usage.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/usage.c b/usage.c
index 8675d72f30..1dad03fb5c 100644
--- a/usage.c
+++ b/usage.c
@@ -148,6 +148,17 @@ void NORETURN die_errno(const char *fmt, ...)
va_end(params);
}
+int error_errno(const char *fmt, ...)
+{
+ char buf[1024];
+ va_list params;
+
+ va_start(params, fmt);
+ error_routine(fmt_with_err(buf, sizeof(buf), fmt), params);
+ va_end(params);
+ return -1;
+}
+
#undef error
int error(const char *err, ...)
{
@@ -159,6 +170,16 @@ int error(const char *err, ...)
return -1;
}
+void warning_errno(const char *warn, ...)
+{
+ char buf[1024];
+ va_list params;
+
+ va_start(params, warn);
+ warn_routine(fmt_with_err(buf, sizeof(buf), warn), params);
+ va_end(params);
+}
+
void warning(const char *warn, ...)
{
va_list params;