aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-02-04 01:12:36 +0000
committerDavid Robillard <d@drobilla.net>2011-02-04 01:12:36 +0000
commitdccceaf112ac67460532dcced9007462bea3a0de (patch)
tree5f66c40f510227b4314bd61055561d3af7461131
parent645d107da822b52f0660163de61ff1a9074fc671 (diff)
downloadserd-dccceaf112ac67460532dcced9007462bea3a0de.tar.gz
serd-dccceaf112ac67460532dcced9007462bea3a0de.tar.bz2
serd-dccceaf112ac67460532dcced9007462bea3a0de.zip
Fix parsing double with signs in their exponents (e.g. 1.234e+56).
git-svn-id: http://svn.drobilla.net/serd/trunk@95 490d8e77-9747-427b-9fa3-0b8f29cee8a0
-rw-r--r--src/reader.c5
-rw-r--r--tests/test-num.out3
-rw-r--r--tests/test-num.ttl4
3 files changed, 11 insertions, 1 deletions
diff --git a/src/reader.c b/src/reader.c
index 79b61385..a342a4d2 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -869,6 +869,11 @@ read_number(SerdReader reader, Node* dest)
if (c == 'e' || c == 'E') {
// double
push_byte(reader, str, eat_byte(reader, c));
+ switch ((c = peek_byte(reader))) {
+ case '+': case '-':
+ push_byte(reader, str, eat_byte(reader, c));
+ default: break;
+ }
read_0_9(reader, str, true);
datatype = push_string(reader, XSD_DOUBLE, strlen(XSD_DOUBLE) + 1);
} else if (has_decimal) {
diff --git a/tests/test-num.out b/tests/test-num.out
index 447f11df..2502580b 100644
--- a/tests/test-num.out
+++ b/tests/test-num.out
@@ -4,3 +4,6 @@
<http://example.org/eg#thing> <http://example.org/eg#num> ".4"^^<http://www.w3.org/2001/XMLSchema#decimal> .
<http://example.org/eg#thing> <http://example.org/eg#num> "+.5"^^<http://www.w3.org/2001/XMLSchema#decimal> .
<http://example.org/eg#thing> <http://example.org/eg#num> "-.6"^^<http://www.w3.org/2001/XMLSchema#decimal> .
+<http://example.org/eg#thing> <http://example.org/eg#num> "1.58490e-05"^^<http://www.w3.org/2001/XMLSchema#double> .
+<http://example.org/eg#thing> <http://example.org/eg#num> "1.58490e+05"^^<http://www.w3.org/2001/XMLSchema#double> .
+<http://example.org/eg#thing> <http://example.org/eg#num> "1.58490e05"^^<http://www.w3.org/2001/XMLSchema#double> .
diff --git a/tests/test-num.ttl b/tests/test-num.ttl
index 086ca5ab..54a425ac 100644
--- a/tests/test-num.ttl
+++ b/tests/test-num.ttl
@@ -6,4 +6,6 @@ eg:thing eg:num -0.3 .
eg:thing eg:num .4 .
eg:thing eg:num +.5 .
eg:thing eg:num -.6 .
-
+eg:thing eg:num 1.58490e-05 .
+eg:thing eg:num 1.58490e+05 .
+eg:thing eg:num 1.58490e05 .