consistent code with panda

This commit is contained in:
David Rose 2009-09-06 22:54:50 +00:00
parent 87776490b4
commit df671dc334

View File

@ -160,21 +160,16 @@ read_header(const string &pathname) {
char this_header[_header_size];
_in.seekg(0);
_in.read(this_header, _header_size);
if (_in.fail() || _in.gcount() != (unsigned)_header_size) {
nout
<< "Unable to read Multifile header " << pathname << ".\n";
return false;
}
// Here's a special case: if the multifile begins with a hash
// character, then we skip at least 6 characters, and continue
// reading and discarding lines of ASCII text, until we come across
// a nonempty line that does not begin with a hash character. This
// allows a P3D application (which is a multifile) to be run
// directly on the command line on Unix-based systems.
if (this_header[0] == '#') {
int ch = '#';
// character, then we continue reading and discarding lines of ASCII
// text, until we come across a nonempty line that does not begin
// with a hash character. This allows a P3D application (which is a
// multifile) to be run directly on the command line on Unix-based
// systems.
int ch = _in.get();
if (ch == '#') {
while (ch != EOF && ch == '#') {
// Skip to the end of the line.
while (ch != EOF && ch != '\n') {
@ -185,10 +180,14 @@ read_header(const string &pathname) {
ch = _in.get();
}
}
}
// Now fill up the header.
this_header[0] = ch;
_in.read(this_header + 1, _header_size - 1);
// Now read the actual Multifile header.
this_header[0] = ch;
_in.read(this_header + 1, _header_size - 1);
if (_in.fail() || _in.gcount() != (unsigned)(_header_size - 1)) {
nout << "Unable to read Multifile header: " << pathname << "\n";
return false;
}
if (memcmp(this_header, _header, _header_size) != 0) {