summaryrefslogtreecommitdiff
path: root/tools/preproc/preproc.cpp
diff options
context:
space:
mode:
authorGriffinR <griffin.g.richards@gmail.com>2021-08-02 14:08:10 -0400
committerGitHub <noreply@github.com>2021-08-02 14:08:10 -0400
commitbd5cf070597e9c9d175777832859ed0c64fe7760 (patch)
tree4dda9e759cbb4cf0c061c24a83832c59277f7d53 /tools/preproc/preproc.cpp
parent06b909bcd80e5b3f882273a317ac957cd57f07a5 (diff)
parentd391486247cc9f29d85787d6711f7cb993cf6585 (diff)
Merge branch 'master' into doc-playerpc
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;