On 5/25/07, Bo Peng <[EMAIL PROTECTED]> wrote:
On 5/25/07, Ozgur Ugras BARAN <[EMAIL PROTECTED]> wrote:
> Attached patch sorts listings inset params, and hence solves bug 3639.
> Please somebody review and apply the patch.

1. table[idx].name is char * so != "" is better because no conversion
would be needed.

I changed it for the other places of usage.

2. you used both std::string and string

stupid me.. changed

3. why do you use string n(*pariter) if *pariter is already a string?

done

4. for(par  ==> for (par

done

5. I would appreciate it you can also implement
  ?xx ==> all parameters that contains xx. That is to say, ?placement
would show floatplacement. style would show all style related
parameters. You can also consider xx ==> all parameters that
prefixIs(xx), and other parameters that contains(xx).


Do you want a full regex implementation or just this? If just this, it
will be easy to implement and I'll do it tonight.

>  I could also sort the listings_param_table[] entries manually, but I find
> this way easier (and more guaranteed).

The order of listings_params_table follows the listings manual. For
maitainence convenience, it is better kept in that order.

Cheers,
Bo


Regards,

Ugras
Index: insets/InsetListingsParams.cpp
===================================================================
--- insets/InsetListingsParams.cpp	(revision 18515)
+++ insets/InsetListingsParams.cpp	(working copy)
@@ -283,23 +283,30 @@
 parValidator::parValidator(string const & n)
 	: name(n), info(0)
 {
+	std::list<string> parlist;
+	std::list<string>::iterator pariter;
+	size_t idx = 0;
+	while (listings_param_table[idx].name != "") {
+		parlist.push_back(listings_param_table[idx].name);
+		++idx;
+	}
+	parlist.sort();
+
 	if (name.empty())
 		throw invalidParam(_("Invalid (empty) listings param name."));
 	else if (name == "?") {
 		string pars;
-		size_t idx = 0;
-		while (listings_param_table[idx].name != string()) {
+		for(pariter = parlist.begin(); pariter != parlist.end(); pariter++) {
 			if (!pars.empty())
 				pars += ", ";
-			pars += listings_param_table[idx].name;
-			++idx;
+			pars += (*pariter);
 		}
 		throw invalidParam(bformat(
 			_("Available listings parameters are %1$s"), from_utf8(pars)));
 	}
 	// locate name in parameter table
-	size_t idx = 0;
-	while (listings_param_table[idx].name != name && listings_param_table[idx].name != string())
+	idx = 0;
+	while (listings_param_table[idx].name != name && listings_param_table[idx].name != "")
 		++idx;
 	// found the name
 	if (listings_param_table[idx].name != "") {
@@ -308,13 +315,12 @@
 	}
 	// otherwise, produce a meaningful error message.
 	string matching_names;
-	for (size_t i = 0; i < idx; ++i) {
-		string n(listings_param_table[i].name);
+	for (pariter = parlist.begin(); pariter != parlist.end(); pariter++) {
 		if (prefixIs(n, name)) {
 			if (matching_names.empty())
-				matching_names += n;
+				matching_names += (*pariter);
 			else
-				matching_names += ", " + n;
+				matching_names += ", " + (*pariter);
 		}
 	}
 	if (matching_names.empty())

Reply via email to