svg_loader SvgPath: Added corner case handling for flags of Arc

It handles the case what the flag of the arc of the path is defined
without spaces or commas, such as 00, 01, 11 or 10.
This commit is contained in:
JunsuChoi 2021-06-23 12:43:45 +09:00 committed by Mira Grudzinska
parent b17f3cc9a4
commit 5da4c81138

View file

@ -57,16 +57,15 @@ static bool _parseNumber(char** content, float* number)
static bool _parseFlag(char** content, int* number) static bool _parseFlag(char** content, int* number)
{ {
char* end = NULL; if (*(*content) != '0' && *(*content) != '1') return false;
*number = strtol(*content, &end, 10); *number = *(*content) - '0';
//If the start of string is not number or a number was a float *content = _skipComma(*content + 1);
if ((*content) == end || *end == '.') return false; if (*(*content) == '.') return false;
//If a flag has a different value than 0 or 1
if (*number != 0 && *number != 1) return false;
*content = _skipComma(end);
return true; return true;
} }
void _pathAppendArcTo(Array<PathCommand>* cmds, Array<Point>* pts, Point* cur, Point* curCtl, float x, float y, float rx, float ry, float angle, bool largeArc, bool sweep) void _pathAppendArcTo(Array<PathCommand>* cmds, Array<Point>* pts, Point* cur, Point* curCtl, float x, float y, float rx, float ry, float angle, bool largeArc, bool sweep)
{ {
float cxp, cyp, cx, cy; float cxp, cyp, cx, cy;