summaryrefslogtreecommitdiff
path: root/boost/date_time/format_date_parser.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/date_time/format_date_parser.hpp')
-rw-r--r--boost/date_time/format_date_parser.hpp34
1 files changed, 11 insertions, 23 deletions
diff --git a/boost/date_time/format_date_parser.hpp b/boost/date_time/format_date_parser.hpp
index 4a76529f6c..a40dee6fb6 100644
--- a/boost/date_time/format_date_parser.hpp
+++ b/boost/date_time/format_date_parser.hpp
@@ -7,7 +7,7 @@
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
- * $Date: 2009-06-04 01:24:49 -0700 (Thu, 04 Jun 2009) $
+ * $Date$
*/
@@ -63,7 +63,7 @@ fixed_string_to_int(std::istreambuf_iterator<charT>& itr,
itr++;
j++;
}
- int_type i = -1;
+ int_type i = static_cast<int_type>(-1);
// mr.cache will hold leading zeros. size() tells us when input is too short.
if(mr.cache.size() < length) {
return i;
@@ -111,7 +111,7 @@ var_string_to_int(std::istreambuf_iterator<charT>& itr,
++itr;
++j;
}
- int_type i = -1;
+ int_type i = static_cast<int_type>(-1);
if(!s.empty()) {
i = boost::lexical_cast<int_type>(s);
}
@@ -256,7 +256,6 @@ class format_date_parser
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
- charT current_char = *sitr;
short year(0), month(0), day(0), day_of_year(0);// wkday(0);
/* Initialized the following to their minimum values. These intermediate
@@ -272,7 +271,8 @@ class format_date_parser
const_itr itr(format_str.begin());
while (itr != format_str.end() && (sitr != stream_end)) {
if (*itr == '%') {
- itr++;
+ if ( ++itr == format_str.end())
+ break;
if (*itr != '%') {
switch(*itr) {
case 'a':
@@ -290,7 +290,6 @@ class format_date_parser
}
wkday = mr.current_match;
if (mr.has_remaining()) {
- current_char = mr.last_char();
use_current_char = true;
}
break;
@@ -310,7 +309,6 @@ class format_date_parser
}
wkday = mr.current_match;
if (mr.has_remaining()) {
- current_char = mr.last_char();
use_current_char = true;
}
break;
@@ -326,7 +324,6 @@ class format_date_parser
}
t_month = month_type(mr.current_match);
if (mr.has_remaining()) {
- current_char = mr.last_char();
use_current_char = true;
}
break;
@@ -342,7 +339,6 @@ class format_date_parser
}
t_month = month_type(mr.current_match);
if (mr.has_remaining()) {
- current_char = mr.last_char();
use_current_char = true;
}
break;
@@ -438,7 +434,6 @@ class format_date_parser
itr++;
if (use_current_char) {
use_current_char = false;
- current_char = *sitr;
}
else {
sitr++;
@@ -476,14 +471,14 @@ class format_date_parser
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
- charT current_char = *sitr;
short month(0);
const_itr itr(format_str.begin());
while (itr != format_str.end() && (sitr != stream_end)) {
if (*itr == '%') {
- itr++;
+ if ( ++itr == format_str.end())
+ break;
if (*itr != '%') {
switch(*itr) {
case 'b':
@@ -491,7 +486,6 @@ class format_date_parser
mr = m_month_short_names.match(sitr, stream_end);
month = mr.current_match;
if (mr.has_remaining()) {
- current_char = mr.last_char();
use_current_char = true;
}
break;
@@ -501,7 +495,6 @@ class format_date_parser
mr = m_month_long_names.match(sitr, stream_end);
month = mr.current_match;
if (mr.has_remaining()) {
- current_char = mr.last_char();
use_current_char = true;
}
break;
@@ -529,7 +522,6 @@ class format_date_parser
itr++;
if (use_current_char) {
use_current_char = false;
- current_char = *sitr;
}
else {
sitr++;
@@ -581,14 +573,14 @@ class format_date_parser
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
- charT current_char = *sitr;
short wkday(0);
const_itr itr(format_str.begin());
while (itr != format_str.end() && (sitr != stream_end)) {
if (*itr == '%') {
- itr++;
+ if ( ++itr == format_str.end())
+ break;
if (*itr != '%') {
switch(*itr) {
case 'a':
@@ -600,7 +592,6 @@ class format_date_parser
mr = m_weekday_short_names.match(sitr, stream_end);
wkday = mr.current_match;
if (mr.has_remaining()) {
- current_char = mr.last_char();
use_current_char = true;
}
break;
@@ -614,7 +605,6 @@ class format_date_parser
mr = m_weekday_long_names.match(sitr, stream_end);
wkday = mr.current_match;
if (mr.has_remaining()) {
- current_char = mr.last_char();
use_current_char = true;
}
break;
@@ -641,7 +631,6 @@ class format_date_parser
itr++;
if (use_current_char) {
use_current_char = false;
- current_char = *sitr;
}
else {
sitr++;
@@ -674,14 +663,14 @@ class format_date_parser
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
- charT current_char = *sitr;
unsigned short year(0);
const_itr itr(format_str.begin());
while (itr != format_str.end() && (sitr != stream_end)) {
if (*itr == '%') {
- itr++;
+ if ( ++itr == format_str.end())
+ break;
if (*itr != '%') {
//match_results mr;
switch(*itr) {
@@ -714,7 +703,6 @@ class format_date_parser
itr++;
if (use_current_char) {
use_current_char = false;
- current_char = *sitr;
}
else {
sitr++;