diff options
author | luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> | 2021-01-19 11:43:50 -0500 |
---|---|---|
committer | luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> | 2021-01-19 11:43:50 -0500 |
commit | 10c0566121cb923b7f4e6c1a97a1df8ad70cb327 (patch) | |
tree | 9aac83d3fd42c4c0331d6cb4c7d2dcf5fee69351 /tools/preproc/preproc.cpp | |
parent | 98f8c96c9e21791651d2274f07046496ab826ff2 (diff) |
Don't keep temporary C build files by default.
Diffstat (limited to 'tools/preproc/preproc.cpp')
-rw-r--r-- | tools/preproc/preproc.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/tools/preproc/preproc.cpp b/tools/preproc/preproc.cpp index c9c6042df..02950a296 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", 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; |