From b43f38447d6f6dbe88c1f87622d334cb0ce1b2c3 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 24 Aug 2006 10:31:54 +0000 Subject: [PATCH] (Source_file): use copy(). Remove contents_str0() --- ChangeLog | 7 ++++++- lily/include/source-file.hh | 1 - lily/source-file.cc | 19 ++++++------------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index e482fa5ef0..f51b12190a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-08-24 Han-Wen Nienhuys + + * lily/source-file.cc (Source_file): use copy(). Remove contents_str0() + 2006-08-24 Graham Percival * Documentation/user/changing-defaults.itely, global.itely, @@ -5,7 +9,8 @@ 2006-08-23 Han-Wen Nienhuys - * buildscripts/mutopia-index.py (allfiles): filter lily-XXX and snippet-map + * buildscripts/mutopia-index.py (allfiles): filter lily-XXX and + snippet-map * scm/define-context-properties.scm (translator-property-description): robustness: detect type errors diff --git a/lily/include/source-file.hh b/lily/include/source-file.hh index 05fd73359f..76942ba6b1 100644 --- a/lily/include/source-file.hh +++ b/lily/include/source-file.hh @@ -32,7 +32,6 @@ class Source_file vector characters_; SCM str_port_; - char const *contents_str0 () const; void load_stdin (); void init_port (); void init (); diff --git a/lily/source-file.cc b/lily/source-file.cc index cfa66b628f..186ea1eaf8 100644 --- a/lily/source-file.cc +++ b/lily/source-file.cc @@ -78,19 +78,13 @@ gulp_file (string filename, int desired_size) vector cxx_arr; cxx_arr.resize (filesize); - /* ugh, how to do neatly in STL? */ - memcpy (&cxx_arr[0], str, filesize); + + copy (str, str + filesize, cxx_arr.begin ()); free (str); return cxx_arr; } -char const * -Source_file::contents_str0 () const -{ - return &characters_[0]; -} - void Source_file::init () { @@ -108,10 +102,9 @@ Source_file::Source_file (string filename, string data) name_ = filename; characters_.resize (data.length ()); - - /* ugh, how to do neatly in STL? */ - memcpy ((&characters_[0]), data.c_str (), data.length ()); - + + copy (data.begin (), data.end (), characters_.begin ()); + init_port (); for (vsize i = 0; i < characters_.size (); i++) @@ -143,7 +136,7 @@ Source_file::Source_file (string filename_string) void Source_file::init_port () { - SCM str = scm_makfrom0str (contents_str0 ()); + SCM str = scm_makfrom0str (c_str ()); str_port_ = scm_mkstrport (SCM_INUM0, str, SCM_OPN | SCM_RDNG, __FUNCTION__); scm_set_port_filename_x (str_port_, scm_makfrom0str (name_.c_str ())); } -- 2.39.2