diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-09 23:53:32 +1300 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-09 23:53:32 +1300 |
commit | 53aa8144851913994b963ed611cca8885b8f9a9e (patch) | |
tree | 1b2a262cedb353b4aff00e14b200918ac17b11ab /src/fltk-filenames.adb | |
parent | 17473af7e8ed13e0a9399a69442f9839e5d83aef (diff) |
Internal_FLTK_Error raises are now pragma Asserts
Diffstat (limited to 'src/fltk-filenames.adb')
-rw-r--r-- | src/fltk-filenames.adb | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/src/fltk-filenames.adb b/src/fltk-filenames.adb index f8f31f0..7674323 100644 --- a/src/fltk-filenames.adb +++ b/src/fltk-filenames.adb @@ -6,6 +6,7 @@ with + Ada.Assertions, Interfaces.C.Strings; use type @@ -17,6 +18,11 @@ use type package body FLTK.Filenames is + package Chk renames Ada.Assertions; + + + + ------------------------ -- Constants From C -- ------------------------ @@ -160,11 +166,11 @@ package body FLTK.Filenames is Result : Interfaces.C.int := filename_alphasort (Interfaces.C.To_C (A), Interfaces.C.To_C (B)); begin - if Result not in Comparison'Pos (Comparison'First) .. Comparison'Pos (Comparison'Last) then - raise Internal_FLTK_Error; - else - return Comparison'Val (Result); - end if; + pragma Assert + (Result in Comparison'Pos (Comparison'First) .. Comparison'Pos (Comparison'Last)); + return Comparison'Val (Result); + exception + when Chk.Assertion_Error => raise Internal_FLTK_Error; end Alpha_Sort; @@ -175,11 +181,11 @@ package body FLTK.Filenames is Result : Interfaces.C.int := filename_casealphasort (Interfaces.C.To_C (A), Interfaces.C.To_C (B)); begin - if Result not in Comparison'Pos (Comparison'First) .. Comparison'Pos (Comparison'Last) then - raise Internal_FLTK_Error; - else - return Comparison'Val (Result); - end if; + pragma Assert + (Result in Comparison'Pos (Comparison'First) .. Comparison'Pos (Comparison'Last)); + return Comparison'Val (Result); + exception + when Chk.Assertion_Error => raise Internal_FLTK_Error; end Case_Alpha_Sort; @@ -190,11 +196,11 @@ package body FLTK.Filenames is Result : Interfaces.C.int := filename_numericsort (Interfaces.C.To_C (A), Interfaces.C.To_C (B)); begin - if Result not in Comparison'Pos (Comparison'First) .. Comparison'Pos (Comparison'Last) then - raise Internal_FLTK_Error; - else - return Comparison'Val (Result); - end if; + pragma Assert + (Result in Comparison'Pos (Comparison'First) .. Comparison'Pos (Comparison'Last)); + return Comparison'Val (Result); + exception + when Chk.Assertion_Error => raise Internal_FLTK_Error; end Numeric_Sort; @@ -205,11 +211,11 @@ package body FLTK.Filenames is Result : Interfaces.C.int := filename_casenumericsort (Interfaces.C.To_C (A), Interfaces.C.To_C (B)); begin - if Result not in Comparison'Pos (Comparison'First) .. Comparison'Pos (Comparison'Last) then - raise Internal_FLTK_Error; - else - return Comparison'Val (Result); - end if; + pragma Assert + (Result in Comparison'Pos (Comparison'First) .. Comparison'Pos (Comparison'Last)); + return Comparison'Val (Result); + exception + when Chk.Assertion_Error => raise Internal_FLTK_Error; end Case_Numeric_Sort; @@ -276,9 +282,11 @@ package body FLTK.Filenames is begin if Result = 0 then raise Open_URI_Error with "Error: " & Interfaces.C.To_Ada (Message); - elsif Result /= 1 then - raise Internal_FLTK_Error; + else + pragma Assert (Result = 1); end if; + exception + when Chk.Assertion_Error => raise Internal_FLTK_Error; end Open_URI; |