Fix more bugs in dsymtable_c (real semantics of std::multimap::lower_bound is not what was assumed!)
authorMario de Sousa <msousa@fe.up.pt>
Thu, 08 Nov 2012 17:54:48 +0000
changeset 722 b051d19d2442
parent 721 5dc33058e041
child 723 d475ae61c7f8
Fix more bugs in dsymtable_c (real semantics of std::multimap::lower_bound is not what was assumed!)
util/dsymtable.hh
--- a/util/dsymtable.hh	Thu Nov 08 17:31:50 2012 +0000
+++ b/util/dsymtable.hh	Thu Nov 08 17:54:48 2012 +0000
@@ -93,7 +93,7 @@
     int count(const symbol_c *symbol)        {return count(symbol_to_string(symbol));}
     
     /* Search for an entry. Will return end_value() if not found */
-    value_t end_value(void)                          {return _base.end(); return null_value;}
+    value_t end_value(void)                          {return null_value;}
     value_t find_value(const char *identifier_str);
     value_t find_value(const symbol_c *symbol)       {return find_value(symbol_to_string(symbol));}
 
@@ -101,9 +101,8 @@
     iterator find(const char *identifier_str)        {return _base.find(identifier_str);}
     iterator find(const symbol_c *symbol)            {return find(symbol_to_string(symbol));}
     
-    /* Search for the first entry associated with (i.e. with key ==) identifier_str. Will return end() if not found */
-    /* Basically, the same as find() */
-    iterator lower_bound(const char *identifier_str) {return _base.lower_bound(identifier_str);}
+    /* Search for the first entry associated with (i.e. with key ==) identifier_str. Will return end() if not found (NOTE: end() != end_value()) */
+    iterator lower_bound(const char *identifier_str) {return ((count(identifier_str) == 0)? _base.end() : _base.lower_bound(identifier_str));}
     iterator lower_bound(const symbol_c *symbol)     {return lower_bound(symbol_to_string(symbol));}
     
     /* Search for the first entry with key greater than identifier_str. Will return end() if not found */