[PATCH 1/4] rtems-exeinfo.cpp: Restore ostream format

Ryan Long ryan.long at oarcorp.com
Mon Jul 19 17:13:30 UTC 2021


CID 1503006: Not restoring ostream format
CID 1503007: Not restoring ostream format

Used a variable to store the format of the ostream before any changes,
and copied what was originally there back into the stream before
returning from the function.

Closes #4469
---
 linkers/rtems-exeinfo.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/linkers/rtems-exeinfo.cpp b/linkers/rtems-exeinfo.cpp
index 6e92206..bc1ad45 100644
--- a/linkers/rtems-exeinfo.cpp
+++ b/linkers/rtems-exeinfo.cpp
@@ -31,6 +31,7 @@
 #endif
 
 #include <iostream>
+#include <fstream>
 #include <iomanip>
 
 #include <cxxabi.h>
@@ -366,6 +367,8 @@ namespace rld
        */
 
       rld::strings all_flags;
+      std::ofstream oldState;
+      oldState.copyfmt( std::cout );
 
       size_t source_max = 0;
 
@@ -512,6 +515,7 @@ namespace rld
       }
 
       std::cout << std::endl;
+      std::cout.copyfmt( oldState );
     }
 
     void
@@ -632,6 +636,9 @@ namespace rld
 
     void image::output_tls ()
     {
+      std::ofstream oldState;
+      oldState.copyfmt( std::cout );
+
       symbols::symbol* tls_data_begin = symbols.find_global("_TLS_Data_begin");
       symbols::symbol* tls_data_end = symbols.find_global("_TLS_Data_end");
       symbols::symbol* tls_data_size = symbols.find_global("_TLS_Data_size");
@@ -709,6 +716,8 @@ namespace rld
                 << std::endl
                 << std::dec << std::setfill (' ')
                 << std::endl;
+
+      std::cout.copyfmt( oldState );
     }
 
     void image::config(const std::string name)
-- 
1.8.3.1



More information about the devel mailing list