From e948d787fa01926ae2113a347846fa7c17ed6a14 Mon Sep 17 00:00:00 2001 From: helly Date: Thu, 22 Feb 2007 01:14:09 +0000 Subject: [PATCH] - Disallow multiple changes to code names --- re2c/code.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/re2c/code.cc b/re2c/code.cc index 8bb0402b..9af34cdb 100644 --- a/re2c/code.cc +++ b/re2c/code.cc @@ -1750,15 +1750,27 @@ void Scanner::config(const Str& cfg, const Str& val) } else if (mapCodeKeys.find(cfg.to_string()) != mapCodeKeys.end()) { - mapCodeName[cfg.to_string().c_str() + sizeof("code:") - 1] = strVal; + if ((bSinglePass || !bLastPass) + && !mapCodeName.insert(std::make_pair(cfg.to_string().substr(sizeof("code:") - 1), strVal)).second) + { + fatal("variable already being used and cannot be changed"); + } } else if (mapDefineKeys.find(cfg.to_string()) != mapDefineKeys.end()) { - mapCodeName[cfg.to_string().c_str() + sizeof("define:") - 1] = strVal; + if ((bSinglePass || !bLastPass) + && !mapCodeName.insert(std::make_pair(cfg.to_string().substr(sizeof("define:") - 1), strVal)).second) + { + fatal("define already being used and cannot be changed"); + } } else if (mapLabelKeys.find(cfg.to_string()) != mapLabelKeys.end()) { - mapCodeName[cfg.to_string().c_str() + sizeof("label:") - 1] = strVal; + if ((bSinglePass || !bLastPass) + && !mapCodeName.insert(std::make_pair(cfg.to_string().substr(sizeof("label:") - 1), strVal)).second) + { + fatal("label already being used and cannot be changed"); + } } else { -- 2.40.0