From c9d4d9f48b3d66e426073b7e8273b95a0b884fab Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 18 Oct 2024 14:06:08 +0000 Subject: [PATCH] FPSpreadsheet: Fix incorrect detection of numeric strings beginning with 'E' as valid numbers (https://forum.lazarus.freepascal.org/index.php/topic,68953.msg534081) git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9487 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/source/common/fpspreadsheet.pas | 3 ++- components/fpspreadsheet/source/common/fpsutils.pas | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/fpspreadsheet/source/common/fpspreadsheet.pas b/components/fpspreadsheet/source/common/fpspreadsheet.pas index e7c0c55dc..3697aad05 100644 --- a/components/fpspreadsheet/source/common/fpspreadsheet.pas +++ b/components/fpspreadsheet/source/common/fpspreadsheet.pas @@ -4648,7 +4648,8 @@ begin end; // Check for a "number" value (floating point, or integer) - if TryStrToFloat(AValue, number, AFormatSettings) then + // BUT: val() (and TryStsrToFloat) assumes that a string beginning with 'E' is a valid number + if not (AValue[1] in ['E', 'e']) and TryStrToFloat(AValue, number, AFormatSettings) then begin if (soAutoDetectCellType in FOptions) then begin if isPercent then diff --git a/components/fpspreadsheet/source/common/fpsutils.pas b/components/fpspreadsheet/source/common/fpsutils.pas index 34ab6d10e..23e478258 100644 --- a/components/fpspreadsheet/source/common/fpsutils.pas +++ b/components/fpspreadsheet/source/common/fpsutils.pas @@ -1785,8 +1785,8 @@ begin end; {@@ ---------------------------------------------------------------------------- - Converts a string to a floating point number. No assumption on decimal and - thousand separator are made. + Converts a string to a floating point number. No assumptions on decimal and + thousand separators are made. Is needed for reading CSV files. -------------------------------------------------------------------------------}