diff --git a/src/value.cpp b/src/value.cpp index d35ee84e..8e5ebe37 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -20,14 +20,14 @@ */ /* File: value.cpp - Version: $Name: $ $Revision: 1.2 $ + Version: $Name: $ $Revision: 1.3 $ Author(s): Andreas Huggel (ahu) History: 26-Jan-04, ahu: created 11-Feb-04, ahu: isolated as a component */ // ***************************************************************************** #include "rcsid.hpp" -EXIV2_RCSID("@(#) $Name: $ $Revision: 1.2 $ $RCSfile: value.cpp,v $") +EXIV2_RCSID("@(#) $Name: $ $Revision: 1.3 $ $RCSfile: value.cpp,v $") // ***************************************************************************** // included header files @@ -187,14 +187,9 @@ namespace Exif { std::ostream& AsciiValue::write(std::ostream& os) const { - // Strip trailing '\0', if any - if (value_.size() > 0 && value_[value_.size() - 1] == '\0') { - os << value_.substr(0, value_.size() - 1); - } - else { - os << value_; - } - return os; + // Strip all trailing '\0's (if any) + std::string::size_type pos = value_.find_last_not_of('\0'); + return os << value_.substr(0, pos + 1); } } // namespace Exif diff --git a/src/value.hpp b/src/value.hpp index f0354959..47b9ed72 100644 --- a/src/value.hpp +++ b/src/value.hpp @@ -21,7 +21,7 @@ /*! @file value.hpp @brief Value interface and concrete subclasses - @version $Name: $ $Revision: 1.4 $ + @version $Name: $ $Revision: 1.5 $ @author Andreas Huggel (ahu) ahuggel@gmx.net @date 09-Jan-04, ahu: created @@ -268,9 +268,9 @@ namespace Exif { virtual long size() const; virtual Value* clone() const; /*! - @brief Write the value to an output stream. One trailing '\\0' - character of the ASCII value is stripped if present and not - written to the output stream. + @brief Write the value to an output stream. Any trailing '\\0' + characters of the ASCII value are stripped and not written to + the output stream. */ virtual std::ostream& write(std::ostream& os) const; virtual long toLong(long n =0) const { return value_[n]; }