24 void BufferedFileReader::fillBuffer() {
26 read = fread(buf,
sizeof(buf[0]),
BUFFERSIZE, fp);
34 static char eol[3] =
"\n\r";
35 static inline bool is_EOL(
char c) {
return c == eol[0] || c == eol[1]; }
38 if (
offset==read)
return false;
43 char *eolPos = (
char*)memchr(buf+offset, eol[0], rest);
46 eolPos = (
char*)memchr(buf+offset, eol[1], rest);
57 if (lineEnd>0 && lineEnd>offset && buf[lineEnd-1] == eol[1]) {
68 char lf = buf[lineEnd];
71 if (
offset == read) fillBuffer();
74 char nextChar = buf[
offset];
76 if (
offset == read) fillBuffer();
83 if (getLine_intern(rest)) line = line+rest;
90 static SmartCharPtr
buffer;
91 static size_t allocated = 0;
93 const string& source = getFilename();
97 len = msg.length()+source.length()+100;
100 len = msg.length()+100;
105 buffer = ARB_alloc<char>(allocated);
109 #if defined(ASSERTION_USED)
111 #endif // ASSERTION_USED
112 sprintf(&*buffer,
"%s:%zu: %s", source.c_str(), lineNumber, msg.c_str());
116 #if defined(ASSERTION_USED)
118 #endif // ASSERTION_USED
119 sprintf(&*buffer,
"while reading line #%zu:\n%s", lineNumber, msg.c_str());
return string(buffer, length)
bool getLine_intern(string &line) OVERRIDE
char buffer[MESSAGE_BUFFERSIZE]
string lineError(const string &msg) const
CONSTEXPR_INLINE_Cxx14 void swap(unsigned char &c1, unsigned char &c2)
static bool is_EOL(char c)