]> git.donarmstrong.com Git - lilypond.git/commitdiff
* flower/file-path.cc:
authorJan Nieuwenhuizen <janneke@gnu.org>
Sun, 22 Jan 2006 21:54:58 +0000 (21:54 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sun, 22 Jan 2006 21:54:58 +0000 (21:54 +0000)
* flower/include/file-path.hh: Use std::string [interface].
Update callers.

* flower/std-string.cc:
* flower/include/std-string.hh: New file.

ChangeLog
flower/file-path.cc
flower/include/file-path.hh
flower/include/std-string.hh
lily/includable-lexer.cc
lily/lily-parser-scheme.cc
lily/relocate.cc
lily/score-engraver.cc

index b6ca2e623ff641a4c3f7912e241389206185f088..05d3dacfbea29ef3dad0f73e154758f3d7dc1d9c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2006-01-22  Jan Nieuwenhuizen  <janneke@gnu.org>
 
+       * flower/file-path.cc: 
+       * flower/include/file-path.hh: Use std::string [interface].
+       Update callers.
+
        * flower/direction.cc: 
        * flower/axis.cc: Unused.  Remove.
 
@@ -9,7 +13,7 @@
        * flower/include/std-string.hh: New file.
 
        * flower/file-name.cc[STD_STRING]:
-       * flower/include/file-name.hh[STD_STRING]: Use it.
+       * flower/include/file-name.hh[STD_STRING]: Use it.  Update callers.
 
 2006-01-22  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
index d6e0e0440300bf2f3bbe7c368597a70c437aed7a..e1c387a5ae0152ad6d40ef88c0b6b30861016bfe 100644 (file)
@@ -29,32 +29,32 @@ using namespace std;
 #define PATHSEP ':'
 #endif
 
-Array<String>
+Array<Std_string>
 File_path::directories () const
 {
   return dirs_;
 }
 
 void
-File_path::parse_path (String p)
+File_path::parse_path (Std_string p)
 {
   int len;
   while ((len = p.length ()))
     {
-      int i = p.index (PATHSEP);
+      int i = p.find (PATHSEP);
       if (i < 0)
        i = len;
-      append (p.left_string (i));
-      p = p.right_string (len - i - 1);
+      append (String (p, 0, i));
+      p = String (p, i + 1);
     }
 }
 
 bool
-is_file (String file_name)
+is_file (Std_string file_name)
 {
 #if 0 /* Check if directory. TODO: encapsulate for autoconf */
   struct stat sbuf;
-  if (stat (file_name.to_str0 (), &sbuf) != 0)
+  if (stat (file_name.c_str (), &sbuf) != 0)
     return false;
 
   if (! (sbuf.st_mode & __S_IFREG))
@@ -63,13 +63,13 @@ is_file (String file_name)
 
 #if !STAT_MACROS_BROKEN
   struct stat sbuf;
-  if (stat (file_name.to_str0 (), &sbuf) != 0)
+  if (stat (file_name.c_str (), &sbuf) != 0)
     return false;
 
   return !S_ISDIR (sbuf.st_mode);
 #endif
 
-  if (FILE *f = fopen (file_name.to_str0 (), "r"))
+  if (FILE *f = fopen (file_name.c_str (), "r"))
     {
       fclose (f);
       return true;
@@ -79,17 +79,17 @@ is_file (String file_name)
 }
 
 bool
-is_dir (String file_name)
+is_dir (Std_string file_name)
 {
 #if !STAT_MACROS_BROKEN
   struct stat sbuf;
-  if (stat (file_name.to_str0 (), &sbuf) != 0)
+  if (stat (file_name.c_str (), &sbuf) != 0)
     return false;
 
   return S_ISDIR (sbuf.st_mode);
 #endif
 
-  if (FILE *f = fopen (file_name.to_str0 (), "r"))
+  if (FILE *f = fopen (file_name.c_str (), "r"))
     {
       fclose (f);
       return true;
@@ -106,14 +106,14 @@ directory, in this order.
 @return
 The file name if found, or empty string if not found. */
 
-String
-File_path::find (String name) const
+Std_string
+File_path::find (Std_string name) const
 {
   if (!name.length () || (name == "-"))
     return name;
 
 #ifdef __MINGW32__
-  if (name.index ('\\') >= 0)
+  if (name.find ('\\') >= 0)
     programming_error ("file name not normalized: " + name);
 #endif /* __MINGW32__ */
 
@@ -146,22 +146,22 @@ File_path::find (String name) const
 
   where EXT is from EXTENSIONS.
 */
-String
-File_path::find (String name, char const *extensions[])
+Std_string
+File_path::find (Std_string name, char const *extensions[])
 {
-  if (name.is_empty () || name == "-")
+  if (name.empty () || name == "-")
     return name;
   
   File_name file_name (name);
-  String orig_ext = file_name.ext_;
+  Std_string orig_ext = file_name.ext_;
   for (int i = 0; extensions[i]; i++)
     {
       file_name.ext_ = orig_ext;
       if (*extensions[i] && !file_name.ext_.empty ())
        file_name.ext_ += ".";
       file_name.ext_ += extensions[i];
-      String found = find (file_name.to_string ());
-      if (!found.is_empty ())
+      Std_string found = find (file_name.to_string ());
+      if (!found.empty ())
        return found;
     }
   
@@ -170,7 +170,7 @@ File_path::find (String name, char const *extensions[])
 
 /** Append a directory, return false if failed.  */
 bool
-File_path::try_append (String s)
+File_path::try_append (Std_string s)
 {
   if (s == "")
     s = ".";
@@ -182,10 +182,10 @@ File_path::try_append (String s)
   return false;
 }
 
-String
+Std_string
 File_path::to_string () const
 {
-  String s;
+  Std_string s;
   for (int i = 0; i < dirs_.size (); i++)
     {
       s = s + dirs_[i];
@@ -196,13 +196,13 @@ File_path::to_string () const
 }
 
 void
-File_path::append (String str)
+File_path::append (Std_string str)
 {
   dirs_.push (str);
 }
 
 void
-File_path::prepend (String str)
+File_path::prepend (Std_string str)
 {
   dirs_.insert (str, 0);
 }
index e63c5eb7fddb9bd3dfaed517d8c7af583ff55d1e..23997002328422f5cdebca12ed1efc65fdfdc397 100644 (file)
@@ -10,7 +10,7 @@
 #define FILE_PATH_HH
 
 #include "array.hh"
-#include "string.hh"
+#include "std-string.hh"
 
 /**
    search in directories for a file.
 
 class File_path
 {
-  Array<String> dirs_;
+  Array<Std_string> dirs_;
 public:
-  Array<String> directories () const;
-  String find (String name) const;
-  String find (String name, char const *extensions[]);
-  String to_string () const;
-  bool try_append (String str);
-  void append (String str);
-  void parse_path (String);
-  void prepend (String str);
+  Array<Std_string> directories () const;
+  Std_string find (Std_string name) const;
+  Std_string find (Std_string name, char const *extensions[]);
+  Std_string to_string () const;
+  bool try_append (Std_string str);
+  void append (Std_string str);
+  void parse_path (Std_string);
+  void prepend (Std_string str);
 };
 
-bool is_file (String file_name);
-bool is_dir (String file_name);
+bool is_file (Std_string file_name);
+bool is_dir (Std_string file_name);
 
 #endif /* FILE_PATH */
index d2b2ffd1a3322b312a67630537f2c85603b6128d..129cf4dfc7747eb1b7d445619a92858bcabd74f0 100644 (file)
@@ -18,7 +18,7 @@
 #else
 
 #include <string>
-#warning Using std::string
+// #warning Using std::string
 
 namespace std {
 
index 243938bc02ef6fbd14e1b3c35ad2eb10aeb389c3..a8edb0f16d63f8df67b5911b0c7b502ce49c1625 100644 (file)
@@ -58,7 +58,7 @@ Includable_lexer::new_input (String name, Sources *sources)
       String msg = _f ("can't find file: `%s'", name);
       msg += "\n";
       msg += _f ("(search path: `%s')",
-                sources->path_->to_string ().to_str0 ());
+                sources->path_->to_string ().c_str ());
       LexerError (msg.to_str0 ());
       return;
     }
index 689b694641c428266b795adb61ebd852f3fdec83..f7eac0e9f19f6c02a223de3cbe98dc16a4325432 100644 (file)
@@ -90,19 +90,19 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
 
   String out_file = out_file_name.to_string ();
 
-  if (init.length () && global_path.find (init).is_empty ())
+  if (init.length () && global_path.find (init).empty ())
     {
       warning (_f ("can't find init file: `%s'", init));
       warning (_f ("(search path: `%s')",
-                  global_path.to_string ().to_str0 ()));
+                  global_path.to_string ().c_str ()));
       exit (2);
     }
 
-  if ((file_name != "-") && global_path.find (file_name).is_empty ())
+  if ((file_name != "-") && global_path.find (file_name).empty ())
     {
       warning (_f ("can't find file: `%s'", file_name));
       scm_throw (ly_symbol2scm ("ly-file-failed"),
-                scm_list_1 (scm_makfrom0str (file_name.to_str0 ())));
+                scm_list_1 (scm_makfrom0str (file_name.c_str ())));
     }
   else
     {
index 1c6c422ad1e918eb7c5c5b0e6a73ebd03da9ac25..fec75ee470cc7012ede1e979a78ba6e77b467e88 100644 (file)
@@ -211,7 +211,7 @@ setup_paths (char const *argv0_ptr)
 
          if (be_verbose_global)
            warning (_f ("Relocation: from PATH=%s\nargv0=%s",
-                        path.to_string ().get_str0 (), argv0_ptr));
+                        path.to_string ().c_str (), argv0_ptr));
 
 #ifndef __MINGW32__
          argv0_abs = path.find (argv0_filename.to_string ());
index 37fbced6c257940bdf02911cef3a7cedd6902d43..e45a99676c1b063514d7e281fe3624ec62da5b71 100644 (file)
@@ -66,7 +66,7 @@ Score_engraver::initialize ()
             + "\n"
             + _ ("Music font has not been installed properly.")
             + "\n"
-            + _f ("Search path `%s'", global_path.to_string ().to_str0 ())
+            + _f ("Search path `%s'", global_path.to_string ().c_str ())
             + "\n"
             + _ ("Aborting"));
     }