diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/log.c | 2 | ||||
-rw-r--r-- | common/stringop.c | 2 | ||||
-rw-r--r-- | common/util.c | 68 |
3 files changed, 36 insertions, 36 deletions
diff --git a/common/log.c b/common/log.c index 61937495..af1bdc3f 100644 --- a/common/log.c +++ b/common/log.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _POSIX_C_SOURCE 1 | 1 | #define _POSIX_C_SOURCE 199506L |
2 | #include <errno.h> | 2 | #include <errno.h> |
3 | #include <libgen.h> | 3 | #include <libgen.h> |
4 | #include <signal.h> | 4 | #include <signal.h> |
diff --git a/common/stringop.c b/common/stringop.c index 99e9636d..4a37543d 100644 --- a/common/stringop.c +++ b/common/stringop.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _XOPEN_SOURCE 700 |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <string.h> | 4 | #include <string.h> |
diff --git a/common/util.c b/common/util.c index a9e6a9c2..d6369853 100644 --- a/common/util.c +++ b/common/util.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _XOPEN_SOURCE 700 |
2 | #include <sys/types.h> | 2 | #include <sys/types.h> |
3 | #include <sys/stat.h> | 3 | #include <sys/stat.h> |
4 | #include <unistd.h> | 4 | #include <unistd.h> |
@@ -124,38 +124,38 @@ uint32_t parse_color(const char *color) { | |||
124 | } | 124 | } |
125 | 125 | ||
126 | char* resolve_path(const char* path) { | 126 | char* resolve_path(const char* path) { |
127 | struct stat sb; | 127 | struct stat sb; |
128 | ssize_t r; | 128 | ssize_t r; |
129 | int i; | 129 | int i; |
130 | char *current = NULL; | 130 | char *current = NULL; |
131 | char *resolved = NULL; | 131 | char *resolved = NULL; |
132 | 132 | ||
133 | if(!(current = strdup(path))) { | 133 | if(!(current = strdup(path))) { |
134 | return NULL; | 134 | return NULL; |
135 | } | 135 | } |
136 | for (i = 0; i < 16; ++i) { | 136 | for (i = 0; i < 16; ++i) { |
137 | if (lstat(current, &sb) == -1) { | 137 | if (lstat(current, &sb) == -1) { |
138 | goto failed; | 138 | goto failed; |
139 | } | 139 | } |
140 | if((sb.st_mode & S_IFMT) != S_IFLNK) { | 140 | if((sb.st_mode & S_IFMT) != S_IFLNK) { |
141 | return current; | 141 | return current; |
142 | } | 142 | } |
143 | if (!(resolved = malloc(sb.st_size + 1))) { | 143 | if (!(resolved = malloc(sb.st_size + 1))) { |
144 | goto failed; | 144 | goto failed; |
145 | } | 145 | } |
146 | r = readlink(current, resolved, sb.st_size); | 146 | r = readlink(current, resolved, sb.st_size); |
147 | if (r == -1 || r > sb.st_size) { | 147 | if (r == -1 || r > sb.st_size) { |
148 | goto failed; | 148 | goto failed; |
149 | } | 149 | } |
150 | resolved[r] = '\0'; | 150 | resolved[r] = '\0'; |
151 | free(current); | 151 | free(current); |
152 | current = strdup(resolved); | 152 | current = strdup(resolved); |
153 | free(resolved); | 153 | free(resolved); |
154 | resolved = NULL; | 154 | resolved = NULL; |
155 | } | 155 | } |
156 | 156 | ||
157 | failed: | 157 | failed: |
158 | free(resolved); | 158 | free(resolved); |
159 | free(current); | 159 | free(current); |
160 | return NULL; | 160 | return NULL; |
161 | } \ No newline at end of file | 161 | } |