X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=flower%2Fdata-file.cc;h=996752cfce34d48e6f8d6d22f8a1e7a7aab2d291;hb=1cf3d59c1559fb9774c4c1c8cae155cfe54a927c;hp=251380d3c806f5a11a16a0696253019e181ccccb;hpb=13e79c0250d34b6bdfbafbc551ef64e8b59b2991;p=lilypond.git diff --git a/flower/data-file.cc b/flower/data-file.cc index 251380d3c8..996752cfce 100644 --- a/flower/data-file.cc +++ b/flower/data-file.cc @@ -1,97 +1,146 @@ +/* + data-file.cc -- implement Data_file + + source file of the Flower Library + + (c) '95, '96, '97 Han-Wen Nienhuys + + */ #include #include +#include "international.hh" #include "data-file.hh" -void +void Data_file::gobble_white() { char c; - + while ((c=data_get()) == ' ' ||c == '\t') - if (eof()) - break; + if (eof_b()) + return; data_unget (c); } String -Data_file::get_word() +Data_file::get_word() {// should handle escape seq's String s; - while (1) + while (1) + { + char c = data_get(); + + if (eof_b ()) + break; + + if (isspace (c)) { - char c = data_get(); - - if (isspace (c) || eof()) - { - data_unget (c); - break; - } - - - if (c == '\"') - { - rawmode= true; - - while ((c = data_get()) != '\"') - if (eof()) - error ("EOF in a string"); - else - s += c; - - - rawmode= false; - } - else - s += c; - } - - return s; + data_unget (c); + break; + } + + + if (c == '\"') + { + rawmode= true; + + while ((c = data_get()) != '\"') + if (eof_b ()) + error (_ ("EOF in a string")); + else + s += to_str (c); + + + rawmode= false; + } + else + s += to_str (c); + } + + return s; } -/** get a char +/** get a char Only class member who uses text_file::get */ char -Data_file::data_get() { - char c = get(); +Data_file::data_get() +{ + char c = get(); if (!rawmode && c == '#') // gobble comment - { - while ((c = get()) != '\n' && !eof ()) - ; - return '\n'; - } + { + while (!eof_b () && (c = get()) != '\n') + ; + return '\n'; + } return c; } -/// read line, gobble '\n' -String Data_file::get_line() +/// read line, gobble '\n' +String +Data_file::get_line() { - char c; + char c; String s; - while ((c = data_get()) != '\n' && !eof ()) - s += c; - return s; + while (!eof_b () && (c = data_get()) != '\n') + s += to_str (c); + return s; } -/// gobble stuff before first entry on a line. +/// gobble stuff before first entry on a line. void -Data_file::gobble_leading_white() +Data_file::gobble_leading_white() { // eat blank lines. - while (!eof()) + while (!eof_b ()) { - char c = data_get(); - if (!isspace (c)) - { - data_unget (c); - break; - } + char c = data_get(); + if (!isspace (c)) + { + data_unget (c); + break; + } } } +Data_file::Data_file (String s) + : Text_stream (s) +{ + //*mlog << "(" << s << flush; + rawmode= false; +} + +void +Data_file::warning (String s) +{ + message (_ ("warning: ") + s); +} + +void +Data_file::error (String s) +{ + message (s); + exit (1); +} + +String +Data_file::gulp () +{ + String s; + while (!eof_b ()) + { + s += to_str (data_get ()); + } + return s; +} + + +Data_file::~Data_file () +{ +}