mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Use istream::getline instead of std::getline for date option type parsing.
This commit is contained in:
@@ -179,9 +179,12 @@ GncOptionDateValue::out_stream(std::ostream& oss) const noexcept
|
|||||||
std::istream&
|
std::istream&
|
||||||
GncOptionDateValue::in_stream(std::istream& iss)
|
GncOptionDateValue::in_stream(std::istream& iss)
|
||||||
{
|
{
|
||||||
std::string type_str;
|
char type_str[10]; //The length of both "absolute" and "relative" plus 1.
|
||||||
std::getline(iss, type_str, '.');
|
iss.getline(type_str, sizeof(type_str), '.');
|
||||||
if (type_str == "absolute ")
|
if(!iss)
|
||||||
|
throw std::invalid_argument("Date Type separator missing");
|
||||||
|
/* strcmp is safe, istream::getline null terminates the buffer. */
|
||||||
|
if (strcmp(type_str, "absolute ") == 0)
|
||||||
{
|
{
|
||||||
time64 time;
|
time64 time;
|
||||||
iss >> time;
|
iss >> time;
|
||||||
@@ -189,7 +192,7 @@ GncOptionDateValue::in_stream(std::istream& iss)
|
|||||||
if (iss.get() != ')')
|
if (iss.get() != ')')
|
||||||
iss.unget();
|
iss.unget();
|
||||||
}
|
}
|
||||||
else if (type_str == "relative ")
|
else if (strcmp(type_str, "relative ") == 0)
|
||||||
{
|
{
|
||||||
std::string period_str;
|
std::string period_str;
|
||||||
iss >> period_str;
|
iss >> period_str;
|
||||||
|
|||||||
Reference in New Issue
Block a user