From 6fc2d532274ead9c903c6d94b1a513b8d9b6f677 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 22 Jun 2018 11:51:58 -0400 Subject: Remove util_bug dependency on compat.h --- src/common/util_bug.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/common/util_bug.c') diff --git a/src/common/util_bug.c b/src/common/util_bug.c index 0e6190caf1..c68519b746 100644 --- a/src/common/util_bug.c +++ b/src/common/util_bug.c @@ -15,6 +15,7 @@ #include "lib/container/smartlist.h" #endif #include "lib/malloc/util_malloc.h" +#include "lib/string/printf.h" #ifdef __COVERITY__ int bug_macro_deadcode_dummy__ = 0; @@ -40,7 +41,7 @@ tor_end_capture_bugs_(void) return; SMARTLIST_FOREACH(bug_messages, char *, cp, tor_free(cp)); smartlist_free(bug_messages); - bug_messages = NULL; +nn bug_messages = NULL; } const smartlist_t * tor_get_captured_bug_log_(void) @@ -119,3 +120,29 @@ tor_bug_occurred_(const char *fname, unsigned int line, } #endif } + +#ifdef _WIN32 +/** Take a filename and return a pointer to its final element. This + * function is called on __FILE__ to fix a MSVC nit where __FILE__ + * contains the full path to the file. This is bad, because it + * confuses users to find the home directory of the person who + * compiled the binary in their warning messages. + */ +const char * +tor_fix_source_file(const char *fname) +{ + const char *cp1, *cp2, *r; + cp1 = strrchr(fname, '/'); + cp2 = strrchr(fname, '\\'); + if (cp1 && cp2) { + r = (cp1