From f0bf7096dab7882ec653dbcca579e6081871d09c Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 9 Aug 2019 21:05:54 +0200 Subject: [PATCH] makeh:: accept #if inside #if HDR --- makeh.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/makeh.cpp b/makeh.cpp index 34714666..9ab5ad3e 100644 --- a/makeh.cpp +++ b/makeh.cpp @@ -26,7 +26,7 @@ void mark_file() { cout << ind() << "#endif\n", ifs_level--; } -bool in_hdr; +int in_hdr; void gen(string s) { which_file = s; @@ -35,10 +35,12 @@ void gen(string s) { while(s != "" && s[0] == ' ') s = s.substr(1); while(s.back() == 10 || s.back() == 13) s = s.substr(0, s.size() - 1); if(in_hdr) { - if(s == "#endif" && in_hdr) { - in_hdr = false; - } - else cout << ind() << s << "\n"; + if(s == "#endif") + in_hdr--; + if(s.substr(0, 3) == "#if") + in_hdr++; + if(in_hdr) + cout << ind() << s << "\n"; continue; } if(s == "#if HDR") {