| 3887 | DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wnull-dereference") |
| 3888 | // depending on the current options this will remove the path of filenames |
| 3889 | const char* skipPathFromFilename(const char* file) { |
| 3890 | #ifndef DOCTEST_CONFIG_DISABLE |
| 3891 | if(getContextOptions()->no_path_in_filenames) { |
| 3892 | auto back = std::strrchr(file, '\\'); |
| 3893 | auto forward = std::strrchr(file, '/'); |
| 3894 | if(back || forward) { |
| 3895 | if(back > forward) |
| 3896 | forward = back; |
| 3897 | return forward + 1; |
| 3898 | } |
| 3899 | } else { |
| 3900 | const auto prefixes = getContextOptions()->strip_file_prefixes; |
| 3901 | const char separator = DOCTEST_CONFIG_OPTIONS_FILE_PREFIX_SEPARATOR; |
| 3902 | String::size_type longest_match = 0U; |
| 3903 | for(String::size_type pos = 0U; pos < prefixes.size(); ++pos) |
| 3904 | { |
| 3905 | const auto prefix_start = pos; |
| 3906 | pos = std::min(prefixes.find(separator, prefix_start), prefixes.size()); |
| 3907 | |
| 3908 | const auto prefix_size = pos - prefix_start; |
| 3909 | if(prefix_size > longest_match) |
| 3910 | { |
| 3911 | // TODO under DOCTEST_MSVC: does the comparison need strnicmp() to work with drive letter capitalization? |
| 3912 | if(0 == std::strncmp(prefixes.c_str() + prefix_start, file, prefix_size)) |
| 3913 | { |
| 3914 | longest_match = prefix_size; |
| 3915 | } |
| 3916 | } |
| 3917 | } |
| 3918 | return &file[longest_match]; |
| 3919 | } |
| 3920 | #endif // DOCTEST_CONFIG_DISABLE |
| 3921 | return file; |
| 3922 | } |
| 3923 | DOCTEST_CLANG_SUPPRESS_WARNING_POP |
| 3924 | DOCTEST_GCC_SUPPRESS_WARNING_POP |
| 3925 |
no test coverage detected