Fixed reverse shape list implementation

This commit is contained in:
daniel-starke 2017-04-21 18:41:59 +02:00
parent c4a603c20e
commit 3f40cbc53e

View File

@ -2787,7 +2787,7 @@ NSVGimage* nsvgParse(char* input, const char* units, float dpi)
{ {
NSVGparser* p; NSVGparser* p;
NSVGimage* ret = 0; NSVGimage* ret = 0;
NSVGshape* cur, *tmp; NSVGshape* cur, *prev, *tmp;
p = nsvg__createParser(); p = nsvg__createParser();
if (p == NULL) { if (p == NULL) {
@ -2799,13 +2799,14 @@ NSVGimage* nsvgParse(char* input, const char* units, float dpi)
// Reverse the list of shapes to match SVG order // Reverse the list of shapes to match SVG order
cur = p->image->shapes; cur = p->image->shapes;
while (cur && cur->next != NULL) { prev = NULL;
tmp = cur->next; while (cur != NULL) {
cur->next = cur->next->next; tmp = cur;
tmp->next = p->image->shapes;
p->image->shapes = tmp;
cur = cur->next; cur = cur->next;
tmp->next = prev;
prev = tmp;
} }
if (prev != NULL) p->image->shapes = prev;
// Scale to viewBox // Scale to viewBox
nsvg__scaleToViewbox(p, units); nsvg__scaleToViewbox(p, units);