]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Fix format string parsing in GNAT.Formatted_String
authorRonan Desplanques <desplanques@adacore.com>
Wed, 7 Dec 2022 16:37:21 +0000 (17:37 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 3 Jan 2023 09:29:53 +0000 (10:29 +0100)
commitd3f50f75aa3e5054b28074c029d36c1cbce2d0cb
treeb6e65bbf1239805f5f77bb9b8a5393423ef2ecee
parent32841e7e8480cb16d34f60feda226e4f582c3186
ada: Fix format string parsing in GNAT.Formatted_String

Before this patch, format strings ending with "%%" (two consecutive
percent signs) caused GNAT.Formatted_String."-" to give the wrong
output, and cause the various GNAT.Formatted_String."&" to raise
exceptions with misleading error messages.

Also before this patch, a bug in GNAT.Formatted_String."-" caused
characters from the format string to be dropped. Calling
GNAT.Formatted_String."-" on an instance of
GNAT.Formatted_String.Formatted_String caused subsequent uses of
that instance to return wrong results.

In addition to fixing the parsing of format strings, this patch
centralizes the detection of format specifiers in a unique
procedure.

gcc/ada/

* libgnat/g-forstr.adb
(Advance_And_Accumulate_Until_Next_Specifier): New procedure.
("-"): Replace inline code with call to
Advance_And_Accumulate_Until_Next_Specifier.
(Next_Format): likewise.
gcc/ada/libgnat/g-forstr.adb