summaryrefslogtreecommitdiff
path: root/tools/preproc/preproc.cpp
diff options
context:
space:
mode:
authorGriffinR <griffin.g.richards@gmail.com>2021-06-13 17:51:17 -0400
committerGitHub <noreply@github.com>2021-06-13 17:51:17 -0400
commitb0dfaa92be48b4dc88af0c1502689fcad7da99ea (patch)
tree5b60e917fc89f39426fd54babfcb0dd5c12822c2 /tools/preproc/preproc.cpp
parentf85fb3af8923b7dce601591dede2d3bee0729d1e (diff)
parent7189e4e26f3da36ed9d373f77a9f51a36fc8ddaf (diff)
Merge pull request #1460 from luckytyphlosion/remove-temps
Buildsystem no longer builds temporary files for C compilation by default, and other makefile optimizations.
Diffstat (limited to 'tools/preproc/preproc.cpp')
-rw-r--r--tools/preproc/preproc.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/tools/preproc/preproc.cpp b/tools/preproc/preproc.cpp
index c9c6042df..eb2d4c8a2 100644
--- a/tools/preproc/preproc.cpp
+++ b/tools/preproc/preproc.cpp
@@ -103,9 +103,9 @@ void PreprocAsmFile(std::string filename)
}
}
-void PreprocCFile(std::string filename)
+void PreprocCFile(const char * filename, bool isStdin)
{
- CFile cFile(filename);
+ CFile cFile(filename, isStdin);
cFile.Preproc();
}
@@ -132,9 +132,9 @@ char* GetFileExtension(char* filename)
int main(int argc, char **argv)
{
- if (argc != 3)
+ if (argc < 3 || argc > 4)
{
- std::fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE", argv[0]);
+ std::fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE [-i]\nwhere -i denotes if input is from stdin\n", argv[0]);
return 1;
}
@@ -147,9 +147,17 @@ int main(int argc, char **argv)
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
+ else if ((extension[0] == 'c' || extension[0] == 'i') && extension[1] == 0) {
+ if (argc == 4) {
+ if (argv[3][0] == '-' && argv[3][1] == 'i' && argv[3][2] == '\0') {
+ PreprocCFile(argv[1], true);
+ } else {
+ FATAL_ERROR("unknown argument flag \"%s\".\n", argv[3]);
+ }
+ } else {
+ PreprocCFile(argv[1], false);
+ }
+ } else
FATAL_ERROR("\"%s\" has an unknown file extension of \"%s\".\n", argv[1], extension);
return 0;