]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
glib-2.0: add non-null support for string.joinv
authorEvan Nemerson <evan@nemerson.com>
Sun, 4 May 2014 03:28:46 +0000 (20:28 -0700)
committerLuca Bruno <lucabru@src.gnome.org>
Wed, 18 Jun 2014 19:53:44 +0000 (21:53 +0200)
Updated patch after fixing accessing .length of arrays
in the non-nullable semantics

Fixes bug 728656

vapi/glib-2.0.vapi

index f30dcbaea0d62bd0c2db5ea57fbdb945e961941a..dbb92fbbb03624b30f5744d5d7966834c27ba713 100644 (file)
@@ -960,7 +960,7 @@ public class string {
        [CCode (cname = "g_stpcpy")]
        private static void* copy_to_buffer (void* dest, string src);
        [CCode (cname = "_vala_g_strjoinv")]
-       public static string joinv (string? separator, string[]? str_array) {
+       public static string joinv (string? separator, string?[]? str_array) {
                if (separator == null) {
                        separator = "";
                }
@@ -968,19 +968,19 @@ public class string {
                        int i;
                        size_t len = 1;
                        for (i = 0 ; (str_array.length != -1 && i < str_array.length) || (str_array.length == -1 && str_array[i] != null) ; i++) {
-                               len += (str_array[i] != null) ? str_array[i].length : 0;
+                               len += (str_array[i] != null) ? ((!) str_array[i]).length : 0;
                        }
                        if (i == 0) {
                                return "";
                        }
                        str_array.length = i;
-                       len += separator.length * (i - 1);
+                       len += ((!) separator).length * (i - 1);
 
                        string* res = GLib.malloc (len);
-                       void* ptr = string.copy_to_buffer ((void*) res, str_array[0]);
+                       void* ptr = string.copy_to_buffer ((void*) res, (!) str_array[0]);
                        for (i = 1 ; i < str_array.length ; i++) {
-                               ptr = string.copy_to_buffer (ptr, separator);
-                               ptr = string.copy_to_buffer (ptr, str_array[i] ?? "");
+                               ptr = string.copy_to_buffer (ptr, (!) separator);
+                               ptr = string.copy_to_buffer (ptr, (str_array[i] != null) ? ((!) str_array[i]) : "");
                        }
 
                        return (owned) res;