]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
utime: restore ostream state
authorSage Weil <sage@inktank.com>
Fri, 28 Sep 2012 14:10:05 +0000 (07:10 -0700)
committerSage Weil <sage@inktank.com>
Fri, 28 Sep 2012 20:18:05 +0000 (13:18 -0700)
CID 717130: Not restoring ostream format (STREAM_FORMAT_STATE)
At (4): Changing format state of stream "out" for category fill without later restoring it.

CID 717131: Not restoring ostream format (STREAM_FORMAT_STATE)
At (4): Changing format state of stream "out" for category fill without later restoring it.

Signed-off-by: Sage Weil <sage@inktank.com>
src/include/utime.h

index 2ef92a0eb2ed409b434f40aedbbaf239eb8c7d5a..5344f04ffc80140fa001c0987ed844ac1dd092d2 100644 (file)
@@ -132,6 +132,7 @@ public:
   // output
   ostream& gmtime(ostream& out) const {
     out.setf(std::ios::right);
+    char oldfill = out.fill();
     out.fill('0');
     if (sec() < ((time_t)(60*60*24*365*10))) {
       // raw seconds.  this looks like a relative time.
@@ -152,12 +153,14 @@ public:
       out << "." << std::setw(6) << usec();
       out << "Z";
     }
+    out.fill(oldfill);
     out.unsetf(std::ios::right);
     return out;
   }
 
   ostream& localtime(ostream& out) const {
     out.setf(std::ios::right);
+    char oldfill = out.fill();
     out.fill('0');
     if (sec() < ((time_t)(60*60*24*365*10))) {
       // raw seconds.  this looks like a relative time.
@@ -178,6 +181,7 @@ public:
       out << "." << std::setw(6) << usec();
       //out << '_' << bdt.tm_zone;
     }
+    out.fill(oldfill);
     out.unsetf(std::ios::right);
     return out;
   }