mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
parent
ef269ea2e0
commit
da150dbb1c
@ -110,7 +110,7 @@ class Genode::Token
|
||||
/**
|
||||
* Access single characters of token
|
||||
*/
|
||||
char operator [] (int idx)
|
||||
char operator [] (int idx) const
|
||||
{
|
||||
return ((idx >= 0) && ((unsigned)idx < _len)) ? _start[idx] : 0;
|
||||
}
|
||||
|
@ -55,17 +55,16 @@ class Genode::Xml_attribute
|
||||
struct Tokens
|
||||
{
|
||||
Token name;
|
||||
Token value;
|
||||
Token equals { name .next().eat_whitespace() };
|
||||
Token value { equals.next().eat_whitespace() };
|
||||
|
||||
Tokens(Token t)
|
||||
: name(t.eat_whitespace()), value(name.next().next()) { };
|
||||
Tokens(Token t) : name(t.eat_whitespace()) { };
|
||||
|
||||
bool valid() const
|
||||
{
|
||||
bool const tag_present = (name.type() == Token::IDENT);
|
||||
bool const value_present = (name.next()[0] == '=' &&
|
||||
value.type() == Token::STRING);
|
||||
return tag_present && value_present;
|
||||
return (name.type() == Token::IDENT)
|
||||
&& (equals[0] == '=')
|
||||
&& (value.type() == Token::STRING);
|
||||
}
|
||||
} _tokens;
|
||||
|
||||
@ -103,7 +102,7 @@ class Genode::Xml_attribute
|
||||
/**
|
||||
* Return token following the attribute declaration
|
||||
*/
|
||||
Token _next_token() const { return _tokens.name.next().next().next(); }
|
||||
Token _next_token() const { return _tokens.value.next(); }
|
||||
|
||||
public:
|
||||
|
||||
@ -355,7 +354,7 @@ class Genode::Xml_node
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if tag as at least one attribute
|
||||
* Return true if tag has at least one attribute
|
||||
*/
|
||||
bool has_attribute() const { return Xml_attribute::_valid(_name.next()); }
|
||||
|
||||
|
@ -99,6 +99,9 @@
|
||||
[init -> test-xml_node] -- Test backslash as attribute value --
|
||||
[init -> test-xml_node] attribute value: '\'
|
||||
[init -> test-xml_node]
|
||||
[init -> test-xml_node] -- Test whitespace around assignment character --
|
||||
[init -> test-xml_node] attribute value: '123'
|
||||
[init -> test-xml_node]
|
||||
[init -> test-xml_node] -- Test exporting decoded content from XML node --
|
||||
[init -> test-xml_node] step 1
|
||||
[init -> test-xml_node] step 2
|
||||
|
@ -152,6 +152,10 @@ static const char *xml_test_comments =
|
||||
static const char *xml_test_backslash =
|
||||
"<config attr=\"\\\"/>";
|
||||
|
||||
/* withspace around attribute assignment character */
|
||||
static const char *xml_test_whitespace_assign =
|
||||
"<config attr = \"123\"/>";
|
||||
|
||||
|
||||
/******************
|
||||
** Test program **
|
||||
@ -415,6 +419,12 @@ void Component::construct(Genode::Env &env)
|
||||
log("attribute value: '", node.attribute_value("attr", String<10>()), "'\n");
|
||||
}
|
||||
|
||||
log("-- Test whitespace around assignment character --");
|
||||
{
|
||||
Xml_node const node(xml_test_whitespace_assign);
|
||||
log("attribute value: '", node.attribute_value("attr", String<10>()), "'\n");
|
||||
}
|
||||
|
||||
log("-- Test exporting decoded content from XML node --");
|
||||
test_decoded_content<~0UL>(env, 1, xml_test_comments, 8, 119);
|
||||
test_decoded_content<119 >(env, 2, xml_test_comments, 8, 119);
|
||||
|
Loading…
x
Reference in New Issue
Block a user