diff options
author | Ronan Desplanques <desplanques@adacore.com> | 2024-04-12 16:45:08 +0200 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-06-10 11:03:59 +0200 |
commit | eb822805b51a1fa5b514a04a6e66556e3dcd3484 (patch) | |
tree | 910f60c6a09e0182c47d4f64506d9e2f23718296 | |
parent | 2d20aaaa8a3cb807431fcd74bec02967fcd60995 (diff) | |
download | gcc-eb822805b51a1fa5b514a04a6e66556e3dcd3484.zip gcc-eb822805b51a1fa5b514a04a6e66556e3dcd3484.tar.gz gcc-eb822805b51a1fa5b514a04a6e66556e3dcd3484.tar.bz2 |
ada: Fix incorrect lower bound presumption in gnatlink
This patch fixes a subprogram in gnatlink that incorrectly assumed
that the strings it is passed as arguments all have a lower bound of
1.
gcc/ada/
* gnatlink.adb (Check_File_Name): Fix incorrect assumption.
-rw-r--r-- | gcc/ada/gnatlink.adb | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/gcc/ada/gnatlink.adb b/gcc/ada/gnatlink.adb index d00fd9e..1455412 100644 --- a/gcc/ada/gnatlink.adb +++ b/gcc/ada/gnatlink.adb @@ -42,6 +42,7 @@ with Types; with Ada.Command_Line; use Ada.Command_Line; with Ada.Exceptions; use Ada.Exceptions; +with Ada.Strings.Fixed; with System.OS_Lib; use System.OS_Lib; with System.CRTL; @@ -1697,15 +1698,13 @@ begin procedure Check_File_Name (S : String) is begin - for J in 1 .. FN'Length - (S'Length - 1) loop - if FN (J .. J + (S'Length - 1)) = S then - Error_Msg - ("warning: executable file name """ & Output_File_Name.all - & """ contains substring """ & S & '"'); - Error_Msg - ("admin privileges may be required to run this file"); - end if; - end loop; + if Ada.Strings.Fixed.Index (FN, S) /= 0 then + Error_Msg + ("warning: executable file name """ & Output_File_Name.all + & """ contains substring """ & S & '"'); + Error_Msg + ("admin privileges may be required to run this file"); + end if; end Check_File_Name; -- Start of processing for Bad_File_Names_On_Windows |