[geany/geany-plugins] 0851d7: pohelper: Explicitly use unsigned length parameter for split_msg()

Colomban Wendling git-noreply at xxxxx
Sun Mar 30 21:54:02 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 21:54:02 UTC
Commit:      0851d72f533523b9fe609c25fd8231827aa74bb9
             https://github.com/geany/geany-plugins/commit/0851d72f533523b9fe609c25fd8231827aa74bb9

Log Message:
-----------
pohelper: Explicitly use unsigned length parameter for split_msg()

Use a real unsigned parameter instead of checking the passed-in value
isn't negative.


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

Modified: pohelper/src/gph-plugin.c
12 files changed, 5 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;
@@ -807,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