在 2023/3/29 16:40, Corinna Vinschen 写道:
No, this would allow splitting `\\host\\share` as `host` and `share`. In
this path the share name is `\share`, and does not match `share`.

I was just pointing out that "\foo" can't be a share name, because
backslashes can't be part of a name.

On second thought, maybe I don't understand what you were trying to say.
Can you rephrase, please?

Apologies for the confusion.

There was a mistake in the quote above, but the point in that message holds: `\\host\\share` is not a valid UNC path. If we allowed `dirname()` to remove the share name as a plain component, then, because `dirname()` treats consecutive separators as a single one, the result would be

   dirname("\\host\\share")   = "\\host"
   basename("\\host\\share")  = "share"

which would be incorrect. "\\host\\share" is a UNC path with an empty share name (that's why it's invalid), and we probably shouldn't make it indistinguishable from `\\host\share`. So it should be

   dirname("\\host\\share")   = "\\host\"
   basename("\\host\\share")  = "share"


Actually, the dirname function is not supposed to fold slashes (or
backslashes) at all, except at the start of the path.  It's also not
supposed to throw any errors.  It just cuts the path so that the last
path component is dropped.

My point is that `\\host\share` is a volume name (the 'prefix', like `C:`) and is not made up of two components. `dirname()` is supposed to remove the last component, but there is no such component to remove.

  "A pathname that begins with two successive slashes may be interpreted
   in an implementation-defined manner, although more than two leading
   slashes shall be treated as a single slash."

Well, Windows paths have different semantics from POSIX paths - for example the 'volume' thing does not exist in POSIX. Thus, largely, UNC paths and paths with DOS drive letters can't follow POSIX semantics, e.g. `C:foo/bar`.


--
Best regards,
LIU Hao

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to