[pango/break-tailoring: 33/37] break: Cosmetics
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/break-tailoring: 33/37] break: Cosmetics
- Date: Sun, 22 Aug 2021 05:46:26 +0000 (UTC)
commit 08006f8e1f23fa2948c0dca4fd45053bbd7a5c33
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Aug 21 23:54:03 2021 -0400
break: Cosmetics
Rearrange the code in break_attr() slightly,
to prepare for handling more attributes.
pango/break.c | 84 ++++++++++++++++++++++++++++++++---------------------------
1 file changed, 45 insertions(+), 39 deletions(-)
---
diff --git a/pango/break.c b/pango/break.c
index 6a6765e3..686944cd 100644
--- a/pango/break.c
+++ b/pango/break.c
@@ -1624,58 +1624,64 @@ break_attrs (const char *text,
PangoLogAttr *log_attrs,
int log_attrs_len)
{
- PangoAttrList list;
- PangoAttrIterator iter;
+ PangoAttrList allow_breaks;
GSList *l;
+ gboolean tailored = FALSE;
+
+ _pango_attr_list_init (&allow_breaks);
- _pango_attr_list_init (&list);
for (l = attributes; l; l = l->next)
{
PangoAttribute *attr = l->data;
if (attr->klass->type == PANGO_ATTR_ALLOW_BREAKS)
- pango_attr_list_insert (&list, pango_attribute_copy (attr));
+ pango_attr_list_insert (&allow_breaks, pango_attribute_copy (attr));
}
- if (!_pango_attr_list_has_attributes (&list))
+ if (_pango_attr_list_has_attributes (&allow_breaks))
{
- _pango_attr_list_destroy (&list);
- return FALSE;
- }
+ PangoAttrIterator iter;
- _pango_attr_list_get_iterator (&list, &iter);
- do {
- const PangoAttribute *attr = pango_attr_iterator_get (&iter, PANGO_ATTR_ALLOW_BREAKS);
+ _pango_attr_list_get_iterator (&allow_breaks, &iter);
+ do
+ {
+ const PangoAttribute *attr = pango_attr_iterator_get (&iter, PANGO_ATTR_ALLOW_BREAKS);
- if (attr && ((PangoAttrInt*)attr)->value == 0)
- {
- int start, end;
- int start_pos, end_pos;
- int pos;
-
- pango_attr_iterator_range (&iter, &start, &end);
- if (start < offset)
- start_pos = 0;
- else
- start_pos = g_utf8_pointer_to_offset (text, text + start - offset);
- if (end >= offset + length)
- end_pos = log_attrs_len;
- else
- end_pos = g_utf8_pointer_to_offset (text, text + end - offset);
-
- for (pos = start_pos + 1; pos < end_pos; pos++)
- {
- log_attrs[pos].is_mandatory_break = FALSE;
- log_attrs[pos].is_line_break = FALSE;
- log_attrs[pos].is_char_break = FALSE;
- }
- }
- } while (pango_attr_iterator_next (&iter));
+ if (attr && ((PangoAttrInt*)attr)->value == 0)
+ {
+ int start, end;
+ int start_pos, end_pos;
+ int pos;
+
+ start = attr->start_index;
+ end = attr->end_index;
+ if (start < offset)
+ start_pos = 0;
+ else
+ start_pos = g_utf8_pointer_to_offset (text, text + start - offset);
+ if (end >= offset + length)
+ end_pos = log_attrs_len;
+ else
+ end_pos = g_utf8_pointer_to_offset (text, text + end - offset);
- _pango_attr_iterator_destroy (&iter);
- _pango_attr_list_destroy (&list);
+ for (pos = start_pos + 1; pos < end_pos; pos++)
+ {
+ log_attrs[pos].is_mandatory_break = FALSE;
+ log_attrs[pos].is_line_break = FALSE;
+ log_attrs[pos].is_char_break = FALSE;
- return TRUE;
+ tailored = TRUE;
+ }
+ }
+ }
+ while (pango_attr_iterator_next (&iter));
+
+ _pango_attr_iterator_destroy (&iter);
+ }
+
+ _pango_attr_list_destroy (&allow_breaks);
+
+ return tailored;
}
/* }}} */
@@ -2350,6 +2356,6 @@ pango_validate_log_attrs (const char *text,
return TRUE;
}
- /* }}} */
+/* }}} */
/* vim:set foldmethod=marker expandtab: */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]