]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/getopt-long.cc
Run `make grand-replace'.
[lilypond.git] / flower / getopt-long.cc
index 31cab7a22d8a97429a0f5bc5d74e9a96c142fa02..7e1f3353357ccdeff64756ad5ef31d0bfad80d6d 100644 (file)
@@ -1,7 +1,7 @@
 /*
   process command line, GNU style.
 
-  this is Copyleft (c) 1996--2005 Han-Wen Nienhuys, <hanwen@cs.uu.nl>
+  this is Copyleft (c) 1996--2008 Han-Wen Nienhuys, <hanwen@xs4all.nl>
 */
 
 #include "getopt-long.hh"
 #include <cassert>
 #include <cstdlib>
 
-#include <iostream>
-using namespace std;
-
 #include "config.hh"
-#include "string-convert.hh"
+#include "international.hh"
 
 #if !HAVE_GETTEXT
 inline char *
@@ -88,23 +85,23 @@ Getopt_long::parselong ()
   return found_option_;
 }
 
-String
+string
 Long_option_init::to_string () const
 {
-  String str;
+  string str;
   if (shortname_char_)
     str += "-" + shortname_char_;
   if (shortname_char_ && longname_str0_)
     str += ", ";
   if (longname_str0_)
-    str += String ("`--") + longname_str0_ + "'";
+    str += string ("`--") + longname_str0_ + "'";
   return str;
 }
 
-String
+string
 Long_option_init::str_for_help () const
 {
-  String s;
+  string s;
   if (shortname_char_)
     s = "-" + ::to_string (shortname_char_);
   else
@@ -135,7 +132,7 @@ Getopt_long::report (Errorcod c)
   if (!error_out_)
     return;
 
-  String str = arg_value_char_a_a_[0];
+  string str = arg_value_char_a_a_[0];
   str += ": ";
   switch (c)
     {
@@ -144,15 +141,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'",
-                String (argument_index_
-                        ? String ("-" + String_convert::form_string ("%c",
-                                                                     arg_value_char_a_a_[array_index_][argument_index_]))
-                        : 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'",
@@ -161,7 +157,7 @@ Getopt_long::report (Errorcod c)
     default:
       assert (false);
     }
-  fprintf (error_out_, "%s\n", str.to_str0 ());
+  fprintf (error_out_, "%s\n", str.c_str ());
   exit (2);
 }
 
@@ -299,22 +295,23 @@ Getopt_long::get_next_arg ()
 
 const int EXTRA_SPACES = 5;
 
-String
+string
 Long_option_init::table_string (Long_option_init *l)
 {
-  String tabstr = "";
+  string tabstr = "";
 
   int wid = 0;
   for (int i = 0; l[i].shortname_char_ || l[i].longname_str0_; i++)
-    wid = max (wid, 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++)
     {
-      String s = "  " + l[i].str_for_help ();
-      s += String_convert::char_string (' ', wid - s.length () + EXTRA_SPACES);
+      string s = "  " + l[i].str_for_help ();
+      s += string (wid - s.length () + EXTRA_SPACES, ' ');
 
-      String help_text (gettext (l[i].help_str0_));
-      help_text.substitute ("\n", "\n" + String_convert::char_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";
     }