summaryrefslogtreecommitdiff
path: root/lib/filemode.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-08-27 21:23:07 +0000
committerJim Meyering <jim@meyering.net>1994-08-27 21:23:07 +0000
commitbea3493f472ff6e99100c15887dff7caca81489e (patch)
treece34ae6219cd76a86576e279258c6591b922d0b6 /lib/filemode.c
parent22a8e9d17e6c448308d3b2b131d6cb744f292678 (diff)
downloadgnulib-bea3493f472ff6e99100c15887dff7caca81489e.tar.gz
.
Diffstat (limited to 'lib/filemode.c')
-rw-r--r--lib/filemode.c51
1 files changed, 40 insertions, 11 deletions
diff --git a/lib/filemode.c b/lib/filemode.c
index 451c7ac652..838f49af0c 100644
--- a/lib/filemode.c
+++ b/lib/filemode.c
@@ -1,5 +1,5 @@
/* filemode.c -- make a string describing file modes
- Copyright (C) 1985, 1990 Free Software Foundation, Inc.
+ Copyright (C) 1985, 1990, 1993 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,36 +15,65 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+#ifdef HAVE_CONFIG_H
+#if defined (emacs) || defined (CONFIG_BROKETS)
+#include <config.h>
+#else
+#include "config.h"
+#endif
+#endif
+
#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
#endif
-#ifndef S_ISREG /* Doesn't have POSIX.1 stat stuff. */
+
+#if 0 /* This is unreliable, since GCC 2.5 always has S_ISREG in its
+ fixed headers but it does not always have mode_t.
+ It seems safer not to try to use mode_t ever. */
+#if !defined(S_ISREG) || defined(NO_MODE_T)
+/* Doesn't have POSIX.1 stat stuff or doesn't have mode_t. */
#define mode_t unsigned short
#endif
+#endif
+
+#ifdef STAT_MACROS_BROKEN
+#undef S_ISBLK
+#undef S_ISCHR
+#undef S_ISDIR
+#undef S_ISFIFO
+#undef S_ISLNK
+#undef S_ISMPB
+#undef S_ISMPC
+#undef S_ISNWK
+#undef S_ISREG
+#undef S_ISSOCK
+#endif /* STAT_MACROS_BROKEN. */
+
#if !defined(S_ISBLK) && defined(S_IFBLK)
-#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
+#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#endif
#if !defined(S_ISCHR) && defined(S_IFCHR)
-#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
+#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#endif
#if !defined(S_ISDIR) && defined(S_IFDIR)
-#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
#if !defined(S_ISREG) && defined(S_IFREG)
-#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
#if !defined(S_ISFIFO) && defined(S_IFIFO)
-#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
+#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#endif
#if !defined(S_ISLNK) && defined(S_IFLNK)
-#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#endif
#if !defined(S_ISSOCK) && defined(S_IFSOCK)
-#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
+#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
#endif
#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
#define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
@@ -111,7 +140,7 @@ mode_string (mode, str)
unsigned short mode;
char *str;
{
- str[0] = ftypelet (mode);
+ str[0] = ftypelet ((long) mode);
rwx ((mode & 0700) << 0, &str[1]);
rwx ((mode & 0070) << 3, &str[4]);
rwx ((mode & 0007) << 6, &str[7]);
@@ -132,7 +161,7 @@ mode_string (mode, str)
static char
ftypelet (bits)
- mode_t bits;
+ long bits;
{
#ifdef S_ISBLK
if (S_ISBLK (bits))