From 06fb83abb4d9a8e41e64234d8aaec1dcc473f613 Mon Sep 17 00:00:00 2001
From: Gabor Szalai <gabor.szalai@ericsson.com>
Date: Thu, 13 Aug 2020 17:54:42 +0200
Subject: [PATCH] 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: Gabor Szalai <gabor.szalai@ericsson.com>
---
 core/Addfunc.cc | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/core/Addfunc.cc b/core/Addfunc.cc
index a6d5b84e1..7ddd2ae23 100644
--- a/core/Addfunc.cc
+++ b/core/Addfunc.cc
@@ -16,6 +16,7 @@
  *   Raduly, Csaba
  *   Szabo, Bence Janos
  *   Szabo, Janos Zoltan – initial implementation
+ *   Szalai, Gabor
  *   Zalanyi, Balazs Andor
  *
  ******************************************************************************/
@@ -1261,7 +1262,6 @@ double str2float(const CHARSTRING& value)
   size_t end = value_len;
   boolean leading_ws = FALSE;
   boolean trailing_ws = FALSE;
-  boolean leading_zero = FALSE;
   double ret_val;
   while (is_whitespace(value_str[start])) {
     leading_ws = TRUE;
@@ -1321,7 +1321,6 @@ double str2float(const CHARSTRING& value)
         if (c == '.') state = S_FIRST_F;
         else if (c == 'E' || c == 'e') state = S_INITIAL_E;
         else if (c >= '0' && c <= '9') {
-          leading_zero = TRUE;
           state = S_MORE_M;
         } else state = S_ERR;
         break;
@@ -1353,7 +1352,6 @@ double str2float(const CHARSTRING& value)
         break;
       case S_ZERO_E:
         if (c >= '0' && c <= '9') {
-          leading_zero = TRUE;
           state = S_MORE_E;
         }
         else state = S_ERR;
@@ -1405,13 +1403,6 @@ double str2float(const CHARSTRING& value)
     TTCN_Logger::log_char('.');
     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) {
     TTCN_warning_begin("Trailing whitespace was detected in the argument "
       "of function str2float(): ");
-- 
GitLab