[haiku-commits] r38230 - haiku/trunk/src/apps/icon-o-matic/import_export/svg

  • From: pulkomandy@xxxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 18 Aug 2010 13:50:50 +0200 (CEST)

Author: pulkomandy
Date: 2010-08-18 13:50:49 +0200 (Wed, 18 Aug 2010)
New Revision: 38230
Changeset: http://dev.haiku-os.org/changeset/38230
Ticket: http://dev.haiku-os.org/ticket/5728

Modified:
   haiku/trunk/src/apps/icon-o-matic/import_export/svg/PathTokenizer.cpp
   haiku/trunk/src/apps/icon-o-matic/import_export/svg/SVGParser.cpp
Log:
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.


Modified: haiku/trunk/src/apps/icon-o-matic/import_export/svg/PathTokenizer.cpp
===================================================================
--- haiku/trunk/src/apps/icon-o-matic/import_export/svg/PathTokenizer.cpp       
2010-08-18 11:39:39 UTC (rev 38229)
+++ haiku/trunk/src/apps/icon-o-matic/import_export/svg/PathTokenizer.cpp       
2010-08-18 11:50:49 UTC (rev 38230)
@@ -142,20 +142,9 @@
 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;
 }
 

Modified: haiku/trunk/src/apps/icon-o-matic/import_export/svg/SVGParser.cpp
===================================================================
--- haiku/trunk/src/apps/icon-o-matic/import_export/svg/SVGParser.cpp   
2010-08-18 11:39:39 UTC (rev 38229)
+++ haiku/trunk/src/apps/icon-o-matic/import_export/svg/SVGParser.cpp   
2010-08-18 11:50:49 UTC (rev 38230)
@@ -364,7 +364,7 @@
 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)


Other related posts:

  • » [haiku-commits] r38230 - haiku/trunk/src/apps/icon-o-matic/import_export/svg - pulkomandy