[pango/more-attr-update-fixes: 1/2] Explicitly preserve unlimited attributes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/more-attr-update-fixes: 1/2] Explicitly preserve unlimited attributes
- Date: Mon, 24 May 2021 01:33:46 +0000 (UTC)
commit 887cc68c36f31c5d8796c377919c186870d2b198
Author: Matthias Clasen <mclasen redhat com>
Date: Sun May 23 21:03:22 2021 -0400
Explicitly preserve unlimited attributes
When calling pango_attr_list_update(), we must not
change the limits or attributes that are unlimited.
pango/pango-attributes.c | 42 ++++++++++++++++++++++++------------------
1 file 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;
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]