aboutsummaryrefslogtreecommitdiffstats
path: root/evaluator.c
diff options
context:
space:
mode:
authormichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2007-06-17 06:06:19 +0000
committermichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2007-06-17 06:06:19 +0000
commit2fcc2950e43cba7cd677057cde39c2766848616f (patch)
tree10410bf31373ac7e1f530effef2cbd9af9efd4d1 /evaluator.c
parentd6c3787acf186f58e3fda571e77f73bea7324f40 (diff)
downloadlcd4linux-2fcc2950e43cba7cd677057cde39c2766848616f.tar.gz
strndup() replacement
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@805 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'evaluator.c')
-rw-r--r--evaluator.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/evaluator.c b/evaluator.c
index aaebee9..958ed6e 100644
--- a/evaluator.c
+++ b/evaluator.c
@@ -199,6 +199,30 @@ static FUNCTION *Function = NULL;
static unsigned int nFunction = 0;
+/* strndup() may be not available on several platforms */
+#ifndef HAVE_STRNDUP
+char *strndup(const char *source, size_t len)
+{
+ char *tmp = NULL;
+
+ if (source == NULL)
+ return NULL;
+
+ if (len >= strlen(source))
+ return strdup(source);
+
+ tmp = malloc(len + 1);
+ if (tmp == 0)
+ return NULL;
+
+ strncpy(tmp, source, len);
+ tmp[len] = '\0';
+
+ return (tmp);
+}
+#endif
+
+
void DelResult(RESULT * result)
{
result->type = 0;