Merge pull request #154 from jzrake/master

Fix parsing of numbers with units ex and em
This commit is contained in:
Mikko Mononen 2019-03-08 22:33:32 +02:00 committed by GitHub
commit 7cd94e3191
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1130,7 +1130,7 @@ static double nsvg__atof(const char* s)
// Parse optional exponent // Parse optional exponent
if (*cur == 'e' || *cur == 'E') { if (*cur == 'e' || *cur == 'E') {
int expPart = 0; long expPart = 0;
cur++; // skip 'E' cur++; // skip 'E'
expPart = strtol(cur, &end, 10); // Parse digit sequence with sign expPart = strtol(cur, &end, 10); // Parse digit sequence with sign
if (cur != end) { if (cur != end) {
@ -1168,7 +1168,7 @@ static const char* nsvg__parseNumber(const char* s, char* it, const int size)
} }
} }
// exponent // exponent
if (*s == 'e' || *s == 'E') { if ((*s == 'e' || *s == 'E') && (s[1] != 'm' && s[1] != 'x')) {
if (i < last) it[i++] = *s; if (i < last) it[i++] = *s;
s++; s++;
if (*s == '-' || *s == '+') { if (*s == '-' || *s == '+') {