bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] canonicalize-lgpl: Canonicalize casing too for MinGW.


From: Bruno Haible
Subject: Re: [PATCH] canonicalize-lgpl: Canonicalize casing too for MinGW.
Date: Thu, 09 Dec 2021 23:06:37 +0100

Hi Jan,

> * lib/canonicalize-lgpl.c (filesystem_name)[__MINGW32__]: New static
> function.
> (realpath_stk)[__MINGW32__]: Use it to return correct canonicalized
> casing.

I don't think this is desirable, because

1) The 'realpath' function that canonicalize-lgpl.c implements is
   specified to return "an absolute pathname that resolves to the same
   directory entry, whose resolution does not involve '.', '..', or symbolic
   links." [1] There is no guarantee in the spec that it prefers lowercase,
   uppercase, or the case of the existing directory entry.

2) If we wanted to make this function consistent on all platforms, we would
   also need to handle
     - Linux with mounted VFAT file systems,
     - macOS with case-insensitive HFS+,
     - different locales on Windows (e.g. to recognize that 'ä' and 'Ä' are
       equivalent in Windows installations with Western locales).
   And, on macOS with HFS+, also the Unicode canonicalization (NFC vs. NFD).

3) By doing this, the function would be slowed down significantly. The
   scandir() call that you added reads all directory entries of a certain
   directory.

What exactly do you want to do? If you want to look at the file name of
an existing directory entry, let your program use scandir().

Additionally,

> +  int select_base (struct dirent const* entry)
> +  {
> +    return strcasecmp (entry->d_name, base) == 0;
> +  }

I would refrain from adding code that requires GCC and does not work with MSVC.

Bruno

[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html






reply via email to

[Prev in Thread] Current Thread [Next in Thread]