This repository has been archived by the owner on Jun 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathreadline_mingw.patch
98 lines (92 loc) · 3.11 KB
/
readline_mingw.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
diff --git a/colors.c b/colors.c
index 7859f5d..5d1835a 100644
--- a/colors.c
+++ b/colors.c
@@ -37,6 +37,10 @@
#include "posixstat.h" // stat related macros (S_ISREG, ...)
#include <fcntl.h> // S_ISUID
+#ifndef S_ISDIR
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#endif
+
// strlen()
#if defined (HAVE_STRING_H)
# include <string.h>
@@ -170,8 +174,10 @@ _rl_print_color_indicator (const char *f)
if (linkok == -1 && _rl_color_indicator[C_MISSING].string != NULL)
colored_filetype = C_MISSING;
+#if defined (HAVE_LSTAT)
else if (linkok == 0 && S_ISLNK(mode) && _rl_color_indicator[C_ORPHAN].string != NULL)
colored_filetype = C_ORPHAN; /* dangling symlink */
+#endif
else if(stat_ok != 0)
{
static enum indicator_no filetype_indicator[] = FILETYPE_INDICATORS;
@@ -182,12 +188,17 @@ _rl_print_color_indicator (const char *f)
if (S_ISREG (mode))
{
colored_filetype = C_FILE;
-
+#ifdef 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
+#ifdef 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;
else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC))
colored_filetype = C_EXEC;
@@ -211,12 +222,16 @@ _rl_print_color_indicator (const char *f)
colored_filetype = C_STICKY;
#endif
}
+#if defined (S_ISLNK)
else if (S_ISLNK (mode))
colored_filetype = C_LINK;
+#endif
else if (S_ISFIFO (mode))
colored_filetype = C_FIFO;
+#if defined (S_ISSOCK)
else if (S_ISSOCK (mode))
colored_filetype = C_SOCK;
+#endif
else if (S_ISBLK (mode))
colored_filetype = C_BLK;
else if (S_ISCHR (mode))
diff --git a/histfile.c b/histfile.c
index 5b057cd..2e69c58 100644
--- a/histfile.c
+++ b/histfile.c
@@ -606,12 +606,14 @@ history_truncate_file (fname, lines)
history_lines_written_to_file = 0;
}
+#if defined (HAVE_CHOWN)
/* Make sure the new filename is owned by the same user as the old. If one
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. */
if (rv == 0 && exists)
r = chown (filename, finfo.st_uid, finfo.st_gid);
+#endif
xfree (filename);
FREE (tempname);
@@ -753,12 +755,14 @@ mmap_error:
history_lines_written_to_file = 0;
}
+#if defined (HAVE_CHOWN)
/* Make sure the new filename is owned by the same user as the old. If one
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. */
if (rv == 0 && exists)
mode = chown (histname, finfo.st_uid, finfo.st_gid);
+#endif
FREE (histname);
FREE (tempname);