source file of the GNU LilyPond music typesetter
- (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+ (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include <stdio.h>
#endif
#include "simple-file-storage.hh"
-#include "varray.hh"
+#include "array.hh"
#include "string.hh"
#include "warn.hh"
void
Simple_file_storage::load_stdin ()
{
- int data_len = 0;
len_i_ = 0;
int c;
if (!f)
{
- warning (_ ("can't open file `") + s + "'");
+ warning (_f ("Can't open file: `%s'", s));
return ;
}
ret = fread (data_p_, sizeof (char), len_i_, f);
if (ret!=len_i_)
- warning (_ ("Huh? got ") + String (ret) + _ (", expected ")
- + String (len_i_) + _ (" characters"));
+ warning (_f ("Huh? Got %d, expected %d characters", ret, len_i_));
fclose (f);
}
Should check IO status
This is of course a build it yourself version of mmap, so we should
- have been using that... (see Mapped_file_storage) But we noticed
- some problems with this (unexplained lexer crashes)
-
- [Some versions later] The crashes aren't caused by the mmap
- code. But no reason to take it out, is there? mmap ()
-
+ have been using that..., but this is simple & portable
+
*/
Simple_file_storage::Simple_file_storage (String s)
data_p_ = 0;
len_i_ = 0;
- if (!s.length_i ())
+ if (!s.length_i () || (s == "-"))
load_stdin ();
else
load_file (s);