From 77c223be193b303b833053a757a2f1f2534da610 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 14 May 2018 18:24:40 +0000 Subject: Use internal wcstof instead of system wcstod in formcalc lexer This CL switches the usage of wcstod to use the FXSYS_wcstof to determine if a given string is a valid floating point number. Using the internal method makes linux slightly slower (10's of ms) makes mac a lot faster 900ms to 60ms for the test case in the bug. The FXSYS_wcstof method has been extended to handle the parsing of float exponents. Unittests were added for FXSYS_wcstof. Bug: chromium:813646 Change-Id: Ie68287a336e3b95a0c0b845d5bf39db6fc82b39c Reviewed-on: https://pdfium-review.googlesource.com/32510 Reviewed-by: Ryan Harrison Commit-Queue: dsinclair --- xfa/fxfa/fm2js/cxfa_fmlexer.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'xfa/fxfa/fm2js') diff --git a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp index 32e29575c5..3a694675b7 100644 --- a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp +++ b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp @@ -303,10 +303,12 @@ CXFA_FMToken CXFA_FMLexer::NextToken() { CXFA_FMToken CXFA_FMLexer::AdvanceForNumber() { // This will set end to the character after the end of the number. - wchar_t* end = nullptr; + int32_t used_length = 0; if (m_cursor) - wcstod(const_cast(m_cursor), &end); - if (!end || FXSYS_iswalpha(*end)) { + FXSYS_wcstof(const_cast(m_cursor), -1, &used_length); + + const wchar_t* end = m_cursor + used_length; + if (used_length == 0 || !end || FXSYS_iswalpha(*end)) { RaiseError(); return CXFA_FMToken(); } -- cgit v1.2.3