]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codewriter: Don't use string.replace() to apply header_to_override
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 18 Jan 2018 22:08:30 +0000 (23:08 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 18 Jan 2018 22:08:30 +0000 (23:08 +0100)
The underlying regex causes faulty replacements.

https://bugzilla.gnome.org/show_bug.cgi?id=731322

vala/valacodewriter.vala

index 8c0e68804d31e52c5a725450a92b56018ac77337..2fed2d8f59ca085993bf4bf83ba900a444c451ca 100644 (file)
@@ -214,7 +214,13 @@ public class Vala.CodeWriter : CodeVisitor {
                        }
 
                        if (header_to_override != null) {
-                               cheaders = cheaders.replace (header_to_override, override_header).replace (",,", ",");
+                               var cheaders_array = cheaders.split (",");
+                               for (int i = 0; i < cheaders_array.length; i++) {
+                                       if (cheaders_array[i] == header_to_override) {
+                                               cheaders_array[i] = override_header;
+                                       }
+                               }
+                               cheaders = string.joinv (",", cheaders_array);
                        }
                }
                return cheaders;