From 14d0e70efc16bfb71c1a235e22b43262942f1674 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 1 Sep 2004 18:41:20 +0000 Subject: [PATCH] remove ly_scm2str0. --- ChangeLog | 4 ++++ lily/include/lily-guile.hh | 2 +- lily/lily-guile.cc | 24 ++++++++++-------------- lily/lily-lexer.cc | 3 ++- lily/lily-parser.cc | 2 +- lily/modified-font-metric.cc | 2 +- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index b0d708aed4..d941200f38 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-09-01 Han-Wen Nienhuys + + * lily/lily-guile.cc: remove ly_scm2str0. + 2004-09-01 Jan Nieuwenhuizen * Documentation/user/macros.itexi: Use @inforef iso @uref for diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh index 4374d028c4..cd6ea97b87 100644 --- a/lily/include/lily-guile.hh +++ b/lily/include/lily-guile.hh @@ -146,7 +146,7 @@ inline bool ly_c_symbol_p (SCM x) { return SCM_SYMBOLP (x); } inline bool ly_c_boolean_p (SCM x) { return SCM_BOOLP (x); } inline bool ly_c_char_p (SCM x) { return SCM_CHARP (x); } inline bool ly_c_number_p (SCM x) { return SCM_NUMBERP (x); } -inline bool ly_c_string_p (SCM x) { return SCM_STRINGP (x); } +inline bool ly_c_string_p (SCM x) { return scm_is_string (x); } inline bool ly_c_vector_p (SCM x) { return SCM_VECTORP (x); } inline bool ly_c_list_p (SCM x) { return SCM_NFALSEP (scm_list_p (x)); } inline bool ly_c_procedure_p (SCM x) { return SCM_NFALSEP (scm_procedure_p (x)); } diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index 9e759e7e9f..fb4903b710 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -73,8 +73,11 @@ ly_quote_scm (SCM s) String ly_symbol2string (SCM s) { - assert (ly_c_symbol_p (s)); - return String ((Byte*)SCM_STRING_CHARS (s), (int) SCM_STRING_LENGTH (s)); + /* + Ugh. this is not very efficient. + */ + SCM str = scm_symbol_to_string (s); + return ly_scm2string (str); } String @@ -122,18 +125,11 @@ ly_display_scm (SCM s) } }; -char const * -ly_scm2str0 (SCM string) -{ - SCM_ASSERT_TYPE (ly_c_string_p (string), string, SCM_ARG1, - __FUNCTION__, "string"); - return SCM_STRING_CHARS (string); -} - String -ly_scm2string (SCM string) +ly_scm2string (SCM str) { - return ly_scm2str0 (string); + return String ((Byte*)scm_i_string_chars (str), + (int) scm_i_string_length (str)); } char * @@ -144,7 +140,7 @@ ly_scm2newstr (SCM str, size_t *lenp) size_t len = SCM_STRING_LENGTH (str); if (char *new_str = (char *) malloc ((len + 1) * sizeof (char))) { - memcpy (new_str, SCM_STRING_CHARS (str), len); + memcpy (new_str, scm_i_string_chars (str), len); new_str[len] = '\0'; if (lenp) @@ -824,5 +820,5 @@ LY_DEFINE (ly_gettext, "ly:gettext", { SCM_ASSERT_TYPE (ly_c_string_p (string), string, SCM_ARG1, __FUNCTION__, "string"); - return scm_makfrom0str (gettext (ly_scm2str0 (string))); + return scm_makfrom0str (gettext (scm_i_string_chars (string))); } diff --git a/lily/lily-lexer.cc b/lily/lily-lexer.cc index 2f926ea674..9226c5440a 100644 --- a/lily/lily-lexer.cc +++ b/lily/lily-lexer.cc @@ -216,7 +216,8 @@ Lily_lexer::set_identifier (SCM name, SCM s) { if (lookup_keyword (ly_symbol2string (sym)) >= 0) { - warning (_f ("Identifier name is a keyword: `%s'", SCM_SYMBOL_CHARS (sym))); + String symstr = ly_symbol2string (sym); + warning (_f ("Identifier name is a keyword: `%s'", symstr.to_str0())); } SCM mod = ly_car (scopes_); diff --git a/lily/lily-parser.cc b/lily/lily-parser.cc index c489c356f2..818ae67289 100644 --- a/lily/lily-parser.cc +++ b/lily/lily-parser.cc @@ -257,7 +257,7 @@ LY_DEFINE (ly_parse_file, "ly:parse-file", "Upon failure, throw @code{ly-file-failed} key.") { SCM_ASSERT_TYPE (ly_c_string_p (name), name, SCM_ARG1, __FUNCTION__, "string"); - char const *file = SCM_STRING_CHARS (name); + char const *file = scm_i_string_chars (name); char const *extensions[] = {"ly", "", 0}; String file_name = global_path.find (file, extensions); diff --git a/lily/modified-font-metric.cc b/lily/modified-font-metric.cc index 875c87ef0c..2b67671b2d 100644 --- a/lily/modified-font-metric.cc +++ b/lily/modified-font-metric.cc @@ -280,7 +280,7 @@ Modified_font_metric::text_dimension (String text) if (!ly_c_symbol_p (sym)) continue; - char const * chars = SCM_SYMBOL_CHARS(sym); + char const * chars = scm_i_string_chars (scm_symbol_to_string(sym)); int idx = orig_->name_to_index (chars); if (idx >= 0) -- 2.39.5