Merge pull request #315 from Diegoisawesome/master

Update scaninc and preproc with multi-file incbins
This commit is contained in:
Diegoisawesome
2018-09-06 12:54:49 -05:00
committed by GitHub
2 changed files with 69 additions and 52 deletions
+17 -9
View File
@@ -325,6 +325,10 @@ void CFile::TryConvertIncbin()
m_pos++; m_pos++;
std::printf("{");
while (true)
{
SkipWhitespace(); SkipWhitespace();
if (m_buffer[m_pos] != '"') if (m_buffer[m_pos] != '"')
@@ -357,15 +361,6 @@ void CFile::TryConvertIncbin()
m_pos++; m_pos++;
SkipWhitespace();
if (m_buffer[m_pos] != ')')
RaiseError("expected ')'");
m_pos++;
std::printf("{");
int fileSize; int fileSize;
std::unique_ptr<unsigned char[]> buffer = ReadWholeFile(path, fileSize); std::unique_ptr<unsigned char[]> buffer = ReadWholeFile(path, fileSize);
@@ -386,6 +381,19 @@ void CFile::TryConvertIncbin()
std::printf("%uu,", data); std::printf("%uu,", data);
} }
SkipWhitespace();
if (m_buffer[m_pos] != ',')
break;
m_pos++;
}
if (m_buffer[m_pos] != ')')
RaiseError("expected ')'");
m_pos++;
std::printf("}"); std::printf("}");
} }
+10 -1
View File
@@ -244,18 +244,27 @@ void CFile::CheckIncbin()
m_pos++; m_pos++;
while (true)
{
SkipWhitespace(); SkipWhitespace();
std::string path = ReadPath(); std::string path = ReadPath();
SkipWhitespace(); SkipWhitespace();
m_incbins.emplace(path);
if (m_buffer[m_pos] != ',')
break;
m_pos++;
}
if (m_buffer[m_pos] != ')') if (m_buffer[m_pos] != ')')
FATAL_INPUT_ERROR("expected ')'"); FATAL_INPUT_ERROR("expected ')'");
m_pos++; m_pos++;
m_incbins.emplace(path);
} }
std::string CFile::ReadPath() std::string CFile::ReadPath()