summaryrefslogtreecommitdiffstats
path: root/gl/stat.c
diff options
context:
space:
mode:
Diffstat (limited to 'gl/stat.c')
-rw-r--r--gl/stat.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/gl/stat.c b/gl/stat.c
index ecf9f9bb..da6a9862 100644
--- a/gl/stat.c
+++ b/gl/stat.c
@@ -1,5 +1,5 @@
1/* Work around platform bugs in stat. 1/* Work around platform bugs in stat.
2 Copyright (C) 2009-2024 Free Software Foundation, Inc. 2 Copyright (C) 2009-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -42,14 +42,7 @@ orig_stat (const char *filename, struct stat *buf)
42#endif 42#endif
43 43
44/* Specification. */ 44/* Specification. */
45#ifdef __osf__ 45#include <sys/stat.h>
46/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
47 eliminates this include because of the preliminary #include <sys/stat.h>
48 above. */
49# include "sys/stat.h"
50#else
51# include <sys/stat.h>
52#endif
53 46
54#include "stat-time.h" 47#include "stat-time.h"
55 48
@@ -118,6 +111,10 @@ rpl_stat (char const *name, struct stat *buf)
118 around length limitations 111 around length limitations
119 <https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file> ? */ 112 <https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file> ? */
120 113
114 /* To ease portability. Like in open.c. */
115 if (streq (name, "/dev/null"))
116 name = "NUL";
117
121 /* POSIX <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13> 118 /* POSIX <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>
122 specifies: "More than two leading <slash> characters shall be treated as 119 specifies: "More than two leading <slash> characters shall be treated as
123 a single <slash> character." */ 120 a single <slash> character." */
@@ -290,8 +287,7 @@ rpl_stat (char const *name, struct stat *buf)
290 if (info.nFileSizeHigh > 0 || info.nFileSizeLow > 0) 287 if (info.nFileSizeHigh > 0 || info.nFileSizeLow > 0)
291 { 288 {
292 const char *last_dot = NULL; 289 const char *last_dot = NULL;
293 const char *p; 290 for (const char *p = info.cFileName; *p != '\0'; p++)
294 for (p = info.cFileName; *p != '\0'; p++)
295 if (*p == '.') 291 if (*p == '.')
296 last_dot = p; 292 last_dot = p;
297 if (last_dot != NULL) 293 if (last_dot != NULL)