mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-06-06 12:50:07 +02: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_CLASS_CONSTANT,
|
||||||
STATE_INTERFACE_CONSTANT,
|
STATE_INTERFACE_CONSTANT,
|
||||||
STATE_ALIAS,
|
STATE_ALIAS,
|
||||||
STATE_TYPE
|
STATE_TYPE,
|
||||||
|
STATE_UNKNOWN
|
||||||
} ParseState;
|
} ParseState;
|
||||||
|
|
||||||
typedef struct _ParseContext ParseContext;
|
typedef struct _ParseContext ParseContext;
|
||||||
@ -75,6 +76,7 @@ struct _ParseContext
|
|||||||
GIrParser *parser;
|
GIrParser *parser;
|
||||||
|
|
||||||
ParseState state;
|
ParseState state;
|
||||||
|
int unknown_depth;
|
||||||
ParseState prev_state;
|
ParseState prev_state;
|
||||||
|
|
||||||
GList *modules;
|
GList *modules;
|
||||||
@ -2640,15 +2642,15 @@ start_element_handler (GMarkupParseContext *context,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_markup_parse_context_get_position (context, &line_number, &char_number);
|
if (ctx->state != STATE_UNKNOWN)
|
||||||
|
{
|
||||||
if (error && *error == NULL)
|
state_switch (ctx, STATE_UNKNOWN);
|
||||||
g_set_error (error,
|
ctx->unknown_depth = 1;
|
||||||
G_MARKUP_ERROR,
|
}
|
||||||
G_MARKUP_ERROR_UNKNOWN_ELEMENT,
|
else
|
||||||
"Unexpected start tag '%s' on line %d char %d; current state=%d",
|
{
|
||||||
element_name,
|
ctx->unknown_depth += 1;
|
||||||
line_number, char_number, ctx->state);
|
}
|
||||||
|
|
||||||
out: ;
|
out: ;
|
||||||
if (*error)
|
if (*error)
|
||||||
@ -3008,6 +3010,11 @@ end_element_handler (GMarkupParseContext *context,
|
|||||||
end_type (ctx);
|
end_type (ctx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case STATE_UNKNOWN:
|
||||||
|
ctx->unknown_depth -= 1;
|
||||||
|
if (ctx->unknown_depth == 0)
|
||||||
|
state_switch (ctx, ctx->prev_state);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
g_error ("Unhandled state %d in end_element_handler\n", ctx->state);
|
g_error ("Unhandled state %d in end_element_handler\n", ctx->state);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user