diff mbox

[2/2] android: add strchrnul to shader_runner.c

Message ID 1359756720-29476-2-git-send-email-tom.gall@linaro.org
State New
Headers show

Commit Message

Tom Gall Feb. 1, 2013, 10:12 p.m. UTC
strchrnul is used in shader_runner.c (and no where else in all
of piglit). Unfortunately bionic, Android's c library does not
include this function. I've writen an implementation of
strchrnul which is only used when compiling for Android.

Signed-off-by: Tom Gall <tom.gall@linaro.org>
---
 tests/shaders/shader_runner.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff mbox

Patch

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 20f1ee0..fab7296 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -38,6 +38,26 @@ 
 
 #include "shader_runner_gles_workarounds.h"
 
+#if defined(__ANDROID__)
+/* on Android there is no strchrnul which is used in this test, so we must fill
+ * in an implementation.
+ *
+ * The strchrnul() function is like strchr() except that if c is not found in s, then
+ * it returns a pointer to the null byte at the end of s, rather than NULL
+ */
+char *
+strchrnul(const char *s, int c)
+{
+	char * result = strchr(s, c);
+
+	if (result == NULL) {
+		result = s + strlen(s);
+	}
+
+	return result;
+}
+#endif /* __ANDROID__ */
+
 static void
 get_required_versions(const char *script_name,
 		      struct piglit_gl_test_config *config);