From: fred Date: Wed, 19 Feb 1997 20:46:22 +0000 (+0000) Subject: flower-1.1.0 X-Git-Tag: release/1.5.59~6315 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=eb0cc24c03e9194b84cd97d64a896dedf00cba18;p=lilypond.git flower-1.1.0 --- diff --git a/flower/Sources.make b/flower/Sources.make index 23d5164f0a..4b7cca4ec6 100644 --- a/flower/Sources.make +++ b/flower/Sources.make @@ -1,6 +1,7 @@ -cc=choleski.cc dataf.cc dstream.cc lgetopt.cc matdebug.cc matrix.cc\ -path.cc scalar.cc smat.cc string.cc textdb.cc unionfind.cc vector.cc +cc=choleski.cc datafile.cc dstream.cc lgetopt.cc matdebug.cc matrix.cc\ +path.cc scalar.cc smat.cc string.cc stringconversion.cc stringutil.cc\ +textdb.cc textstream.cc unionfind.cc vector.cc templatecc=cursor.tcc list.tcc plist.tcc interval.tcc\ pcursor.tcc @@ -9,5 +10,8 @@ inl=link.inl list.inl cursor.inl plist.inl hh=assoc.hh associter.hh choleski.hh compare.hh cursor.hh dstream.hh\ fproto.hh handle.hh interval.hh iterate.hh lgetopt.hh link.hh list.hh\ matrix.hh path.hh pcursor.hh plist.hh rational.hh real.hh scalar.hh\ -smat.hh string.hh stringutil.hh textdb.hh textstr.hh unionfind.hh\ -varray.hh vector.hh vsmat.hh +smat.hh string.hh stringconversion.hh stringutil.hh \ +textdb.hh textstream.hh unionfind.hh\ +varray.hh vector.hh vsmat.hh datafile.hh + +extra=stringtest.cc diff --git a/flower/Variables.make b/flower/Variables.make index 6d0cec88bd..d2a35182bd 100644 --- a/flower/Variables.make +++ b/flower/Variables.make @@ -1,12 +1,12 @@ MAJVER=1 -MINVER=0 -PATCHLEVEL=27 +MINVER=1 +PATCHLEVEL=0 PACKAGENAME=flower #PROFILEFLAG=-pg -DEBUGFLAG= -O2 -DNDEBUG # -g -OPTIFLAG=-DNDEBUG -DNPRINT -O2 +DEBUGFLAG= -g +OPTIFLAG= -DNPRINT -O2 -DSTRING_UTILS_INLINED -DNDEBUG ######################################### @@ -32,7 +32,7 @@ include Sources.make obs=$(cc:.cc=.o) staticlib=libflower.a -ALLSOURCES=$(hh) $(cc) $(inl) $(templatecc) +ALLSOURCES=$(hh) $(cc) $(inl) $(templatecc) $(extra) DFILES=$(ALLSOURCES) Makefile Variables.make make_version\ Sources.make TODO README NEWS DDIR=$(DNAME) diff --git a/flower/dataf.cc b/flower/dataf.cc deleted file mode 100644 index 29b366c860..0000000000 --- a/flower/dataf.cc +++ /dev/null @@ -1,122 +0,0 @@ -#include -#include - -#include "textstr.hh" -Text_stream::Text_stream(String fn) -{ - if (fn == "") - { - name = ""; - f = stdin; - } - - else - { - name = fn; - f = fopen(fn, "r"); - } - - if (!f) { - cerr <<__FUNCTION__<< ": can't open `" << fn << "'\n"; - exit(1); - } - - line_no = 1; - } - -void -Text_stream::message(String s) -{ - cerr << "\n"< +#include + +#include "datafile.hh" + +void +Data_file::gobble_white() +{ + char c; + + while ((c=data_get()) == ' ' ||c == '\t') + if (eof()) + break; + + data_unget(c); +} + +String +Data_file::get_word() +{// should handle escape seq's + String s; + + while (1) + { + 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; +} + +/** get a char + Only class member who uses text_file::get + */ +char +Data_file::data_get() { + char c = get(); + if (!rawmode && c == '#') // gobble comment + { + while ((c = get()) != '\n' && !eof()) + ; + return '\n'; + } + + return c; +} + +/// read line, gobble '\n' +String Data_file::get_line() +{ + char c; + String s; + + while ((c = data_get()) != '\n' && !eof()) + s += c; + return s; +} + +/// gobble stuff before first entry on a line. +void +Data_file::gobble_leading_white() +{ + // eat blank lines. + while (!eof()) { + char c = data_get(); + if (!isspace(c)) { + data_unget(c); + break; + } + } +} + + diff --git a/flower/datafile.hh b/flower/datafile.hh new file mode 100644 index 0000000000..14d57369a3 --- /dev/null +++ b/flower/datafile.hh @@ -0,0 +1,59 @@ +/* + datafile.hh -- declare Data_file + + source file of the LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef DATAFILE_HH +#define DATAFILE_HH + +#include "textstream.hh" + +/// read a data file +class Data_file : private Text_stream +{ + + public: + bool rawmode; + + Text_stream::line; + Text_stream::eof; + Text_stream::get_name; + + char data_get(); + void data_unget(char c) { + unget(c); + } + + /// read line, eat #\n# + String get_line(); + + /// read a word till next space, leave space. Also does quotes + String get_word(); + + /// gobble horizontal white stuff. + void gobble_white(); + + /// gobble empty stuff before first field. + void gobble_leading_white(); + Data_file(String s) : Text_stream(s) { + //*mlog << "(" << s << flush; + rawmode= false; + } + + ~Data_file() { + // *mlog << ")"<; + indentlvl = 0; if (!os) return; - indentlvl = 0; const char * fn =cfg_nm ? cfg_nm : ".dstreamrc"; { diff --git a/flower/textdb.hh b/flower/textdb.hh index 3586c0d180..c2cff2461b 100644 --- a/flower/textdb.hh +++ b/flower/textdb.hh @@ -1,7 +1,7 @@ #ifndef TEXTDB_HH #define TEXTDB_HH -#include "textstr.hh" +#include "datafile.hh" /**a "const" Array. Contents can't be changed. do "#" comments, read quote enclosed fields */ diff --git a/flower/textstr.hh b/flower/textstr.hh deleted file mode 100644 index 2d648d4c19..0000000000 --- a/flower/textstr.hh +++ /dev/null @@ -1,116 +0,0 @@ - -#ifndef TEXTSTR_HH -#define TEXTSTR_HH - -#include -#include -#include "string.hh" -#include "varray.hh" - -/** line counting input stream. - a stream for textfiles. linecounting. Thin interface getchar and - ungetchar. (ungetc is unlimited) - - should protect get and unget against improper use -*/ - - -class Text_stream -{ - int line_no; - - // could just have used streams. - FILE *f; - Array pushback; - String name; - - public: - Text_stream(String fn); - String get_name() { return name; } - bool eof() { - return feof(f); - } - bool eol() { - return (peek() == '\n'); - } - char peek() { - char c = get(); - unget(c); - return c; - } - int line(){ - return line_no; - } - - char get() { - char c; - - if (pushback.empty()) - c = getc(f); - else - c = pushback.pop(); - - if (c =='\n') - line_no++; - return c; - } - void unget(char c) { - if (c =='\n') - line_no--; - pushback.push(c); - } - ~Text_stream (){ - if (!eof()) - cerr <<__FUNCTION__<< ": closing unended file"; - - fclose(f); - } - - /// GNU format message. - void message(String s); -}; -/// read a data file -class Data_file : private Text_stream -{ - - public: - bool rawmode; - - Text_stream::line; - Text_stream::eof; - Text_stream::get_name; - - char data_get(); - void data_unget(char c) { - unget(c); - } - - /// read line, eat #\n# - String get_line(); - - /// read a word till next space, leave space. Also does quotes - String get_word(); - - /// gobble horizontal white stuff. - void gobble_white(); - - /// gobble empty stuff before first field. - void gobble_leading_white(); - Data_file(String s) : Text_stream(s) { - //*mlog << "(" << s << flush; - rawmode= false; - } - - ~Data_file() { - // *mlog << ")"< +#include +#include "string.hh" +#include "varray.hh" + +/** + line counting input stream. + a stream for textfiles. linecounting. Thin interface getchar and + ungetchar. (ungetc is unlimited) + + should protect get and unget against improper use +*/ + + +class Text_stream +{ + int line_no; + + // could just have used streams. + FILE *f; + Array pushback; + String name; + + public: + Text_stream(String fn); + String get_name() { return name; } + bool eof() { + return feof(f); + } + bool eol() { + return (peek() == '\n'); + } + char peek() { + char c = get(); + unget(c); + return c; + } + int line(){ + return line_no; + } + + char get() { + char c; + + if (pushback.empty()) + c = getc(f); + else + c = pushback.pop(); + + if (c =='\n') + line_no++; + return c; + } + void unget(char c) { + if (c =='\n') + line_no--; + pushback.push(c); + } + ~Text_stream (){ + if (!eof()) + cerr <<__FUNCTION__<< ": closing unended file"; + + fclose(f); + } + + /// GNU format message. + void message(String s); +}; + +#endif