[geany/geany-plugins] 8996f6: Merge branch 'pohelper/sane-reflow'

Colomban Wendling git-noreply at xxxxx
Sun Mar 30 22:04:33 UTC 2014


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sun, 30 Mar 2014 22:04:33 UTC
Commit:      8996f6cf56743e15cff6c4356c09115bc5d79bb0
             https://github.com/geany/geany-plugins/commit/8996f6cf56743e15cff6c4356c09115bc5d79bb0

Log Message:
-----------
Merge branch 'pohelper/sane-reflow'


Modified Paths:
--------------
    pohelper/src/gph-plugin.c

Modified: pohelper/src/gph-plugin.c
17 files changed, 10 insertions(+), 7 deletions(-)
===================================================================
@@ -727,14 +727,12 @@ enum {
  * cuts first at \n, then at spaces and punctuation */
 static gchar **
 split_msg (const gchar *str,
-           gint         len)
+           gsize        len)
 {
   GPtrArray *chunks = g_ptr_array_new ();
   
-  g_return_val_if_fail (len >= 0, NULL);
-  
   while (*str) {
-    GString *chunk = g_string_sized_new ((gsize) len);
+    GString *chunk = g_string_sized_new (len);
     
     while (*str) {
       const gchar *nl = strstr (str, "\\n");
@@ -749,12 +747,12 @@ enum {
       else /* if there is no separator, use the end of the string */
         p = strchr (str, 0);
       
-      if (nl && ((chunk_len + g_utf8_strlen (str, nl - str)) <= len ||
+      if (nl && ((gsize)(chunk_len + g_utf8_strlen (str, nl - str)) <= len ||
                  (nl < p && chunk->len == 0))) {
         g_string_append_len (chunk, str, nl - str);
         str = nl;
         break;
-      } else if ((chunk_len + g_utf8_strlen (str, p - str)) <= len ||
+      } else if ((gsize)(chunk_len + g_utf8_strlen (str, p - str)) <= len ||
                  chunk->len == 0) {
         g_string_append_len (chunk, str, p - str);
         str = p;
@@ -789,6 +787,11 @@ enum {
       gint line_len = geany_data->editor_prefs->line_break_column;
       gint msgstr_kw_len;
       
+      /* if line break column doesn't have a reasonable value, don't use it */
+      if (line_len < 8) {
+        line_len = 72;
+      }
+      
       sci_start_undo_action (sci);
       scintilla_send_message (sci, SCI_DELETERANGE,
                               (uptr_t) start, end + 1 - start);
@@ -802,7 +805,7 @@ enum {
       } else {
         /* otherwise, put nothing on the msgstr line and split it up through
          * next ones */
-        gchar **chunks = split_msg (msgstr->str, line_len - 2);
+        gchar **chunks = split_msg (msgstr->str, (gsize)(line_len - 2));
         guint i;
         
         sci_insert_text (sci, start, "\"\""); /* nothing on the msgstr line */



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list