Skip to content

Commit

Permalink
fix path number parse, leadin zero is just zero #167
Browse files Browse the repository at this point in the history
  • Loading branch information
tesch1 committed Oct 10, 2019
1 parent 6f6fb16 commit bd684c8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
11 changes: 7 additions & 4 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/example)

find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
include_directories(${GLFW_INCLUDE_DIRS})
#pkg_search_module(GLFW REQUIRED glfw3)
#
add_compile_options(-O2 -Wall)
find_package(OpenGL REQUIRED)
find_package(glfw3 3.3 REQUIRED)
include_directories(${GLFW_INCLUDE_DIRS})

add_executable(dump dump.c)
add_executable(example1 example1.c)
add_executable(example2 example2.c)

target_link_libraries(dump m )
target_link_libraries(example1 m GL ${GLFW_STATIC_LIBRARIES})
target_link_libraries(example2 m GL ${GLFW_STATIC_LIBRARIES})
target_link_libraries(example1 m ${OPENGL_LIBRARIES} glfw)
target_link_libraries(example2 m ${OPENGL_LIBRARIES} glfw)

#
# if fuzzing is enabled
Expand Down
2 changes: 1 addition & 1 deletion example/example1.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ int main(int argc, char *argv[])
filename = argv[1];
g_image = nsvgParseFromFile(filename, "px", 96.0f);
if (g_image == NULL) {
printf("Could not open SVG image.\n");
printf("Could not open SVG image '%s'.\n", filename);
glfwTerminate();
return -1;
}
Expand Down
8 changes: 7 additions & 1 deletion src/nanosvg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1153,10 +1153,16 @@ static const char* nsvg__parseNumber(const char* s, char* it, const int size)
s++;
}
// integer part
while (*s && nsvg__isdigit(*s)) {
// leading zero
if (*s && *s == '0') {
if (i < last) it[i++] = *s;
s++;
}
else
while (*s && nsvg__isdigit(*s)) {
if (i < last) it[i++] = *s;
s++;
}
if (*s == '.') {
// decimal point
if (i < last) it[i++] = *s;
Expand Down

0 comments on commit bd684c8

Please sign in to comment.