|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50942 - in branches/release: boost/date_time libs/date_time/test/posix_time libs/date_time/xmldoc
From: andrey.semashev_at_[hidden]
Date: 2009-02-01 06:29:44
Author: andysem
Date: 2009-02-01 06:29:43 EST (Sun, 01 Feb 2009)
New Revision: 50942
URL: http://svn.boost.org/trac/boost/changeset/50942
Log:
Merged fixes for #2688 and #2698 from trunk.
Text files modified:
branches/release/boost/date_time/date_facet.hpp | 5 +++--
branches/release/boost/date_time/filetime_functions.hpp | 1 +
branches/release/boost/date_time/strings_from_facet.hpp | 10 ++++++----
branches/release/libs/date_time/test/posix_time/testtime_facet.cpp | 16 +++++++++++++++-
branches/release/libs/date_time/xmldoc/changes.xml | 17 +++++++++++++++++
5 files changed, 42 insertions(+), 7 deletions(-)
Modified: branches/release/boost/date_time/date_facet.hpp
==============================================================================
--- branches/release/boost/date_time/date_facet.hpp (original)
+++ branches/release/boost/date_time/date_facet.hpp 2009-02-01 06:29:43 EST (Sun, 01 Feb 2009)
@@ -352,11 +352,12 @@
m_month_short_names[tm_value.tm_mon]);
}
// use time_put facet to create final string
+ const char_type* p_format = a_format.c_str();
return std::use_facet<std::time_put<CharT> >(a_ios.getloc()).put(next, a_ios,
fill_char,
&tm_value,
- &*a_format.begin(),
- &*a_format.begin()+a_format.size());
+ p_format,
+ p_format + a_format.size());
}
protected:
string_type m_format;
Modified: branches/release/boost/date_time/filetime_functions.hpp
==============================================================================
--- branches/release/boost/date_time/filetime_functions.hpp (original)
+++ branches/release/boost/date_time/filetime_functions.hpp 2009-02-01 06:29:43 EST (Sun, 01 Feb 2009)
@@ -25,6 +25,7 @@
#include <boost/cstdint.hpp>
#include <boost/date_time/time.hpp>
+#include <boost/date_time/date_defs.hpp>
namespace boost {
Modified: branches/release/boost/date_time/strings_from_facet.hpp
==============================================================================
--- branches/release/boost/date_time/strings_from_facet.hpp (original)
+++ branches/release/boost/date_time/strings_from_facet.hpp 2009-02-01 06:29:43 EST (Sun, 01 Feb 2009)
@@ -49,6 +49,7 @@
{
//grab the needed strings by using the locale to
//output each month
+ const charT* p_outfmt = outfmt.c_str(), *p_outfmt_end = p_outfmt + outfmt.size();
for (int m=0; m < 12; m++) {
tm tm_value;
tm_value.tm_mon = m;
@@ -56,8 +57,8 @@
ostream_iter_type oitr(ss);
std::use_facet<time_put_facet_type>(locale).put(oitr, ss, ss.fill(),
&tm_value,
- &*outfmt.begin(),
- &*outfmt.begin()+outfmt.size());
+ p_outfmt,
+ p_outfmt_end);
months.push_back(ss.str());
}
}
@@ -101,6 +102,7 @@
{
//grab the needed strings by using the locale to
//output each month / weekday
+ const charT* p_outfmt = outfmt.c_str(), *p_outfmt_end = p_outfmt + outfmt.size();
for (int i=0; i < 7; i++) {
tm tm_value;
tm_value.tm_wday = i;
@@ -108,8 +110,8 @@
ostream_iter_type oitr(ss);
std::use_facet<time_put_facet_type>(locale).put(oitr, ss, ss.fill(),
&tm_value,
- &*outfmt.begin(),
- &*outfmt.begin()+outfmt.size());
+ p_outfmt,
+ p_outfmt_end);
weekdays.push_back(ss.str());
}
Modified: branches/release/libs/date_time/test/posix_time/testtime_facet.cpp
==============================================================================
--- branches/release/libs/date_time/test/posix_time/testtime_facet.cpp (original)
+++ branches/release/libs/date_time/test/posix_time/testtime_facet.cpp 2009-02-01 06:29:43 EST (Sun, 01 Feb 2009)
@@ -196,7 +196,21 @@
check("Long negative time durations", ss.str() == std::string("-300:02:01"));
ss.str("");
}
-
+
+ // The test verifies that #2698 is fixed. That is, the time and date facet should
+ // not dereference end() iterator for the format string in do_put_tm.
+ {
+ boost::gregorian::date date(2009, 1, 1);
+ boost::posix_time::time_duration td(0, 0, 0, 0);
+ boost::posix_time::ptime boost_time(date, td);
+ std::stringstream sstr;
+
+ boost::posix_time::time_facet* pFacet = new boost::posix_time::time_facet("");
+ sstr.imbue(std::locale(std::locale::classic(), pFacet));
+
+ sstr << boost_time;
+ }
+
#if !defined(BOOST_NO_STD_WSTRING)
std::copy(&short_month_names[0],
&short_month_names[12],
Modified: branches/release/libs/date_time/xmldoc/changes.xml
==============================================================================
--- branches/release/libs/date_time/xmldoc/changes.xml (original)
+++ branches/release/libs/date_time/xmldoc/changes.xml 2009-02-01 06:29:43 EST (Sun, 01 Feb 2009)
@@ -118,6 +118,23 @@
</entry>
</row>
+ <row>
+ <entry>Bug fix</entry>
+ <entry>
+ Fixed missing include in <code>filetime_functions.hpp</code>
+ (<ulink url="https://svn.boost.org/trac/boost/ticket/2688">#2688</ulink>).
+ </entry>
+ </row>
+
+ <row>
+ <entry>Bug fix</entry>
+ <entry>
+ Fixed dereferencing end string iterators in different places of code,
+ which could cause crashes on MSVC
+ (<ulink url="https://svn.boost.org/trac/boost/ticket/2698">#2698</ulink>).
+ </entry>
+ </row>
+
</tbody>
</tgroup>
</informaltable>
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk