anjuta r4420 - in trunk: . libanjuta manuals/reference/libanjuta plugins/build-basic-autotools plugins/project-wizard



Author: sgranjoux
Date: Fri Dec  5 21:59:26 2008
New Revision: 4420
URL: http://svn.gnome.org/viewvc/anjuta?rev=4420&view=rev

Log:
	* plugins/build-basic-autotools/plugin.c,
	plugins/build-basic-autotools/program.c,
	manuals/reference/libanjuta/libanjuta-sections.txt,
	libanjuta/anjuta-utils.c,
	libanjuta/anjuta-utils.h:
	Move shell_expand function in anjuta-util

	* plugins/project-wizard/property.c:
	Fix #562623: Project creation fails if path uses a tilde


Modified:
   trunk/ChangeLog
   trunk/libanjuta/anjuta-utils.c
   trunk/libanjuta/anjuta-utils.h
   trunk/manuals/reference/libanjuta/libanjuta-sections.txt
   trunk/plugins/build-basic-autotools/plugin.c
   trunk/plugins/build-basic-autotools/program.c
   trunk/plugins/project-wizard/property.c

Modified: trunk/libanjuta/anjuta-utils.c
==============================================================================
--- trunk/libanjuta/anjuta-utils.c	(original)
+++ trunk/libanjuta/anjuta-utils.c	Fri Dec  5 21:59:26 2008
@@ -1615,6 +1615,68 @@
 	return g_strdup (uri);
 }
 
+/**
+ * anjuta_util_shell_expand:
+ * @string: input string
+ *
+ * Expand environment variables $(var_name) and tilde (~) in the input string.
+ *
+ * Returns: a newly-allocated string that must be freed with g_free().
+ */
+gchar*
+anjuta_util_shell_expand (const gchar *string)
+{
+	GString* expand;
+	
+	if (string == NULL) return NULL;
+	
+	expand = g_string_sized_new (strlen (string));
+	
+	for (; *string != '\0'; string++)
+	{
+		switch (*string)
+		{
+			case '$':
+			{
+				/* Variable expansion */
+				const gchar *end;
+				gint var_name_len;
+
+				end = string + 1;
+				while (isalnum (*end) || (*end == '_')) end++;
+				var_name_len = end - string - 1;
+				if (var_name_len > 0)
+				{
+					const gchar *value;
+					
+					g_string_append_len (expand, string + 1, var_name_len);
+					value = g_getenv (expand->str + expand->len - var_name_len);
+					g_string_truncate (expand, expand->len - var_name_len);
+					g_string_append (expand, value);
+					string = end - 1;
+					continue;
+				}
+				break;
+			}
+			case '~':
+			{
+				/* User home directory expansion */
+				if (isspace(string[1]) || (string[1] == G_DIR_SEPARATOR) || (string[1] == '\0'))
+				{
+					g_string_append (expand, g_get_home_dir());
+					continue;
+				}
+				break;
+			}
+			default:
+				break;
+		}
+		g_string_append_c (expand, *string);
+	}
+	
+	return g_string_free (expand, FALSE);
+}
+
 gchar *
 anjuta_util_str_middle_truncate (const gchar *string,
 								  guint        truncate_length)

Modified: trunk/libanjuta/anjuta-utils.h
==============================================================================
--- trunk/libanjuta/anjuta-utils.h	(original)
+++ trunk/libanjuta/anjuta-utils.h	Fri Dec  5 21:59:26 2008
@@ -115,6 +115,7 @@
 
 gchar* anjuta_util_uri_get_dirname (const gchar *uri);
 gchar* anjuta_util_replace_home_dir_with_tilde (const gchar *uri);
+gchar* anjuta_util_shell_expand (const gchar *string);
 gchar* anjuta_util_str_middle_truncate (const gchar *string,
 										 guint        truncate_length);
 

Modified: trunk/manuals/reference/libanjuta/libanjuta-sections.txt
==============================================================================
--- trunk/manuals/reference/libanjuta/libanjuta-sections.txt	(original)
+++ trunk/manuals/reference/libanjuta/libanjuta-sections.txt	Fri Dec  5 21:59:26 2008
@@ -1887,6 +1887,7 @@
 anjuta_util_get_real_path
 anjuta_util_uri_get_dirname
 anjuta_util_replace_home_dir_with_tilde
+anjuta_util_shell_expand
 anjuta_util_str_middle_truncate
 anjuta_util_get_uri_mime_type
 anjuta_util_get_local_path_from_uri

Modified: trunk/plugins/build-basic-autotools/plugin.c
==============================================================================
--- trunk/plugins/build-basic-autotools/plugin.c	(original)
+++ trunk/plugins/build-basic-autotools/plugin.c	Fri Dec  5 21:59:26 2008
@@ -1360,7 +1360,6 @@
 {
 	BuildContext *context;
 	gchar *build_dir;
-	gchar *src_dir;
 	gchar *target;
 	BuildProgram *prog;
 	

Modified: trunk/plugins/build-basic-autotools/program.c
==============================================================================
--- trunk/plugins/build-basic-autotools/program.c	(original)
+++ trunk/plugins/build-basic-autotools/program.c	Fri Dec  5 21:59:26 2008
@@ -35,6 +35,8 @@
 
 #include "program.h"
 
+#include <libanjuta/anjuta-utils.h>
+
 #include <glib/gi18n.h>
 
 #include <string.h>
@@ -45,60 +47,6 @@
 /* Helper functions
  *---------------------------------------------------------------------------*/
 
-static gchar*
-build_shell_expand (const gchar *input)
-{
-	GString* expand;
-	
-	if (input == NULL) return NULL;
-	
-	expand = g_string_sized_new (strlen (input));
-	
-	for (; *input != '\0'; input++)
-	{
-		switch (*input)
-		{
-			case '$':
-			{
-				/* Variable expansion */
-				const gchar *end;
-				gint var_name_len;
-
-				end = input + 1;
-				while (isalnum (*end) || (*end == '_')) end++;
-				var_name_len = end - input - 1;
-				if (var_name_len > 0)
-				{
-					const gchar *value;
-					
-					g_string_append_len (expand, input + 1, var_name_len);
-					value = g_getenv (expand->str + expand->len - var_name_len);
-					g_string_truncate (expand, expand->len - var_name_len);
-					g_string_append (expand, value);
-					input = end - 1;
-					continue;
-				}
-				break;
-			}
-			case '~':
-			{
-				/* User home directory expansion */
-				if (isspace(input[1]) || (input[1] == G_DIR_SEPARATOR) || (input[1] == '\0'))
-				{
-					g_string_append (expand, g_get_home_dir());
-					continue;
-				}
-				break;
-			}
-			default:
-				break;
-		}
-		g_string_append_c (expand, *input);
-	}
-	
-	return g_string_free (expand, FALSE);
-}
-
 static gchar **
 build_strv_insert_before (gchar ***pstrv, gint pos)
 {
@@ -202,7 +150,7 @@
 	{
 		gchar *new_arg;
 		
-		new_arg = build_shell_expand (*arg);
+		new_arg = anjuta_util_shell_expand (*arg);
 		g_free (*arg);
 		*arg = new_arg;
 	}
@@ -238,7 +186,7 @@
 	gchar **parg;
 	
 	parg = build_strv_insert_before (&prog->argv, pos);
-	*parg = build_shell_expand (arg);
+	*parg = anjuta_util_shell_expand (arg);
 	
 	return TRUE;
 }
@@ -253,7 +201,7 @@
 	else
 	{
 		g_free (prog->argv[pos]);
-		prog->argv[pos] = build_shell_expand (arg);
+		prog->argv[pos] = anjuta_util_shell_expand (arg);
 	}
 	
 	return TRUE;

Modified: trunk/plugins/project-wizard/property.c
==============================================================================
--- trunk/plugins/project-wizard/property.c	(original)
+++ trunk/plugins/project-wizard/property.c	Fri Dec  5 21:59:26 2008
@@ -38,6 +38,7 @@
 #include <ctype.h>
 
 #include <libanjuta/anjuta-debug.h>
+#include <libanjuta/anjuta-utils.h>
 
 /*---------------------------------------------------------------------------*/
 
@@ -494,6 +495,9 @@
 		{
 			/* a GtkEntry is used in this case*/
 			value = gtk_entry_get_text (GTK_ENTRY (this->widget));
+			/* Expand ~ and environment variable */
+			alloc_value = anjuta_util_shell_expand (value);
+			value = alloc_value;
 		}
 		else
 		{



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