From a5fbba52e98f8685220ce13d06716cde2ed6a598 Mon Sep 17 00:00:00 2001 From: Ronan Desplanques Date: Mon, 23 Oct 2023 16:02:07 +0200 Subject: ada: Fix Ada.Text_IO.Delete with "encoding=8bits" form Before this patch, on Windows, file with non-ASCII Latin1 names could be created with Ada.Text_IO.Create by passing "encoding=8bits" through the Form parameter and a Latin1-encoded string through the Name parameter, but calling Ada.Text_IO.Delete on them raised an illegitimate exception. This patch fixes this by making the wrappers of the unlink system function aware of the encoding value passed through the Form parameter. It also removes an unnecessary curly-brace block. gcc/ada/ * adaint.c (__gnat_unlink): Add new parameter and fix text conversion on Windows. Remove unnecessary curly braces. * adaint.h (__gnat_unlink): Add new parameter. * libgnat/i-cstrea.ads (unlink): Adapt to __gnat_unlink signature change. * libgnat/i-cstrea.adb (unlink): New Subprogram definition. * libgnat/s-crtl.ads (unlink): Adapt to __gnat_unlink signature change. * libgnat/s-fileio.adb (Delete): Pass encoding argument to unlink. --- gcc/ada/libgnat/s-fileio.adb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/ada/libgnat/s-fileio.adb') diff --git a/gcc/ada/libgnat/s-fileio.adb b/gcc/ada/libgnat/s-fileio.adb index 931b68a..f55cdc7 100644 --- a/gcc/ada/libgnat/s-fileio.adb +++ b/gcc/ada/libgnat/s-fileio.adb @@ -350,6 +350,7 @@ package body System.File_IO is declare Filename : aliased constant String := File.Name.all; Is_Temporary_File : constant Boolean := File.Is_Temporary_File; + Encoding : constant CRTL.Filename_Encoding := File.Encoding; begin Close (File_Ptr); @@ -360,7 +361,7 @@ package body System.File_IO is -- it's a temporary file, then closing it already unlinked it. if not Is_Temporary_File then - if unlink (Filename'Address) = -1 then + if System.CRTL.unlink (Filename'Address, Encoding) = -1 then raise Use_Error with OS_Lib.Errno_Message; end if; end if; -- cgit v1.1