From ccf8b3bf2854641388619e68325998b9ddd229de Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Wed, 12 Dec 2018 18:23:58 +0100 Subject: Add Location_File_Line_To_Offset. --- src/files_map.adb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/files_map.adb') diff --git a/src/files_map.adb b/src/files_map.adb index e9d0a2e9e..46d09b04b 100644 --- a/src/files_map.adb +++ b/src/files_map.adb @@ -415,6 +415,17 @@ package body Files_Map is return Coord_To_Col (File, Line_Pos, Natural (Pos - Line_Pos)); end Location_File_Line_To_Col; + function Location_File_Line_To_Offset + (Loc : Location_Type; File : Source_File_Entry; Line : Positive) + return Natural + is + F : Source_File_Record renames Source_Files.Table (File); + Line_Pos : constant Source_Ptr := F.Lines.Table (Line); + Pos : constant Source_Ptr := Location_File_To_Pos (Loc, File); + begin + return Natural (Pos - Line_Pos); + end Location_File_Line_To_Offset; + -- Convert the first digit of VAL into a character (base 10). function Digit_To_Char (Val: Natural) return Character is begin -- cgit v1.2.3