mirror of
https://github.com/SAT-R/sa2.git
synced 2026-10-28 09:43:38 +00:00
do initial work to enable preproc processing
This commit is contained in:
1 parent
246f0d1b17
commit
66aba058c3
8 files changed
+59
-31
No files matched your search
@@ -1,6 +1,6 @@
|
||||
CXX := g++
|
||||
|
||||
CXXFLAGS := -std=c++11 -O2 -s -Wall -Wno-switch -Werror
|
||||
CXXFLAGS := -std=c++11 -O3 -Wall -Wno-switch -Werror
|
||||
|
||||
SRCS := asm_file.cpp c_file.cpp charmap.cpp preproc.cpp string_parser.cpp \
|
||||
utf8.cpp
|
||||
|
||||
@@ -476,11 +476,9 @@ void AsmFile::ExpectEmptyRestOfLine()
|
||||
m_lineStart = m_pos;
|
||||
m_lineNum++;
|
||||
}
|
||||
else if (m_buffer[m_pos] == '\r' && m_buffer[m_pos + 1] == '\n')
|
||||
else if (m_buffer[m_pos] == '\r')
|
||||
{
|
||||
m_pos += 2;
|
||||
m_lineStart = m_pos;
|
||||
m_lineNum++;
|
||||
RaiseError("only Unix-style LF newlines are supported");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -67,6 +67,14 @@ private:
|
||||
|
||||
CharmapReader::CharmapReader(std::string filename) : m_filename(filename)
|
||||
{
|
||||
if (filename == "")
|
||||
{
|
||||
m_size = 0;
|
||||
m_pos = 0;
|
||||
m_buffer = new char[1] {};
|
||||
return;
|
||||
}
|
||||
|
||||
FILE *fp = std::fopen(filename.c_str(), "rb");
|
||||
|
||||
if (fp == NULL)
|
||||
|
||||
+13
-16
@@ -132,30 +132,27 @@ char* GetFileExtension(char* filename)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 3)
|
||||
if (argc != 3 && argc != 2)
|
||||
{
|
||||
std::fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_charmap = new Charmap(argv[2]);
|
||||
g_charmap = new (std::nothrow) Charmap(argc == 3 ? argv[2] : "");
|
||||
if (!g_charmap)
|
||||
FATAL_ERROR("Failed to allocate space for Charmap.\n");
|
||||
|
||||
if (argv[1][0] == '-' && argv[1][1] == 0) {
|
||||
PreprocCFile("-");
|
||||
} else {
|
||||
char* extension = GetFileExtension(argv[1]);
|
||||
char* extension = GetFileExtension(argv[1]);
|
||||
|
||||
if (!extension)
|
||||
FATAL_ERROR("\"%s\" has no file extension.\n", argv[1]);
|
||||
|
||||
if ((extension[0] == 's') && extension[1] == 0)
|
||||
PreprocAsmFile(argv[1]);
|
||||
else if ((extension[0] == 'c' || extension[0] == 'i') && extension[1] == 0)
|
||||
PreprocCFile(argv[1]);
|
||||
else
|
||||
FATAL_ERROR("\"%s\" has an unknown file extension of \"%s\".\n", argv[1], extension);
|
||||
}
|
||||
if (!extension)
|
||||
FATAL_ERROR("\"%s\" has no file extension.\n", argv[1]);
|
||||
|
||||
if ((extension[0] == 's') && extension[1] == 0)
|
||||
PreprocAsmFile(argv[1]);
|
||||
else if ((extension[0] == 'c' || extension[0] == 'i') && extension[1] == 0)
|
||||
PreprocCFile(argv[1]);
|
||||
else
|
||||
FATAL_ERROR("\"%s\" has an unknown file extension of \"%s\".\n", argv[1], extension);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user