[anjuta] project-wizard: bug #650930 - anjuta-3.x project wizard fails to detect autogen-5.11.x



commit 1f76c55a9d1c6e056f8068f229704dfe45c0e5dd
Author: Alexandre Rostovtsev <tetromino gmail com>
Date:   Wed May 25 21:01:47 2011 +0200

    project-wizard: bug #650930 - anjuta-3.x project wizard fails to detect autogen-5.11.x

 plugins/project-wizard/autogen.c |   37 +++++++++++++++++++++++++------------
 1 files changed, 25 insertions(+), 12 deletions(-)
---
diff --git a/plugins/project-wizard/autogen.c b/plugins/project-wizard/autogen.c
index ca6492a..1b521f5 100644
--- a/plugins/project-wizard/autogen.c
+++ b/plugins/project-wizard/autogen.c
@@ -95,19 +95,32 @@ npw_check_autogen (void)
 	if (g_spawn_sync (NULL, args, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL,
 		NULL, NULL, &output, NULL, NULL, NULL))
 	{
-		gint ver[3];
-		gchar* ptr;
-
-		/* Check autogen */
-		if (strstr(output, "The Automated Program Generator") == NULL) return FALSE;
-
-		/* Get version number */
-		ptr = strstr(output, "Ver. ");
-	       	if (ptr == NULL) return FALSE;
-		ptr += 5;
-		sscanf(ptr,"%d.%d.%d", &ver[0], &ver[1], &ver[2]);
+		GRegex *re;
+		GMatchInfo *minfo;
+		gint ver[3] = {0, 0, 0};
+
+		/* Check autogen 5 version string
+		 * Examples:
+		 * autogen - The Automated Program Generator - Ver. 5.5.7
+		 * autogen (GNU AutoGen) - The Automated Program Generator - Ver. 5.11
+		 * autogen (GNU AutoGen) 5.11.9
+		 */
+		re = g_regex_new ("autogen.* (\\d+)\\.(\\d+)(?:\\.(\\d+))?", 0, 0, NULL);
+		g_regex_match (re, output, 0, &minfo);
+		if (g_match_info_matches (minfo)) {
+			gchar **match_strings;
+
+			match_strings = g_match_info_fetch_all (minfo);
+			ver[0] = g_ascii_strtoll (match_strings[1], NULL, 10);
+			ver[1] = g_ascii_strtoll (match_strings[2], NULL, 10);
+			ver[2] = g_ascii_strtoll (match_strings[3], NULL, 10); /* match_strings[3] may be NULL */
+
+			g_strfreev (match_strings);
+		}
+		g_match_info_free (minfo);
+		g_regex_unref (re);
 
-		return (ver[0] == 5);
+		return ver[0] == 5;
 	}
 
 	return FALSE;



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