summaryrefslogtreecommitdiff
path: root/src/cairo-tag-stack.c
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2021-07-26 18:45:31 +0930
committerAdrian Johnson <ajohnson@redneon.com>2021-07-29 06:00:37 +0930
commit24616585ecb83ead34b4662e8a07957da5299c28 (patch)
tree7a69a0590b310e227f89f20a89ed6a9ef1d215ca /src/cairo-tag-stack.c
parent4e3f6bf0c2eb4ff5065bb18fb846019d4fef597f (diff)
downloadcairo-24616585ecb83ead34b4662e8a07957da5299c28.tar.gz
Print tag error details when CAIRO_DEBUG_TAG is defined
Add a _cairo_tag_error(fmt, ...) function that is used liked _cairo_error() but allows an error message to be specified. When CAIRO_DEBUG_TAG is defined the error is printed.
Diffstat (limited to 'src/cairo-tag-stack.c')
-rw-r--r--src/cairo-tag-stack.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/cairo-tag-stack.c b/src/cairo-tag-stack.c
index 7c2d5245e..7341aa41a 100644
--- a/src/cairo-tag-stack.c
+++ b/src/cairo-tag-stack.c
@@ -163,7 +163,7 @@ _cairo_tag_stack_push (cairo_tag_stack_t *stack,
! name_in_list (name, _cairo_tag_stack_cairo_tag_list))
{
stack->type = TAG_TYPE_INVALID;
- return _cairo_error (CAIRO_STATUS_TAG_ERROR);
+ return _cairo_tag_error ("Invalid tag: %s", name);
}
if (stack->type == TAG_TREE_TYPE_NO_TAGS) {
@@ -227,7 +227,7 @@ _cairo_tag_stack_pop (cairo_tag_stack_t *stack,
top = _cairo_tag_stack_top_elem (stack);
if (!top) {
stack->type = TAG_TYPE_INVALID;
- return _cairo_error (CAIRO_STATUS_TAG_ERROR);
+ return _cairo_tag_error ("cairo_tag_end(\"%s\") no matching begin tag", name);
}
cairo_list_del (&top->link);
@@ -235,7 +235,8 @@ _cairo_tag_stack_pop (cairo_tag_stack_t *stack,
if (strcmp (top->name, name) != 0) {
stack->type = TAG_TYPE_INVALID;
_cairo_tag_stack_free_elem (top);
- return _cairo_error (CAIRO_STATUS_TAG_ERROR);
+ return _cairo_tag_error ("cairo_tag_end(\"%s\") does not matching previous begin tag \"%s\"",
+ name, top->name);
}
if (elem)
@@ -278,3 +279,18 @@ _cairo_tag_get_type (const char *name)
return TAG_TYPE_STRUCTURE;
}
+
+cairo_status_t
+_cairo_tag_error (const char *fmt, ...)
+{
+ va_list ap;
+
+ if (getenv ("CAIRO_DEBUG_TAG") != NULL) {
+ printf ("TAG ERROR: ");
+ va_start (ap, fmt);
+ vprintf (fmt, ap);
+ va_end (ap);
+ printf ("\n");
+ }
+ return _cairo_error (CAIRO_STATUS_TAG_ERROR);
+}