aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-01-21 02:08:45 -0800
committerChris Robinson <[email protected]>2016-01-21 02:09:32 -0800
commit9c05a16c9a394dea90fcefc29eb2ef2be06dc4b5 (patch)
treeb3cc0c79d77e6b36dca7f8f658b34691808116e6
parentbbd2876afb5265517d25e78d7dcaf7ccb494af0f (diff)
Fix for systems that don't have strnlen
-rw-r--r--Alc/backends/oss.c18
-rw-r--r--CMakeLists.txt3
-rw-r--r--config.h.in3
3 files changed, 19 insertions, 5 deletions
diff --git a/Alc/backends/oss.c b/Alc/backends/oss.c
index 1e286791..33d7750a 100644
--- a/Alc/backends/oss.c
+++ b/Alc/backends/oss.c
@@ -27,6 +27,7 @@
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <memory.h>
#include <unistd.h>
#include <errno.h>
@@ -93,15 +94,21 @@ static void ALCossListPopulate(struct oss_device *UNUSED(playback), struct oss_d
#else
+#ifndef HAVE_STRNLEN
+static size_t strnlen(const char *str, size_t maxlen)
+{
+ const char *end = memchr(str, 0, maxlen);
+ if(!end) return maxlen;
+ return end - str;
+}
+#endif
+
static void ALCossListAppend(struct oss_device *list, const char *handle, size_t hlen, const char *path, size_t plen)
{
struct oss_device *next;
struct oss_device *last;
size_t i;
- if(plen == 0 || path[0] == '\0')
- return;
-
/* skip the first item "OSS Default" */
last = list;
next = list->next;
@@ -173,7 +180,10 @@ static void ALCossListPopulate(struct oss_device *playback, struct oss_device *c
ERR("SNDCTL_AUDIOINFO (%d) failed: %s\n", i, strerror(errno));
continue;
}
- if(ai.handle[0])
+ if(ai.devnode[0] == '\0')
+ continue;
+
+ if(ai.handle[0] != '\0')
{
len = strnlen(ai.handle, sizeof(ai.handle));
handle = ai.handle;
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 513bd037..e503df92 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -453,8 +453,8 @@ IF(HAVE_FLOAT_H)
CHECK_SYMBOL_EXISTS(__control87_2 float.h HAVE___CONTROL87_2)
ENDIF()
-CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
CHECK_FUNCTION_EXISTS(stat HAVE_STAT)
+CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
IF(NOT HAVE_STRCASECMP)
CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
@@ -475,6 +475,7 @@ IF(NOT HAVE_STRNCASECMP)
ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
ENDIF()
+CHECK_SYMBOL_EXISTS(strnlen string.h HAVE_STRNLEN)
CHECK_SYMBOL_EXISTS(snprintf stdio.h HAVE_SNPRINTF)
IF(NOT HAVE_SNPRINTF)
CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
diff --git a/config.h.in b/config.h.in
index e66b1fe8..3bc3eb48 100644
--- a/config.h.in
+++ b/config.h.in
@@ -86,6 +86,9 @@
/* Define if we have the strtof function */
#cmakedefine HAVE_STRTOF
+/* Define if we have the strnlen function */
+#cmakedefine HAVE_STRNLEN
+
/* Define if we have the __int64 type */
#cmakedefine HAVE___INT64