Skip to content
Snippets Groups Projects
Commit 06fb83ab authored by Gábor Szalai's avatar Gábor Szalai
Browse files

Remove leading zero warning from str2float (bug 566028)


The standard explicitly allow the leading zero for str2float
Leading zero warning is not needed as it is allowed.

C.1.29  Character string to float
str2float(in charstring invalue) return float This function
converts a charstring comprising a number into a float value.
The format of the number in the charstring shall follow rules
in clause 6.1.0, items a) or b) with the following exceptions:

leading zeros are allowed;

EXAMPLE:

str2float("12345.6") // is the same as str2float("123.456E+02")

Change-Id: Ia3a81017b234dae493cd33ccc4ce3ea124727be2
Signed-off-by: default avatarGabor Szalai <gabor.szalai@ericsson.com>
parent 06f872c1
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
* Raduly, Csaba * Raduly, Csaba
* Szabo, Bence Janos * Szabo, Bence Janos
* Szabo, Janos Zoltan – initial implementation * Szabo, Janos Zoltan – initial implementation
* Szalai, Gabor
* Zalanyi, Balazs Andor * Zalanyi, Balazs Andor
* *
******************************************************************************/ ******************************************************************************/
...@@ -1261,7 +1262,6 @@ double str2float(const CHARSTRING& value) ...@@ -1261,7 +1262,6 @@ double str2float(const CHARSTRING& value)
size_t end = value_len; size_t end = value_len;
boolean leading_ws = FALSE; boolean leading_ws = FALSE;
boolean trailing_ws = FALSE; boolean trailing_ws = FALSE;
boolean leading_zero = FALSE;
double ret_val; double ret_val;
while (is_whitespace(value_str[start])) { while (is_whitespace(value_str[start])) {
leading_ws = TRUE; leading_ws = TRUE;
...@@ -1321,7 +1321,6 @@ double str2float(const CHARSTRING& value) ...@@ -1321,7 +1321,6 @@ double str2float(const CHARSTRING& value)
if (c == '.') state = S_FIRST_F; if (c == '.') state = S_FIRST_F;
else if (c == 'E' || c == 'e') state = S_INITIAL_E; else if (c == 'E' || c == 'e') state = S_INITIAL_E;
else if (c >= '0' && c <= '9') { else if (c >= '0' && c <= '9') {
leading_zero = TRUE;
state = S_MORE_M; state = S_MORE_M;
} else state = S_ERR; } else state = S_ERR;
break; break;
...@@ -1353,7 +1352,6 @@ double str2float(const CHARSTRING& value) ...@@ -1353,7 +1352,6 @@ double str2float(const CHARSTRING& value)
break; break;
case S_ZERO_E: case S_ZERO_E:
if (c >= '0' && c <= '9') { if (c >= '0' && c <= '9') {
leading_zero = TRUE;
state = S_MORE_E; state = S_MORE_E;
} }
else state = S_ERR; else state = S_ERR;
...@@ -1405,13 +1403,6 @@ double str2float(const CHARSTRING& value) ...@@ -1405,13 +1403,6 @@ double str2float(const CHARSTRING& value)
TTCN_Logger::log_char('.'); TTCN_Logger::log_char('.');
TTCN_warning_end(); TTCN_warning_end();
} }
if (leading_zero) {
TTCN_warning_begin("Leading zero digit was detected in the argument "
"of function str2float(): ");
value.log();
TTCN_Logger::log_char('.');
TTCN_warning_end();
}
if (trailing_ws) { if (trailing_ws) {
TTCN_warning_begin("Trailing whitespace was detected in the argument " TTCN_warning_begin("Trailing whitespace was detected in the argument "
"of function str2float(): "); "of function str2float(): ");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment