From: Jürg Billeter Date: Sat, 15 Aug 2009 14:22:25 +0000 (+0200) Subject: glib-2.0: Fix g_strchomp, g_strchug, and g_strstrip bindings X-Git-Tag: 0.7.6~208 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2bc68bf6c0f9b6bca0f7cb02a5a8d89ee6ff993;p=thirdparty%2Fvala.git glib-2.0: Fix g_strchomp, g_strchug, and g_strstrip bindings Strings are immutable in Vala. Fixes bug 571470. --- diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala index cc74b5cc0..76c6698f1 100644 --- a/compiler/valacompiler.vala +++ b/compiler/valacompiler.vala @@ -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)); diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi index 9cfa89473..da61974cf 100644 --- a/vapi/glib-2.0.vapi +++ b/vapi/glib-2.0.vapi @@ -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); diff --git a/vapigen/valavapigen.vala b/vapigen/valavapigen.vala index e65df13c2..e5e640b83 100644 --- a/vapigen/valavapigen.vala +++ b/vapigen/valavapigen.vala @@ -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));