aboutsummaryrefslogtreecommitdiffstats
path: root/src/serd_internal.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-05-11 16:03:03 +0000
committerDavid Robillard <d@drobilla.net>2011-05-11 16:03:03 +0000
commitefd2a2ecb17a8c633f634c2cf38fb8be48db9af5 (patch)
tree2513b24e985a02e10565563a2a9151c58f38d2c1 /src/serd_internal.h
parent1dc85d2924eacef71d0cc9144c6c33e6f84248b1 (diff)
downloadserd-efd2a2ecb17a8c633f634c2cf38fb8be48db9af5.tar.gz
serd-efd2a2ecb17a8c633f634c2cf38fb8be48db9af5.tar.bz2
serd-efd2a2ecb17a8c633f634c2cf38fb8be48db9af5.zip
Record whether strings contains quotes or newlines for smart selection of long strings vs short strings in writer output.
git-svn-id: http://svn.drobilla.net/serd/trunk@167 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/serd_internal.h')
-rw-r--r--src/serd_internal.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/serd_internal.h b/src/serd_internal.h
index dd57af1e..e573a806 100644
--- a/src/serd_internal.h
+++ b/src/serd_internal.h
@@ -105,7 +105,7 @@ is_digit(const uint8_t c)
@param n_bytes (Output) Set to the size of @a str in bytes (incl. NULL).
*/
static inline size_t
-serd_strlen(const uint8_t* str, size_t* n_bytes)
+serd_strlen(const uint8_t* str, size_t* n_bytes, uint32_t* flags)
{
size_t n_chars = 0;
size_t i = 0;
@@ -113,6 +113,14 @@ serd_strlen(const uint8_t* str, size_t* n_bytes)
if ((str[i] & 0xC0) != 0x80) {
// Does not start with `10', start of a new character
++n_chars;
+ switch (str[i]) {
+ case '\r':
+ case '\n':
+ *flags |= SERD_HAS_NEWLINE;
+ break;
+ case '"':
+ *flags |= SERD_HAS_QUOTE;
+ }
}
}
if (n_bytes) {