Currently, key=value,key=value1 is disallowed but this is a valid
usage of listings parameters. (e.g. emph={key1},emph={key2} ) The
attached patch fixes this. OK to apply? Jose?

Bo
Index: src/insets/InsetListingsParams.cpp
===================================================================
--- src/insets/InsetListingsParams.cpp	(revision 18599)
+++ src/insets/InsetListingsParams.cpp	(working copy)
@@ -35,6 +35,7 @@
 
 using support::bformat;
 using support::trim;
+using support::rtrim;
 using support::subst;
 using support::isStrInt;
 using support::prefixIs;
@@ -679,10 +680,11 @@
 		it != params_.end(); ++it) {
 		if (!par.empty())
 			par += sep;
+		// key=value,key=value1 is stored in params_ as key=value,key_=value1. 
 		if (it->second.empty())
-			par += it->first;
+			par += rtrim(it->first, "_");
 		else
-			par += it->first + '=' + it->second;
+			par += rtrim(it->first, "_") + '=' + it->second;
 	}
 	return par;
 }
@@ -698,16 +700,18 @@
 	// exception may be thown.
 	ListingsParam const & lparam = par_validator.validate(key, value);
 	// duplicate parameters!
+	string keyname = key;
 	if (params_.find(key) != params_.end())
-		throw invalidParam(bformat(_("Parameter %1$s has already been defined"),
-					  from_utf8(key)));
+		// key=value,key=value1 is allowed in listings
+		// use key_, key__, key___ etc to avoid name conflict
+		while (params_.find(keyname += '_') != params_.end());
 	// check onoff flag
 	// onoff parameter with value false
 	if (lparam.onoff_ && (value == "false" || value == "{false}"))
-		params_[key] = string();
+		params_[keyname] = string();
 	// if the parameter is surrounded with {}, good
 	else if (prefixIs(value, "{") && suffixIs(value, "}"))
-		params_[key] = value;
+		params_[keyname] = value;
 	// otherwise, check if {} is needed. Add {} to all values with
 	// non-ascii/number characters, just to be safe
 	else {
@@ -718,9 +722,9 @@
 				break;
 			}
 		if (has_special_char)
-			params_[key] = "{" + value + "}";
+			params_[keyname] = "{" + value + "}";
 		else
-			params_[key] = value;
+			params_[keyname] = value;
 	}
 }
 

Reply via email to