-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
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
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
#########################################
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)
+++ /dev/null
-#include <fstream.h>
-#include <ctype.h>
-
-#include "textstr.hh"
-Text_stream::Text_stream(String fn)
-{
- if (fn == "")
- {
- name = "<STDIN>";
- 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"<<get_name() << ": " << line()<<": "<<s<<endl;
-}
-
-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;
- }
- }
-}
-
-
--- /dev/null
+#include <fstream.h>
+#include <ctype.h>
+
+#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;
+ }
+ }
+}
+
+
--- /dev/null
+/*
+ datafile.hh -- declare Data_file
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#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 << ")"<<flush;
+ }
+
+ warning(String s) {
+ message("warning: " + s);
+ }
+ error(String s){
+ message(s);
+ exit(1);
+ }
+};
+#endif // DATAFILE_HH
{
os = r;
silent = new Assoc<String,bool>;
+ indentlvl = 0;
if (!os)
return;
- indentlvl = 0;
const char * fn =cfg_nm ? cfg_nm : ".dstreamrc";
{
#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 */
+++ /dev/null
-
-#ifndef TEXTSTR_HH
-#define TEXTSTR_HH
-
-#include <stdio.h>
-#include <ctype.h>
-#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<char> 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 << ")"<<flush;
- }
-
- warning(String s) {
- message("warning: " + s);
- }
- error(String s){
- message(s);
- exit(1);
- }
-};
-#endif
--- /dev/null
+#include "textstream.hh"
+
+Text_stream::Text_stream(String fn)
+{
+ ios::sync_with_stdio();
+ if (fn == "")
+ {
+ name = "<STDIN>";
+ 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"<<get_name() << ": " << line()<<": "<<s<<endl;
+}
+
--- /dev/null
+
+#ifndef TEXTSTR_HH
+#define TEXTSTR_HH
+
+#include <stdio.h>
+#include <ctype.h>
+#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<char> 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