]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.1.44
authorfred <fred>
Sun, 24 Mar 2002 20:05:38 +0000 (20:05 +0000)
committerfred <fred>
Sun, 24 Mar 2002 20:05:38 +0000 (20:05 +0000)
flower/NEWS
flower/path.cc
flower/test/stringtest.cc

index 1e795d59c381c63103f80f2582bce4eb085d1cd2..06f5939f5908e72848e78cd3a82a86fb1920e675 100644 (file)
@@ -1,3 +1,6 @@
+pl 37
+       - various String/File_path mucking
+
 pl 36
        - memmem fix: bugfree and *really* conforming to /usr/include/string.h
 
index a499d0abf4ee3d6572dffb8dbc145a8bf9d44c03..b9ed1c5320373920fc4e5fa7f23f8dc8e21e3ec5 100644 (file)
@@ -26,7 +26,7 @@ split_path (String path,
   if (di >= 0)
     {
       drive = path.left_str (di + 1);
-      path = path.right_str (path.len() - di -1);
+      path = path.right_str (path.length_i () - di -1);
     }
   else
     drive = "";
@@ -35,7 +35,7 @@ split_path (String path,
   if (di >=0)
     {
       dirs = path.left_str (di + 1);
-      path = path.right_str (path.len()-di -1);
+      path = path.right_str (path.length_i ()-di -1);
     }
   else
     dirs = "";
@@ -44,7 +44,7 @@ split_path (String path,
   if (di >= 0)
     {
       filebase = path.left_str (di);
-      extension =path.right_str (path.len()-di);
+      extension =path.right_str (path.length_i ()-di);
     }
   else
     {
@@ -77,7 +77,6 @@ File_path::parse_path (String p)
   */
 String
 File_path::find (String nm) const
-
 {
   fdebug << _("looking for ") << nm << ": ";
   if (!nm.length_i() || (nm == "-") )
@@ -85,8 +84,10 @@ File_path::find (String nm) const
   for (int i=0; i < size(); i++)
     {
       String path  = elem(i);
-      if (path.length_i() )
-       path += "/";
+      String sep (DIRSEP);
+      String right(path.right_str (1));
+      if (path.length_i () && right != sep)
+       path += DIRSEP;
 
       path += nm;
 
@@ -102,3 +103,9 @@ File_path::find (String nm) const
   fdebug << "\n";
   return "";
 }
+
+void
+File_path::add (String s)
+{
+   push (s); 
+}
index 79ec1e443a7f5a7c9fcb6540858093b50e679ce6..4597ff3b8558c6476976971f920cefe1e9778eda 100644 (file)
@@ -8,18 +8,18 @@
 #include "flower-test.hh"
 
 void
-ctors()
+ctors ()
 {
   cout << "constructors"<<endl;
   {
-    String str( "hai" );
+    String str ("hai");
     cout << str << endl;
   }
   {
-    String fromi(10);
+    String fromi (10);
     cout << fromi<< endl;
   }
-  {String fromf(1.32e-2, "%g");
+  {String fromf (1.32e-2, "%g");
   cout << fromf<< endl;
   }
   {
@@ -27,40 +27,47 @@ ctors()
     cout << def << endl;
   }
   {
-    String fromc('c');
+    String fromc ('c');
     cout << fromc<< endl;       
   }
 }
 void
-cmp()
+cmp ()
 {
+  
+  String path  = "";
+  String sep ('/');
+  String right(path.right_str (1));
+  cout << "cmp ('', '/'): " << String::compare_i (sep,right) << endl;
+  
   Array<String> a;
-  a.push("abcd");
-  a.push("zxy");
-  a.push("abc");
-  a.push("");
-  a.sort(String::compare_i);
+  a.push ("abcd");
+  a.push ("zxy");
+  a.push ("abc");
+  a.push ("");
+  a.push  ("a");
+  a.sort (String::compare_i);
   cout << "compares: "<<endl;
-  for (int i=0; i < a.size(); i++)
+  for  (int i=0; i < a.size (); i++)
     cout << a[i] << endl;
 }
 
 
 void
-searching()
+searching ()
 {
   String hay = "foobarbazblub";
 
   char c =   'b';
   String cstr =c;
   String set = "bar";
-  cout << "hay = \"" << hay << "\" len="<< hay.length_i()<<endl;
-  cout << "index_i('"<< c<<"') " << c << "= " << hay.index_i(c) <<endl;
-  cout << "last_index_i('"<< c<<"') " << c << "= " << hay.index_last_i(c) <<endl;    
-  //    cout << "last index of cstr " << c << ": " << hay.index_last_i(cstr) <<endl;    
-  //    cout << "index_last_i(\""<<set<<"\"): " << hay.index_last_i(set) <<endl;
-  cout << "index_i(\""<<set<<"\"): " << hay.index_i(set) <<endl;    
-  cout << "index_any(\"" << set << "\"): " << cstr << ": " << hay.index_any_i(cstr) <<endl;
+  cout << "hay = \"" << hay << "\" len="<< hay.length_i ()<<endl;
+  cout << "index_i ('"<< c<<"') " << c << "= " << hay.index_i (c) <<endl;
+  cout << "last_index_i ('"<< c<<"') " << c << "= " << hay.index_last_i (c) <<endl;    
+  //    cout << "last index of cstr " << c << ": " << hay.index_last_i (cstr) <<endl;    
+  //    cout << "index_last_i (\""<<set<<"\"): " << hay.index_last_i (set) <<endl;
+  cout << "index_i (\""<<set<<"\"): " << hay.index_i (set) <<endl;    
+  cout << "index_any (\"" << set << "\"): " << cstr << ": " << hay.index_any_i (cstr) <<endl;
 
     
     
@@ -68,25 +75,25 @@ searching()
 
 
 void
-kutenpeer()
+kutenpeer ()
 {
-  String str( "hai" );
-  for (int i=-1; i < str.length_i()+2; i++) {
-    cout<<" left_str(" << i<<"): " << str.left_str( i ) << endl;
-    cout<<" right_str( "<<i<<"): " << str.right_str( i ) << endl;
+  String str ("hai");
+  for  (int i=-1; i < str.length_i ()+2; i++) {
+    cout<<" left_str (" << i<<"): " << str.left_str (i) << endl;
+    cout<<" right_str ("<<i<<"): " << str.right_str (i) << endl;
   }
   str = "blonde haren";
   cout << str<<endl;
-  cout << "mid(2,6)="<<str.cut(2,6)<<endl;
-  cout << "nomid(2,6)="<<str.nomid_str(2,6)<<endl;
+  cout << "mid (2,6)="<<str.cut (2,6)<<endl;
+  cout << "nomid (2,6)="<<str.nomid_str (2,6)<<endl;
 }
 
 bool
-test_empty_b( String str )
+test_empty_b (String str)
 {
   cout << "`" << str << "' is ";
 
-  if ( str == String( "" ) ) {
+  if  (str == String ("")) {
     cout << "empty" << endl;
     return true;
   }
@@ -96,42 +103,42 @@ test_empty_b( String str )
 }
 
 void
-stringtest()
+stringtest ()
 {
-  ctors();
-  cmp();
-  searching();
-  kutenpeer();
-  String str( "hai" );
+  ctors ();
+  cmp ();
+  searching ();
+  kutenpeer ();
+  String str ("hai");
   cout <<  str << endl;
   cout << "left" << endl;
   str += " daar";
   cout << str << endl;
 
-  //    str = String( "Hallo" ) + " daaR" + '!'; // no go on doze-s gcc2.7.2?
-  str = String( "Hallo" ) + " daaR" + "!";
+  //    str = String ("Hallo") + " daaR" + '!'; // no go on doze-s gcc2.7.2?
+  str = String ("Hallo") + " daaR" + "!";
   cout << str << endl;
 
-  cout << "up: " << str.upper_str() << " down: " << str.lower_str()<<endl;
+  cout << "up: " << str.upper_str () << " down: " << str.lower_str ()<<endl;
     
-  if ( test_empty_b( str ) )
+  if  (test_empty_b (str))
     cout << "failed";
 
   String fn = "";
-  if ( !test_empty_b( fn ) )
+  if  (!test_empty_b (fn))
     cout << "failed";
 
     
   fn = "";
   fn += "";
-  delete fn.copy_byte_p();
-  delete str.copy_byte_p();
+  delete fn.copy_byte_p ();
+  delete str.copy_byte_p ();
 
-  cout << String_convert::bin2hex_str( String( (char)0xff ) ) << endl;
-  cout << "-1:" << String_convert::i2hex_str( -1, 2, '0' );
+  cout << String_convert::bin2hex_str (String ( (char)0xff)) << endl;
+  cout << "-1:" << String_convert::i2hex_str (-1, 2, '0');
   cout << endl;
 
 }
 
 
-ADD_TEST(stringtest);
+ADD_TEST (stringtest);