This commit fixes the locale dependency (re-)introduced by commit
c3ad36ef81 by using sscanf() to parse
floating point values.
This modification uses nsvg__atof() which is independent of the
current locale.
Fix "No newline at end of file" warning. The newline was removed
by commit 47f28a2a78, probably unintentionally.
Add missing comments to #endif statements for clarity and consistency.
In some unusual cases, r->nedges == 0 and r->edges == NULL.
At least glibc declares the array pointer for qsort() to be non-NULL,
causing UBSan (-fsanitize=nonnull-attribute) to complain.
`a` is implicitly cast to (signed) `int` before shifting, and when `int`
is 32-bit, it is undefined behavior to left-shift `a` by 24 when its
most significant bit is 1. Error from UBSan (`-fsanitize=shift-base`):
nanosvgrast.h:975:41: runtime error: left shift of 255 by 24 places
cannot be represented in type 'int'
Casting `a` to `unsigned int` before shifting avoids undefined behavior.
- prevent infinite loop when gradient ID is left to empty string
- prevent infinite loop when gradient references to self
- lookup up to 32 references back
- make sure nsvg__addPath() hands only valid number of pointts (1+N*3)
- require moveTo path command before handling other commands
- require (sign+)digit for a valid path command coordinate
- allow to add bezier segment only after there’s at leat one point (now
also consistent with nsvg__lineTo)
Instead of calculating percentage coordinates relative to 1px, we calculate them
relative to 0px width, that way an explicit <svg width="100%"> will be converted
to <svg width="0px"> and trigger the bounding-box sizing calculation.
Use custom strong to float conversion instead of the one from std
library to fix parsing floats with locales which use different number
format than specified by SVG.