]> git.donarmstrong.com Git - lilypond.git/blob - flower/data-file.cc
lpb and l2d fixes
[lilypond.git] / flower / data-file.cc
1 /*   
2   data-file.cc --  implement Data_file 
3   
4   source file of the Flower Library
5   
6   (c) '95, '96, '97 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7
8   DEPRECATED
9   
10   */
11 #include <ctype.h>
12 #include <stdlib.h>
13
14 #include "international.hh"
15 #include "data-file.hh"
16
17 void
18 Data_file::gobble_white ()
19 {
20   char c;
21
22   while ((c=data_get ()) == ' ' ||c == '\t')
23     if (eof_b ())
24       return;
25
26   data_unget (c);
27 }
28
29 String
30 Data_file::get_word ()
31 {// should handle escape seq's
32   String s;
33
34   while (1)
35     {
36       char      c  = data_get ();
37       
38       if (eof_b ())
39         break;
40
41       if (isspace (c))
42         {
43           data_unget (c);
44           break;
45         }
46
47
48       if (c == '\"')
49         {
50           rawmode= true;
51
52           while ((c  = data_get ()) != '\"')
53             if (eof_b ())
54               error (_ ("EOF in a string"));
55             else
56               s += to_str (c);
57
58
59           rawmode= false;
60         }
61       else
62         s += to_str (c);
63     }
64
65   return s;
66 }
67
68 char
69 Data_file::data_get ()
70 {
71   char c =  get ();
72   if (!rawmode && c == '#') // gobble comment
73     {
74       while (!eof_b () && (c = get ()) != '\n')
75         ;
76       return '\n';
77     }
78
79   return c;
80 }
81
82 String
83 Data_file::get_line ()
84 {
85   char c;
86   String s;
87
88   while (!eof_b () && (c  = data_get ()) != '\n')
89     s += to_str (c);
90   return s;
91 }
92
93 void
94 Data_file::gobble_leading_white ()
95 {
96   // eat blank lines.
97   while (!eof_b ())
98     {
99       char c = data_get ();
100       if (!isspace (c))
101         {
102           data_unget (c);
103           break;
104         }
105     }
106 }
107
108 Data_file::Data_file (String s)
109   : Text_stream (s) 
110 {
111   //*mlog << " (" << s << flush;        
112   rawmode=  false;      
113 }
114
115 void
116 Data_file::warning (String s)
117 {
118   message (_ ("warning: ") + s);
119 }
120
121 void
122 Data_file::error (String s)
123 {
124   message (s);
125   exit (1);    
126 }
127
128 String
129 Data_file::gulp ()
130 {
131   String s;
132
133   while (!eof_b ())
134     {
135       s += to_str (data_get ());
136     }
137   return s;
138 }
139   
140
141 Data_file::~Data_file ()
142 {
143 }