From 2c3ff62e1b6ab1bba1ec858c2adf3c4459a92bb1 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Tue, 16 Dec 2003 13:05:22 +0000 Subject: [PATCH] Added explicit calls to fstream::close rather than relying on destructors as a tentative gcc-cygwin fix. [SVN r21287] --- example/snippets/partial_regex_grep.cpp | 1 + example/snippets/regex_grep_example_1.cpp | 1 + example/snippets/regex_grep_example_2.cpp | 1 + example/snippets/regex_grep_example_3.cpp | 1 + example/snippets/regex_grep_example_4.cpp | 1 + example/snippets/regex_iterator_example.cpp | 1 + example/snippets/regex_merge_example.cpp | 2 ++ example/snippets/regex_replace_example.cpp | 2 ++ example/snippets/regex_search_example.cpp | 1 + example/snippets/regex_split_example_2.cpp | 2 ++ example/snippets/regex_token_iterator_eg_2.cpp | 2 ++ example/timer/regex_timer.cpp | 3 +++ 12 files changed, 18 insertions(+) diff --git a/example/snippets/partial_regex_grep.cpp b/example/snippets/partial_regex_grep.cpp index 016d6fb5..0e4e7f65 100644 --- a/example/snippets/partial_regex_grep.cpp +++ b/example/snippets/partial_regex_grep.cpp @@ -79,6 +79,7 @@ int main(int argc, char* argv[]) std::ifstream fs(argv[i]); if(fs.bad()) continue; search(fs); + fs.close(); } } else diff --git a/example/snippets/regex_grep_example_1.cpp b/example/snippets/regex_grep_example_1.cpp index 90298fa5..bb8bcbef 100644 --- a/example/snippets/regex_grep_example_1.cpp +++ b/example/snippets/regex_grep_example_1.cpp @@ -105,6 +105,7 @@ int main(int argc, const char** argv) map_type m; std::ifstream fs(argv[i]); load_file(text, fs); + fs.close(); IndexClasses(m, text); cout << m.size() << " matches found" << endl; map_type::iterator c, d; diff --git a/example/snippets/regex_grep_example_2.cpp b/example/snippets/regex_grep_example_2.cpp index daa01c19..1a90357e 100644 --- a/example/snippets/regex_grep_example_2.cpp +++ b/example/snippets/regex_grep_example_2.cpp @@ -101,6 +101,7 @@ int main(int argc, const char** argv) cout << "Processing file " << argv[i] << endl; std::ifstream fs(argv[i]); load_file(text, fs); + fs.close(); IndexClasses(text); cout << class_index.size() << " matches found" << endl; map_type::iterator c, d; diff --git a/example/snippets/regex_grep_example_3.cpp b/example/snippets/regex_grep_example_3.cpp index 66f44fd7..163dc979 100644 --- a/example/snippets/regex_grep_example_3.cpp +++ b/example/snippets/regex_grep_example_3.cpp @@ -124,6 +124,7 @@ int main(int argc, const char** argv) cout << "Processing file " << argv[i] << endl; std::ifstream fs(argv[i]); load_file(text, fs); + fs.close(); class_index idx; idx.IndexClasses(text); cout << idx.get_map().size() << " matches found" << endl; diff --git a/example/snippets/regex_grep_example_4.cpp b/example/snippets/regex_grep_example_4.cpp index 20e222d6..f259ef4b 100644 --- a/example/snippets/regex_grep_example_4.cpp +++ b/example/snippets/regex_grep_example_4.cpp @@ -123,6 +123,7 @@ int main(int argc, const char** argv) cout << "Processing file " << argv[i] << endl; std::ifstream fs(argv[i]); load_file(text, fs); + fs.close(); class_index i; i.IndexClasses(text); cout << i.get_map().size() << " matches found" << endl; diff --git a/example/snippets/regex_iterator_example.cpp b/example/snippets/regex_iterator_example.cpp index a541ffb0..dca22572 100644 --- a/example/snippets/regex_iterator_example.cpp +++ b/example/snippets/regex_iterator_example.cpp @@ -89,6 +89,7 @@ int main(int argc, const char** argv) cout << "Processing file " << argv[i] << endl; std::ifstream fs(argv[i]); load_file(text, fs); + fs.close(); // construct our iterators: boost::sregex_iterator m1(text.begin(), text.end(), expression); boost::sregex_iterator m2; diff --git a/example/snippets/regex_merge_example.cpp b/example/snippets/regex_merge_example.cpp index 54eb3499..f40cf64e 100644 --- a/example/snippets/regex_merge_example.cpp +++ b/example/snippets/regex_merge_example.cpp @@ -62,6 +62,7 @@ int main(int argc, const char** argv) std::ifstream fs(argv[i]); std::string in; load_file(in, fs); + fs.close(); std::string out_name = std::string(argv[i]) + std::string(".htm"); std::ofstream os(out_name.c_str()); os << header_text; @@ -76,6 +77,7 @@ int main(int argc, const char** argv) std::ostream_iterator out(os); boost::regex_merge(out, s.begin(), s.end(), e1, format_string, boost::match_default | boost::format_all); os << footer_text; + os.close(); } } catch(...) diff --git a/example/snippets/regex_replace_example.cpp b/example/snippets/regex_replace_example.cpp index a89a8156..326ef6e6 100644 --- a/example/snippets/regex_replace_example.cpp +++ b/example/snippets/regex_replace_example.cpp @@ -62,6 +62,7 @@ int main(int argc, const char** argv) std::ifstream fs(argv[i]); std::string in; load_file(in, fs); + fs.close(); std::string out_name = std::string(argv[i]) + std::string(".htm"); std::ofstream os(out_name.c_str()); os << header_text; @@ -76,6 +77,7 @@ int main(int argc, const char** argv) std::ostream_iterator out(os); boost::regex_replace(out, s.begin(), s.end(), e1, format_string, boost::match_default | boost::format_all); os << footer_text; + os.close(); } } catch(...) diff --git a/example/snippets/regex_search_example.cpp b/example/snippets/regex_search_example.cpp index c7dd2f16..175047ae 100644 --- a/example/snippets/regex_search_example.cpp +++ b/example/snippets/regex_search_example.cpp @@ -103,6 +103,7 @@ int main(int argc, const char** argv) map_type m; std::ifstream fs(argv[i]); load_file(text, fs); + fs.close(); IndexClasses(m, text); cout << m.size() << " matches found" << endl; map_type::iterator c, d; diff --git a/example/snippets/regex_split_example_2.cpp b/example/snippets/regex_split_example_2.cpp index 8a05e942..c0fd4ea2 100644 --- a/example/snippets/regex_split_example_2.cpp +++ b/example/snippets/regex_split_example_2.cpp @@ -55,6 +55,7 @@ int main(int argc, char** argv) s.erase(); std::ifstream is(argv[i]); load_file(s, is); + is.close(); boost::regex_split(std::back_inserter(l), s, e); while(l.size()) { @@ -74,6 +75,7 @@ int main(int argc, char** argv) s.erase(); std::ifstream is(argv[i]); load_file(s, is); + is.close(); while(boost::regex_split(std::ostream_iterator(std::cout), s, e, boost::match_default, 1)) std::cout << std::endl; } diff --git a/example/snippets/regex_token_iterator_eg_2.cpp b/example/snippets/regex_token_iterator_eg_2.cpp index 0eef3c30..9883fb08 100644 --- a/example/snippets/regex_token_iterator_eg_2.cpp +++ b/example/snippets/regex_token_iterator_eg_2.cpp @@ -53,6 +53,7 @@ int main(int argc, char** argv) s.erase(); std::ifstream is(argv[i]); load_file(s, is); + is.close(); boost::sregex_token_iterator i(s.begin(), s.end(), e, 1); boost::sregex_token_iterator j; while(i != j) @@ -71,6 +72,7 @@ int main(int argc, char** argv) s.erase(); std::ifstream is(argv[i]); load_file(s, is); + is.close(); const int subs[] = {1, 0,}; boost::sregex_token_iterator i(s.begin(), s.end(), e, subs); boost::sregex_token_iterator j; diff --git a/example/timer/regex_timer.cpp b/example/timer/regex_timer.cpp index c29504ad..5e92cf7f 100644 --- a/example/timer/regex_timer.cpp +++ b/example/timer/regex_timer.cpp @@ -359,7 +359,10 @@ int main(int argc, char**argv) } if(pbuf) + { cin.rdbuf(pbuf); + ifs.close(); + } return 0; }