From b1c417e7b7a48e2673225d6f9dde1b96e4be0bb0 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 20 Apr 2015 17:58:42 +0200 Subject: [PATCH] fix reading of doubles. There may be a + after the e --- Stream_support/include/CGAL/IO/io.h | 2 +- Stream_support/test/Stream_support/data/double.txt | 4 ++++ Stream_support/test/Stream_support/double.cpp | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100755 Stream_support/test/Stream_support/data/double.txt create mode 100644 Stream_support/test/Stream_support/double.cpp diff --git a/Stream_support/include/CGAL/IO/io.h b/Stream_support/include/CGAL/IO/io.h index 3e16c8d18b6..949f2253539 100644 --- a/Stream_support/include/CGAL/IO/io.h +++ b/Stream_support/include/CGAL/IO/io.h @@ -132,7 +132,7 @@ public: break; } c = static_cast(i); - if(std::isdigit(c) || (c =='.') || (c =='E') || (c =='e') || (c =='-')){ + if(std::isdigit(c) || (c =='.') || (c =='E') || (c =='e') || (c =='+') || (c =='-')){ buffer += c; }else{ is.unget(); diff --git a/Stream_support/test/Stream_support/data/double.txt b/Stream_support/test/Stream_support/data/double.txt new file mode 100755 index 00000000000..83c4c0e8a01 --- /dev/null +++ b/Stream_support/test/Stream_support/data/double.txt @@ -0,0 +1,4 @@ ++1.2e+3 45 12 ++1.2e03 45 12 ++1.2e003 45 12 +-1.2e03 45 12 diff --git a/Stream_support/test/Stream_support/double.cpp b/Stream_support/test/Stream_support/double.cpp new file mode 100644 index 00000000000..076ae9767bc --- /dev/null +++ b/Stream_support/test/Stream_support/double.cpp @@ -0,0 +1,14 @@ +#include +#include +#include + + +int main() +{ + std::ifstream in("data/double.txt"); + CGAL::Simple_cartesian::Point_3 p; + while(in >> p){ + std::cout << p << std::endl; + } + return 0; +}