Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/symal
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2015-04-15 23:50:54 +0300
committerHieu Hoang <hieuhoang@gmail.com>2015-04-15 23:50:54 +0300
commite279135d78ce2690bb17a5216d7eede715c77e1a (patch)
tree71d1f1ceacd60f6b6a1601549535c5b9d6c698e8 /symal
parent54c16ee86e47e29a407735fd8f1fc5cc3bac5518 (diff)
create file stream and delete it at the end if user has specified a file for input & output
Diffstat (limited to 'symal')
-rw-r--r--symal/symal.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/symal/symal.cpp b/symal/symal.cpp
index b0cec8251..249aa6caa 100644
--- a/symal/symal.cpp
+++ b/symal/symal.cpp
@@ -425,8 +425,6 @@ int main(int argc, char** argv)
istream *inp = &std::cin;
ostream *out = &std::cout;
- //fstream inp(input,ios::in);
- //fstream out(output,ios::out);
if (input) {
fstream *fin = new fstream(input,ios::in);
@@ -434,7 +432,7 @@ int main(int argc, char** argv)
cerr << "cannot open " << input << "\n";
exit(1);
}
- //inp = *fin;
+ inp = fin;
}
if (output) {
@@ -443,7 +441,7 @@ int main(int argc, char** argv)
cerr << "cannot open " << output << "\n";
exit(1);
}
- //out = *fout;
+ out = fout;
}
int a[MAX_M],b[MAX_N],m,n;
@@ -508,5 +506,12 @@ int main(int argc, char** argv)
for (int i=1; i<=MAX_N; i++) delete [] A[i];
delete [] A;
+ if (inp != &std::cin) {
+ delete inp;
+ }
+ if (out != &std::cout) {
+ delete inp;
+ }
+
exit(0);
}