<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From f1e13c623483700806cc8c5cf997d11e485ad1db Mon Sep 17 00:00:00 2001
From: Adam Sampson &lt;ats@offog.org&gt;
Date: Fri, 11 Jul 2025 04:53:45 +0100
Subject: [PATCH 1/2] Move "string content as stream" banner to the right place

The name of this test (which happened to be the one that was failing for
me!) was only being printed on failure.
---
 src/rdf_parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/rdf_parser.c b/src/rdf_parser.c
index 5ddbf05d..9e62aac8 100644
--- a/src/rdf_parser.c
+++ b/src/rdf_parser.c
@@ -1138,11 +1138,11 @@ main(int argc, char *argv[])
     }
 
 
+    fprintf(stderr, "%s: Adding %s string content as stream\n", program, type);
     stream = librdf_parser_parse_string_as_stream(parser,
                                                   file_content[testi],
                                                   uris[testi]);
     if(!stream) {
-    fprintf(stderr, "%s: Adding %s string content as stream\n", program, type);
       fprintf(stderr, "%s: Failed to parse RDF from string %d as stream\n",
               program, testi);
       failures++;
-- 
2.50.1

From 19b642a4add75b519074591d0b62b266fa066a25 Mon Sep 17 00:00:00 2001
From: Adam Sampson &lt;ats@offog.org&gt;
Date: Fri, 11 Jul 2025 04:55:18 +0100
Subject: [PATCH 2/2] Add a second set of examples to the parser test

I've just tracked down an issue in raptor where the turtle parser's
buffer wasn't being cleared. The test was passing on most platforms -
because the condition being checked for was still true even if the
parser read the same data again.

Add a test that reads a different input (just one triple) through the
same parser, in the hope of catching similar problems in the future.
---
 src/rdf_parser.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 67 insertions(+), 1 deletion(-)

diff --git a/src/rdf_parser.c b/src/rdf_parser.c
index 9e62aac8..93c0b59f 100644
--- a/src/rdf_parser.c
+++ b/src/rdf_parser.c
@@ -1017,7 +1017,6 @@ int main(int argc, char *argv[]);
 "&lt;http://purl.org/net/dajobe/&gt; &lt;http://purl.org/dc/elements/1.1/description&gt; \"The generic home page of Dave Beckett.\" .\n" \
 "&lt;http://purl.org/net/dajobe/&gt; &lt;http://purl.org/dc/elements/1.1/title&gt; \"Dave Beckett's Home Page\" . \n"
 
-
 #define TURTLE_CONTENT \
 "@prefix dc: &lt;http://purl.org/dc/elements/1.1/&gt; .\n" \
 "\n" \
@@ -1030,6 +1029,28 @@ int main(int argc, char *argv[]);
 #define EXPECTED_TRIPLES_COUNT 3
 
 
+#define RDFXML_CONTENT_2 \
+"&lt;?xml version=\"1.0\"?&gt;\n" \
+"&lt;rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" \
+"         xmlns:dc=\"http://purl.org/dc/elements/1.1/\"&gt;\n" \
+"  &lt;rdf:Description rdf:about=\"http://purl.org/net/dajobe/\"&gt;\n" \
+"    &lt;dc:title&gt;Dave Beckett's Home Page&lt;/dc:title&gt;\n" \
+"  &lt;/rdf:Description&gt;\n" \
+"&lt;/rdf:RDF&gt;"
+
+#define NTRIPLES_CONTENT_2 \
+"&lt;http://purl.org/net/dajobe/&gt; &lt;http://purl.org/dc/elements/1.1/title&gt; \"Dave Beckett's Home Page\" . \n"
+
+#define TURTLE_CONTENT_2 \
+"@prefix dc: &lt;http://purl.org/dc/elements/1.1/&gt; .\n" \
+"\n" \
+"&lt;http://purl.org/net/dajobe/&gt;\n" \
+"      dc:title \"Dave Beckett's Home Page\" . \n"
+
+/* All the examples above give the same single triple */
+#define EXPECTED_TRIPLES_COUNT_2 1
+
+
 #define URI_STRING_COUNT 3
 static const char *test_parser_types[] = {
   "rdfxml", "ntriples", "turtle",
@@ -1048,6 +1069,12 @@ static const unsigned char *file_content[URI_STRING_COUNT] = {
   (const unsigned char*)TURTLE_CONTENT
 };
 
+static const unsigned char *file_content_2[URI_STRING_COUNT] = {
+  (const unsigned char*)RDFXML_CONTENT_2,
+  (const unsigned char*)NTRIPLES_CONTENT_2,
+  (const unsigned char*)TURTLE_CONTENT_2
+};
+
 int
 main(int argc, char *argv[])
 {
@@ -1073,6 +1100,7 @@ main(int argc, char *argv[])
     librdf_stream *stream = NULL;
     raptor_iostream *iostream = NULL;
     size_t length = strlen((const char*)file_content[testi]);
+    size_t length_2 = strlen((const char*)file_content_2[testi]);
     int size;
     char *accept_h;
     int i;
@@ -1138,6 +1166,44 @@ main(int argc, char *argv[])
     }
 
 
+    /* Clear the model */
+    librdf_free_model(model);
+    model = librdf_new_model(world, storage, NULL);
+    if(!model) {
+      fprintf(stderr, "%s: Failed to create new model\n", program);
+      return(1);
+    }
+
+
+    /* Try parsing a different string, to make sure the previous one hasn't
+     * been kept in the buffer */
+    fprintf(stderr, "%s: Adding %s different counted string content as stream\n",
+            program, type);
+    stream = librdf_parser_parse_counted_string_as_stream(parser,
+							  file_content_2[testi],
+							  length_2,
+							  uris[testi]);
+    if(!stream) {
+      fprintf(stderr,
+              "%s: Failed to parse RDF from counted string %d as stream\n",
+              program, testi);
+      failures++;
+      goto tidy_test;
+    }
+    librdf_model_add_statements(model, stream);
+    librdf_free_stream(stream);
+    stream = NULL;
+
+    size = librdf_model_size(model);
+    fprintf(stderr, "%s: Model size is %d triples\n", program, size);
+    if(size != EXPECTED_TRIPLES_COUNT_2) {
+      fprintf(stderr, "%s: Returned %d triples, not %d as expected\n",
+              program, size, EXPECTED_TRIPLES_COUNT_2);
+      failures++;
+      goto tidy_test;
+    }
+
+
     fprintf(stderr, "%s: Adding %s string content as stream\n", program, type);
     stream = librdf_parser_parse_string_as_stream(parser,
                                                   file_content[testi],
-- 
2.50.1

</pre></body></html>