]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/text-stream.cc
release: 1.3.18
[lilypond.git] / flower / text-stream.cc
index 530c6f8ecd5f1c5b5b84fa7627b3b3e6c1ab70ab..cb88bcd498165d5db03eff0170050c90c5b524cf 100644 (file)
@@ -1,32 +1,50 @@
+#include <iostream.h>
 #include "text-stream.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);
-         }
+  if (fn == "")
+    {
+      name = _ ("<stdin>");
+      f = stdin;
+    }
+
+  else
+    {
+      name = fn;
+      f = fopen (fn.ch_C (), "r");
+    }
 
-       line_no = 1;
+  if (!f)
+    {
+      cerr << __FUNCTION__ 
+          << ": " << _f ("Can't open file: `%s'", fn) << '\n';
+      exit (1);
     }
 
+  line_no = 1;
+}
+
 void
 Text_stream::message (String s)
 {
-  cerr << "\n"<<get_name() << ": " << line ()<<": "<<s<<endl;
+  cerr << '\n'<<get_name() << ": " << line ()<<": "<<s<<endl;
 }
 
+bool
+Text_stream::eof_b ()
+{
+  /* UGH UGH ugh*/
+    return
+      // !pushback.size () && 
+      feof (f);
+}
+
+Text_stream::~Text_stream()
+{
+    if (!eof_b()) 
+      cerr <<__FUNCTION__<< ": closing unended file";
+    
+    fclose (f);
+  }