aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/lex/rust-lex.h11
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);
}