* Copyright 2008-2009 James Bursa <james@semichrome.net>
*/
-#define _GNU_SOURCE /* for strndup */
#include <assert.h>
#include <math.h>
#include <setjmp.h>
s += 13;
while (*s == ' ')
s++;
- state->stroke_width = svgtiny_parse_length(s,
+ value = strndup(s, strcspn(s, "; "));
+ state->stroke_width = svgtiny_parse_length(value,
state->viewport_width, *state);
+ free(value);
}
}
}
free(svg);
}
+#ifndef HAVE_STRNDUP
+char *svgtiny_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
+