(g_markup_parse_context_parse): Add comment processing.
authorMiguel de Icaza <miguel@gnome.org>
Tue, 5 Sep 2006 03:13:10 +0000 (03:13 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Tue, 5 Sep 2006 03:13:10 +0000 (03:13 -0000)
svn path=/trunk/mono/; revision=64911

eglib/ChangeLog
eglib/src/gmarkup.c
eglib/test/markup.c

index 61b980f50e7f255043053e736dbb82e9c608fdfa..a2a0a711efb629708419c3822f9b313d62f6a6c2 100644 (file)
@@ -10,7 +10,8 @@
        "error!=NULL && *error != NULL" upon return from callbacks,
        it is only then that its valid to check for *error for error
        conditions. 
-       
+       (g_markup_parse_context_parse): Add comment processing.
+
        Only release one element of the list.
 
        * test/markup.c: Incorporate the kind of code that is used in Mono
index 95cbfd4aee098b22030ea087fa49839f13e07d2a..d3eef9aaf3d082a13dcd67c73a86f49641480983 100644 (file)
@@ -9,7 +9,11 @@
  * "return to caller" and only at end parse this would be a fatal
  * error.
  *
- * Not that it matters to Mono, but it is very simple to change. 
+ * Not that it matters to Mono, but it is very simple to change, there
+ * is a tricky situation: there are a few places where we check p+n
+ * in the source, and that would have to change to be progressive, instead
+ * of depending on the string to be complete at that point, so we would
+ * have to introduce extra states to cope with that.
  *
  * Author:
  *   Miguel de Icaza (miguel@novell.com)
@@ -45,7 +49,8 @@ typedef enum {
        START_ELEMENT,
        TEXT,
        FLUSH_TEXT,
-       CLOSING_ELEMENT
+       CLOSING_ELEMENT,
+       COMMENT
 } ParseState;
 
 struct _GMarkupParseContext {
@@ -250,6 +255,13 @@ g_markup_parse_context_parse (GMarkupParseContext *context,
                                set_error ("Unfinished element");
                                goto fail;
                        }
+
+                       if (*p == '!' && (p+2 < end) && (p [1] == '-') && (p [2] == '-')){
+                               context->state = COMMENT;
+                               p += 2;
+                               break;
+                       }
+                       
                        if (!(isascii (*p) && isalpha (*p))){
                                set_error ("Expected an element name");
                                goto fail;
@@ -326,6 +338,16 @@ g_markup_parse_context_parse (GMarkupParseContext *context,
                        break;
                }
 
+               case COMMENT:
+                       if (*p != '-')
+                               break;
+                       if (p+2 < end && (p [1] == '-') && (p [2] == '>')){
+                               context->state = TEXT;
+                               p += 2;
+                               break;
+                       }
+
+                       
                case FLUSH_TEXT:
                        if (context->parser.text != NULL){
                                context->parser.text (context, context->text->str, context->text->len,
index 99ba945bc9ee5a70bbdcac1a9ae7e62232302209..fb91133cfb6e273e3f5dd76d2a1c5c628ce6b31f 100644 (file)
@@ -162,21 +162,21 @@ mono_domain (void)
 {
        AppConfigInfo *info;
 
-       info = domain_test ("<configuration><startup><requiredRuntime version=\"v1\"></requiredRuntime></startup></configuration>");
+       info = domain_test ("<configuration><!--hello--><startup><!--world--><requiredRuntime version=\"v1\"><!--r--></requiredRuntime></startup></configuration>");
        if (info->required_runtime == NULL)
                return FAILED ("No required runtime section");
        if (strcmp (info->required_runtime, "v1") != 0)
                return FAILED ("Got a runtime version %s, expected v1", info->required_runtime);
        domain_free (info);
 
-       info = domain_test ("<configuration><startup><requiredRuntime version=\"v1\"/></configuration>");
+       info = domain_test ("<configuration><startup><requiredRuntime version=\"v1\"/><!--comment--></configuration><!--end-->");
        if (info->required_runtime == NULL)
                return FAILED ("No required runtime section on auto-close section");
        if (strcmp (info->required_runtime, "v1") != 0)
                return FAILED ("Got a runtime version %s, expected v1", info->required_runtime);
        domain_free (info);
 
-       info = domain_test ("<configuration><startup><supportedRuntime version=\"v1\"><supportedRuntime version=\"v2\"/></startup></configuration>");
+       info = domain_test ("<!--start--><configuration><startup><supportedRuntime version=\"v1\"/><!--middle--><supportedRuntime version=\"v2\"/></startup></configuration>");
        if ((strcmp ((char*)info->supported_runtimes->data, "v1") == 0)){
                if (info->supported_runtimes->next == NULL)
                        return FAILED ("Expected 2 supported runtimes");