From 23ff00baa73cb7fe1de647366018733175fc89cc Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock <ksherlock@gmail.com> Date: Sun, 14 Jul 2013 15:17:59 -0400 Subject: [PATCH] trap file loading improvements --- bin/loadtrap.rl | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/bin/loadtrap.rl b/bin/loadtrap.rl index 7bc6c22..e8c5a09 100644 --- a/bin/loadtrap.rl +++ b/bin/loadtrap.rl @@ -19,16 +19,24 @@ action emplace { auto iter = map.find(name); - if (iter != map.end() && iter->second != trap) + + if (iter == map.end()) { - fprintf(stderr, "Warning: redefining %s ($%04x -> $%04x)\n", - name.c_str(), - iter->second, - trap + map[std::move(name)] = trap; + } + else + { + if (iter->second != trap) + { + fprintf(stderr, "Warning: redefining %s ($%04x -> $%04x)\n", + name.c_str(), + iter->second, + trap ); + iter->second = trap; + } } - map[std::move(name)] = trap; } ws = [ \t]; @@ -112,7 +120,7 @@ std::unordered_map<std::string, uint32_t> LoadTrapFile(const std::string &path) const char *p = buffer.c_str(); const char *pe = p + buffer.length(); - const char *eof = pe; + //const char *eof = pe; const char *ts; const char *te;