summaryrefslogtreecommitdiff
path: root/vala/valamarkupreader.vala
diff options
context:
space:
mode:
authorFlorian Brosch <flo.brosch@gmail.com>2010-08-08 16:00:37 +0200
committerJürg Billeter <j@bitron.ch>2010-08-09 10:08:01 +0200
commitba68965853126361e2a9c5932ff0b5ccee05db1d (patch)
tree7f3a78b58b86f9be3fc338a7517bccc734b0ed61 /vala/valamarkupreader.vala
parent508e36dc7b3c2078187bf1bd1c3bdf843bd6a7b6 (diff)
downloadvala-ba68965853126361e2a9c5932ff0b5ccee05db1d.tar.gz
Remove trailing whitespace from content in markup reader
Diffstat (limited to 'vala/valamarkupreader.vala')
-rw-r--r--vala/valamarkupreader.vala13
1 files changed, 10 insertions, 3 deletions
diff --git a/vala/valamarkupreader.vala b/vala/valamarkupreader.vala
index 7805e256e..843fba69b 100644
--- a/vala/valamarkupreader.vala
+++ b/vala/valamarkupreader.vala
@@ -154,7 +154,7 @@ public class Vala.MarkupReader : Object {
}
current++;
- string attr_value = text ('"');
+ string attr_value = text ('"', false);
if (current >= end || current[0] != '"') {
// error
@@ -179,7 +179,7 @@ public class Vala.MarkupReader : Object {
space ();
if (current[0] != '<') {
- content = text ('<');
+ content = text ('<', true);
} else {
// no text
// read next token
@@ -196,7 +196,7 @@ public class Vala.MarkupReader : Object {
return type;
}
- string text (char end_char) {
+ string text (char end_char, bool rm_trailing_whitespace) {
StringBuilder content = new StringBuilder ();
char* text_begin = current;
char* last_linebreak = current;
@@ -253,6 +253,13 @@ public class Vala.MarkupReader : Object {
column += (int) (current - last_linebreak);
+ // Removes trailing whitespace
+ if (rm_trailing_whitespace) {
+ char* str_pos = ((char*)content.str) + content.len;
+ for (str_pos--; str_pos > ((char*)content.str) && str_pos[0].isspace(); str_pos--);
+ content.erase ((ssize_t) (str_pos-((char*) content.str) + 1), -1);
+ }
+
return content.str;
}