Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions include/boost/wave/util/cpp_include_paths.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,24 @@ class include_paths
boost::filesystem::path current_dir;
boost::filesystem::path current_rel_dir;

bool may_be_includable(const boost::filesystem::path& p) const
{
namespace fs = boost::filesystem;
if (!fs::exists(p) || fs::is_directory(p)) {
return false;
}
if (fs::is_symlink(p)) {
boost::system::error_code ec;
fs::file_status target = fs::status(p, ec);
if (ec || !fs::exists(target) || fs::is_directory(target)) {
return false;
}
return true;
} else {
return true;
}
}

#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
public:
bool has_pragma_once(std::string const &filename)
Expand Down Expand Up @@ -328,7 +346,7 @@ bool include_paths::find_include_file (std::string &s, std::string &dir,
currpath /= create_path(s); // append filename
}

if (fs::exists(currpath)) {
if (may_be_includable(currpath)) {
fs::path dirpath (create_path(s));
if (!dirpath.has_root_directory()) {
dirpath = create_path((*it).second);
Expand Down Expand Up @@ -362,7 +380,7 @@ include_paths::find_include_file (std::string &s, std::string &dir,
currpath /= create_path(s);
}

if (fs::exists(currpath) && 0 == current_file) {
if (0 == current_file && may_be_includable(currpath)) {
// if 0 != current_path (#include_next handling) it can't be
// the file in the current directory
fs::path dirpath(create_path(s));
Expand Down
17 changes: 17 additions & 0 deletions test/testwave/testfiles/t_2_032.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/

Copyright (c) 2026 Rac75116. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/

// Verify include lookup ignores directories named like the header.

//O -I$P(t_2_032_dir)
//O -I$P(t_2_032_inc)

//R #line 10 "t_2_032_target.hpp"
//R t_2_032_target_from_file
#include "t_2_032_target.hpp"
Empty file.
10 changes: 10 additions & 0 deletions test/testwave/testfiles/t_2_032_inc/t_2_032_target.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/

Copyright (c) 2026 Rac75116. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/

t_2_032_target_from_file
1 change: 1 addition & 0 deletions test/testwave/testfiles/test.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ t_2_028.cpp
t_2_029.cpp
t_2_030.cpp
t_2_031.cpp
t_2_032.cpp

#
# t_3: Predefined macros
Expand Down