public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/104421] New: The Ada.Directories.Modification_Time procedure does not work for non-ASCII filenames in the Windows environment.
@ 2022-02-07 14:05 yeongtaek.ham at gmail dot com
  2024-01-09 10:56 ` [Bug ada/104421] " ebotcazou at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: yeongtaek.ham at gmail dot com @ 2022-02-07 14:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104421

            Bug ID: 104421
           Summary: The Ada.Directories.Modification_Time procedure does
                    not work for non-ASCII filenames in the Windows
                    environment.
           Product: gcc
           Version: 10.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yeongtaek.ham at gmail dot com
  Target Milestone: ---

The Ada.Directories.Modification_Time procedure does not work for non-ASCII
filenames in the Windows environment.

Example code (file is UTF-8 encoded):
--------------------------------------------------------------------------------
with Ada.Calendar;
with Ada.Directories;
with Ada.Text_IO;
with GNAT.Calendar.Time_IO;

procedure Main is
   package TEXT_IO renames Ada.Text_IO;
   package TIME_IO renames GNAT.Calendar.Time_IO;

   Mod_Time : Ada.Calendar.Time;
begin
   TEXT_IO.Put_Line ("한글 출력");

   -- Good
   Mod_Time := Ada.Directories.Modification_Time("modtime.gpr");
   TIME_IO.Put_Time (Mod_Time, TIME_IO.ISO_Time);
   TEXT_IO.NEW_LINE;

   -- Error
   Mod_Time := Ada.Directories.Modification_Time("한글.txt");
   TIME_IO.Put_Time (Mod_Time, TIME_IO.ISO_Time);
   TEXT_IO.NEW_LINE;
end Main;
--------------------------------------------------------------------------------


Execution result:
--------------------------------------------------------------------------------
PS C:\Users\Regentag\desktop\AdaDev\FileModTime> chcp 65001
Active code page: 65001
PS C:\Users\Regentag\desktop\AdaDev\FileModTime> dir


    디렉터리: C:\Users\Regentag\desktop\AdaDev\FileModTime


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----          22-02-07     22:46                obj
d-----          22-02-07     21:02                src
-a----          22-02-07     19:30            126 modtime.gpr
-a----          22-02-07     19:30            126 한글.txt                        


PS C:\Users\Regentag\desktop\AdaDev\FileModTime> C:\GNAT\2021\bin\gprbuild.exe
.\modtime.gpr
Compile
   [Ada]          main.adb
Bind
   [gprbind]      main.bexch
   [Ada]          main.ali
Link
   [link]         main.adb
PS C:\Users\Regentag\desktop\AdaDev\FileModTime> .\obj\main.exe
한글 출력
2022-02-07T19:30:02+09

raised ADA.IO_EXCEPTIONS.USE_ERROR : Unable to get modification time of the
file "한글.txt"
PS C:\Users\Regentag\desktop\AdaDev\FileModTime>
--------------------------------------------------------------------------------


My GCC version info:
--------------------------------------------------------------------------------
PS C:\GNAT\2021\bin> ./gcc -v
Using built-in specs.
COLLECT_GCC=C:\GNAT\2021\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/gnat/2021/bin/../libexec/gcc/x86_64-w64-mingw32/10.3.1/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../src/configure --enable-languages=ada,c,c++
--enable-checking=release --enable-threads=win32 --enable-libstdcxx-threads
--enable-lto --enable-large-address-aware
--with-bugurl=URL:mailto:report@adacore.com --disable-nls
--without-libiconv-prefix --disable-libstdcxx-pch --disable-libada
--disable-multilib --enable-libstdcxx
--with-mpfr=/it/sbx/a2c2/x86_64-windows64/mpfr-3.1.5/install
--with-gmp=/it/sbx/a2c2/x86_64-windows64/gmp-6.1.2/install
--with-mpc=/it/sbx/a2c2/x86_64-windows64/mpc-1.0.3/install
--with-build-time-tools=/it/sbx/a2c2/x86_64-windows64/gcc-c/build/buildtools/bin
--prefix=/it/sbx/a2c2/x86_64-windows64/gcc-c/pkg --build=x86_64-w64-mingw32
Thread model: win32
Supported LTO compression algorithms: zlib
gcc version 10.3.1 20210520 (for GNAT Community 2021 20210519) (GCC)
PS C:\GNAT\2021\bin>
--------------------------------------------------------------------------------


In my opinion, the cause is the use of the GetFileAttributesExA() function
without proper handling of the file name in the __gnat_file_time() function
implemented in adaint.c.
 *
https://github.com/gcc-mirror/gcc/blob/db95441cf5399aabc46ca83df19f7290c3e23cb1/gcc/ada/adaint.c#L1515

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug ada/104421] The Ada.Directories.Modification_Time procedure does not work for non-ASCII filenames in the Windows environment.
  2022-02-07 14:05 [Bug ada/104421] New: The Ada.Directories.Modification_Time procedure does not work for non-ASCII filenames in the Windows environment yeongtaek.ham at gmail dot com
@ 2024-01-09 10:56 ` ebotcazou at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-01-09 10:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104421

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |14.0
                 CC|                            |ebotcazou at gcc dot gnu.org

--- Comment #1 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
https://gcc.gnu.org/g:63eaa7eeb68cd967ce9a93a4669dc46f1048b0bc

commit r14-5208-g63eaa7eeb68cd967ce9a93a4669dc46f1048b0bc
Author: Ronan Desplanques <desplanques@adacore.com>
Date:   Mon Oct 16 17:09:25 2023 +0200

    ada: Fix Ada.Directories.Modification_Time on Windows

    Before this patch, Ada.Directories.Modification_Time called
    GetFileAttributesExA under the hood on Windows. That would sometimes
    fail to work with files whose names were non-ASCII.

    This patch replaces the call to GetFileAttributesExA with a call to
    GetFileAttributesEx preceded by an encoding scheme conversion, as is
    done in other functions of the run-time library. This fixes the issues
    that were observed with the previous implementations.

    gcc/ada/

            * adaint.c (__gnat_file_time): Fix Windows version.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-09 10:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-07 14:05 [Bug ada/104421] New: The Ada.Directories.Modification_Time procedure does not work for non-ASCII filenames in the Windows environment yeongtaek.ham at gmail dot com
2024-01-09 10:56 ` [Bug ada/104421] " ebotcazou at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).