fix: allow to use a minus sign in strings with FT::numeric flag

This commit is contained in:
Tomasz Sowa 2023-01-11 23:06:27 +01:00
parent 794051fa15
commit d1c86c84cf
1 changed files with 19 additions and 5 deletions

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2018-2022, Tomasz Sowa
* Copyright (c) 2018-2023, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -795,6 +795,7 @@ protected:
{
bool was_comma = false;
bool was_something_printed = false;
bool was_digit_printed = false;
for(size_t i = 0 ; has_known_length ? (i < len) : val[i] != 0 ; ++i)
{
@ -803,17 +804,30 @@ protected:
if( c == ',' )
c = '.';
if( (c=='.' && !was_comma) || (c>='0' && c<='9') )
if( (c=='.' && !was_comma) || (c>='0' && c<='9') || (c=='-' && !was_something_printed) )
{
if( c=='.' )
{
if( !was_digit_printed )
{
esc(static_cast<CharType>('0'), stream, field_type, model_env);
was_digit_printed = true;
}
was_comma = true;
}
esc(c, stream, field_type, model_env);
was_something_printed = true;
if( c == '.' )
was_comma = true;
if( c>='0' && c<='9' )
{
was_digit_printed = true;
}
}
}
if( !was_something_printed )
if( !was_digit_printed )
{
esc(static_cast<CharType>('0'), stream, field_type, model_env);
}