From eb0cc24c03e9194b84cd97d64a896dedf00cba18 Mon Sep 17 00:00:00 2001 From: fred Date: Wed, 19 Feb 1997 20:46:22 +0000 Subject: [PATCH] flower-1.1.0 --- flower/Sources.make | 12 ++-- flower/Variables.make | 10 +-- flower/{dataf.cc => datafile.cc} | 29 +------- flower/datafile.hh | 59 ++++++++++++++++ flower/dstream.cc | 2 +- flower/textdb.hh | 2 +- flower/textstr.hh | 116 ------------------------------- flower/textstream.cc | 31 +++++++++ flower/textstream.hh | 74 ++++++++++++++++++++ 9 files changed, 180 insertions(+), 155 deletions(-) rename flower/{dataf.cc => datafile.cc} (75%) create mode 100644 flower/datafile.hh delete mode 100644 flower/textstr.hh create mode 100644 flower/textstream.cc create mode 100644 flower/textstream.hh 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/datafile.cc similarity index 75% rename from flower/dataf.cc rename to flower/datafile.cc index 29b366c860..e5940b4c40 100644 --- a/flower/dataf.cc +++ b/flower/datafile.cc @@ -1,34 +1,7 @@ #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"< +*/ + + +#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 -- 2.39.5