diff options
author | harti <harti@FreeBSD.org> | 2005-03-08 07:47:14 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2005-03-08 07:47:14 +0000 |
commit | 9719ee7af7c8b60de76c62724d80f8113c15d152 (patch) | |
tree | 567268fa60e34f72b7bcf97041ab472cdbd8d522 | |
parent | d28f5e232e0b1f88280ceb6c41ee4b552d18ac76 (diff) | |
download | FreeBSD-src-9719ee7af7c8b60de76c62724d80f8113c15d152.zip FreeBSD-src-9719ee7af7c8b60de76c62724d80f8113c15d152.tar.gz |
Add a debugging function that prints a message and appends the
current strerror.
-rw-r--r-- | usr.bin/make/util.c | 18 | ||||
-rw-r--r-- | usr.bin/make/util.h | 6 |
2 files changed, 24 insertions, 0 deletions
diff --git a/usr.bin/make/util.c b/usr.bin/make/util.c index ba11f4b..e0dbfdc 100644 --- a/usr.bin/make/util.c +++ b/usr.bin/make/util.c @@ -86,6 +86,24 @@ Debug(const char *fmt, ...) } /*- + * Print a debugging message given its format and append the current + * errno description. Terminate with a newline. + */ +/* VARARGS */ +void +DebugM(const char *fmt, ...) +{ + va_list ap; + int e = errno; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + fprintf(stderr, ": %s\n", strerror(e)); + va_end(ap); + fflush(stderr); +} + +/*- * Error -- * Print an error message given its format. * diff --git a/usr.bin/make/util.h b/usr.bin/make/util.h index 1d65db0..84fc6b9 100644 --- a/usr.bin/make/util.h +++ b/usr.bin/make/util.h @@ -70,11 +70,17 @@ do { \ Debug args ; \ } \ } while (0) +#define DEBUGM(module, args) do { \ + if (DEBUG(module)) { \ + DebugM args; \ + } \ + } while (0) #define ISDOT(c) ((c)[0] == '.' && (((c)[1] == '\0') || ((c)[1] == '/'))) #define ISDOTDOT(c) ((c)[0] == '.' && ISDOT(&((c)[1]))) void Debug(const char *, ...); +void DebugM(const char *, ...); void Error(const char *, ...); void Fatal(const char *, ...) __dead2; void Punt(const char *, ...) __dead2; |