rust/library/std/src/sys
bors c00a4648a4 Auto merge of #78833 - CDirkx:parse_prefix, r=dtolnay
Refactor and fix `parse_prefix` on Windows

This PR is an extension of #78692 as well as a general refactor of `parse_prefix`:

**Fixes**:
There are two errors in the current implementation of `parse_prefix`:

Firstly, in the current implementation only `\` is recognized as a separator character in device namespace prefixes. This behavior is only correct for verbatim paths; `"\\.\C:/foo"` should be parsed as `"C:"` instead of `"C:/foo"`.

Secondly, the current implementation only handles single separator characters. In non-verbatim paths a series of separator characters should be recognized as a single boundary, e.g. the UNC path `"\\localhost\\\\\\C$\foo"` should be parsed as `"\\localhost\\\\\\C$"` and then `UNC(server: "localhost", share: "C$")`, but currently it is not parsed at all, because it starts being parsed as `\\localhost\` and then has an invalid empty share location.

Paths like `"\\.\C:/foo"` and `"\\localhost\\\\\\C$\foo"` are valid on Windows, they are equivalent to just `"C:\foo"`.

**Refactoring**:
All uses of `&[u8]` within `parse_prefix` are extracted to helper functions and`&OsStr` is used instead. This reduces the number of places unsafe is used:
- `get_first_two_components` is adapted to the more general `parse_next_component` and used in more places
- code for parsing drive prefixes is extracted to `parse_drive`
2020-12-16 00:47:50 +00:00
..
hermit Disambiguate symlink argument names 2020-11-14 14:46:14 -08:00
sgx Auto merge of #78953 - mzohreva:mz/from_raw_fd, r=Mark-Simulacrum 2020-11-24 03:12:20 +00:00
unix Rollup merge of #79375 - vext01:kernel-copy-temps, r=bjorn3 2020-12-10 21:33:02 -08:00
unsupported Disambiguate symlink argument names 2020-11-14 14:46:14 -08:00
vxworks
wasi Disambiguate symlink argument names 2020-11-14 14:46:14 -08:00
wasm Rollup merge of #78138 - fortanix:raoul/dlmalloc0.2, r=Mark-Simulacrum 2020-11-17 10:06:16 +01:00
windows Auto merge of #78833 - CDirkx:parse_prefix, r=dtolnay 2020-12-16 00:47:50 +00:00
mod.rs Drop support for cloudabi targets 2020-11-22 17:11:41 -05:00