diff options
author | David Robillard <d@drobilla.net> | 2025-02-25 09:56:01 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2025-03-16 20:22:36 -0400 |
commit | e0c3ff08acbc25040e73838770435e1d2a89265e (patch) | |
tree | ea28a29a85f74b8d42bf41cff7230c6fa595fbfa | |
parent | 5ecac71066475b2bb55758ae138afeebeaa5b948 (diff) | |
download | serd-e0c3ff08acbc25040e73838770435e1d2a89265e.tar.gz serd-e0c3ff08acbc25040e73838770435e1d2a89265e.tar.bz2 serd-e0c3ff08acbc25040e73838770435e1d2a89265e.zip |
Fix reading numbers with no space before the final dot
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/n3.c | 12 | ||||
-rw-r--r-- | test/extra/good/manifest.ttl | 35 | ||||
-rw-r--r-- | test/extra/good/test-decimal-ends-with-dot.nt | 1 | ||||
-rw-r--r-- | test/extra/good/test-decimal-ends-with-dot.ttl | 4 | ||||
-rw-r--r-- | test/extra/good/test-double-ends-with-dot.nt | 1 | ||||
-rw-r--r-- | test/extra/good/test-double-ends-with-dot.ttl | 4 | ||||
-rw-r--r-- | test/extra/good/test-false-ends-with-dot.nt | 1 | ||||
-rw-r--r-- | test/extra/good/test-false-ends-with-dot.ttl | 4 | ||||
-rw-r--r-- | test/extra/good/test-integer-ends-with-dot.nt | 1 | ||||
-rw-r--r-- | test/extra/good/test-integer-ends-with-dot.ttl | 4 | ||||
-rw-r--r-- | test/extra/good/test-true-ends-with-dot.nt | 1 | ||||
-rw-r--r-- | test/extra/good/test-true-ends-with-dot.ttl | 4 |
13 files changed, 67 insertions, 8 deletions
@@ -2,10 +2,11 @@ serd (0.32.5) unstable; urgency=medium * Fix handling of some invalid EOF cases in lax mode * Fix invalid characters in error messages + * Fix reading numbers with no space before the final dot * Refuse to write incoherent statements * Remove project and version number from man page OS field - -- David Robillard <d@drobilla.net> Tue, 25 Feb 2025 14:22:43 +0000 + -- David Robillard <d@drobilla.net> Tue, 25 Feb 2025 14:55:48 +0000 serd (0.32.4) stable; urgency=medium @@ -814,18 +814,16 @@ read_number(SerdReader* const reader, // all other cases ::= ( '-' | '+' ) [0-9]+ ( . )? ( [0-9]+ )? ... TRY(st, read_0_9(reader, *dest, true)); if ((c = peek_byte(reader)) == '.') { - has_decimal = true; - // Annoyingly, dot can be end of statement, so tentatively eat skip_byte(reader, c); c = peek_byte(reader); if (!is_digit(c) && c != 'e' && c != 'E') { - *ate_dot = true; // Force caller to deal with stupid grammar - return SERD_SUCCESS; // Next byte is not a number character + *ate_dot = true; // Force caller to deal with silly grammar + } else { + has_decimal = true; + push_byte(reader, *dest, '.'); + read_0_9(reader, *dest, false); } - - push_byte(reader, *dest, '.'); - read_0_9(reader, *dest, false); } } c = peek_byte(reader); diff --git a/test/extra/good/manifest.ttl b/test/extra/good/manifest.ttl index 350d7d9c..2ac0ba59 100644 --- a/test/extra/good/manifest.ttl +++ b/test/extra/good/manifest.ttl @@ -20,12 +20,16 @@ <#test-comment-whitespace> <#test-cr> <#test-digit-start-pname> + <#test-decimal-ends-with-dot> <#test-double> + <#test-double-ends-with-dot> <#test-empty-path-base> <#test-eof-at-page-end> <#test-ext-namedblank-iri> <#test-ext-namedblank-prefix> + <#test-false-ends-with-dot> <#test-id> + <#test-integer-ends-with-dot> <#test-list-in-blank> <#test-list-subject> <#test-local-name-ends-with-dot> @@ -56,6 +60,7 @@ <#test-several-eaten-dots> <#test-string-escapes> <#test-trig-syntax-all-rules> + <#test-true-ends-with-dot> <#test-ttl-syntax-all-rules> <#test-uri> ) . @@ -144,12 +149,24 @@ mf:name "test-digit-start-pname" ; mf:result <test-digit-start-pname.nt> . +<#test-decimal-ends-with-dot> + a rdft:TestTurtleEval ; + mf:action <test-decimal-ends-with-dot.ttl> ; + mf:name "test-decimal-ends-with-dot" ; + mf:result <test-decimal-ends-with-dot.nt> . + <#test-double> a rdft:TestTurtleEval ; mf:action <test-double.ttl> ; mf:name "test-double" ; mf:result <test-double.nt> . +<#test-double-ends-with-dot> + a rdft:TestTurtleEval ; + mf:action <test-double-ends-with-dot.ttl> ; + mf:name "test-double-ends-with-dot" ; + mf:result <test-double-ends-with-dot.nt> . + <#test-empty-path-base> a rdft:TestTurtleEval ; mf:action <test-empty-path-base.ttl> ; @@ -174,12 +191,24 @@ mf:name "test-ext-namedblank-prefix" ; mf:result <test-ext-namedblank-prefix.nt> . +<#test-false-ends-with-dot> + a rdft:TestTurtleEval ; + mf:action <test-false-ends-with-dot.ttl> ; + mf:name "test-false-ends-with-dot" ; + mf:result <test-false-ends-with-dot.nt> . + <#test-id> a rdft:TestTurtleEval ; mf:action <test-id.ttl> ; mf:name "test-id" ; mf:result <test-id.nt> . +<#test-integer-ends-with-dot> + a rdft:TestTurtleEval ; + mf:action <test-integer-ends-with-dot.ttl> ; + mf:name "test-integer-ends-with-dot" ; + mf:result <test-integer-ends-with-dot.nt> . + <#test-list-in-blank> a rdft:TestTurtleEval ; mf:action <test-list-in-blank.ttl> ; @@ -344,6 +373,12 @@ mf:action <test-trig-syntax-all-rules.trig> ; mf:name "test-trig-syntax-all-rules" . +<#test-true-ends-with-dot> + a rdft:TestTurtleEval ; + mf:action <test-true-ends-with-dot.ttl> ; + mf:name "test-true-ends-with-dot" ; + mf:result <test-true-ends-with-dot.nt> . + <#test-ttl-syntax-all-rules> a rdft:TestTurtlePositiveSyntax ; mf:action <test-ttl-syntax-all-rules.ttl> ; diff --git a/test/extra/good/test-decimal-ends-with-dot.nt b/test/extra/good/test-decimal-ends-with-dot.nt new file mode 100644 index 00000000..be0802bc --- /dev/null +++ b/test/extra/good/test-decimal-ends-with-dot.nt @@ -0,0 +1 @@ +<http://example.org/eg#s> <http://example.org/eg#p> "12.3"^^<http://www.w3.org/2001/XMLSchema#decimal> . diff --git a/test/extra/good/test-decimal-ends-with-dot.ttl b/test/extra/good/test-decimal-ends-with-dot.ttl new file mode 100644 index 00000000..a63970d3 --- /dev/null +++ b/test/extra/good/test-decimal-ends-with-dot.ttl @@ -0,0 +1,4 @@ +@prefix eg: <http://example.org/eg#> . + +eg:s + eg:p 12.3. diff --git a/test/extra/good/test-double-ends-with-dot.nt b/test/extra/good/test-double-ends-with-dot.nt new file mode 100644 index 00000000..20e4395e --- /dev/null +++ b/test/extra/good/test-double-ends-with-dot.nt @@ -0,0 +1 @@ +<http://example.org/eg#s> <http://example.org/eg#p> "12.3e4"^^<http://www.w3.org/2001/XMLSchema#double> . diff --git a/test/extra/good/test-double-ends-with-dot.ttl b/test/extra/good/test-double-ends-with-dot.ttl new file mode 100644 index 00000000..4bd17a0b --- /dev/null +++ b/test/extra/good/test-double-ends-with-dot.ttl @@ -0,0 +1,4 @@ +@prefix eg: <http://example.org/eg#> . + +eg:s + eg:p 12.3e4. diff --git a/test/extra/good/test-false-ends-with-dot.nt b/test/extra/good/test-false-ends-with-dot.nt new file mode 100644 index 00000000..3b811813 --- /dev/null +++ b/test/extra/good/test-false-ends-with-dot.nt @@ -0,0 +1 @@ +<http://example.org/eg#s> <http://example.org/eg#p> "false"^^<http://www.w3.org/2001/XMLSchema#boolean> . diff --git a/test/extra/good/test-false-ends-with-dot.ttl b/test/extra/good/test-false-ends-with-dot.ttl new file mode 100644 index 00000000..14e2aa90 --- /dev/null +++ b/test/extra/good/test-false-ends-with-dot.ttl @@ -0,0 +1,4 @@ +@prefix eg: <http://example.org/eg#> . + +eg:s + eg:p false. diff --git a/test/extra/good/test-integer-ends-with-dot.nt b/test/extra/good/test-integer-ends-with-dot.nt new file mode 100644 index 00000000..7d6ff362 --- /dev/null +++ b/test/extra/good/test-integer-ends-with-dot.nt @@ -0,0 +1 @@ +<http://example.org/eg#s> <http://example.org/eg#p> "12"^^<http://www.w3.org/2001/XMLSchema#integer> . diff --git a/test/extra/good/test-integer-ends-with-dot.ttl b/test/extra/good/test-integer-ends-with-dot.ttl new file mode 100644 index 00000000..350ea41d --- /dev/null +++ b/test/extra/good/test-integer-ends-with-dot.ttl @@ -0,0 +1,4 @@ +@prefix eg: <http://example.org/eg#> . + +eg:s + eg:p 12. diff --git a/test/extra/good/test-true-ends-with-dot.nt b/test/extra/good/test-true-ends-with-dot.nt new file mode 100644 index 00000000..9938065b --- /dev/null +++ b/test/extra/good/test-true-ends-with-dot.nt @@ -0,0 +1 @@ +<http://example.org/eg#s> <http://example.org/eg#p> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> . diff --git a/test/extra/good/test-true-ends-with-dot.ttl b/test/extra/good/test-true-ends-with-dot.ttl new file mode 100644 index 00000000..ebd3b6e1 --- /dev/null +++ b/test/extra/good/test-true-ends-with-dot.ttl @@ -0,0 +1,4 @@ +@prefix eg: <http://example.org/eg#> . + +eg:s + eg:p true. |