summaryrefslogtreecommitdiff
path: root/tools/preproc/preproc.cpp
diff options
context:
space:
mode:
authorhuderlem <huderlem@gmail.com>2019-03-18 18:23:47 -0500
committerGitHub <noreply@github.com>2019-03-18 18:23:47 -0500
commitf9543a54fd857d600668e6512dc31eb0c3da6403 (patch)
treeb17cd21d191a2e33de6764b985179dd78ef3bcb1 /tools/preproc/preproc.cpp
parentb2bedda2a123a13ccaefdd09342c953d397edbd2 (diff)
parentd4f953f87af7b1354d6dfb8593424375fc9f18a2 (diff)
Merge pull request #727 from PikalaxALT/preproc_stdin
preproc supports GNU-processed C pipe from stdin
Diffstat (limited to 'tools/preproc/preproc.cpp')
-rw-r--r--tools/preproc/preproc.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/tools/preproc/preproc.cpp b/tools/preproc/preproc.cpp
index c9c6042df..2d51ab175 100644
--- a/tools/preproc/preproc.cpp
+++ b/tools/preproc/preproc.cpp
@@ -140,17 +140,22 @@ int main(int argc, char **argv)
g_charmap = new Charmap(argv[2]);
- char* extension = GetFileExtension(argv[1]);
-
- if (!extension)
- FATAL_ERROR("\"%s\" has no file extension.\n", argv[1]);
+ if (argv[1][0] == '-' && argv[1][1] == 0) {
+ PreprocCFile("-");
+ } else {
+ 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[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;
}