# # # patch "ChangeLog" # from [6cbd487c772cb5a8934bc5ab6b063f82f1a21c2e] # to [d767f33edcae9a74f132aa11870c5b9ec118344f] # # patch "ui.cc" # from [a1622de96871c80dafc936cfd844660dc51803b0] # to [c14363bf4526326bf2b370dbd3611ead4eec0b2b] # ============================================================ --- ChangeLog 6cbd487c772cb5a8934bc5ab6b063f82f1a21c2e +++ ChangeLog d767f33edcae9a74f132aa11870c5b9ec118344f @@ -1,3 +1,9 @@ +2006-12-10 Richard Levitte + + * ui.cc (redirect_output_to, redirect_errors_to): Changed the + implementation to use cstdio's freopen(), so the redirection + is also recognised by C libraries we call, such as Lua. + 2006-12-09 Richard Levitte * ui.cc, ui.hh (redirect_output_to, redirect_errors_to): New ============================================================ --- ui.cc a1622de96871c80dafc936cfd844660dc51803b0 +++ ui.cc c14363bf4526326bf2b370dbd3611ead4eec0b2b @@ -28,6 +28,7 @@ #include #include +#include // Add #ifdeffage here as appropriate for other compiler-specific ways to // get this information. Windows note: as best I can determine from poking @@ -575,23 +576,15 @@ user_interface::redirect_output_to(syste void user_interface::redirect_output_to(system_path const & filename) { - static ofstream filestr; - if (filestr.is_open()) - filestr.close(); - filestr.open(filename.as_external().c_str(), ofstream::out | ofstream::app); - E(filestr.is_open(), F("failed to open log file '%s'") % filename); - cout.rdbuf(filestr.rdbuf()); + FILE *f = freopen(filename.as_external().c_str(), "a", stdout); + E(f, F("failed to open log file '%s'") % filename); } void user_interface::redirect_errors_to(system_path const & filename) { - static ofstream filestr; - if (filestr.is_open()) - filestr.close(); - filestr.open(filename.as_external().c_str(), ofstream::out | ofstream::app); - E(filestr.is_open(), F("failed to open log file '%s'") % filename); - cerr.rdbuf(filestr.rdbuf()); + FILE *f = freopen(filename.as_external().c_str(), "a", stderr); + E(f, F("failed to open log file '%s'") % filename); } void