From dc46f954b60b9425f685db5146d8b17787d00191 Mon Sep 17 00:00:00 2001 From: Jonathan Zrake Date: Fri, 8 Mar 2019 13:48:30 -0500 Subject: [PATCH] Fix parsing of numbers with units ex and em Unrelated: kill precision warning in nsvg__atof, make expPart long. --- src/nanosvg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nanosvg.h b/src/nanosvg.h index 8c8b061..4797afd 100644 --- a/src/nanosvg.h +++ b/src/nanosvg.h @@ -1130,7 +1130,7 @@ static double nsvg__atof(const char* s) // Parse optional exponent if (*cur == 'e' || *cur == 'E') { - int expPart = 0; + long expPart = 0; cur++; // skip 'E' expPart = strtol(cur, &end, 10); // Parse digit sequence with sign if (cur != end) { @@ -1168,7 +1168,7 @@ static const char* nsvg__parseNumber(const char* s, char* it, const int size) } } // exponent - if (*s == 'e' || *s == 'E') { + if ((*s == 'e' || *s == 'E') && (s[1] != 'm' && s[1] != 'x')) { if (i < last) it[i++] = *s; s++; if (*s == '-' || *s == '+') {