From d245ceac3d43f31d20a77084d34a1e06eab4b874 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Tue, 26 Nov 2013 14:08:41 +0100 Subject: [PATCH] zapit: fix debug message filenames Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9d70399578fd5051a27967a2c22a09bfe98ac831 Author: Stefan Seyfried Date: 2013-11-26 (Tue, 26 Nov 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/zapit/include/zapit/debug.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/zapit/include/zapit/debug.h b/src/zapit/include/zapit/debug.h index 606e62aad..6a7ed9e6f 100644 --- a/src/zapit/include/zapit/debug.h +++ b/src/zapit/include/zapit/debug.h @@ -46,11 +46,19 @@ extern int zapit_debug; #if defined __NFILE__ -/* this is ugly. __FILE__ here is always zapit/include/debug.h, if it is called from - * src/neutrino.cpp, src/gui/... simply strip less characters */ -static int __striplen = strstr(__FILE__, "src/zapit") ? (strstr(__FILE__, "src/zapit") - __FILE__ + 4) : 0; +/* this is ugly. + * __FILE__ here is /.../zapit/include/debug.h when building outside the + * source tree, but it is ../../src/zapit/include/zapit/debug.h (relative), + * when building inside the source_tree. + * So we cannot find the real filename here. Hack: when including this file + * from src/neutrino.cpp, src/gui/..., __NFILE__ is defined => strip less characters + * Later on, __FILE__ is the real filename, so if it starts with ../ now, the build + * is from within the source tree => __FILE__ is only basename => strip nothing */ +static int __striplen = (strncmp(__FILE__, "../", 3) == 0) ? 0 : + (strstr(__FILE__, "src/zapit") != NULL) ? (strstr(__FILE__, "src/zapit") - __FILE__ + 4) : 0; #else -static int __striplen = strstr(__FILE__, "src/zapit") ? (strstr(__FILE__, "src/zapit") - __FILE__ + 14) : 0; +static int __striplen = (strncmp(__FILE__, "../", 3) == 0) ? 0 : + (strstr(__FILE__, "src/zapit") != NULL) ? (strstr(__FILE__, "src/zapit") - __FILE__ + 14) : 0; #endif #define __SHORTFILE__ (__FILE__ + __striplen)