[pango/log-attr-things: 2/4] break: Some code reorganization




commit c407656eab8777cfdbdf7f5109dba72795f7e996
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Aug 21 22:44:18 2021 -0400

    break: Some code reorganization
    
    Shuffle break.c around a bit.

 pango/break.c       | 102 ++++++++++++++++++++++++++++------------------------
 pango/pango-break.h |   7 ++--
 2 files changed, 60 insertions(+), 49 deletions(-)
---
diff --git a/pango/break.c b/pango/break.c
index b2586da2..271c8db7 100644
--- a/pango/break.c
+++ b/pango/break.c
@@ -139,29 +139,12 @@ typedef enum
   WordNumbers
 } WordType;
 
-
-/**
- * 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 Unicode rules without language-specific
- * tailoring, therefore the @analyis argument is unused
- * and can be %NULL.
- *
- * See [func@Pango.tailor_break] for language-specific breaks.
- */
-void
-pango_default_break (const gchar   *text,
-                    gint           length,
-                    PangoAnalysis *analysis G_GNUC_UNUSED,
-                    PangoLogAttr  *attrs,
-                    int            attrs_len G_GNUC_UNUSED)
+static void
+default_break (const char    *text,
+               int            length,
+               PangoAnalysis *analysis G_GNUC_UNUSED,
+               PangoLogAttr  *attrs,
+               int            attrs_len G_GNUC_UNUSED)
 {
   /* The rationale for all this is in section 5.15 of the Unicode 3.0 book,
    * the line breaking stuff is also in TR14 on unicode.org
@@ -1639,7 +1622,7 @@ break_script (const char          *item_text,
 }
 
 /* }}} */
-/* {{{ Attribute-based tailoring */
+/* {{{ Attribute-based customization */
 
 static gboolean
 break_attrs (const char   *text,
@@ -1707,11 +1690,11 @@ break_attrs (const char   *text,
 
 static gboolean
 tailor_break (const char    *text,
-             int            length,
-             PangoAnalysis *analysis,
+              int            length,
+              PangoAnalysis *analysis,
               int            item_offset,
-             PangoLogAttr  *attrs,
-             int            attrs_len)
+              PangoLogAttr  *attrs,
+              int            attrs_len)
 {
   gboolean res;
 
@@ -1731,6 +1714,32 @@ tailor_break (const char    *text,
 /* }}} */
 /* {{{ Public API */
 
+/**
+ * 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 Unicode rules without language-specific
+ * tailoring, therefore the @analyis argument is unused
+ * and can be %NULL.
+ *
+ * See [func@Pango.tailor_break] for language-specific breaks.
+ */
+void
+pango_default_break (const char    *text,
+                     int            length,
+                     PangoAnalysis *analysis G_GNUC_UNUSED,
+                     PangoLogAttr  *attrs,
+                     int            attrs_len G_GNUC_UNUSED)
+{
+  default_break (text, length, analysis, attrs, attrs_len);
+}
+
 /**
  * pango_break:
  * @text: the text to process. Must be valid UTF-8
@@ -1749,7 +1758,7 @@ tailor_break (const char    *text,
  *   [func@Pango.tailor_break]
  */
 void
-pango_break (const gchar   *text,
+pango_break (const char    *text,
              gint           length,
              PangoAnalysis *analysis,
              PangoLogAttr  *attrs,
@@ -1758,7 +1767,7 @@ pango_break (const gchar   *text,
   g_return_if_fail (analysis != NULL);
   g_return_if_fail (attrs != NULL);
 
-  pango_default_break (text, length, analysis, attrs, attrs_len);
+  default_break (text, length, analysis, attrs, attrs_len);
   tailor_break (text, length, analysis, -1, attrs, attrs_len);
 }
 
@@ -1769,12 +1778,11 @@ pango_break (const gchar   *text,
  * @analysis: `PangoAnalysis` for @text
  * @offset: Byte offset of @text from the beginning of the
  *   paragraph, or -1 to ignore attributes from @analysis
- * @log_attrs: (array length=log_attrs_len): array with one `PangoLogAttr`
+ * @attrs: (array length=attrs_len): array with one `PangoLogAttr`
  *   per character in @text, plus one extra, to be filled in
- * @log_attrs_len: length of @log_attrs array
+ * @attrs_len: length of @attrs array
  *
- * Apply language-specific tailoring to the breaks
- * in @log_attrs.
+ * Apply language-specific tailoring to the breaks in @attrs.
  *
  * The line breaks are assumed to have been produced
  * by [func@Pango.default_break].
@@ -1789,13 +1797,13 @@ pango_tailor_break (const char    *text,
                     int            length,
                     PangoAnalysis *analysis,
                     int            offset,
-                    PangoLogAttr  *log_attrs,
-                    int            log_attrs_len)
+                    PangoLogAttr  *attrs,
+                    int            attrs_len)
 {
-  PangoLogAttr *start = log_attrs;
+  PangoLogAttr *start = attrs;
   PangoLogAttr attr_before = *start;
 
-  if (tailor_break (text, length, analysis, offset, log_attrs, log_attrs_len))
+  if (tailor_break (text, length, analysis, offset, attrs, attrs_len))
     {
       /* if tailored, we enforce some of the attrs from before
        * tailoring at the boundary
@@ -1815,13 +1823,13 @@ pango_tailor_break (const char    *text,
  * @length: length in bytes of @text
  * @level: embedding level, or -1 if unknown
  * @language: language tag
- * @log_attrs: (array length=attrs_len): array with one `PangoLogAttr`
+ * @attrs: (array length=attrs_len): array with one `PangoLogAttr`
  *   per character in @text, plus one extra, to be filled in
- * @attrs_len: length of @log_attrs array
+ * @attrs_len: length of @attrs array
  *
  * Computes a `PangoLogAttr` for each character in @text.
  *
- * The @log_attrs array must have one `PangoLogAttr` for
+ * The @attrs array must have one `PangoLogAttr` for
  * each position in @text; if @text contains N characters,
  * it has N+1 positions, including the last position at the
  * end of the text. @text should be an entire paragraph;
@@ -1834,7 +1842,7 @@ pango_get_log_attrs (const char    *text,
                      int            length,
                      int            level,
                      PangoLanguage *language,
-                     PangoLogAttr  *log_attrs,
+                     PangoLogAttr  *attrs,
                      int            attrs_len)
 {
   int chars_broken;
@@ -1842,12 +1850,12 @@ pango_get_log_attrs (const char    *text,
   PangoScriptIter iter;
 
   g_return_if_fail (length == 0 || text != NULL);
-  g_return_if_fail (log_attrs != NULL);
+  g_return_if_fail (attrs != NULL);
 
   analysis.level = level;
   analysis.language = language;
 
-  pango_default_break (text, length, &analysis, log_attrs, attrs_len);
+  pango_default_break (text, length, &analysis, attrs, attrs_len);
 
   chars_broken = 0;
 
@@ -1867,7 +1875,7 @@ pango_get_log_attrs (const char    *text,
                           run_end - run_start,
                           &analysis,
                           -1,
-                          log_attrs + chars_broken,
+                          attrs + chars_broken,
                           chars_in_range + 1);
 
       chars_broken += chars_in_range;
@@ -1881,4 +1889,6 @@ pango_get_log_attrs (const char    *text,
                attrs_len);
 }
 
-/* }}} */
+ /* }}} */
+
+/* vim:set foldmethod=marker expandtab: */
diff --git a/pango/pango-break.h b/pango/pango-break.h
index 81526e9a..f514d168 100644
--- a/pango/pango-break.h
+++ b/pango/pango-break.h
@@ -105,7 +105,7 @@ void                    pango_get_log_attrs     (const char    *text,
                                                  int            length,
                                                  int            level,
                                                  PangoLanguage *language,
-                                                 PangoLogAttr  *log_attrs,
+                                                 PangoLogAttr  *attrs,
                                                  int            attrs_len);
 
 PANGO_AVAILABLE_IN_ALL
@@ -120,8 +120,9 @@ void                    pango_tailor_break      (const char    *text,
                                                  int            length,
                                                  PangoAnalysis *analysis,
                                                  int            offset,
-                                                 PangoLogAttr  *log_attrs,
-                                                 int            log_attrs_len);
+                                                 PangoLogAttr  *attrs,
+                                                 int            attrs_len);
+
 
 G_END_DECLS
 


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