This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH setup 2/9] Alphabetically sort options in usage help


---
 libgetopt++/src/OptionSet.cc | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libgetopt++/src/OptionSet.cc b/libgetopt++/src/OptionSet.cc
index bc3f018..82e1253 100644
--- a/libgetopt++/src/OptionSet.cc
+++ b/libgetopt++/src/OptionSet.cc
@@ -314,9 +314,16 @@ OptionSet::Register (Option * anOption)
     options.push_back(anOption);
 }
 
+static bool
+comp_long_option(const Option *a, const Option *b)
+{
+  return (a->longOption().compare(b->longOption()) < 0);
+}
+
 void
 OptionSet::ParameterUsage (ostream &aStream)
 {
+    std::sort(options.begin(), options.end(), comp_long_option);
     for_each (options.begin(), options.end(), DefaultFormatter (aStream));
 }
 
-- 
2.12.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]