Opened 11 years ago

Last modified 11 years ago

#6034 new Bugs

Problem of the split function in boost/date_time/time_parsing.hpp

Reported by: fbriol@… Owned by: az_sw_dude
Milestone: To Be Determined Component: date_time
Version: Boost 1.47.0 Severity: Problem
Keywords: Cc:

Description

If we call the function split with the string "2010-01-01" and " " as delimiter then the function sets the variables first and second with "2010-01-01" Maybe we should write this piece of code to initialize the parameter second with the correct value.

bool 
  split(const std::string& s,
        char sep,
        std::string& first,
        std::string& second)
  {
    int sep_pos = static_cast<int>(s.find(sep));
    first = s.substr(0,sep_pos);
    second = sep_pos == -1 ? "" : s.substr(sep_pos+1);
    return true;
  }

Change History (1)

comment:1 by fbriol@…, 11 years ago

The problem was discovered by calling

boost::posix_times::time_from_string("2010-05-30")

Indeed in this case the function call parse_time_duration with "2010-05-30" !

Note: See TracTickets for help on using tickets.