diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-06-22 11:51:58 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-06-22 11:51:58 -0400 |
commit | 6fc2d532274ead9c903c6d94b1a513b8d9b6f677 (patch) | |
tree | 1322e7fe3f1dca69e41127bb2a46d6dca54479d0 /src/common/util_bug.c | |
parent | 7a93ce8f6382a2fe8687e7e42dc398e08480c901 (diff) | |
download | tor-6fc2d532274ead9c903c6d94b1a513b8d9b6f677.tar.gz tor-6fc2d532274ead9c903c6d94b1a513b8d9b6f677.zip |
Remove util_bug dependency on compat.h
Diffstat (limited to 'src/common/util_bug.c')
-rw-r--r-- | src/common/util_bug.c | 29 |
1 files changed, 28 insertions, 1 deletions
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<cp2)?(cp2+1):(cp1+1); + } else if (cp1) { + r = cp1+1; + } else if (cp2) { + r = cp2+1; + } else { + r = fname; + } + return r; +} +#endif /* defined(_WIN32) */ |