]> git.donarmstrong.com Git - lilypond.git/commitdiff
(substitute_char): Rename, rewrite, modify this.
authorJan Nieuwenhuizen <janneke@gnu.org>
Sat, 11 Dec 2004 16:16:26 +0000 (16:16 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sat, 11 Dec 2004 16:16:26 +0000 (16:16 +0000)
(upper_string, lower_string, reverse_string): Remove.

ChangeLog
flower/include/string.hh
flower/string.cc
lily/all-font-metrics.cc
lily/font-metric.cc
lily/open-type-font.cc

index c2143e7cac29bca6ef94081b81f0209db5dfe4f8..ef7e2641f112f449ecc4bf09f97438c5c10dc6ea 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2004-12-11  Jan Nieuwenhuizen  <janneke@gnu.org>
 
+       * flower/string.cc (substitute_char): Rename, rewrite, modify this.
+       (upper_string, lower_string, reverse_string): Remove.
+
        * configure.in (fontforge): Reinstate version check.
 
        * ly/engraver-init.ly: Fix clef glyph names.
index 252fdb48f2b3888d8c7553a41962c693f10af1fb..b3f08e6738966ce511f3dcc59d5b9c6923d18004 100644 (file)
@@ -71,8 +71,8 @@ public:
 
   /// String s = "abc";
   String (char const* source); 
-  String (Byte const* byte, int length_i); 
-    
+  String (Byte const* byte, int length_i);
+
   ///  return "new"-ed copy of contents
   Byte* get_copy_byte () const;
   char* get_copy_str0 () const;
@@ -105,13 +105,8 @@ public:
   /// return n rightmost chars
   String right_string (int n) const;
 
-  /// return uppercase of *this
-  String upper_string () const;
-  /// return lowercase of *this
-  String lower_string () const;
-
   /// return the "esrever" of *this
-  String reversed_string () const;
+  void reverse ();
 
   /// return a piece starting at index (first char = index_i 0), length n
   String cut_string (int index_i, int n) const;
@@ -153,7 +148,7 @@ public:
   /// convert to a double
   double to_double () const;
 
-  String substituted (char text, String sub) const; 
+  void substitute_char (char text, String sub);
 };
 
 /*
index beb445f2555e80c4df5ac4eaae17b243795f41f6..2df83ba95bcf054732f4f7fd89722197a3ab67d4 100644 (file)
@@ -234,7 +234,7 @@ String::index (char c) const
   find a substring.
 
   @return
-1  index of leftmost occurrence of #searchfor#
+  index of leftmost occurrence of #searchfor#
  */
 int
 String::index (String searchfor) const
@@ -246,8 +246,8 @@ String::index (String searchfor) const
   
   if (p)
     return p - me;
-  else
-    return -1;
+
+  return -1;
 }
 
 /** find chars of a set.
@@ -317,9 +317,7 @@ String::nomid_string (int index_i, int n) const
   if (n <= 0)
     return *this;
   
-  return
-    left_string (index_i)   +
-    right_string (length () - index_i - n) ;
+  return left_string (index_i) + right_string (length () - index_i - n);
 }
 
 String
@@ -340,41 +338,23 @@ String::cut_string (int index_i, int n) const
   return String (to_bytes () + index_i, n);
 }
 \f
-String
-String::upper_string () const
-{
-  String str = *this;
-  str.to_upper ();
-  return str;
-}
+
 void
 String::to_upper ()
 {
-  char *s = (char*)strh_.get_bytes ();
-  strnupr (s ,length ());
+  strnupr (get_str0 (), length ());
 }
 
 void
 String::to_lower ()
 {
-  char* s = strh_.get_str0 ();
-  strnlwr (s,length ());    
+  strnlwr (get_str0 (), length ());    
 }
 
-
-String 
-String::lower_string () const
+void 
+String::reverse ()
 {
-  String str = *this;
-  str.to_lower ();
-  return str;
-}
-String 
-String::reversed_string () const
-{
-  String str = *this;
-  strrev (str.get_bytes (), str.length ());
-  return str;    
+  strrev (get_bytes (), length ());
 }
 
 int
@@ -397,7 +377,6 @@ operator << (ostream& os, String d)
   return os;
 }
 
-
 void
 String::print_on (ostream& os) const
 {
@@ -409,21 +388,9 @@ String::print_on (ostream& os) const
 }
 #endif
 
-
-String
-String::substituted (char chr, String sub) const
+void
+String::substitute_char (char chr, String sub)
 {
-  Byte const* t = this->to_bytes ();
-  
-  String accumulator;
-  int n = length();
-  for (int i = 0; i < n; i++)
-    {
-      if (t[i] == chr)
-       accumulator += sub;
-      else
-       accumulator += String_convert::char_string (t[i], 1); 
-    }
-
-  return accumulator;
+  for (int i = index (chr); i > -1; i = index (chr))
+    *this = left_string (i) + sub + right_string (length () - i - 1);
 }
index 63658d6be34b3f5d901102653551db02b25fe439..a73e22a2fc02f8e251b022ab8b2502014026baf7 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "all-font-metrics.hh"
 
-#include "open-type-font.hh"
+//#include "open-type-font.hh"
 #include "config.hh"
 #include "main.hh"
 #include "warn.hh"
@@ -17,7 +17,7 @@
 #include "scm-hash.hh"
 #include "kpath.hh"
 
-static const char *default_font_str0_ = "cmr10";
+static char const *default_font_str0_ = "cmr10";
 
 All_font_metrics::All_font_metrics (String path)
 {
@@ -120,6 +120,7 @@ All_font_metrics::find_afm (String name)
   return dynamic_cast<Adobe_font_metric*> (unsmob_metrics (val));
 }
 
+#if 0
 
 Open_type_font*
 All_font_metrics::find_otf (String name)
@@ -153,7 +154,7 @@ All_font_metrics::find_otf (String name)
 
   return dynamic_cast<Open_type_font*> (unsmob_metrics (val));
 }
-
+#endif
 
 Tex_font_metric*
 All_font_metrics::find_tfm (String name)
@@ -200,13 +201,13 @@ All_font_metrics::find_tfm (String name)
 Font_metric*
 All_font_metrics::find_font (String name)
 {
-  Font_metric *f = find_otf (name);
-
+  //Font_metric *f = find_otf (name);
+  Font_metric *f = 0;
   
   if (!f &&
-      (name.left_string (4) == "feta")
-      || (name.left_string (8) == "parmesan")
-      || (name.left_string (2) == "lm"))
+      (name.left_string (4) == "feta"
+       || (name.left_string (8) == "parmesan")
+       || (name.left_string (2) == "lm")))
     {
       f = find_afm (name);
       if (!f)
index cbaa78603cdaead298f736b2be54597c56225ecb..2e25dfac9c848f2e30693ed7a36a42897ec6b54a 100644 (file)
@@ -35,9 +35,7 @@ Font_metric::coding_scheme () const
 Stencil
 Font_metric::find_by_name (String s) const
 {
-  // FIXME: past tense in func name?
-  // $23 = 0x865ba10 "clefsMG_change"
-  s = s.substituted ('-', "M");
+  s.substitute_char ('-', "M");
   int idx = name_to_index (s);
   Box b;
   
index f053f441b42e9afd7cbd8916d3c384b744e63190..ac30e89b703758687e12f7951f06e4d89cb491ce 100644 (file)
@@ -7,6 +7,7 @@
 
 */
 
+#if 0
 #include "warn.hh"
 #include "open-type-font.hh"
 
@@ -66,3 +67,4 @@ Open_type_font::get_design_size () const
 {
   return 20.0;
 }
+#endif