summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@users.noreply.github.com>2019-12-25 12:27:21 +0100
committerGitHub <noreply@github.com>2019-12-25 12:27:21 +0100
commitd341b91b0a79390aa7c5f1a8095d3d48ddfef9ad (patch)
tree77628f1eca8c99b046bb62f255e966edbfa20ef9
parent50cd151523c2d6379329b946c56d030d8f44e578 (diff)
parentb0d6f44779a9e8d8ed2bb0751d3af3bfd484f1a0 (diff)
downloadi3-d341b91b0a79390aa7c5f1a8095d3d48ddfef9ad.tar.gz
i3-d341b91b0a79390aa7c5f1a8095d3d48ddfef9ad.zip
Merge pull request #3824 from orestisfl/ac_replace_funcs
Use AC_REPLACE_FUNCS
-rw-r--r--configure.ac3
-rw-r--r--include/libi3.h6
-rw-r--r--include/util.h11
-rw-r--r--libi3/mkdirp.c3
-rw-r--r--libi3/strndup.c4
-rw-r--r--src/util.c36
6 files changed, 6 insertions, 57 deletions
diff --git a/configure.ac b/configure.ac
index 22e27f6f..82f6fccd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -72,7 +72,8 @@ AC_CHECK_TYPES([mode_t, off_t, pid_t, size_t, ssize_t], , [AC_MSG_FAILURE([canno
AC_FUNC_FORK
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_STRNLEN
-AC_CHECK_FUNCS([atexit dup2 ftruncate getcwd gettimeofday localtime_r memchr memset mkdir rmdir setlocale socket strcasecmp strchr strdup strerror strncasecmp strndup strrchr strspn strstr strtol strtoul], , [AC_MSG_FAILURE([cannot find the $ac_func function, which i3 requires])])
+AC_CHECK_FUNCS([atexit dup2 ftruncate getcwd gettimeofday localtime_r memchr memset mkdir rmdir setlocale socket strcasecmp strchr strdup strerror strncasecmp strrchr strspn strstr strtol strtoul], , [AC_MSG_FAILURE([cannot find the $ac_func function, which i3 requires])])
+AC_REPLACE_FUNCS([mkdirp strndup])
# Checks for libraries.
diff --git a/include/libi3.h b/include/libi3.h
index 790baba9..15d1bc76 100644
--- a/include/libi3.h
+++ b/include/libi3.h
@@ -341,8 +341,7 @@ gchar *g_utf8_make_valid(const gchar *str, gssize len);
*/
uint32_t get_colorpixel(const char *hex) __attribute__((const));
-#if defined(__APPLE__)
-
+#ifndef HAVE_strndup
/**
* Taken from FreeBSD
* Returns a pointer to a new string which is a duplicate of the
@@ -350,7 +349,6 @@ uint32_t get_colorpixel(const char *hex) __attribute__((const));
*
*/
char *strndup(const char *str, size_t n);
-
#endif
/**
@@ -528,7 +526,7 @@ char *resolve_tilde(const char *path);
*/
char *get_config_path(const char *override_configpath, bool use_system_paths);
-#if !defined(__sun)
+#ifndef HAVE_mkdirp
/**
* Emulates mkdir -p (creates any missing folders)
*
diff --git a/include/util.h b/include/util.h
index ad7195ee..6d525626 100644
--- a/include/util.h
+++ b/include/util.h
@@ -124,17 +124,6 @@ bool path_exists(const char *path);
*/
void i3_restart(bool forget_layout);
-#if defined(__OpenBSD__) || defined(__APPLE__)
-
-/**
- * Taken from FreeBSD
- * Find the first occurrence of the byte string s in byte string l.
- *
- */
-void *memmem(const void *l, size_t l_len, const void *s, size_t s_len);
-
-#endif
-
/**
* Escapes the given string if a pango font is currently used.
* If the string has to be escaped, the input string will be free'd.
diff --git a/libi3/mkdirp.c b/libi3/mkdirp.c
index f5281bd7..35a30475 100644
--- a/libi3/mkdirp.c
+++ b/libi3/mkdirp.c
@@ -12,12 +12,11 @@
#include <string.h>
#include <sys/stat.h>
+#ifndef HAVE_mkdirp
/*
* Emulates mkdir -p (creates any missing folders)
*
*/
-
-#if !defined(__sun)
int mkdirp(const char *path, mode_t mode) {
if (mkdir(path, mode) == 0)
return 0;
diff --git a/libi3/strndup.c b/libi3/strndup.c
index e17f843c..e215a76f 100644
--- a/libi3/strndup.c
+++ b/libi3/strndup.c
@@ -10,8 +10,7 @@
#include <sys/types.h>
#include <string.h>
-#if defined(__APPLE__)
-
+#ifndef HAVE_strndup
/*
* Taken from FreeBSD
* Returns a pointer to a new string which is a duplicate of the
@@ -30,5 +29,4 @@ char *strndup(const char *str, size_t n) {
copy[len] = '\0';
return (copy);
}
-
#endif
diff --git a/src/util.c b/src/util.c
index 8c84a436..f0e053be 100644
--- a/src/util.c
+++ b/src/util.c
@@ -312,42 +312,6 @@ void i3_restart(bool forget_layout) {
/* not reached */
}
-#if defined(__OpenBSD__) || defined(__APPLE__)
-
-/*
- * Taken from FreeBSD
- * Find the first occurrence of the byte string s in byte string l.
- *
- */
-void *memmem(const void *l, size_t l_len, const void *s, size_t s_len) {
- register char *cur, *last;
- const char *cl = (const char *)l;
- const char *cs = (const char *)s;
-
- /* we need something to compare */
- if (l_len == 0 || s_len == 0)
- return NULL;
-
- /* "s" must be smaller or equal to "l" */
- if (l_len < s_len)
- return NULL;
-
- /* special case where s_len == 1 */
- if (s_len == 1)
- return memchr(l, (int)*cs, l_len);
-
- /* the last position where its possible to find "s" in "l" */
- last = (char *)cl + l_len - s_len;
-
- for (cur = (char *)cl; cur <= last; cur++)
- if (cur[0] == cs[0] && memcmp(cur, cs, s_len) == 0)
- return cur;
-
- return NULL;
-}
-
-#endif
-
/*
* Escapes the given string if a pango font is currently used.
* If the string has to be escaped, the input string will be free'd.