summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flower/file-name.cc6
-rw-r--r--flower/getopt-long.cc2
-rw-r--r--flower/include/std-string.hh4
-rw-r--r--flower/std-string.cc16
-rw-r--r--lily/accidental.cc2
-rw-r--r--lily/break-substitution.cc2
-rw-r--r--lily/easy-notation.cc4
-rw-r--r--lily/font-metric.cc2
-rw-r--r--lily/general-scheme.cc11
-rw-r--r--lily/lily-guile.cc44
-rw-r--r--lily/misc.cc6
-rw-r--r--lily/program-option-scheme.cc2
-rw-r--r--lily/translator.cc6
13 files changed, 50 insertions, 57 deletions
diff --git a/flower/file-name.cc b/flower/file-name.cc
index bf645df23d..1eff46be52 100644
--- a/flower/file-name.cc
+++ b/flower/file-name.cc
@@ -61,8 +61,8 @@ static /* avoid warning */
string
slashify (string file_name)
{
- replace_all (file_name, '\\', '/');
- replace_all (file_name, string ("//"), "/");
+ replace_all (&file_name, '\\', '/');
+ replace_all (&file_name, string ("//"), "/");
return file_name;
}
@@ -185,7 +185,7 @@ File_name::canonicalized () const
{
File_name c = *this;
- replace_all (c.dir_, string ("//"), string ("/"));
+ replace_all (&c.dir_, string ("//"), string ("/"));
vector<string> components = string_split (c.dir_, '/');
vector<string> new_components;
diff --git a/flower/getopt-long.cc b/flower/getopt-long.cc
index 2cb537c67b..37a964219d 100644
--- a/flower/getopt-long.cc
+++ b/flower/getopt-long.cc
@@ -310,7 +310,7 @@ Long_option_init::table_string (Long_option_init *l)
s += string (wid - s.length () + EXTRA_SPACES, ' ');
string help_text (gettext (l[i].help_str0_));
- replace_all (help_text, "\n",
+ replace_all (&help_text, "\n",
"\n" + string (wid + EXTRA_SPACES + 2, ' '));
tabstr += s + help_text + "\n";
}
diff --git a/flower/include/std-string.hh b/flower/include/std-string.hh
index 57805bbe21..d5933d8f99 100644
--- a/flower/include/std-string.hh
+++ b/flower/include/std-string.hh
@@ -38,8 +38,8 @@ string to_string (bool b);
string to_string (char const *format, ...)
__attribute__ ((format (printf, 1, 2)));
-string &replace_all (string &str, string find, string replace);
-string &replace_all (string &str, char find, char replace);
+string &replace_all (string* str, string const &find, string const &replace);
+string &replace_all (string* str, char find, char replace);
char *string_copy (string s);
int string_compare (string const &, string const &);
diff --git a/flower/std-string.cc b/flower/std-string.cc
index 1221609c6c..5232574366 100644
--- a/flower/std-string.cc
+++ b/flower/std-string.cc
@@ -71,20 +71,20 @@ to_string (char const *format, ...)
TODO: this O(n^2) in #occurences of find, due to repeated copying.
*/
string &
-replace_all (string &str, string find, string replace)
+replace_all (string *str, string const &find, string const &replace)
{
ssize len = find.length ();
- for (ssize i = str.find (find); i != NPOS; i = str.find (find, i + len))
- str = str.replace (i, len, replace);
- return str;
+ for (ssize i = str->find (find); i != NPOS; i = str->find (find, i + len))
+ *str = str->replace (i, len, replace);
+ return *str;
}
string &
-replace_all (string &str, char find, char replace)
+replace_all (string *str, char find, char replace)
{
- for (ssize i = str.find (find); i != NPOS; i = str.find (find, i + 1))
- str[i] = replace;
- return str;
+ for (ssize i = str->find (find); i != NPOS; i = str->find (find, i + 1))
+ (*str)[i] = replace;
+ return *str;
}
char *
diff --git a/lily/accidental.cc b/lily/accidental.cc
index c911525228..7f3a97b4f7 100644
--- a/lily/accidental.cc
+++ b/lily/accidental.cc
@@ -189,7 +189,7 @@ Accidental_interface::get_stencil (Grob *me)
return SCM_EOL;
}
- Stencil mol (fm->find_by_name (scm_i_string_chars (glyph_name)));
+ Stencil mol (fm->find_by_name (ly_scm2string (glyph_name)));
if (to_boolean (me->get_property ("restore-first")))
{
/*
diff --git a/lily/break-substitution.cc b/lily/break-substitution.cc
index f283010303..67697136d2 100644
--- a/lily/break-substitution.cc
+++ b/lily/break-substitution.cc
@@ -263,6 +263,8 @@ grob_system_range (Grob *g)
struct Substitution_entry
{
Grob *grob_;
+
+ /* Assumption: we have less than 32k paper columns. */
short left_;
short right_;
diff --git a/lily/easy-notation.cc b/lily/easy-notation.cc
index 34c0a97f78..c5d886147b 100644
--- a/lily/easy-notation.cc
+++ b/lily/easy-notation.cc
@@ -45,8 +45,8 @@ Note_head::brew_ez_stencil (SCM smob)
else
{
char s[2] = "a";
- s[0] = (pit->get_notename () + 2) % 7 + 'a';
- s[0] = toupper (s[0]);
+ s[0] = char ((pit->get_notename () + 2) % 7 + 'a');
+ s[0] = char (toupper (s[0]));
charstr = scm_from_locale_string (s);
}
diff --git a/lily/font-metric.cc b/lily/font-metric.cc
index 655d992123..215bf67981 100644
--- a/lily/font-metric.cc
+++ b/lily/font-metric.cc
@@ -31,7 +31,7 @@ Font_metric::design_size () const
Stencil
Font_metric::find_by_name (string s) const
{
- replace_all (s, '-', 'M');
+ replace_all (&s, '-', 'M');
int idx = name_to_index (s);
Box b;
diff --git a/lily/general-scheme.cc b/lily/general-scheme.cc
index 7d4b5c1c30..fd27481938 100644
--- a/lily/general-scheme.cc
+++ b/lily/general-scheme.cc
@@ -180,8 +180,9 @@ LY_DEFINE (ly_string_substitute, "ly:string-substitute",
LY_ASSERT_TYPE (scm_is_string, s, 3);
string ss = ly_scm2string (s);
- replace_all (ss, string (scm_i_string_chars (a)),
- string (scm_i_string_chars (b)));
+ replace_all (&ss, ly_scm2string (a),
+ ly_scm2string (b));
+
return ly_string2scm (ss);
}
@@ -245,11 +246,11 @@ LY_DEFINE (ly_protects, "ly:protects",
}
LY_DEFINE (ly_gettext, "ly:gettext",
- 1, 0, 0, (SCM string),
+ 1, 0, 0, (SCM original),
"A Scheme wrapper function for @code{gettext}.")
{
- LY_ASSERT_TYPE (scm_is_string, string, 1);
- return ly_string2scm (_ (scm_i_string_chars (string)));
+ LY_ASSERT_TYPE (scm_is_string, original, 1);
+ return ly_string2scm (_ (ly_scm2string (original).c_str ()));
}
LY_DEFINE (ly_output_formats, "ly:output-formats",
diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc
index 9da6823f19..9f62fbb670 100644
--- a/lily/lily-guile.cc
+++ b/lily/lily-guile.cc
@@ -111,8 +111,13 @@ string
ly_scm2string (SCM str)
{
assert (scm_is_string (str));
- return string (scm_i_string_chars (str),
- (int) scm_i_string_length (str));
+ string result;
+ size_t len = scm_c_string_length (str);
+ if (len) {
+ result.resize(len);
+ scm_to_locale_stringbuf(str, &result.at(0), len);
+ }
+ return result;
}
SCM
@@ -126,30 +131,16 @@ ly_string2scm (string const &str)
char *
ly_scm2newstr (SCM str, size_t *lenp)
{
- LY_ASSERT_TYPE (scm_is_string, str, 1);
-
- size_t len = scm_i_string_length (str);
- if (char *new_str = (char *) malloc ((len + 1) * sizeof (char)))
- {
- memcpy (new_str, scm_i_string_chars (str), len);
- new_str[len] = '\0';
-
- if (lenp)
- *lenp = len;
-
- return new_str;
- }
- return 0;
+ char* p = scm_to_locale_stringn(str, lenp);
+ return p;
}
-
/*
PAIRS
*/
-SCM
+SCM
index_get_cell (SCM s, Direction d)
{
-
assert (d);
return (d == LEFT) ? scm_car (s) : scm_cdr (s);
}
@@ -178,7 +169,6 @@ ly_scm_hash (SCM s)
return scm_ihashv (s, ~1u);
}
-
bool
is_axis (SCM s)
{
@@ -634,10 +624,10 @@ mangle_cxx_identifier (string cxx_id)
else if (cxx_id.substr (cxx_id.length () - 2) == "_x")
cxx_id = cxx_id.replace (cxx_id.length () - 2, 2, "!");
- cxx_id = replace_all (cxx_id, "_less?", "<?");
- cxx_id = replace_all (cxx_id, "_2_", "->");
- cxx_id = replace_all (cxx_id, "__", "::");
- cxx_id = replace_all (cxx_id, '_', '-');
+ replace_all (&cxx_id, "_less?", "<?");
+ replace_all (&cxx_id, "_2_", "->");
+ replace_all (&cxx_id, "__", "::");
+ replace_all (&cxx_id, '_', '-');
return cxx_id;
@@ -661,9 +651,9 @@ parse_symbol_list (char const *symbols)
while (isspace (*symbols))
*symbols++;
string s = symbols;
- replace_all (s, '\n', ' ');
- replace_all (s, '\t', ' ');
- replace_all (s, " ", " ");
+ replace_all (&s, '\n', ' ');
+ replace_all (&s, '\t', ' ');
+ replace_all (&s, " ", " ");
return ly_string_array_to_scm (string_split (s, ' '));
}
diff --git a/lily/misc.cc b/lily/misc.cc
index 6837df0d74..3b9d87da16 100644
--- a/lily/misc.cc
+++ b/lily/misc.cc
@@ -71,17 +71,17 @@ camel_case_to_lisp_identifier (string in)
vector<char> out;
/* don't add '-' before first character */
- out.push_back (tolower (in[0]));
+ out.push_back (char (tolower (in[0])));
for (size_t inpos = 1; inpos < in.size (); inpos++)
{
if (isupper (in[inpos]))
out.push_back ('-');
- out.push_back (tolower (in[inpos]));
+ out.push_back ( char(tolower (in[inpos])));
}
string result (&out[0], out.size ());
- replace_all (result, '_', '-');
+ replace_all (&result, '_', '-');
return result;
}
diff --git a/lily/program-option-scheme.cc b/lily/program-option-scheme.cc
index 4ec898092e..f47abed2cc 100644
--- a/lily/program-option-scheme.cc
+++ b/lily/program-option-scheme.cc
@@ -149,7 +149,7 @@ get_help_string ()
SCM opt_help_scm
= scm_object_property (sym, ly_symbol2scm ("program-option-documentation"));
string opt_help = ly_scm2string (opt_help_scm);
- replace_all (opt_help,
+ replace_all (&opt_help,
string ("\n"),
string ("\n")
+ String_convert::char_string (' ', HELP_INDENT));
diff --git a/lily/translator.cc b/lily/translator.cc
index e4cb27d3b7..dc70c155ce 100644
--- a/lily/translator.cc
+++ b/lily/translator.cc
@@ -171,7 +171,7 @@ Translator::add_translator_listener (translator_listener_record **listener_list,
{
/* ev_class is the C++ identifier name. Convert to scm symbol */
string name = string (ev_class);
- name = replace_all (name, '_', '-');
+ name = replace_all (&name, '_', '-');
name += "-event";
SCM class_sym = scm_str2symbol (name.c_str ());
@@ -275,7 +275,7 @@ add_acknowledger (Engraver_void_function_engraver_grob_info ptr,
string interface_name (func_name);
- interface_name = replace_all (interface_name, '_', '-');
+ interface_name = replace_all (&interface_name, '_', '-');
interface_name += "-interface";
/*
@@ -342,7 +342,7 @@ internal_event_assignment (Stream_event **old_ev, Stream_event *new_ev, const ch
/* "listen_foo_bar" -> "foo-bar" */
ev_class.erase (0, strlen (prefix));
- replace_all (ev_class, '_', '-');
+ replace_all (&ev_class, '_', '-');
new_ev->origin ()->warning (_f ("Two simultaneous %s events, junking this one", ev_class.c_str ()));
(*old_ev)->origin ()->warning (_f ("Previous %s event here", ev_class.c_str ()));