fixed a bug where too long filenames would not be printed in errors
and the porgam would jsut essentially print spaced forever
This commit is contained in:
+23
-21
@@ -1,15 +1,17 @@
|
||||
#define concat_( a, b) a##b
|
||||
#define label(prefix, lnum) concat_(prefix,lnum)
|
||||
|
||||
#define log_location() \
|
||||
do { \
|
||||
if (Globals::log_level == Log_Level::Debug) { \
|
||||
printf("in"); \
|
||||
for (int i = 0; i < 30-strlen(__FILE__);++i) \
|
||||
printf(" "); \
|
||||
printf("%s (%d) ", __FILE__, __LINE__); \
|
||||
printf("-> %s\n",__FUNCTION__); \
|
||||
} \
|
||||
#define log_location() \
|
||||
do { \
|
||||
if (Globals::log_level == Log_Level::Debug) { \
|
||||
printf("in"); \
|
||||
int spacing = 30-(int)strlen(__FILE__); \
|
||||
if (spacing < 1) spacing = 1; \
|
||||
for (int i = 0; i < spacing;++i) \
|
||||
printf(" "); \
|
||||
printf("%s (%d) ", __FILE__, __LINE__); \
|
||||
printf("-> %s\n",__FUNCTION__); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define if_error_log_location_and_return() \
|
||||
@@ -21,18 +23,18 @@
|
||||
} while(0)
|
||||
|
||||
|
||||
#define try_or_else_return(val) \
|
||||
if (1) \
|
||||
goto label(body,__LINE__); \
|
||||
else \
|
||||
while (1) \
|
||||
if (1) { \
|
||||
if (Globals::error) { \
|
||||
log_location(); \
|
||||
return val; \
|
||||
} \
|
||||
break; \
|
||||
} \
|
||||
#define try_or_else_return(val) \
|
||||
if (1) \
|
||||
goto label(body,__LINE__); \
|
||||
else \
|
||||
while (1) \
|
||||
if (1) { \
|
||||
if (Globals::error) { \
|
||||
log_location(); \
|
||||
return val; \
|
||||
} \
|
||||
break; \
|
||||
} \
|
||||
else label(body,__LINE__):
|
||||
;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user