]> 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>
Fri, 19 Jan 2018 08:38:28 +0000 (09:38 +0100)
The underlying regex causes faulty replacements.

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

vala/valacodewriter.vala

index ec48ed03dd4c32dfd10125350dc54a376f022947..7318c35a6c3594cb198893c5992ff5315a85aa46 100644 (file)
@@ -212,7 +212,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;