[sword-svn] r3748 - in trunk: include src/mgr

scribe at crosswire.org scribe at crosswire.org
Thu Jul 2 13:20:40 EDT 2020


Author: scribe
Date: 2020-07-02 13:20:40 -0400 (Thu, 02 Jul 2020)
New Revision: 3748

Modified:
   trunk/include/swconfig.h
   trunk/src/mgr/swconfig.cpp
Log:
Corrected SWConfig::augment parameter 'from' to const


Modified: trunk/include/swconfig.h
===================================================================
--- trunk/include/swconfig.h	2020-05-18 16:18:49 UTC (rev 3747)
+++ trunk/include/swconfig.h	2020-07-02 17:20:40 UTC (rev 3748)
@@ -67,7 +67,7 @@
 	/** Merges into this config the values from addFrom
 	 * @param addFrom The config which values should be merged to this config object. Already existing values will be overwritten.
 	 */
-	virtual void augment(SWConfig &addFrom);
+	virtual void augment(const SWConfig &addFrom);
 
 	/** Get a specified section from config, creating the section if needed
 	 * There is no const version of this method because it returns a ConfigEntMap reference, creating the requested section if it doesn't exist.
@@ -92,7 +92,7 @@
 
 	/** shorthand operator for augment
 	 */
-	SWConfig &operator +=(SWConfig &addFrom) { augment(addFrom); return *this; }
+	SWConfig &operator +=(const SWConfig &addFrom) { augment(addFrom); return *this; }
 
 	/** get a value from a [section] key=value
 	 * @param section  the section name containing the key

Modified: trunk/src/mgr/swconfig.cpp
===================================================================
--- trunk/src/mgr/swconfig.cpp	2020-05-18 16:18:49 UTC (rev 3747)
+++ trunk/src/mgr/swconfig.cpp	2020-07-02 17:20:40 UTC (rev 3748)
@@ -145,18 +145,22 @@
 }
 
 
-void SWConfig::augment(SWConfig &addFrom) {
+void SWConfig::augment(const SWConfig &addFrom) {
 
-	SectionMap::iterator section;
-	ConfigEntMap::iterator entry, start, end;
+	SectionMap::const_iterator section;
+	ConfigEntMap::const_iterator entry, start, end;
 
 	for (section = addFrom.getSections().begin(); section != addFrom.getSections().end(); ++section) {
 		for (entry = (*section).second.begin(); entry != (*section).second.end(); ++entry) {
 			start = getSections()[section->first].lower_bound(entry->first);
 			end   = getSections()[section->first].upper_bound(entry->first);
+			// do we have multiple instances of the same key?
 			if (start != end) {
-				if (((++start) != end)
-						|| ((++(addFrom.getSections()[section->first].lower_bound(entry->first))) != addFrom.getSections()[section->first].upper_bound(entry->first))) {
+				// TODO: what is this?
+				ConfigEntMap::const_iterator x = addFrom.getSections().find(section->first)->second.lower_bound(entry->first);
+				ConfigEntMap::const_iterator y = addFrom.getSections().find(section->first)->second.upper_bound(entry->first);
+				++x;
+				if (((++start) != end) || (x != y)) {
 					for (--start; start != end; ++start) {
 						if (!strcmp(start->second.c_str(), entry->second.c_str()))
 							break;



More information about the sword-cvs mailing list