Let scaninc/preproc ignore empty asm files

This commit is contained in:
GriffinR 2023-02-27 12:47:35 -05:00
parent 588100e4ab
commit be84793713
2 changed files with 9 additions and 2 deletions

View File

@ -41,6 +41,8 @@ AsmFile::AsmFile(std::string filename) : m_filename(filename)
if (m_size < 0) if (m_size < 0)
FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str()); FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str());
else if (m_size == 0)
return; // Empty file
m_buffer = new char[m_size + 1]; m_buffer = new char[m_size + 1];
@ -73,7 +75,7 @@ AsmFile::AsmFile(AsmFile&& other) : m_filename(std::move(other.m_filename))
AsmFile::~AsmFile() AsmFile::~AsmFile()
{ {
delete[] m_buffer; if (m_size > 0) delete[] m_buffer;
} }
// Removes comments to simplify further processing. // Removes comments to simplify further processing.

View File

@ -36,6 +36,11 @@ AsmFile::AsmFile(std::string path)
m_size = std::ftell(fp); m_size = std::ftell(fp);
if (m_size < 0)
FATAL_ERROR("File size of \"%s\" is less than zero.\n", path.c_str());
else if (m_size == 0)
return; // Empty file
m_buffer = new char[m_size]; m_buffer = new char[m_size];
std::rewind(fp); std::rewind(fp);
@ -51,7 +56,7 @@ AsmFile::AsmFile(std::string path)
AsmFile::~AsmFile() AsmFile::~AsmFile()
{ {
delete[] m_buffer; if (m_size > 0) delete[] m_buffer;
} }
IncDirectiveType AsmFile::ReadUntilIncDirective(std::string &path) IncDirectiveType AsmFile::ReadUntilIncDirective(std::string &path)