[gtksourceview/meson.msvc: 5/8] gtksourceutils.c: Don't define variables in a for loop statement



commit ee3dc533d699d6b15282a1adef13d35a35636c11
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Apr 24 16:31:11 2019 +0800

    gtksourceutils.c: Don't define variables in a for loop statement
    
    pre-C99 compilers don't like this idea...
    
    Also change a call of snprintf() to g_snprintf() so that all supported
    platforms can build the code properly.

 gtksourceview/gtksourceutils.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/gtksourceview/gtksourceutils.c b/gtksourceview/gtksourceutils.c
index 8bc2d0ef..e6a3ca98 100644
--- a/gtksourceview/gtksourceutils.c
+++ b/gtksourceview/gtksourceutils.c
@@ -554,8 +554,9 @@ _gtk_source_utils_int_to_string (guint         value,
        if G_LIKELY (value == fi.value + 1)
        {
                guint carry = 1;
+               gint i;
 
-               for (gint i = fi.len - 1; i >= 0; i--)
+               for (i = fi.len - 1; i >= 0; i--)
                {
                        fi.str[i] += carry;
                        carry = fi.str[i] == ':';
@@ -572,7 +573,7 @@ _gtk_source_utils_int_to_string (guint         value,
 
                if G_UNLIKELY (carry)
                {
-                       for (guint i = fi.len; i > 0; i--)
+                       for (i = fi.len; i > 0; i--)
                        {
                                fi.str[i] = fi.str[i-1];
                        }
@@ -587,7 +588,7 @@ _gtk_source_utils_int_to_string (guint         value,
                return fi.len;
        }
 
-       fi.len = snprintf (fi.str, sizeof fi.str - 1, "%u", value);
+       fi.len = g_snprintf (fi.str, sizeof fi.str - 1, "%u", value);
        fi.str[fi.len] = 0;
        fi.value = value;
 


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