aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;