ConvertObj: insist on proper "first" record and version

This commit is contained in:
Wolfgang Thaller 2019-01-23 23:10:57 +01:00
parent 2cf217fb64
commit 3327705fb3

View File

@ -282,6 +282,32 @@ int main(int argc, char* argv[])
std::shared_ptr<Module> module;
std::vector<std::shared_ptr<Module>> modules;
{
int firstRecord = byte(in);
/*int flags =*/ byte(in);
int version = word(in);
if(firstRecord != kFirst)
{
std::cerr << "Not an MPW object file.\n";
return 1;
}
if(version > 3)
{
std::cerr << "Unknown/invalid MPW object file version "
<< version << std::endl;
return 1;
}
if(verbose)
{
std::cerr << "First\n";
std::cerr << "Version: " << version << std::endl;
}
}
std::cout << "\t.text\n\t.align 2\n";
for(bool endOfObject = false; !endOfObject;) {
@ -304,17 +330,6 @@ int main(int argc, char* argv[])
if(verbose)
std::cerr << "Pad\n";
break;
case kFirst:
{
/*int flags =*/ byte(in);
int version = word(in);
if(verbose)
{
std::cerr << "First\n";
std::cerr << "Version: " << version << std::endl;
}
}
break;
case kComment:
{
/*int flags =*/ byte(in);