(rwx): Use S_IRUSR, S_IWUSR, S_IXUSR instead of obsolete
authorJim Meyering <jim@meyering.net>
Thu, 3 Nov 1994 22:03:54 +0000 (22:03 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 3 Nov 1994 22:03:54 +0000 (22:03 +0000)
S_IREAD, S_IWRITE, S_IEXEC.
Make sure the former three are defined.

lib/filemode.c

index c86ee2f..20c65c4 100644 (file)
 #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,