summaryrefslogtreecommitdiff
path: root/lib/filemode.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-11-03 22:03:54 +0000
committerJim Meyering <jim@meyering.net>1994-11-03 22:03:54 +0000
commitb808409fe72e99490c5242d7cc0baa366cc06749 (patch)
treea0d84fbe2cfbf3b0948efc018420aba8647d6a64 /lib/filemode.c
parent17a29b6eea6539100f722fc37e5bec8aa9b8da0b (diff)
downloadcoreutils-b808409fe72e99490c5242d7cc0baa366cc06749.tar.xz
(rwx): Use S_IRUSR, S_IWUSR, S_IXUSR instead of obsolete
S_IREAD, S_IWRITE, S_IEXEC. Make sure the former three are defined.
Diffstat (limited to 'lib/filemode.c')
-rw-r--r--lib/filemode.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/lib/filemode.c b/lib/filemode.c
index c86ee2ff5..20c65c4b0 100644
--- a/lib/filemode.c
+++ b/lib/filemode.c
@@ -22,10 +22,28 @@
#include <sys/types.h>
#include <sys/stat.h>
-#ifndef S_IREAD
-#define S_IREAD S_IRUSR
-#define S_IWRITE S_IWUSR
-#define S_IEXEC S_IXUSR
+#if !S_IRUSR
+# if S_IREAD
+# define S_IRUSR S_IREAD
+# else
+# define S_IRUSR 00400
+# endif
+#endif
+
+#if !S_IWUSR
+# if S_IWRITE
+# define S_IWUSR S_IWRITE
+# else
+# define S_IWUSR 00200
+# endif
+#endif
+
+#if !S_IXUSR
+# if S_IEXEC
+# define S_IXUSR S_IEXEC
+# else
+# define S_IXUSR 00100
+# endif
#endif
#ifdef STAT_MACROS_BROKEN
@@ -191,9 +209,9 @@ rwx (bits, chars)
unsigned short bits;
char *chars;
{
- chars[0] = (bits & S_IREAD) ? 'r' : '-';
- chars[1] = (bits & S_IWRITE) ? 'w' : '-';
- chars[2] = (bits & S_IEXEC) ? 'x' : '-';
+ chars[0] = (bits & S_IRUSR) ? 'r' : '-';
+ chars[1] = (bits & S_IWUSR) ? 'w' : '-';
+ chars[2] = (bits & S_IXUSR) ? 'x' : '-';
}
/* Set the 's' and 't' flags in file attributes string CHARS,