summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/preproc/asm_file.cpp2
-rw-r--r--tools/preproc/c_file.cpp16
-rw-r--r--tools/preproc/preproc.cpp14
-rw-r--r--tools/scaninc/asm_file.cpp12
-rw-r--r--tools/scaninc/c_file.cpp54
-rw-r--r--tools/scaninc/c_file.h1
-rw-r--r--tools/scaninc/scaninc.cpp6
7 files changed, 31 insertions, 74 deletions
diff --git a/tools/preproc/asm_file.cpp b/tools/preproc/asm_file.cpp
index 49c9e3c66..bb296b78b 100644
--- a/tools/preproc/asm_file.cpp
+++ b/tools/preproc/asm_file.cpp
@@ -494,7 +494,7 @@ bool AsmFile::IsAtEnd()
// Output the current location to set gas's logical file and line numbers.
void AsmFile::OutputLocation()
{
- printf("# %ld \"%s\"\n", m_lineNum, m_filename.c_str());
+ std::printf("# %ld \"%s\"\n", m_lineNum, m_filename.c_str());
}
// Reports a diagnostic message.
diff --git a/tools/preproc/c_file.cpp b/tools/preproc/c_file.cpp
index a2f178623..5bfdee086 100644
--- a/tools/preproc/c_file.cpp
+++ b/tools/preproc/c_file.cpp
@@ -247,23 +247,23 @@ bool CFile::CheckIdentifier(const std::string& ident)
std::unique_ptr<unsigned char[]> CFile::ReadWholeFile(const std::string& path, int& size)
{
- FILE* fp = fopen(path.c_str(), "rb");
+ FILE* fp = std::fopen(path.c_str(), "rb");
if (fp == nullptr)
RaiseError("Failed to open \"%s\" for reading.\n", path.c_str());
- fseek(fp, 0, SEEK_END);
+ std::fseek(fp, 0, SEEK_END);
- size = ftell(fp);
+ size = std::ftell(fp);
std::unique_ptr<unsigned char[]> buffer = std::unique_ptr<unsigned char[]>(new unsigned char[size]);
- rewind(fp);
+ std::rewind(fp);
- if (fread(buffer.get(), size, 1, fp) != 1)
+ if (std::fread(buffer.get(), size, 1, fp) != 1)
RaiseError("Failed to read \"%s\".\n", path.c_str());
- fclose(fp);
+ std::fclose(fp);
return buffer;
}
@@ -379,9 +379,9 @@ void CFile::TryConvertIncbin()
offset += size;
if (isSigned)
- printf("%d,", data);
+ std::printf("%d,", data);
else
- printf("%uu,", data);
+ std::printf("%uu,", data);
}
std::printf("}");
diff --git a/tools/preproc/preproc.cpp b/tools/preproc/preproc.cpp
index b51861580..8320a2d27 100644
--- a/tools/preproc/preproc.cpp
+++ b/tools/preproc/preproc.cpp
@@ -31,15 +31,15 @@ void PrintAsmBytes(unsigned char *s, int length)
{
if (length > 0)
{
- printf("\t.byte ");
+ std::printf("\t.byte ");
for (int i = 0; i < length; i++)
{
- printf("0x%02X", s[i]);
+ std::printf("0x%02X", s[i]);
if (i < length - 1)
- printf(", ");
+ std::printf(", ");
}
- putchar('\n');
+ std::putchar('\n');
}
}
@@ -89,8 +89,8 @@ void PreprocAsmFile(std::string filename)
if (globalLabel.length() != 0)
{
- printf("\t.global %s\n", globalLabel.c_str());
- printf("%s:\n", globalLabel.c_str());
+ std::printf("\t.global %s\n", globalLabel.c_str());
+ std::printf("%s:\n", globalLabel.c_str());
}
else
{
@@ -134,7 +134,7 @@ int main(int argc, char **argv)
{
if (argc != 3)
{
- fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE", argv[0]);
+ std::fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE", argv[0]);
return 1;
}
diff --git a/tools/scaninc/asm_file.cpp b/tools/scaninc/asm_file.cpp
index 143c70242..c3d140bb1 100644
--- a/tools/scaninc/asm_file.cpp
+++ b/tools/scaninc/asm_file.cpp
@@ -27,23 +27,23 @@ AsmFile::AsmFile(std::string path)
{
m_path = path;
- FILE *fp = fopen(path.c_str(), "rb");
+ FILE *fp = std::fopen(path.c_str(), "rb");
if (fp == NULL)
FATAL_ERROR("Failed to open \"%s\" for reading.\n", path.c_str());
- fseek(fp, 0, SEEK_END);
+ std::fseek(fp, 0, SEEK_END);
- m_size = ftell(fp);
+ m_size = std::ftell(fp);
m_buffer = new char[m_size];
- rewind(fp);
+ std::rewind(fp);
- if (fread(m_buffer, m_size, 1, fp) != 1)
+ if (std::fread(m_buffer, m_size, 1, fp) != 1)
FATAL_ERROR("Failed to read \"%s\".\n", path.c_str());
- fclose(fp);
+ std::fclose(fp);
m_pos = 0;
m_lineNum = 1;
diff --git a/tools/scaninc/c_file.cpp b/tools/scaninc/c_file.cpp
index bb84fedbe..b82276dd6 100644
--- a/tools/scaninc/c_file.cpp
+++ b/tools/scaninc/c_file.cpp
@@ -24,24 +24,24 @@ CFile::CFile(std::string path)
{
m_path = path;
- FILE *fp = fopen(path.c_str(), "rb");
+ FILE *fp = std::fopen(path.c_str(), "rb");
if (fp == NULL)
FATAL_ERROR("Failed to open \"%s\" for reading.\n", path.c_str());
- fseek(fp, 0, SEEK_END);
+ std::fseek(fp, 0, SEEK_END);
- m_size = ftell(fp);
+ m_size = std::ftell(fp);
m_buffer = new char[m_size + 1];
m_buffer[m_size] = 0;
- rewind(fp);
+ std::rewind(fp);
- if (fread(m_buffer, m_size, 1, fp) != 1)
+ if (std::fread(m_buffer, m_size, 1, fp) != 1)
FATAL_ERROR("Failed to read \"%s\".\n", path.c_str());
- fclose(fp);
+ std::fclose(fp);
m_pos = 0;
m_lineNum = 1;
@@ -211,48 +211,6 @@ bool CFile::CheckIdentifier(const std::string& ident)
return (i == ident.length());
}
-std::unique_ptr<unsigned char[]> CFile::ReadWholeFile(const std::string& path, int& size)
-{
- FILE* fp = fopen(path.c_str(), "rb");
-
- if (fp == nullptr)
- FATAL_INPUT_ERROR("Failed to open \"%s\" for reading.\n", path.c_str());
-
- fseek(fp, 0, SEEK_END);
-
- size = ftell(fp);
-
- std::unique_ptr<unsigned char[]> buffer = std::unique_ptr<unsigned char[]>(new unsigned char[size]);
-
- rewind(fp);
-
- if (fread(buffer.get(), size, 1, fp) != 1)
- FATAL_INPUT_ERROR("Failed to read \"%s\".\n", path.c_str());
-
- fclose(fp);
-
- return buffer;
-}
-
-int ExtractData(const std::unique_ptr<unsigned char[]>& buffer, int offset, int size)
-{
- switch (size)
- {
- case 1:
- return buffer[offset];
- case 2:
- return (buffer[offset + 1] << 8)
- | buffer[offset];
- case 4:
- return (buffer[offset + 3] << 24)
- | (buffer[offset + 2] << 16)
- | (buffer[offset + 1] << 8)
- | buffer[offset];
- default:
- FATAL_ERROR("Invalid size passed to ExtractData.\n");
- }
-}
-
void CFile::CheckIncbin()
{
std::string idents[6] = { "INCBIN_S8", "INCBIN_U8", "INCBIN_S16", "INCBIN_U16", "INCBIN_S32", "INCBIN_U32" };
diff --git a/tools/scaninc/c_file.h b/tools/scaninc/c_file.h
index 2503acac1..922cb4639 100644
--- a/tools/scaninc/c_file.h
+++ b/tools/scaninc/c_file.h
@@ -46,7 +46,6 @@ private:
bool ConsumeHorizontalWhitespace();
bool ConsumeNewline();
void SkipWhitespace();
- std::unique_ptr<unsigned char[]> ReadWholeFile(const std::string& path, int& size);
bool CheckIdentifier(const std::string& ident);
void CheckIncbin();
};
diff --git a/tools/scaninc/scaninc.cpp b/tools/scaninc/scaninc.cpp
index 2f9ed81e9..b6f7ba767 100644
--- a/tools/scaninc/scaninc.cpp
+++ b/tools/scaninc/scaninc.cpp
@@ -29,12 +29,12 @@
bool CanOpenFile(std::string path)
{
- FILE *fp = fopen(path.c_str(), "rb");
+ FILE *fp = std::fopen(path.c_str(), "rb");
if (fp == NULL)
return false;
- fclose(fp);
+ std::fclose(fp);
return true;
}
@@ -92,6 +92,6 @@ int main(int argc, char **argv)
for (const std::string &path : dependencies)
{
- printf("%s\n", path.c_str());
+ std::printf("%s\n", path.c_str());
}
}