]> git.donarmstrong.com Git - lilypond.git/blob - flower/text-stream.cc
e6a1202a14769970432b83edced5768433eba07b
[lilypond.git] / flower / text-stream.cc
1 #include <stdlib.h>
2 #include <iostream.h>
3 #include "text-stream.hh"
4
5 Text_stream::Text_stream (String fn)
6 {
7   ios::sync_with_stdio ();
8   if (fn == "")
9     {
10       name = _ ("<stdin>");
11       f = stdin;
12     }
13
14   else
15     {
16       name = fn;
17       f = fopen (fn.ch_C (), "r");
18     }
19
20   if (!f)
21     {
22       cerr << __FUNCTION__ 
23            << ": " << _f ("can't open file: `%s'", fn) << '\n';
24       exit (1);
25     }
26
27   line_no = 1;
28 }
29
30 void
31 Text_stream::message (String s)
32 {
33   cerr << '\n'<<get_name () << ": " << line ()<<": "<<s<<endl;
34 }
35
36 bool
37 Text_stream::eof_b ()
38 {
39   /* UGH UGH ugh*/
40     return
41       // !pushback.size () && 
42       feof (f);
43 }
44
45 Text_stream::~Text_stream ()
46 {
47     if (!eof_b ()) 
48       cerr <<__FUNCTION__<< ": closing unended file";
49     
50     fclose (f);
51   }