]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/getopt-long.cc
Imported Upstream version 2.14.2
[lilypond.git] / flower / getopt-long.cc
index 8829c27ee9d069c6c83691e992dbc2a1210438fa..51e11d896c3908ba0056ce71894e0f1942095f65 100644 (file)
@@ -1,7 +1,20 @@
 /*
-  process command line, GNU style.
+  This file is part of LilyPond, the GNU music typesetter.
 
-  this is Copyleft (c) 1996--2006 Han-Wen Nienhuys, <hanwen@xs4all.nl>
+  Copyright (C) 1996--2011 Han-Wen Nienhuys, <hanwen@xs4all.nl>
+
+  LilyPond is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  LilyPond is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "getopt-long.hh"
@@ -10,9 +23,8 @@
 #include <cassert>
 #include <cstdlib>
 
-using namespace std;
-
 #include "config.hh"
+#include "international.hh"
 
 #if !HAVE_GETTEXT
 inline char *
@@ -86,23 +98,23 @@ Getopt_long::parselong ()
   return found_option_;
 }
 
-Std_string
+string
 Long_option_init::to_string () const
 {
-  Std_string str;
+  string str;
   if (shortname_char_)
     str += "-" + shortname_char_;
   if (shortname_char_ && longname_str0_)
     str += ", ";
   if (longname_str0_)
-    str += Std_string ("`--") + longname_str0_ + "'";
+    str += string ("`--") + longname_str0_ + "'";
   return str;
 }
 
-Std_string
+string
 Long_option_init::str_for_help () const
 {
-  Std_string s;
+  string s;
   if (shortname_char_)
     s = "-" + ::to_string (shortname_char_);
   else
@@ -133,7 +145,7 @@ Getopt_long::report (Errorcod c)
   if (!error_out_)
     return;
 
-  Std_string str = arg_value_char_a_a_[0];
+  string str = arg_value_char_a_a_[0];
   str += ": ";
   switch (c)
     {
@@ -142,14 +154,14 @@ Getopt_long::report (Errorcod c)
                 found_option_->to_string ());
       break;
     case E_NOARGEXPECT:
-      str += _f ("option `%s' doesn't allow an argument",
+      str += _f ("option `%s' does not allow an argument",
                 found_option_->to_string ());
       break;
     case E_UNKNOWNOPTION:
       str += _f ("unrecognized option: `%s'",
-                Std_string (argument_index_
-                            ? Std_string ("-" + Std_string (1, arg_value_char_a_a_[array_index_][argument_index_]))
-                        : Std_string (arg_value_char_a_a_[array_index_])));
+                string (argument_index_
+                            ? string ("-" + string (1, arg_value_char_a_a_[array_index_][argument_index_]))
+                        : string (arg_value_char_a_a_[array_index_])));
       break;
     case E_ILLEGALARG:
       str += _f ("invalid argument `%s' to option `%s'",
@@ -296,23 +308,23 @@ Getopt_long::get_next_arg ()
 
 const int EXTRA_SPACES = 5;
 
-Std_string
+string
 Long_option_init::table_string (Long_option_init *l)
 {
-  Std_string tabstr = "";
+  string tabstr = "";
 
   int wid = 0;
   for (int i = 0; l[i].shortname_char_ || l[i].longname_str0_; i++)
-    wid = max (wid, int(l[i].str_for_help ().length ()));
+    wid = max (int(wid), int(l[i].str_for_help ().length ()));
 
   for (int i = 0; l[i].shortname_char_ || l[i].longname_str0_; i++)
     {
-      Std_string s = "  " + l[i].str_for_help ();
-      s += Std_string (wid - s.length () + EXTRA_SPACES, ' ');
+      string s = "  " + l[i].str_for_help ();
+      s += string (wid - s.length () + EXTRA_SPACES, ' ');
 
-      Std_string help_text (gettext (l[i].help_str0_));
-      replace_all (help_text, "\n",
-                  "\n" + Std_string (wid + EXTRA_SPACES + 2, ' '));
+      string help_text (gettext (l[i].help_str0_));
+      replace_all (&help_text, "\n",
+                  "\n" + string (wid + EXTRA_SPACES + 2, ' '));
       tabstr += s + help_text + "\n";
     }