diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-11-15 06:36:34 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-11-15 06:36:34 +0100 |
commit | ac54fb8f7f7130c9bb18124694ea9de07266f214 (patch) | |
tree | cd36bfdbc55c98bed4f030ef68f8bf571b410ee1 /src/grt | |
parent | 9518660d894ff1695ba84f7fe060f50bc643d701 (diff) | |
download | ghdl-ac54fb8f7f7130c9bb18124694ea9de07266f214.tar.gz ghdl-ac54fb8f7f7130c9bb18124694ea9de07266f214.tar.bz2 ghdl-ac54fb8f7f7130c9bb18124694ea9de07266f214.zip |
grt-files_operations: reduce dependencies.
Diffstat (limited to 'src/grt')
-rw-r--r-- | src/grt/grt-files_operations.adb | 33 | ||||
-rw-r--r-- | src/grt/grt-files_operations.ads | 6 |
2 files changed, 20 insertions, 19 deletions
diff --git a/src/grt/grt-files_operations.adb b/src/grt/grt-files_operations.adb index a9af35ade..ed15f7fa0 100644 --- a/src/grt/grt-files_operations.adb +++ b/src/grt/grt-files_operations.adb @@ -22,11 +22,9 @@ -- covered by the GNU General Public License. This exception does not -- however invalidate any other reasons why the executable file might be -- covered by the GNU Public License. -with Grt.Errors; use Grt.Errors; with Grt.Stdio; use Grt.Stdio; with Grt.C; use Grt.C; with Grt.Table; -with Grt.Options; with System; use System; pragma Elaborate_All (Grt.Table); @@ -177,13 +175,6 @@ package body Grt.Files_Operations is end if; end Destroy_File; - procedure File_Error (File : Ghdl_File_Index) - is - pragma Unreferenced (File); - begin - Internal_Error ("file: IO error"); - end File_Error; - function Ghdl_Text_File_Elaborate return Ghdl_File_Index is begin return Create_File (True, ' ', null); @@ -319,9 +310,9 @@ package body Grt.Files_Operations is Status := Op_Name_Error; return; end if; - if Grt.Options.Unbuffered_Writes and Mode /= Read_Mode then - setbuf (F, NULL_voids); - end if; + -- if Grt.Options.Unbuffered_Writes and Mode /= Read_Mode then + -- setbuf (F, NULL_voids); + -- end if; end if; Sig := Files_Table.Table (File).Signature; @@ -332,12 +323,14 @@ package body Grt.Files_Operations is if fwrite (Sig_Header'Address, 1, Sig_Header'Length, F) /= Sig_Header'Length then - File_Error (File); + Status := Op_Write_Error; + return; end if; if fwrite (Sig (1)'Address, 1, size_t (Sig_Len), F) /= size_t (Sig_Len) then - File_Error (File); + Status := Op_Write_Error; + return; end if; when Read_Mode => declare @@ -345,18 +338,22 @@ package body Grt.Files_Operations is Sig_Buf : String (1 .. Sig_Len); begin if fread (Hdr'Address, 1, Hdr'Length, F) /= Hdr'Length then - File_Error (File); + Status := Op_Read_Error; + return; end if; if Hdr /= Sig_Header then - File_Error (File); + Status := Op_Signature_Error; + return; end if; if fread (Sig_Buf'Address, 1, Sig_Buf'Length, F) /= Sig_Buf'Length then - File_Error (File); + Status := Op_Read_Error; + return; end if; if Sig_Buf /= Sig (1 .. Sig_Len) then - File_Error (File); + Status := Op_Signature_Error; + return; end if; end; when Append_Mode => diff --git a/src/grt/grt-files_operations.ads b/src/grt/grt-files_operations.ads index ab3f70ef2..c6ee8751d 100644 --- a/src/grt/grt-files_operations.ads +++ b/src/grt/grt-files_operations.ads @@ -83,7 +83,11 @@ package Grt.Files_Operations is Op_Close_Error, -- Incorrect file name (too long). - Op_Filename_Error + Op_Filename_Error, + + -- Incorrect file type. + Op_Signature_Error + ); -- General files. |