(upper_string, lower_string, reverse_string): Remove.
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.
/// 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;
/// 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;
/// convert to a double
double to_double () const;
- String substituted (char text, String sub) const;
+ void substitute_char (char text, String sub);
};
/*
find a substring.
@return
-1 index of leftmost occurrence of #searchfor#
+ index of leftmost occurrence of #searchfor#
*/
int
String::index (String searchfor) const
if (p)
return p - me;
- else
- return -1;
+
+ return -1;
}
/** find chars of a set.
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
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
return os;
}
-
void
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);
}
#include "all-font-metrics.hh"
-#include "open-type-font.hh"
+//#include "open-type-font.hh"
#include "config.hh"
#include "main.hh"
#include "warn.hh"
#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)
{
return dynamic_cast<Adobe_font_metric*> (unsmob_metrics (val));
}
+#if 0
Open_type_font*
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)
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)
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;
*/
+#if 0
#include "warn.hh"
#include "open-type-font.hh"
{
return 20.0;
}
+#endif