Report unexpected character data as error from the GMarkup parser,

2003-09-17  Matthias Clasen  <maclas@gmx.de>

	* gtk/gtkuimanager.c (text_handler): Report unexpected character
	data as error from the GMarkup parser, otherwise things like
	gtk_ui_manager_add_ui_from_string (ui, "Hi there!", -1, &error)
	pass unexpectedly.
This commit is contained in:
Matthias Clasen
2003-09-17 19:18:45 +00:00
committed by Matthias Clasen
parent 77d23072c2
commit 3044d0f514
6 changed files with 74 additions and 9 deletions

View File

@ -1,3 +1,10 @@
2003-09-17 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c (text_handler): Report unexpected character
data as error from the GMarkup parser, otherwise things like
gtk_ui_manager_add_ui_from_string (ui, "Hi there!", -1, &error)
pass unexpectedly.
Wed Sep 17 02:38:53 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbar.c (gtk_toolbar_class_init): revert accidentally

View File

@ -1,3 +1,10 @@
2003-09-17 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c (text_handler): Report unexpected character
data as error from the GMarkup parser, otherwise things like
gtk_ui_manager_add_ui_from_string (ui, "Hi there!", -1, &error)
pass unexpectedly.
Wed Sep 17 02:38:53 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbar.c (gtk_toolbar_class_init): revert accidentally

View File

@ -1,3 +1,10 @@
2003-09-17 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c (text_handler): Report unexpected character
data as error from the GMarkup parser, otherwise things like
gtk_ui_manager_add_ui_from_string (ui, "Hi there!", -1, &error)
pass unexpectedly.
Wed Sep 17 02:38:53 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbar.c (gtk_toolbar_class_init): revert accidentally

View File

@ -1,3 +1,10 @@
2003-09-17 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c (text_handler): Report unexpected character
data as error from the GMarkup parser, otherwise things like
gtk_ui_manager_add_ui_from_string (ui, "Hi there!", -1, &error)
pass unexpectedly.
Wed Sep 17 02:38:53 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbar.c (gtk_toolbar_class_init): revert accidentally

View File

@ -1,3 +1,10 @@
2003-09-17 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c (text_handler): Report unexpected character
data as error from the GMarkup parser, otherwise things like
gtk_ui_manager_add_ui_from_string (ui, "Hi there!", -1, &error)
pass unexpectedly.
Wed Sep 17 02:38:53 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktoolbar.c (gtk_toolbar_class_init): revert accidentally

View File

@ -1087,21 +1087,51 @@ cleanup (GMarkupParseContext *context,
gtk_ui_manager_remove_ui (ctx->self, ctx->merge_id);
}
static GMarkupParser ui_parser = {
start_element_handler,
end_element_handler,
NULL,
NULL,
cleanup
};
static gboolean
xml_isspace (char c)
{
return c == ' ' || c == '\t' || c == '\n' || c == '\r';
}
static void
text_handler (GMarkupParseContext *context,
const gchar *text,
gsize text_len,
gpointer user_data,
GError **error)
{
const gchar *p;
const gchar *end;
p = text;
end = text + text_len;
while (p != end && xml_isspace (*p))
++p;
if (p != end)
{
gint line_number, char_number;
g_markup_parse_context_get_position (context,
&line_number, &char_number);
g_set_error (error,
G_MARKUP_ERROR,
G_MARKUP_ERROR_INVALID_CONTENT,
_("Unexpected character data on line %d char %d"),
line_number, char_number);
}
}
static GMarkupParser ui_parser = {
start_element_handler,
end_element_handler,
text_handler,
NULL,
cleanup
};
static guint
add_ui_from_string (GtkUIManager *self,
const gchar *buffer,