summaryrefslogtreecommitdiff
path: root/src/common/compat.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-12-22 02:32:26 +0000
committerNick Mathewson <nickm@torproject.org>2004-12-22 02:32:26 +0000
commit32978afa5481f66c9ff4fb7ededbdecf6800c16c (patch)
tree3bf7fdc0ad64e66a100f0a987c9777a671a41136 /src/common/compat.c
parent64195e380d08b7e293071392ffb16d5691129eda (diff)
downloadtor-32978afa5481f66c9ff4fb7ededbdecf6800c16c.tar.gz
tor-32978afa5481f66c9ff4fb7ededbdecf6800c16c.zip
Workaround for brain-damaged __FILE__ handling on MSVC: keep Nick's name out
of the warning messages. svn:r3199
Diffstat (limited to 'src/common/compat.c')
-rw-r--r--src/common/compat.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index 1c184de4a2..1b00c6395d 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -113,6 +113,29 @@ int tor_vsnprintf(char *str, size_t size, const char *format, va_list args)
return r;
}
+/** 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 warrning messages.
+ */
+const char *
+_tor_fix_source_file(const char *fname)
+{
+ const char *cp1, *cp2;
+ cp1 = strrchr(fname, '/');
+ cp2 = strrchr(fname, '\\');
+ if (cp1 && cp2) {
+ return (cp1<cp2)?(cp2+1):(cp1+1);
+ } else if (cp1) {
+ return cp1+1;
+ } else if (cp2) {
+ return cp2+2;
+ } else {
+ return fname;
+ }
+}
+
#ifndef UNALIGNED_INT_ACCESS_OK
/**
* Read a 16-bit value beginning at <b>cp</b>. Equivalent to