Skip to content

Commit

Permalink
Don't forcibly fail linkchecking if there's a broken intra-doc link o…
Browse files Browse the repository at this point in the history
…n Windows
  • Loading branch information
jyn514 authored and GuillaumeGomez committed Aug 25, 2021
1 parent dfedd33 commit 41d815e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/tools/linkchecker/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,10 @@ impl Checker {

/// Load a file from disk, or from the cache if available.
fn load_file(&mut self, file: &Path, report: &mut Report) -> (String, &FileEntry) {
// https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-
#[cfg(windows)]
const ERROR_INVALID_NAME: i32 = 123;

let pretty_path =
file.strip_prefix(&self.root).unwrap_or(&file).to_str().unwrap().to_string();

Expand All @@ -405,6 +409,14 @@ impl Checker {
}
Err(e) if e.kind() == ErrorKind::NotFound => FileEntry::Missing,
Err(e) => {
// If a broken intra-doc link contains `::`, on windows, it will cause `ERROR_INVALID_NAME` rather than `NotFound`.
// Explicitly check for that so that the broken link can be allowed in `LINKCHECK_EXCEPTIONS`.
#[cfg(windows)]
if e.raw_os_error() == Some(ERROR_INVALID_NAME)
&& file.as_os_str().to_str().map_or(false, |s| s.contains("::"))
{
return FileEntry::Missing;
}
panic!("unexpected read error for {}: {}", file.display(), e);
}
});
Expand Down

0 comments on commit 41d815e

Please sign in to comment.