summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCpp/Preprocessor.cpp
diff options
context:
space:
mode:
authorItamar <itamar8910@gmail.com>2021-05-21 15:41:38 +0300
committerAndreas Kling <kling@serenityos.org>2021-05-22 15:52:11 +0200
commit0522a4360bc7abd5a8c814db9b02d00a24a98ae6 (patch)
tree605a947f01fe159bfed6817483c311fc7d548e83 /Userland/Libraries/LibCpp/Preprocessor.cpp
parent14e00118251f84b469952d2b885fae9655897ccb (diff)
downloadserenity-0522a4360bc7abd5a8c814db9b02d00a24a98ae6.zip
LibCpp: Add option in Preprocessor to keep #include's in processed text
Diffstat (limited to 'Userland/Libraries/LibCpp/Preprocessor.cpp')
-rw-r--r--Userland/Libraries/LibCpp/Preprocessor.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/Userland/Libraries/LibCpp/Preprocessor.cpp b/Userland/Libraries/LibCpp/Preprocessor.cpp
index c1dac5cae2..6dbb601201 100644
--- a/Userland/Libraries/LibCpp/Preprocessor.cpp
+++ b/Userland/Libraries/LibCpp/Preprocessor.cpp
@@ -22,11 +22,20 @@ const String& Preprocessor::process()
{
for (; m_line_index < m_lines.size(); ++m_line_index) {
auto& line = m_lines[m_line_index];
+
+ bool include_in_processed_text = false;
if (line.starts_with("#")) {
- handle_preprocessor_line(line);
+ auto keyword = handle_preprocessor_line(line);
+ if (m_options.keep_include_statements && keyword == "include")
+ include_in_processed_text = true;
} else if (m_state == State::Normal) {
+ include_in_processed_text = true;
+ }
+
+ if (include_in_processed_text) {
m_builder.append(line);
}
+
m_builder.append("\n");
}