[vala] glib-2.0: Fix g_strchomp, g_strchug, and g_strstrip bindings



commit c2bc68bf6c0f9b6bca0f7cb02a5a8d89ee6ff993
Author: Jürg Billeter <j bitron ch>
Date:   Sat Aug 15 16:22:25 2009 +0200

    glib-2.0: Fix g_strchomp, g_strchug, and g_strstrip bindings
    
    Strings are immutable in Vala. Fixes bug 571470.

 compiler/valacompiler.vala |    2 +-
 vapi/glib-2.0.vapi         |   25 ++++++++++++++++++++++---
 vapigen/valavapigen.vala   |    2 +-
 3 files changed, 24 insertions(+), 5 deletions(-)
---
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala
index cc74b5c..76c6698 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 9cfa894..da61974 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 e65df13..e5e640b 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));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]