X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2Fsvgtiny.c;h=8fa09a5bdd6e66ed2cdbdcb01d690af3f277e0f3;hb=035aa3397d290e4e475ede4c7faa1f40f52e454e;hp=d87a862f9a013c5047ca3d33ce84c2b5c6a29ba6;hpb=ff9998942c6940fe0fbc1151093527179e853cf0;p=libsvgtiny.git diff --git a/src/svgtiny.c b/src/svgtiny.c index d87a862..8fa09a5 100644 --- a/src/svgtiny.c +++ b/src/svgtiny.c @@ -5,7 +5,6 @@ * Copyright 2008-2009 James Bursa */ -#define _GNU_SOURCE /* for strndup */ #include #include #include @@ -917,8 +916,10 @@ void svgtiny_parse_paint_attributes(const xmlNode *node, 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); } } } @@ -1230,3 +1231,23 @@ void svgtiny_free(struct svgtiny_diagram *svg) 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 +