From: Ronan Desplanques Date: Mon, 5 May 2025 09:37:00 +0000 (+0200) Subject: ada: Clarify numeric parsing code X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ba50ebb54d800eecb84cbe8ddb5b50f388be7c34;p=thirdparty%2Fgcc.git ada: Clarify numeric parsing code This patch rephrases some code in System.Value_R to make it easier to read. gcc/ada/ChangeLog: * libgnat/s-valuer.adb (Scan_Decimal_Digits, Scan_Integral_Digits): Minor rephrasing. --- diff --git a/gcc/ada/libgnat/s-valuer.adb b/gcc/ada/libgnat/s-valuer.adb index faedb884a6a..25f54079bfe 100644 --- a/gcc/ada/libgnat/s-valuer.adb +++ b/gcc/ada/libgnat/s-valuer.adb @@ -236,18 +236,17 @@ package body System.Value_R is Digit := As_Digit (Str (Index)); loop - -- Check if base is correct. If the base is not specified, the digit - -- E or e cannot be considered as a base violation as it can be used - -- for exponentiation. + -- If the base is not explicitly specified, 'e' or 'E' marks the + -- beginning of the exponent part. + + if not Base_Specified and then Digit = E_Digit then + return; + end if; + + -- Check that Digit is a valid digit with respect to Base if Digit >= Base then - if Base_Specified then - Base_Violation := True; - elsif Digit = E_Digit then - return; - else - Base_Violation := True; - end if; + Base_Violation := True; end if; -- If precision limit has been reached, just ignore any remaining @@ -426,18 +425,17 @@ package body System.Value_R is Digit := As_Digit (Str (Index)); loop - -- Check if base is correct. If the base is not specified, the digit - -- E or e cannot be considered as a base violation as it can be used - -- for exponentiation. + -- If the base is not explicitly specified, 'e' or 'E' marks the + -- beginning of the exponent part. + + if not Base_Specified and then Digit = E_Digit then + return; + end if; + + -- Check that Digit is a valid digit with respect to Base if Digit >= Base then - if Base_Specified then - Base_Violation := True; - elsif Digit = E_Digit then - return; - else - Base_Violation := True; - end if; + Base_Violation := True; end if; -- If precision limit has been reached, just ignore any remaining