diff options
author | Vasily_Makarov <danilka.pro@gmail.com> | 2012-02-08 21:42:49 +0400 |
---|---|---|
committer | Vasily_Makarov <danilka.pro@gmail.com> | 2012-02-08 21:42:49 +0400 |
commit | 6545f58904d754db19800a1cd21f472eb13339bd (patch) | |
tree | 31302573e165c3eaab15ed6eef879e5b5d6324eb /saedit/xml.c | |
parent | 6cef75a6df920f13a42b0ab17e2539aacc5e79e5 (diff) | |
download | evol-tools-6545f58904d754db19800a1cd21f472eb13339bd.tar.gz evol-tools-6545f58904d754db19800a1cd21f472eb13339bd.tar.bz2 evol-tools-6545f58904d754db19800a1cd21f472eb13339bd.tar.xz evol-tools-6545f58904d754db19800a1cd21f472eb13339bd.zip |
SAE: Add Debug mode
Diffstat (limited to 'saedit/xml.c')
-rw-r--r-- | saedit/xml.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/saedit/xml.c b/saedit/xml.c index d7b697e..602dfaf 100644 --- a/saedit/xml.c +++ b/saedit/xml.c @@ -42,6 +42,76 @@ gint xml_node_compare_with_attr_func(const XMLNode *node, const gchar **attr) { xml_node_get_attr_value(node, attr[0])); } +typedef enum +{ + STATE_START, + STATE_AFTER_OPEN_ANGLE, + STATE_AFTER_CLOSE_ANGLE, + STATE_AFTER_ELISION_SLASH, /* the slash that obviates need for end element */ + STATE_INSIDE_OPEN_TAG_NAME, + STATE_INSIDE_ATTRIBUTE_NAME, + STATE_AFTER_ATTRIBUTE_NAME, + STATE_BETWEEN_ATTRIBUTES, + STATE_AFTER_ATTRIBUTE_EQUALS_SIGN, + STATE_INSIDE_ATTRIBUTE_VALUE_SQ, + STATE_INSIDE_ATTRIBUTE_VALUE_DQ, + STATE_INSIDE_TEXT, + STATE_AFTER_CLOSE_TAG_SLASH, + STATE_INSIDE_CLOSE_TAG_NAME, + STATE_AFTER_CLOSE_TAG_NAME, + STATE_INSIDE_PASSTHROUGH, + STATE_ERROR +} GMarkupParseState; + +typedef struct +{ + const GMarkupParser *parser; + + GMarkupParseFlags flags; + + gint line_number; + gint char_number; + + GMarkupParseState state; + + gpointer user_data; + GDestroyNotify dnotify; + + /* A piece of character data or an element that + * hasn't "ended" yet so we haven't yet called + * the callback for it. + */ + GString *partial_chunk; + GSList *spare_chunks; + + GSList *tag_stack; + GSList *tag_stack_gstr; + GSList *spare_list_nodes; + + GString **attr_names; + GString **attr_values; + gint cur_attr; + gint alloc_attrs; + + const gchar *current_text; + gssize current_text_len; + const gchar *current_text_end; + + /* used to save the start of the last interesting thingy */ + const gchar *start; + + const gchar *iter; + + guint document_empty : 1; + guint parsing : 1; + guint awaiting_pop : 1; + gint balance; + + /* subparser support */ + GSList *subparser_stack; /* (GMarkupRecursionTracker *) */ + const char *subparser_element; + gpointer held_user_data; +} _GMarkupParseContext; static GMarkupParser parser; void @@ -99,6 +169,7 @@ _start_element_cb (GMarkupParseContext *context, gpointer user_data, GError **error) { + XMLNode *node = (XMLNode *) user_data; if (node->text) { @@ -123,6 +194,8 @@ _start_element_cb (GMarkupParseContext *context, } p->attributes = (gchar **)g_array_free (attributes, FALSE); + + p->line_number = ((_GMarkupParseContext*)context)->line_number - (((_GMarkupParseContext*)context)->char_number <= 1); } static void |