mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-24 11:12:11 +01:00
Bug 571248 - Ignore unknown elements in girparser
We want the gir to be extensible. svn path=/trunk/; revision=1096
This commit is contained in:
parent
3490a56ba4
commit
97a2e7f5fc
27
girparser.c
27
girparser.c
@ -66,7 +66,8 @@ typedef enum
|
||||
STATE_CLASS_CONSTANT,
|
||||
STATE_INTERFACE_CONSTANT,
|
||||
STATE_ALIAS,
|
||||
STATE_TYPE
|
||||
STATE_TYPE,
|
||||
STATE_UNKNOWN
|
||||
} ParseState;
|
||||
|
||||
typedef struct _ParseContext ParseContext;
|
||||
@ -75,6 +76,7 @@ struct _ParseContext
|
||||
GIrParser *parser;
|
||||
|
||||
ParseState state;
|
||||
int unknown_depth;
|
||||
ParseState prev_state;
|
||||
|
||||
GList *modules;
|
||||
@ -2640,15 +2642,15 @@ start_element_handler (GMarkupParseContext *context,
|
||||
break;
|
||||
}
|
||||
|
||||
g_markup_parse_context_get_position (context, &line_number, &char_number);
|
||||
|
||||
if (error && *error == NULL)
|
||||
g_set_error (error,
|
||||
G_MARKUP_ERROR,
|
||||
G_MARKUP_ERROR_UNKNOWN_ELEMENT,
|
||||
"Unexpected start tag '%s' on line %d char %d; current state=%d",
|
||||
element_name,
|
||||
line_number, char_number, ctx->state);
|
||||
if (ctx->state != STATE_UNKNOWN)
|
||||
{
|
||||
state_switch (ctx, STATE_UNKNOWN);
|
||||
ctx->unknown_depth = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx->unknown_depth += 1;
|
||||
}
|
||||
|
||||
out: ;
|
||||
if (*error)
|
||||
@ -3008,6 +3010,11 @@ end_element_handler (GMarkupParseContext *context,
|
||||
end_type (ctx);
|
||||
break;
|
||||
}
|
||||
case STATE_UNKNOWN:
|
||||
ctx->unknown_depth -= 1;
|
||||
if (ctx->unknown_depth == 0)
|
||||
state_switch (ctx, ctx->prev_state);
|
||||
break;
|
||||
default:
|
||||
g_error ("Unhandled state %d in end_element_handler\n", ctx->state);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user