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