bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-readline] [PATCH] add define guards for features missing on mingw-w


From: Marty E. Plummer
Subject: [Bug-readline] [PATCH] add define guards for features missing on mingw-w64
Date: Sun, 14 Jan 2018 09:47:09 -0600

Current mingw-w64 is missing certain posix functions and capabilities
(because windows itself is missing them). Add some guards around those,
and use no-ops when needed.

Signed-off-by: Marty E. Plummer <address@hidden>
---
 colors.c    | 14 ++++++++++++--
 colors.h    |  2 +-
 histfile.c  |  4 ++++
 posixstat.h | 16 ++++++++++++++++
 4 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/colors.c b/colors.c
index 7859f5d..ad29e23 100644
--- a/colors.c
+++ b/colors.c
@@ -183,14 +183,22 @@ _rl_print_color_indicator (const char *f)
         {
           colored_filetype = C_FILE;
 
+#if defined (S_ISUID)
           if ((mode & S_ISUID) != 0 && is_colored (C_SETUID))
             colored_filetype = C_SETUID;
-          else if ((mode & S_ISGID) != 0 && is_colored (C_SETGID))
+          else
+#endif
+#if defined (S_ISGID)
+          if ((mode & S_ISGID) != 0 && is_colored (C_SETGID))
             colored_filetype = C_SETGID;
-          else if (is_colored (C_CAP) && 0) //f->has_capability)
+          else
+#endif
+          if (is_colored (C_CAP) && 0) //f->has_capability)
             colored_filetype = C_CAP;
+#if defined(S_IXUGO)
           else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC))
             colored_filetype = C_EXEC;
+#endif
           else if ((1 < astat.st_nlink) && is_colored (C_MULTIHARDLINK))
             colored_filetype = C_MULTIHARDLINK;
         }
@@ -204,8 +212,10 @@ _rl_print_color_indicator (const char *f)
             colored_filetype = C_STICKY_OTHER_WRITABLE;
           else
 #endif
+#if defined (S_IWOTH)
           if ((mode & S_IWOTH) != 0 && is_colored (C_OTHER_WRITABLE))
             colored_filetype = C_OTHER_WRITABLE;
+#endif
 #if defined (S_ISVTX)
           else if ((mode & S_ISVTX) != 0 && is_colored (C_STICKY))
             colored_filetype = C_STICKY;
diff --git a/colors.h b/colors.h
index 6561ad9..4a32d43 100644
--- a/colors.h
+++ b/colors.h
@@ -96,7 +96,7 @@ enum indicator_no
   };
 
 
-#if !S_IXUGO
+#if !S_IXUGO && defined(S_IXUSR) && defined(S_IXGRP) && defined(S_IXOTH)
 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
 #endif
 
diff --git a/histfile.c b/histfile.c
index 5b057cd..256b373 100644
--- a/histfile.c
+++ b/histfile.c
@@ -610,8 +610,10 @@ history_truncate_file (fname, lines)
      user is running this, it's a no-op.  If the shell is running after sudo
      with a shared history file, we don't want to leave the history file
      owned by root. */
+#ifdef HAVE_CHOWN
   if (rv == 0 && exists)
     r = chown (filename, finfo.st_uid, finfo.st_gid);
+#endif
 
   xfree (filename);
   FREE (tempname);
@@ -757,8 +759,10 @@ mmap_error:
      user is running this, it's a no-op.  If the shell is running after sudo
      with a shared history file, we don't want to leave the history file
      owned by root. */
+#ifdef HAVE_CHOWN
   if (rv == 0 && exists)
     mode = chown (histname, finfo.st_uid, finfo.st_gid);
+#endif
 
   FREE (histname);
   FREE (tempname);
diff --git a/posixstat.h b/posixstat.h
index 3eb7f29..854a2c9 100644
--- a/posixstat.h
+++ b/posixstat.h
@@ -78,30 +78,44 @@
 
 #if defined (S_IFBLK) && !defined (S_ISBLK)
 #define        S_ISBLK(m)      (((m)&S_IFMT) == S_IFBLK)       /* block device 
*/
+#elif !defined (S_IFBLK)
+#define S_ISBLK(m)     0
 #endif
 
 #if defined (S_IFCHR) && !defined (S_ISCHR)
 #define        S_ISCHR(m)      (((m)&S_IFMT) == S_IFCHR)       /* character 
device */
+#elif !defined (S_IFCHR)
+#define S_ISCHR(m)     0
 #endif
 
 #if defined (S_IFDIR) && !defined (S_ISDIR)
 #define        S_ISDIR(m)      (((m)&S_IFMT) == S_IFDIR)       /* directory */
+#elif !defined (S_IFDIR)
+#define S_ISDIR(m)     0
 #endif
 
 #if defined (S_IFREG) && !defined (S_ISREG)
 #define        S_ISREG(m)      (((m)&S_IFMT) == S_IFREG)       /* file */
+#elif !defined (S_IFREG)
+#define S_ISREG(m)     0
 #endif
 
 #if defined (S_IFIFO) && !defined (S_ISFIFO)
 #define        S_ISFIFO(m)     (((m)&S_IFMT) == S_IFIFO)       /* fifo - named 
pipe */
+#elif !defined (S_IFIFO)
+#define S_ISFIFO(m)    0
 #endif
 
 #if defined (S_IFLNK) && !defined (S_ISLNK)
 #define        S_ISLNK(m)      (((m)&S_IFMT) == S_IFLNK)       /* symbolic 
link */
+#elif !defined (S_IFLNK)
+#define S_ISLNK(m)     0
 #endif
 
 #if defined (S_IFSOCK) && !defined (S_ISSOCK)
 #define        S_ISSOCK(m)     (((m)&S_IFMT) == S_IFSOCK)      /* socket */
+#elif !defined (S_IFSOCK)
+#define S_ISSOCK(m)    0
 #endif
 
 /*
@@ -137,6 +151,8 @@
 /* These are non-standard, but are used in builtins.c$symbolic_umask() */
 #define S_IRUGO                (S_IRUSR | S_IRGRP | S_IROTH)
 #define S_IWUGO                (S_IWUSR | S_IWGRP | S_IWOTH)
+#if defined(S_IXUSR) && defined(S_IXGRP) && defined(S_IXOTH)
 #define S_IXUGO                (S_IXUSR | S_IXGRP | S_IXOTH)
+#endif
 
 #endif /* _POSIXSTAT_H_ */
-- 
2.15.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]