[vala/staging: 4/5] vala: Add MarkupReader.from_string() and support add support for "percnt; "



commit 2cd816590cd17a2a40f92f04ad711277e984226d
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Nov 26 15:36:58 2017 +0100

    vala: Add MarkupReader.from_string() and support add support for "percnt;"

 vala/valamarkupreader.vala |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/vala/valamarkupreader.vala b/vala/valamarkupreader.vala
index 2ecca0c..0197320 100644
--- a/vala/valamarkupreader.vala
+++ b/vala/valamarkupreader.vala
@@ -61,6 +61,18 @@ public class Vala.MarkupReader {
                }
        }
 
+       public MarkupReader.from_string (string filename, string content) {
+               this.filename = filename;
+
+               begin = content;
+               end = begin + content.length;
+
+               current = begin;
+
+               line = 1;
+               column = 1;
+       }
+
        public string? get_attribute (string attr) {
                return attributes[attr];
        }
@@ -108,6 +120,9 @@ public class Vala.MarkupReader {
                        return MarkupTokenType.END_ELEMENT;
                }
 
+               content = null;
+               name = null;
+
                space ();
 
                MarkupTokenType type = MarkupTokenType.NONE;
@@ -243,6 +258,11 @@ public class Vala.MarkupReader {
                                        content.append_c ('>');
                                        current += 4;
                                        text_begin = current;
+                               } else if (((string) next_pos).has_prefix ("percnt;")) {
+                                       content.append (((string) text_begin).substring (0, (int) (current - 
text_begin)));
+                                       content.append_c ('%');
+                                       current += 8;
+                                       text_begin = current;
                                } else {
                                        current += u.to_utf8 (null);
                                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]