svn path=/trunk/libsvgtiny/; revision=11140
* Copyright 2008-2009 James Bursa <james@semichrome.net>
*/
-#define _GNU_SOURCE /* for strndup */
#include <assert.h>
#include <math.h>
#include <setjmp.h>
free(svg);
}
+#ifndef HAVE_STRNDUP
+char *strndup(const char *s, size_t n)
+{
+ size_t len;
+ char *s2;
+
+ for (len = 0; len != n && s[len]; len++)
+ continue;
+
+ s2 = malloc(len + 1);
+ if (s2 == NULL)
+ return NULL;
+
+ memcpy(s2, s, len);
+ s2[len] = '\0';
+
+ return s2;
+}
+#endif
+
* Copyright 2008 James Bursa <james@semichrome.net>
*/
-#define _GNU_SOURCE /* for strndup */
#include <assert.h>
#include <math.h>
#include <string.h>
struct svgtiny_shape *svgtiny_add_shape(struct svgtiny_parse_state *state);
void svgtiny_transform_path(float *p, unsigned int n,
struct svgtiny_parse_state *state);
+#if defined(_GNU_SOURCE)
+#define HAVE_STRNDUP
+#else
+#undef HAVE_STRNDUP
+char *strndup(const char *s, size_t n);
+#endif
/* svgtiny_gradient.c */
void svgtiny_find_gradient(const char *id, struct svgtiny_parse_state *state);