Error on #ifdef/#ifhave without argument

This commit is contained in:
Gunter Labes 2023-08-16 22:25:31 +02:00 committed by GitHub
parent 8f74a27b90
commit ab5475172e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1323,6 +1323,9 @@ bool preprocessor_data::get_chunk()
const bool negate = command[2] == 'n';
skip_spaces();
const std::string& symbol = read_word();
if(symbol.empty()) {
parent_.error("No macro argument found after #ifdef/#ifndef directive", linenum_);
}
bool found = parent_.defines_->count(symbol) != 0;
DBG_PREPROC << "testing for macro " << symbol << ": " << (found ? "defined" : "not defined");
conditional_skip(negate ? found : !found);
@ -1330,6 +1333,9 @@ bool preprocessor_data::get_chunk()
const bool negate = command[2] == 'n';
skip_spaces();
const std::string& symbol = read_word();
if(symbol.empty()) {
parent_.error("No path argument found after #ifhave/#ifnhave directive", linenum_);
}
bool found = !filesystem::get_wml_location(symbol, directory_).empty();
DBG_PREPROC << "testing for file or directory " << symbol << ": " << (found ? "found" : "not found");
conditional_skip(negate ? found : !found);