From 24fcc1eecb87b8fa598cd5aa8bab9fdb6f657b3d Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 18 Aug 2010 11:50:49 +0000 Subject: [PATCH] Fix parsing of numbers in svg files : the code used obsolete atod instead of strtod and led to numbers in the form 2.5e-4 to make the parsing fail as 'e' was interpreted as the end of the number. Fixes #5728. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38230 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../import_export/svg/PathTokenizer.cpp | 17 +++-------------- .../import_export/svg/SVGParser.cpp | 2 +- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/apps/icon-o-matic/import_export/svg/PathTokenizer.cpp b/src/apps/icon-o-matic/import_export/svg/PathTokenizer.cpp index e17f47df56..38999ad933 100644 --- a/src/apps/icon-o-matic/import_export/svg/PathTokenizer.cpp +++ b/src/apps/icon-o-matic/import_export/svg/PathTokenizer.cpp @@ -142,20 +142,9 @@ PathTokenizer::is_separator(unsigned c) const bool PathTokenizer::parse_number() { - char buf[256]; // Should be enough for any number - char* buf_ptr = buf; - - // Copy all sign characters - while (buf_ptr < buf+255 && *fPath == '-' || *fPath == '+') { - *buf_ptr++ = *fPath++; - } - - // Copy all numeric characters - while (buf_ptr < buf+255 && isNumeric(*fPath)) { - *buf_ptr++ = *fPath++; - } - *buf_ptr = 0; - fLastNumber = atof(buf); + char* end; + fLastNumber = strtod(fPath, &end); + fPath = end; return true; } diff --git a/src/apps/icon-o-matic/import_export/svg/SVGParser.cpp b/src/apps/icon-o-matic/import_export/svg/SVGParser.cpp index 49f37b283b..e4253dc736 100644 --- a/src/apps/icon-o-matic/import_export/svg/SVGParser.cpp +++ b/src/apps/icon-o-matic/import_export/svg/SVGParser.cpp @@ -364,7 +364,7 @@ Parser::parse(const char* pathToFile) void Parser::start_element(void* data, const char* el, const char** attr) { -//printf("Parser::start_element(%s)\n", el); +// printf("Parser::start_element(%s)\n", el); Parser& self = *(Parser*)data; if (strcmp(el, "svg") == 0)