From 94eb8559035a47162da90ff9443f67852f990cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Fri, 21 Aug 2015 07:42:03 +0200 Subject: [PATCH] VM: make the debug output a little prettier --- vm/debug.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/vm/debug.hpp b/vm/debug.hpp index 3a52431e00..a422eab84d 100644 --- a/vm/debug.hpp +++ b/vm/debug.hpp @@ -2,15 +2,20 @@ namespace factor { extern bool factor_print_p; -} - #ifdef FACTOR_DEBUG +/* To chop the directory path of the __FILE__ macro. */ +inline const char* abbrev_path(const char* path) { + const char* p1 = strrchr(path, '\\'); + const char* p2 = strrchr(path, '/'); + return (p1 > p2 ? p1 : p2) + 1; +} + #define FACTOR_PRINT(x) \ do { \ if (factor_print_p) { \ std::cerr \ - << std::setw(28) << std::left << __FILE__ \ + << std::setw(16) << std::left << abbrev_path(__FILE__) \ << " " << std::setw(4) << std::right << __LINE__ \ << " " << std::setw(20) << std::left << __FUNCTION__ \ << " " << x \ @@ -23,3 +28,5 @@ extern bool factor_print_p; #define FACTOR_PRINT(fmt, ...) ((void)0) #define FACTOR_PRINT_MARK ((void)0) #endif + +}