aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/lex/rust-lex.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/gcc/rust/lex/rust-lex.h b/gcc/rust/lex/rust-lex.h
index 00f9d21..ba37c63 100644
--- a/gcc/rust/lex/rust-lex.h
+++ b/gcc/rust/lex/rust-lex.h
@@ -15,6 +15,12 @@ struct RAIIFile
private:
FILE *file;
+ void close ()
+ {
+ if (file != nullptr && file != stdin)
+ fclose (file);
+ }
+
public:
RAIIFile (const char *filename)
{
@@ -31,17 +37,14 @@ public:
RAIIFile (RAIIFile &&other) : file (other.file) { other.file = nullptr; }
RAIIFile &operator= (RAIIFile &&other)
{
+ close ();
file = other.file;
other.file = nullptr;
return *this;
}
- ~RAIIFile ()
- {
- if (file != nullptr && file != stdin)
- fclose (file);
- }
+ ~RAIIFile () { close (); }
FILE *get_raw () { return file; }
};