]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
glib-2.0: Fix g_strchomp, g_strchug, and g_strstrip bindings
authorJürg Billeter <j@bitron.ch>
Sat, 15 Aug 2009 14:22:25 +0000 (16:22 +0200)
committerJürg Billeter <j@bitron.ch>
Sat, 15 Aug 2009 14:22:25 +0000 (16:22 +0200)
Strings are immutable in Vala. Fixes bug 571470.

compiler/valacompiler.vala
vapi/glib-2.0.vapi
vapigen/valavapigen.vala

index cc74b5cc03233db7b48d96c0ec888c093b7d1e41..76c6698f113d36677188dae8a5fb695d2018355c 100644 (file)
@@ -146,7 +146,7 @@ class Vala.Compiler {
                                ulong deps_len;
                                FileUtils.get_contents (deps_filename, out deps_content, out deps_len);
                                foreach (string dep in deps_content.split ("\n")) {
-                                       dep.strip ();
+                                       dep = dep.strip ();
                                        if (dep != "") {
                                                if (!add_package (context, dep)) {
                                                        Report.error (null, "%s, dependency of %s, not found in specified Vala API directories".printf (dep, pkg));
index 9cfa89473c3630a6e5fa6bdd5af05bddc934dc63..da61974cf9807ddfa65c7ea4be27eb1b1f04ebba 100644 (file)
@@ -878,11 +878,28 @@ public class string {
        public string locale_to_utf8 (ssize_t len, out size_t bytes_read, out size_t bytes_written, out GLib.Error error = null);
   
        [CCode (cname = "g_strchomp")]
-       public weak string chomp();
+       public weak string _chomp();
+       public string chomp () {
+               string result = this.dup ();
+               result._chomp ();
+               return result;
+       }
+
        [CCode (cname = "g_strchug")]
-       public weak string chug();
+       public weak string _chug();
+       public string chug () {
+               string result = this.dup ();
+               result._chug ();
+               return result;
+       }
+
        [CCode (cname = "g_strstrip")]
-       public weak string strip ();
+       public weak string _strip ();
+       public string strip () {
+               string result = this.dup ();
+               result._strip ();
+               return result;
+       }
        
        [CCode (cname = "g_str_hash")]
        public uint hash ();
@@ -915,6 +932,8 @@ public class string {
        [CCode (cname = "g_strcanon")]
        public void canon (string valid_chars, char substitutor);
 
+       [CCode (cname = "g_strdup")]
+       public string dup ();
        // n is size in bytes, not length in characters
        [CCode (cname = "g_strndup")]
        public string ndup (size_t n);
index e65df13c23857e1136fcde083f50387f425c52ee..e5e640b83cb1b29f81e998ddcdc23e4721786957 100644 (file)
@@ -89,7 +89,7 @@ class Vala.VAPIGen : Object {
                                ulong deps_len;
                                FileUtils.get_contents (deps_filename, out deps_content, out deps_len);
                                foreach (string dep in deps_content.split ("\n")) {
-                                       dep.strip ();
+                                       dep = dep.strip ();
                                        if (dep != "") {
                                                if (!add_package (dep)) {
                                                        Report.error (null, "%s, dependency of %s, not found in specified Vala API directories".printf (dep, pkg));