Apache OpenOffice (AOO) Bugzilla – Issue 2947
bug in sal/rtl/source/strtmpl.c
Last modified: 2002-05-08 09:01:26 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.
Created attachment 988 [details] Fix for issue: added a missing "else"
> 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 */
Stephan, this seems to belong to you?!
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.
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
Created attachment 1286 [details] This patch is correct for this issue
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).
Verified that fix is in internal build UDK305C.
Closing it...