Issue 2947 - bug in sal/rtl/source/strtmpl.c
Summary: bug in sal/rtl/source/strtmpl.c
Status: CLOSED FIXED
Alias: None
Product: udk
Classification: Code
Component: code (show other issues)
Version: 638
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: Stephan Bergmann
QA Contact: issues@udk
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-01-25 19:11 UTC by Unknown
Modified: 2002-05-08 09:01 UTC (History)
1 user (show)

See Also:
Issue Type: PATCH
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Fix for issue: added a missing "else" (50.44 KB, patch)
2002-01-25 19:14 UTC, Unknown
no flags Details | Diff
This patch is correct for this issue (618 bytes, patch)
2002-03-28 09:10 UTC, Unknown
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description Unknown 2002-01-25 19:11:08 UTC
In strtmpl.c, the function IMPL_RTL_STRNAME( ImplStringToDouble ), which
converts a string to double is missing an else at line 1109.  It exits out of
the while loop when it encounters a '+' in the string.  For example, if the
string is '1.7e+308', the converted string to double would be 1.7, 
which is not correct.  However, it returns a correct value if the string is
'1.7e-308'. The code for '-' and '+' looks very similar except that an else is
missing in '+'. When we add the 'else' part into the '+' part of the code,
everything works fine.
Comment 1 Unknown 2002-01-25 19:14:48 UTC
Created attachment 988 [details]
Fix for issue: added a missing "else"
Comment 2 Unknown 2002-01-25 20:32:41 UTC
> diff -c strtmpl.c ~chanv/origoo/oo_638c_src/sal/rtl/source/strtmpl.c
*** strtmpl.c	Fri Jan 25 14:10:30 2002
--- /usr/local/home/chanv/origoo/oo_638c_src/sal/rtl/source/strtmpl.c
Mon Jul 30 13:46:11 2001
***************
*** 1106,1112 ****
          {
              if ( bExp && (nExp != 0) )
                  break;
!             else if ( fRet != 0.0 )
                  break;
          }
          /* Exponent separator */
--- 1106,1112 ----
          {
              if ( bExp && (nExp != 0) )
                  break;
!             if ( fRet != 0.0 )
                  break;
          }
          /* Exponent separator */
Comment 3 kay.ramme 2002-01-28 10:38:11 UTC
Stephan, this seems to belong to you?!

Comment 4 Stephan Bergmann 2002-01-28 15:32:02 UTC
The proposed patch seems not to fix the bug (with or without the 
patch, lines 1106--1112 are equivalent to "if (bExp && nExp != 0 || 
fRet != 0.0) break;"), but I'll take care of the bug.
Comment 5 Unknown 2002-01-28 19:29:32 UTC
The reason we found the problem is that errors were generated when
running the test program in stoc/testconv which complains about
converting a String such as "1.723847e+308" to double.  We traced down
the problem and found that the function in strtmpl.c only converts the
string to "1.723847", the exponent part is gone.  If we add the else
part, it works fine.  For some strange reason, adding just the else
may not work.  Consider this?

        else if ( *pStr == '+' )
        {
            if ( bExp )
            {
                if ( nExp != 0 )
                    break;
            }
            else
            {
                if ( fRet != 0.0 )
                    break;
            } 
        }

Thanks,

Vicky
Comment 6 Unknown 2002-03-28 09:10:43 UTC
Created attachment 1286 [details]
This patch is correct for this issue
Comment 7 Stephan Bergmann 2002-03-28 10:36:55 UTC
Fixed this in the top-level branch (sal/rtl/source/strtmpl.c 1.11,
sal/test/teststring.cxx 1.5).  Vicky, Tim, after commiting the change
I realized I did not give credit to you in the code.  Sorry, it was an
oversight (bit stressed right now).
Comment 8 Stephan Bergmann 2002-05-08 08:58:50 UTC
Verified that fix is in internal build UDK305C.
Comment 9 Stephan Bergmann 2002-05-08 09:01:26 UTC
Closing it...