diff options
author | CohenArthur <arthur.cohen@epita.fr> | 2021-05-31 20:21:34 +0200 |
---|---|---|
committer | CohenArthur <arthur.cohen@epita.fr> | 2021-05-31 22:32:56 +0200 |
commit | 5b0433b4beaee7adf59ad6ff79c83f4285a995b0 (patch) | |
tree | 6e488a2a3e61e34c4e1be217e2cb836adb9eed3b | |
parent | 75de60e68b46c555a87822a78d20c7197bddffb5 (diff) | |
download | gcc-5b0433b4beaee7adf59ad6ff79c83f4285a995b0.zip gcc-5b0433b4beaee7adf59ad6ff79c83f4285a995b0.tar.gz gcc-5b0433b4beaee7adf59ad6ff79c83f4285a995b0.tar.bz2 |
stdin: Allow compilation from standard input
-rw-r--r-- | gcc/rust/lex/rust-lex.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/gcc/rust/lex/rust-lex.h b/gcc/rust/lex/rust-lex.h index 5ac3a4b..8a9640e 100644 --- a/gcc/rust/lex/rust-lex.h +++ b/gcc/rust/lex/rust-lex.h @@ -16,7 +16,14 @@ private: FILE *file; public: - RAIIFile (const char *filename) : file (fopen (filename, "r")) {} + RAIIFile (const char *filename) + { + if (strncmp (filename, "-", 1) == 0) + file = stdin; + else + file = fopen (filename, "r"); + } + RAIIFile (const RAIIFile &other) = delete; RAIIFile &operator= (const RAIIFile &other) = delete; @@ -32,7 +39,7 @@ public: ~RAIIFile () { - if (file != nullptr) + if (file != nullptr && file != stdin) fclose (file); } |