summaryrefslogtreecommitdiff
path: root/pango/pango-attributes.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-05-23 21:03:22 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-05-23 21:03:22 -0400
commit887cc68c36f31c5d8796c377919c186870d2b198 (patch)
treeb04b13157a18ae6996713ef4aebd7f41e20adebf /pango/pango-attributes.c
parentc40a071b47aff7f50cdf48fc94b63baa5f1c82f6 (diff)
downloadpango-887cc68c36f31c5d8796c377919c186870d2b198.tar.gz
Explicitly preserve unlimited attributes
When calling pango_attr_list_update(), we must not change the limits or attributes that are unlimited.
Diffstat (limited to 'pango/pango-attributes.c')
-rw-r--r--pango/pango-attributes.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 8b4b2f7a..0d604f3d 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -1760,28 +1760,34 @@ pango_attr_list_update (PangoAttrList *list,
continue;
}
- if (attr->start_index >= pos &&
- attr->start_index < pos + remove)
- {
- attr->start_index = pos + add;
- }
- else if (attr->start_index >= pos + remove)
+ if (attr->start_index != PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING)
{
- attr->start_index += add - remove;
+ if (attr->start_index >= pos &&
+ attr->start_index < pos + remove)
+ {
+ attr->start_index = pos + add;
+ }
+ else if (attr->start_index >= pos + remove)
+ {
+ attr->start_index += add - remove;
+ }
}
- if (attr->end_index >= pos &&
- attr->end_index < pos + remove)
- {
- attr->end_index = pos;
- }
- else if (attr->end_index >= pos + remove)
+ if (attr->end_index != PANGO_ATTR_INDEX_TO_TEXT_END)
{
- if (add > remove &&
- G_MAXUINT - attr->end_index < add - remove)
- attr->end_index = G_MAXUINT;
- else
- attr->end_index += add - remove;
+ if (attr->end_index >= pos &&
+ attr->end_index < pos + remove)
+ {
+ attr->end_index = pos;
+ }
+ else if (attr->end_index >= pos + remove)
+ {
+ if (add > remove &&
+ G_MAXUINT - attr->end_index < add - remove)
+ attr->end_index = G_MAXUINT;
+ else
+ attr->end_index += add - remove;
+ }
}
}
}