[pango/pango2: 36/201] Clean up break api a bit




commit 5bebd46cea8ab04518a899b9b521a58fb2a9cb8a
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Feb 8 15:21:34 2022 -0500

    Clean up break api a bit
    
    Remove an unused argument, and pass attributes
    to pango_get_log_attrs().

 pango/break.c              | 23 ++++++++++++-----------
 pango/pango-break.h        |  2 +-
 pango/pango-layout.c       |  2 +-
 tests/testboundaries.c     |  7 +------
 tests/testboundaries_ucd.c |  2 +-
 5 files changed, 16 insertions(+), 20 deletions(-)
---
diff --git a/pango/break.c b/pango/break.c
index 3b4b1b0d..db36847c 100644
--- a/pango/break.c
+++ b/pango/break.c
@@ -142,7 +142,6 @@ typedef enum
 static void
 default_break (const char    *text,
                int            length,
-               PangoAnalysis *analysis G_GNUC_UNUSED,
                PangoLogAttr  *attrs,
                int            attrs_len G_GNUC_UNUSED)
 {
@@ -2162,30 +2161,27 @@ tailor_break (const char    *text,
  * pango_default_break:
  * @text: text to break. Must be valid UTF-8
  * @length: length of text in bytes (may be -1 if @text is nul-terminated)
- * @analysis: (nullable): a `PangoAnalysis` structure for the @text
  * @attrs: logical attributes to fill in
  * @attrs_len: size of the array passed as @attrs
  *
  * This is the default break algorithm.
  *
  * It applies rules from the [Unicode Line Breaking Algorithm](http://www.unicode.org/unicode/reports/tr14/)
- * without language-specific tailoring, therefore the @analyis argument is unused
- * and can be %NULL.
+ * without language-specific tailoring.
  *
  * See [func@Pango.tailor_break] for language-specific breaks.
  *
  * See [func@Pango.attr_break] for attribute-based customization.
  */
 void
-pango_default_break (const char    *text,
-                     int            length,
-                     PangoAnalysis *analysis G_GNUC_UNUSED,
-                     PangoLogAttr  *attrs,
-                     int            attrs_len G_GNUC_UNUSED)
+pango_default_break (const char   *text,
+                     int           length,
+                     PangoLogAttr *attrs,
+                     int           attrs_len G_GNUC_UNUSED)
 {
   PangoLogAttr before = *attrs;
 
-  default_break (text, length, analysis, attrs, attrs_len);
+  default_break (text, length, attrs, attrs_len);
 
   attrs->is_line_break      |= before.is_line_break;
   attrs->is_mandatory_break |= before.is_mandatory_break;
@@ -2290,6 +2286,7 @@ pango_attr_break (const char    *text,
  * pango_get_log_attrs:
  * @text: text to process. Must be valid UTF-8
  * @length: length in bytes of @text
+ * @attr_list: (nullable): `PangoAttrList` to apply
  * @level: embedding level, or -1 if unknown
  * @language: language tag
  * @attrs: (array length=attrs_len): array with one `PangoLogAttr`
@@ -2309,6 +2306,7 @@ pango_attr_break (const char    *text,
 void
 pango_get_log_attrs (const char    *text,
                      int            length,
+                     PangoAttrList *attr_list,
                      int            level,
                      PangoLanguage *language,
                      PangoLogAttr  *attrs,
@@ -2324,7 +2322,7 @@ pango_get_log_attrs (const char    *text,
   analysis.level = level;
   analysis.language = language;
 
-  pango_default_break (text, length, &analysis, attrs, attrs_len);
+  pango_default_break (text, length, attrs, attrs_len);
 
   chars_broken = 0;
 
@@ -2352,6 +2350,9 @@ pango_get_log_attrs (const char    *text,
   while (pango_script_iter_next (&iter));
   _pango_script_iter_fini (&iter);
 
+  if (attr_list)
+    pango_attr_break (text, length, attr_list, 0, attrs, attrs_len);
+
   if (chars_broken + 1 > attrs_len)
     g_warning ("pango_get_log_attrs: attrs_len should have been at least %d, but was %d.  Expect corrupted 
memory.",
                chars_broken + 1,
diff --git a/pango/pango-break.h b/pango/pango-break.h
index 021af0d4..55274211 100644
--- a/pango/pango-break.h
+++ b/pango/pango-break.h
@@ -104,6 +104,7 @@ struct _PangoLogAttr
 PANGO_AVAILABLE_IN_ALL
 void                    pango_get_log_attrs     (const char    *text,
                                                  int            length,
+                                                 PangoAttrList *attr_list,
                                                  int            level,
                                                  PangoLanguage *language,
                                                  PangoLogAttr  *attrs,
@@ -112,7 +113,6 @@ void                    pango_get_log_attrs     (const char    *text,
 PANGO_AVAILABLE_IN_ALL
 void                    pango_default_break     (const char    *text,
                                                  int            length,
-                                                 PangoAnalysis *analysis,
                                                  PangoLogAttr  *attrs,
                                                  int            attrs_len);
 
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 59808416..e6be7143 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -4597,7 +4597,7 @@ get_items_log_attrs (const char    *text,
   int offset = 0;
   GList *l;
 
-  pango_default_break (text + start, length, NULL, log_attrs, log_attrs_len);
+  pango_default_break (text + start, length, log_attrs, log_attrs_len);
 
   for (l = items; l; l = l->next)
     {
diff --git a/tests/testboundaries.c b/tests/testboundaries.c
index dbc3b5b7..c492b577 100644
--- a/tests/testboundaries.c
+++ b/tests/testboundaries.c
@@ -282,12 +282,7 @@ check_invariants (const char *text)
   len = g_utf8_strlen (text, -1);
   attrs = g_new0 (PangoLogAttr, len + 1);
 
-  pango_get_log_attrs (text,
-                      -1,
-                      0,
-                      pango_language_from_string ("C"),
-                      attrs,
-                      len + 1);
+  pango_get_log_attrs (text, -1, NULL, 0, pango_language_from_string ("C"), attrs, len + 1);
 
   check_line_invariants (text, attrs);
   check_sentence_invariants (text, attrs);
diff --git a/tests/testboundaries_ucd.c b/tests/testboundaries_ucd.c
index bcc7ed45..f69769cc 100644
--- a/tests/testboundaries_ucd.c
+++ b/tests/testboundaries_ucd.c
@@ -274,7 +274,7 @@ do_test (const gchar *filename,
       if (num_attrs > 0)
         {
           PangoLogAttr *attrs = g_new0 (PangoLogAttr, num_attrs);
-          pango_get_log_attrs (string, -1, 0, pango_language_from_string ("C"), attrs, num_attrs);
+          pango_get_log_attrs (string, -1, NULL, 0, pango_language_from_string ("C"), attrs, num_attrs);
 
           if (! attrs_equal (attrs, expected_attrs, num_attrs, bits))
             {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]