aboutsummaryrefslogtreecommitdiffstats
path: root/src/reader.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-01-23 09:16:38 +0000
committerDavid Robillard <d@drobilla.net>2011-01-23 09:16:38 +0000
commitebcef72577398fa10a6ad6545317f704bcf9a1c4 (patch)
treecb6ada04b2a4c4eefa1fa86c6b8a854c7fc7488d /src/reader.c
parent5de15ccf0a0216e5aadd93ab9095bf15279bfb7c (diff)
downloadserd-ebcef72577398fa10a6ad6545317f704bcf9a1c4.tar.gz
serd-ebcef72577398fa10a6ad6545317f704bcf9a1c4.tar.bz2
serd-ebcef72577398fa10a6ad6545317f704bcf9a1c4.zip
Rearrange code, put common internal stuff in serd_internal.h.
git-svn-id: http://svn.drobilla.net/serd/trunk@46 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/reader.c')
-rw-r--r--src/reader.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/reader.c b/src/reader.c
index 9667abf5..8bae4c03 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -23,8 +23,7 @@
#include <stdlib.h>
#include <string.h>
-#include "serd/serd.h"
-#include "serd_stack.h"
+#include "serd_internal.h"
#define NS_XSD "http://www.w3.org/2001/XMLSchema#"
#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
@@ -185,12 +184,6 @@ eat_string(SerdReader reader, const char* str, unsigned n)
}
}
-static inline bool
-in_range(const uchar c, const uchar min, const uchar max)
-{
- return (c >= min && c <= max);
-}
-
#ifdef STACK_DEBUG
static inline bool
stack_is_top_string(SerdReader reader, Ref ref)
@@ -687,7 +680,7 @@ static inline uchar
read_nameStartChar(SerdReader reader, bool required)
{
const uint8_t c = peek_byte(reader);
- if (in_range(c, 'A', 'Z') || (c == '_') || in_range(c, 'a', 'z')) {
+ if (c == '_' || is_alpha(c)) {
return eat_byte(reader, c);
} else {
if (required) {
@@ -711,9 +704,8 @@ read_nameChar(SerdReader reader)
case '5': case '6': case '7': case '8': case '9':
return eat_byte(reader, c);
default:
- if (in_range(c, 0x300, 0x036F) || in_range(c, 0x203F, 0x2040)) {
- return eat_byte(reader, c);
- }
+ // TODO: 0x300-0x036F | 0x203F-0x2040
+ return 0;
}
return 0;
}
@@ -814,10 +806,10 @@ read_0_9(SerdReader reader, Ref str, bool at_least_one)
{
uint8_t c;
if (at_least_one) {
- TRY_RET(in_range(c = peek_byte(reader), '0', '9'));
+ TRY_RET(is_digit((c = peek_byte(reader))));
push_byte(reader, str, eat_byte(reader, c));
}
- while (in_range((c = peek_byte(reader)), '0', '9')) {
+ while (is_digit((c = peek_byte(reader)))) {
push_byte(reader, str, eat_byte(reader, c));
}
return str;
@@ -900,7 +892,7 @@ read_literal(SerdReader reader, Node* dest)
Ref str = 0;
Node datatype = SERD_NODE_NULL;
const uint8_t c = peek_byte(reader);
- if (in_range(c, '0', '9') || c == '-' || c == '+') {
+ if (c == '-' || c == '+' || is_digit(c)) {
return read_number(reader, dest);
} else if (c == '\"') {
str = read_quotedString(reader);