libiberty/ChangeLog: * unlink-if-ordinary.c (unlink_if_ordinary): Handle Windows nul device
--- libiberty/unlink-if-ordinary.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libiberty/unlink-if-ordinary.c b/libiberty/unlink-if-ordinary.c index 84328b216..ae9090e54 100644 --- a/libiberty/unlink-if-ordinary.c +++ b/libiberty/unlink-if-ordinary.c @@ -62,11 +62,18 @@ was made to unlink the file because it is special. int unlink_if_ordinary (const char *name) { +/* MS-Windows 'stat' function (and in turn, S_ISREG) + reports the null device as a regular file. */ +#ifdef _WIN32 + if (stricmp (name, "nul") == 0) + return 1; +#else struct stat st; if (lstat (name, &st) == 0 && (S_ISREG (st.st_mode) || S_ISLNK (st.st_mode))) return unlink (name); +#endif return 1; } -- 2.39.0