aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-12-09 10:05:19 -0500
committerDavid Robillard <d@drobilla.net>2022-12-09 10:05:19 -0500
commit221636904b9389a3709c40c38ca3dbf51e4c32f7 (patch)
tree3227a9e14cb71d9e1fb5e88a6a167f149f662165
parent9a222ac2ae6b4dac6dd8a414498523f472e90279 (diff)
downloadserd-221636904b9389a3709c40c38ca3dbf51e4c32f7.tar.gz
serd-221636904b9389a3709c40c38ca3dbf51e4c32f7.tar.bz2
serd-221636904b9389a3709c40c38ca3dbf51e4c32f7.zip
Add serd_reader_skip_until_byte() to public API
-rw-r--r--NEWS5
-rw-r--r--doc/serdi.12
-rw-r--r--include/serd/serd.h13
-rw-r--r--meson.build2
-rw-r--r--src/n3.c13
-rw-r--r--src/serd_config.h2
6 files changed, 28 insertions, 9 deletions
diff --git a/NEWS b/NEWS
index 2c896ec3..550a3321 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
-serd (0.30.17) unstable; urgency=medium
+serd (0.31.0) unstable; urgency=medium
* Add Windows path separator support to serd_node_new_file_uri()
+ * Add serd_reader_skip_until_byte() to public API
* Fix crash when trying to read chunks without starting
* Fix hang when skipping an error at EOF when lax parsing
* Gracefully handle bad characters in Turtle blank node syntax
@@ -10,7 +11,7 @@ serd (0.30.17) unstable; urgency=medium
* Replace duplicated dox_to_sphinx script with sphinxygen dependency
* Test header for warnings more strictly
- -- David Robillard <d@drobilla.net> Sun, 04 Dec 2022 18:33:52 +0000
+ -- David Robillard <d@drobilla.net> Fri, 09 Dec 2022 14:53:37 +0000
serd (0.30.16) stable; urgency=medium
diff --git a/doc/serdi.1 b/doc/serdi.1
index 48b1a5d4..997676a0 100644
--- a/doc/serdi.1
+++ b/doc/serdi.1
@@ -2,7 +2,7 @@
.\" # SPDX-License-Identifier: ISC
.Dd Jul 15, 2022
.Dt SERDI 1
-.Os Serd 0.30.17
+.Os Serd 0.31.0
.Sh NAME
.Nm serdi
.Nd read and write RDF syntax
diff --git a/include/serd/serd.h b/include/serd/serd.h
index cf6b5e4d..42e85f87 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -856,6 +856,19 @@ SerdStatus
serd_reader_read_string(SerdReader* SERD_NONNULL reader,
const uint8_t* SERD_NONNULL utf8);
+/**
+ Skip over bytes in the input until a specific byte is encountered.
+
+ Typically used for recording from errors in a line-based syntax by skipping
+ ahead to the next newline.
+
+ @return #SERD_SUCCESS if the given byte was reached, or #SERD_FAILURE if the
+ end of input is reached.
+*/
+SERD_API
+SerdStatus
+serd_reader_skip_until_byte(SerdReader* SERD_NONNULL reader, uint8_t byte);
+
/// Free `reader`
SERD_API
void
diff --git a/meson.build b/meson.build
index 8c3db730..b569c460 100644
--- a/meson.build
+++ b/meson.build
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: 0BSD OR ISC
project('serd', ['c'],
- version: '0.30.17',
+ version: '0.31.0',
license: 'ISC',
meson_version: '>= 0.56.0',
default_options: [
diff --git a/src/n3.c b/src/n3.c
index e36d753c..6577fa3b 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -1672,12 +1672,17 @@ read_n3_statement(SerdReader* const reader)
return st;
}
-static void
-skip_until(SerdReader* const reader, const uint8_t byte)
+SerdStatus
+serd_reader_skip_until_byte(SerdReader* const reader, const uint8_t byte)
{
- for (int c = 0; (c = peek_byte(reader)) && c != byte && c != EOF;) {
+ int c = peek_byte(reader);
+
+ while (c != byte && c != EOF) {
skip_byte(reader, c);
+ c = peek_byte(reader);
}
+
+ return c == EOF ? SERD_FAILURE : SERD_SUCCESS;
}
SerdStatus
@@ -1689,7 +1694,7 @@ read_turtleTrigDoc(SerdReader* const reader)
if (reader->strict) {
return st;
}
- skip_until(reader, '\n');
+ serd_reader_skip_until_byte(reader, '\n');
}
}
diff --git a/src/serd_config.h b/src/serd_config.h
index 98fb01c9..df73522b 100644
--- a/src/serd_config.h
+++ b/src/serd_config.h
@@ -16,7 +16,7 @@
#define SERD_CONFIG_H
// Define version unconditionally so a warning will catch a mismatch
-#define SERD_VERSION "0.30.17"
+#define SERD_VERSION "0.31.0"
#if !defined(SERD_NO_DEFAULT_CONFIG)