aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/files_map-editor.adb36
-rw-r--r--src/files_map-editor.ads29
2 files changed, 35 insertions, 30 deletions
diff --git a/src/files_map-editor.adb b/src/files_map-editor.adb
index fb5721a47..1324ef62c 100644
--- a/src/files_map-editor.adb
+++ b/src/files_map-editor.adb
@@ -248,12 +248,12 @@ package body Files_Map.Editor is
return Res;
end Count_Newlines;
- procedure Replace_Text (File : Source_File_Entry;
- Start_Line : Positive;
- Start_Off : Natural;
- End_Line : Positive;
- End_Off : Natural;
- Text : File_Buffer)
+ function Replace_Text (File : Source_File_Entry;
+ Start_Line : Positive;
+ Start_Off : Natural;
+ End_Line : Positive;
+ End_Off : Natural;
+ Text : File_Buffer) return Boolean
is
pragma Assert (File <= Source_Files.Last);
F : Source_File_Record renames Source_Files.Table (File);
@@ -276,7 +276,7 @@ package body Files_Map.Editor is
-- Check there is enough space.
if Text_Len > Gap_Size + Range_Size then
- raise Constraint_Error;
+ return False;
end if;
-- Replace text, handle new lines.
@@ -323,7 +323,7 @@ package body Files_Map.Editor is
begin
-- No change in newlines.
if Text_Lines = 0 and then Orig_Lines = 0 then
- return;
+ return True;
end if;
-- Make room for lines table.
@@ -359,18 +359,20 @@ package body Files_Map.Editor is
Check_Buffer_Lines (File);
end;
end;
+
+ return True;
end Replace_Text;
- procedure Replace_Text_Ptr (File : Source_File_Entry;
- Start_Line : Positive;
- Start_Off : Natural;
- End_Line : Positive;
- End_Off : Natural;
- Text_Ptr : File_Buffer_Ptr;
- Text_Len : Source_Ptr) is
+ function Replace_Text_Ptr (File : Source_File_Entry;
+ Start_Line : Positive;
+ Start_Off : Natural;
+ End_Line : Positive;
+ End_Off : Natural;
+ Text_Ptr : File_Buffer_Ptr;
+ Text_Len : Source_Ptr) return Boolean is
begin
- Replace_Text (File, Start_Line, Start_Off, End_Line, End_Off,
- Text_Ptr (0 .. Text_Len - 1));
+ return Replace_Text (File, Start_Line, Start_Off, End_Line, End_Off,
+ Text_Ptr (0 .. Text_Len - 1));
end Replace_Text_Ptr;
procedure Set_Gap (File : Source_File_Entry;
diff --git a/src/files_map-editor.ads b/src/files_map-editor.ads
index a2e3175e1..d45e83c45 100644
--- a/src/files_map-editor.ads
+++ b/src/files_map-editor.ads
@@ -17,20 +17,23 @@
-- 02111-1307, USA.
package Files_Map.Editor is
- procedure Replace_Text (File : Source_File_Entry;
- Start_Line : Positive;
- Start_Off : Natural;
- End_Line : Positive;
- End_Off : Natural;
- Text : File_Buffer);
+ -- Replace [START; END) by TEXT. Return True in case of success, False
+ -- in case of failure (the gap is too small).
+ function Replace_Text (File : Source_File_Entry;
+ Start_Line : Positive;
+ Start_Off : Natural;
+ End_Line : Positive;
+ End_Off : Natural;
+ Text : File_Buffer) return Boolean;
- procedure Replace_Text_Ptr (File : Source_File_Entry;
- Start_Line : Positive;
- Start_Off : Natural;
- End_Line : Positive;
- End_Off : Natural;
- Text_Ptr : File_Buffer_Ptr;
- Text_Len : Source_Ptr);
+ -- Likewise, but with pointer + length string.
+ function Replace_Text_Ptr (File : Source_File_Entry;
+ Start_Line : Positive;
+ Start_Off : Natural;
+ End_Line : Positive;
+ End_Off : Natural;
+ Text_Ptr : File_Buffer_Ptr;
+ Text_Len : Source_Ptr) return Boolean;
-- Replace the content of FILE with TEXT.
procedure Fill_Text_Ptr (File : Source_File_Entry;