fix: Handle test case with PINELOG_STRIP_FILE_PATH

pull/66/head
nirenjan 2026-04-03 23:47:46 -07:00
parent de465fbf6a
commit c0c8787331
1 changed files with 14 additions and 13 deletions

View File

@ -103,22 +103,23 @@ static int test_setup(int module, int level, int filter, const char *file, int l
}
if (PINELOG_SHOW_BACKTRACE) {
char * basename = NULL;
#if defined __has_builtin
#if __has_builtin(__builtin_strrchr)
basename = strrchr(file, '/');
#endif
#endif
if (basename != NULL) {
basename++;
} else {
// Override the const
basename = (char *)file;
/* Match pinelog.h PINELOG_FILE (basename only when strip + __builtin_strrchr). */
const char *display_file = file;
#if PINELOG_STRIP_FILE_PATH
# if defined __has_builtin
# if __has_builtin(__builtin_strrchr)
{
const char *slash = strrchr(file, '/');
if (slash != NULL) {
display_file = slash + 1;
}
}
# endif
# endif
#endif
expected_len += snprintf(&expected_output[expected_len],
sizeof(expected_output) - expected_len,
"%s:%d ", basename, line);
"%s:%d ", display_file, line);
}
if (module >= 0) {