SF.net SVN: geany: [714] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Mon Aug 14 15:03:05 UTC 2006


Revision: 714
Author:   ntrel
Date:     2006-08-14 08:02:52 -0700 (Mon, 14 Aug 2006)
ViewCVS:  http://svn.sourceforge.net/geany/?rev=714&view=rev

Log Message:
-----------
Store build information instead of using app->cur_idx; Assume C-like warning messages when running make when the current file is a Makefile; Moved some msgwin setup and cleanup code to msgwindow.c; Moved utils_parse_compiler_error_line to msgwindow.c

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/build.c
    trunk/src/callbacks.c
    trunk/src/geany.h
    trunk/src/main.c
    trunk/src/msgwindow.c
    trunk/src/msgwindow.h
    trunk/src/search.c
    trunk/src/search.h
    trunk/src/utils.c
    trunk/src/utils.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-08-14 10:35:57 UTC (rev 713)
+++ trunk/ChangeLog	2006-08-14 15:02:52 UTC (rev 714)
@@ -1,3 +1,17 @@
+2006-08-14  Nick Treleaven  <nick.treleaven at btinternet.com>
+
+ * src/sci_cb.c: Applied patch from Jens Granseuer to fix build with
+                 gcc 2.95 (closes #1539502).
+ * src/build.c, src/geany.h, src/msgwindow.c, src/msgwindow.h,
+   src/callbacks.c, src/search.c, src/search.h, src/main.c:
+   Store build information instead of using app->cur_idx.
+   Assume C-like warning messages when running make when the current
+   file is a Makefile.
+   Moved some msgwin setup and cleanup code to msgwindow.c.
+ * src/utils.c, src/utils.h
+   Moved utils_parse_compiler_error_line to msgwindow.c.
+
+
 2006-08-13  Enrico Tröger  <enrico.troeger at uvena.de>
 
  * src/document.c:

Modified: trunk/src/build.c
===================================================================
--- trunk/src/build.c	2006-08-14 10:35:57 UTC (rev 713)
+++ trunk/src/build.c	2006-08-14 15:02:52 UTC (rev 714)
@@ -249,7 +249,8 @@
 	gint     stdout_fd;
 	gint     stderr_fd;
 
-	app->cur_idx = idx;
+	g_return_val_if_fail(idx >= 0 && doc_list[idx].is_valid, (GPid) 1);
+
 	document_clear_indicators(idx);
 
 	cmd_string = g_strjoinv(" ", cmd);
@@ -282,6 +283,13 @@
 	msgwin_compiler_add(COLOR_BLUE, FALSE, _("%s (in directory: %s)"), utf8_cmd_string, utf8_working_dir);
 	gtk_notebook_set_current_page(GTK_NOTEBOOK(msgwindow.notebook), MSG_COMPILER);
 
+	// set the build info for the message window
+	{
+		filetype *ft = doc_list[idx].file_type;
+		guint ft_id = (ft == NULL) ? filetypes[GEANY_FILETYPES_ALL]->id : ft->id;
+		msgwin_set_build_info(working_dir, ft_id);
+	}
+
 	if (! g_spawn_async_with_pipes(working_dir, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
 						NULL, NULL, &child_pid, NULL, &stdout_fd, &stderr_fd, &error))
 	{
@@ -473,7 +481,7 @@
 			{
 				gchar *filename;
 				gint line;
-				utils_parse_compiler_error_line(g_strstrip(msg), &filename, &line);
+				msgwin_parse_compiler_error_line(g_strstrip(msg), &filename, &line);
 				if (line != -1)
 				{
 					gint idx = document_find_by_filename(filename, FALSE);

Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2006-08-14 10:35:57 UTC (rev 713)
+++ trunk/src/callbacks.c	2006-08-14 15:02:52 UTC (rev 714)
@@ -135,6 +135,9 @@
 	}
 	g_queue_free(app->recent_queue);
 
+	msgwin_finalize();
+	search_finalize();
+
 	if (app->prefs_dialog && GTK_IS_WIDGET(app->prefs_dialog)) gtk_widget_destroy(app->prefs_dialog);
 	if (app->save_filesel && GTK_IS_WIDGET(app->save_filesel)) gtk_widget_destroy(app->save_filesel);
 	if (app->open_filesel && GTK_IS_WIDGET(app->open_filesel)) gtk_widget_destroy(app->open_filesel);
@@ -145,7 +148,6 @@
 		g_object_unref(app->default_tag_tree);
 		gtk_widget_destroy(app->default_tag_tree);
 	}
-	search_finalise();
 	scintilla_release_resources();
 #ifdef HAVE_VTE
 	if (app->have_vte) vte_close();

Modified: trunk/src/geany.h
===================================================================
--- trunk/src/geany.h	2006-08-14 10:35:57 UTC (rev 713)
+++ trunk/src/geany.h	2006-08-14 15:02:52 UTC (rev 714)
@@ -164,7 +164,6 @@
 	gint				 tab_pos_editor;
 	gint				 tab_pos_msgwin;
 	gint				 tab_pos_sidebar;
-	gint				 cur_idx;	// currently only used by the build system (build_spawn_cmd)
 	guint				 mru_length;
 	gint				 autocompletion_max_height;
 	gint				 long_line_type;

Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c	2006-08-14 10:35:57 UTC (rev 713)
+++ trunk/src/main.c	2006-08-14 15:02:52 UTC (rev 714)
@@ -253,7 +253,6 @@
 	app->tagbar = lookup_widget(app->window, "scrolledwindow2");
 	app->treeview_notebook = lookup_widget(app->window, "notebook3");
 	app->notebook = lookup_widget(app->window, "notebook1");
-	msgwindow.notebook = lookup_widget(app->window, "notebook_info");
 	app->statusbar = lookup_widget(app->window, "statusbar");
 	app->popup_menu = create_edit_menu1();
 	app->toolbar_menu = create_toolbar_popup_menu1();
@@ -317,10 +316,8 @@
 	app->undo_items[0] = lookup_widget(app->popup_menu, "undo1");
 	app->undo_items[1] = lookup_widget(app->window, "menu_undo2");
 	app->undo_items[2] = lookup_widget(app->window, "toolbutton_undo");
-	msgwindow.tree_status = lookup_widget(app->window, "treeview3");
-	msgwindow.tree_msg = lookup_widget(app->window, "treeview4");
-	msgwindow.tree_compiler = lookup_widget(app->window, "treeview5");
 
+	msgwin_init();
 	search_init();
 }
 

Modified: trunk/src/msgwindow.c
===================================================================
--- trunk/src/msgwindow.c	2006-08-14 10:35:57 UTC (rev 713)
+++ trunk/src/msgwindow.c	2006-08-14 15:02:52 UTC (rev 714)
@@ -35,15 +35,47 @@
 #include <stdlib.h>
 
 
+static struct
+{
+	gchar	*dir;
+	guint	file_type_id;
+} build_info = {NULL, GEANY_FILETYPES_ALL};
+
+
 static GdkColor dark = {0, 58832, 58832, 58832};
 static GdkColor white = {0, 65535, 65535, 65535};
 
-gchar *find_in_files_dir = NULL;
+MessageWindow msgwindow;
 
 
 static void msgwin_parse_grep_line(const gchar *string, gchar **filename, gint *line);
 
 
+void msgwin_init()
+{
+	msgwindow.tree_status = lookup_widget(app->window, "treeview3");
+	msgwindow.tree_msg = lookup_widget(app->window, "treeview4");
+	msgwindow.tree_compiler = lookup_widget(app->window, "treeview5");
+	msgwindow.notebook = lookup_widget(app->window, "notebook_info");
+	msgwindow.find_in_files_dir = NULL;
+}
+
+
+void msgwin_finalize()
+{
+	g_free(msgwindow.find_in_files_dir);
+	g_free(build_info.dir);
+}
+
+
+void msgwin_set_build_info(const gchar *dir, guint file_type_id)
+{
+	g_free(build_info.dir);
+	build_info.dir = g_strdup(dir);
+	build_info.file_type_id = file_type_id;
+}
+
+
 /* does some preparing things to the status message list widget */
 void msgwin_prepare_status_tree_view(void)
 {
@@ -263,15 +295,21 @@
 			gint line;
 			gint idx;
 			gchar *filename;
-			utils_parse_compiler_error_line(string, &filename, &line);
+			msgwin_parse_compiler_error_line(string, &filename, &line);
 			if (filename != NULL && line > -1)
 			{
-				// use document_open_file to find an already open file, or open it in place
-				idx = document_open_file(-1, filename, 0, FALSE, NULL, NULL);
-				// document_set_indicator will check valid idx
-				document_set_indicator(idx, line - 1);
-				// utils_goto_file_line will check valid filename.
-				ret = utils_goto_file_line(filename, FALSE, line);
+				gchar *utf8_filename = utils_get_utf8_from_locale(filename);
+				idx = document_find_by_filename(utf8_filename, FALSE);
+				g_free(utf8_filename);
+
+				if (idx < 0)	// file not already open
+					idx = document_open_file(-1, filename, 0, FALSE, NULL, NULL);
+
+				if (idx >= 0 && doc_list[idx].is_valid)
+				{
+					document_set_indicator(idx, line - 1);
+					ret = utils_goto_line(idx, line);
+				}
 			}
 			g_free(filename);
 		}
@@ -281,6 +319,134 @@
 }
 
 
+/* try to parse the file and line number where the error occured described in line
+ * and when something useful is found, it stores the line number in *line and the
+ * relevant file with the error in *filename.
+ * *line will be -1 if no error was found in string.
+ * *filename must be freed unless it is NULL. */
+void msgwin_parse_compiler_error_line(const gchar *string, gchar **filename, gint *line)
+{
+	gchar *end = NULL;
+	gchar **fields;
+	gchar *pattern;				// pattern to split the error message into some fields
+	guint field_min_len;		// used to detect errors after parsing
+	guint field_idx_line;		// idx of the field where the line is
+	guint field_idx_file;		// idx of the field where the filename is
+	guint skip_dot_slash = 0;	// number of characters to skip at the beginning of the filename
+
+	*filename = NULL;
+	*line = -1;
+
+	g_return_if_fail(build_info.dir != NULL);
+	if (string == NULL) return;
+
+	switch (build_info.file_type_id)
+	{
+		// only gcc is supported, I don't know any other C(++) compilers and their error messages
+		case GEANY_FILETYPES_C:
+		case GEANY_FILETYPES_CPP:
+		case GEANY_FILETYPES_RUBY:
+		case GEANY_FILETYPES_JAVA:
+		case GEANY_FILETYPES_MAKE:	// Assume makefile is building C-like code
+		{
+			// empty.h:4: Warnung: type defaults to `int' in declaration of `foo'
+			// empty.c:21: error: conflicting types for `foo'
+			pattern = ":";
+			field_min_len = 4;
+			field_idx_line = 1;
+			field_idx_file = 0;
+			break;
+		}
+		case GEANY_FILETYPES_LATEX:
+		{
+			// ./kommtechnik_2b.tex:18: Emergency stop.
+			pattern = ":";
+			field_min_len = 3;
+			field_idx_line = 1;
+			field_idx_file = 0;
+			break;
+		}
+		case GEANY_FILETYPES_PHP:
+		{
+			// Parse error: parse error, unexpected T_CASE in brace_bug.php on line 3
+			pattern = " ";
+			field_min_len = 11;
+			field_idx_line = 10;
+			field_idx_file = 7;
+			break;
+		}
+		case GEANY_FILETYPES_PERL:
+		{
+			// syntax error at test.pl line 7, near "{
+			pattern = " ";
+			field_min_len = 6;
+			field_idx_line = 5;
+			field_idx_file = 3;
+			break;
+		}
+		// the error output of python and tcl equals
+		case GEANY_FILETYPES_TCL:
+		case GEANY_FILETYPES_PYTHON:
+		{
+			// File "HyperArch.py", line 37, in ?
+			// (file "clrdial.tcl" line 12)
+			pattern = " \"";
+			field_min_len = 6;
+			field_idx_line = 5;
+			field_idx_file = 2;
+			break;
+		}
+		case GEANY_FILETYPES_PASCAL:
+		{
+			// bandit.pas(149,3) Fatal: Syntax error, ";" expected but "ELSE" found
+			pattern = "(";
+			field_min_len = 2;
+			field_idx_line = 1;
+			field_idx_file = 0;
+			break;
+		}
+		case GEANY_FILETYPES_D:
+		{
+			// warning - pi.d(118): implicit conversion of expression (digit) of type int ...
+			pattern = " (";
+			field_min_len = 4;
+			field_idx_line = 3;
+			field_idx_file = 2;
+			break;
+		}
+		default: return;
+	}
+
+	fields = g_strsplit_set(string, pattern, field_min_len);
+
+	// parse the line
+	if (g_strv_length(fields) < field_min_len)
+	{
+		g_strfreev(fields);
+		return;
+	}
+
+	*line = strtol(fields[field_idx_line], &end, 10);
+
+	// if the line could not be read, line is 0 and an error occurred, so we leave
+	if (fields[field_idx_line] == end)
+	{
+		g_strfreev(fields);
+		return;
+	}
+
+	// skip some characters at the beginning of the filename, at the moment only "./"
+	// can be extended if other "trash" is known
+	if (strncmp(fields[field_idx_file], "./", 2) == 0) skip_dot_slash = 2;
+
+	// get the build directory to get the path to look for other files
+	*filename = g_strconcat(build_info.dir, G_DIR_SEPARATOR_S,
+		fields[field_idx_file] + skip_dot_slash, NULL);
+
+	g_strfreev(fields);
+}
+
+
 gboolean msgwin_goto_messages_file_line()
 {
 	GtkTreeIter iter;
@@ -370,7 +536,7 @@
 	cur_idx = document_get_cur_idx();
 	if (cur_idx >= 0 && doc_list[cur_idx].is_valid)
 	{
-		*filename = g_strconcat(find_in_files_dir, G_DIR_SEPARATOR_S,
+		*filename = g_strconcat(msgwindow.find_in_files_dir, G_DIR_SEPARATOR_S,
 			fields[field_idx_file] + skip_dot_slash, NULL);
 	}
 

Modified: trunk/src/msgwindow.h
===================================================================
--- trunk/src/msgwindow.h	2006-08-14 10:35:57 UTC (rev 713)
+++ trunk/src/msgwindow.h	2006-08-14 15:02:52 UTC (rev 714)
@@ -42,7 +42,7 @@
 };
 
 
-typedef struct msgwin
+typedef struct
 {
 	GtkListStore	*store_status;
 	GtkListStore	*store_msg;
@@ -54,13 +54,16 @@
 	GtkWidget		*popup_msg_menu;
 	GtkWidget		*popup_compiler_menu;
 	GtkWidget		*notebook;
-} msgwin;
+	gchar			*find_in_files_dir;
+} MessageWindow;
 
-msgwin msgwindow;
+extern MessageWindow msgwindow;
 
-extern gchar *find_in_files_dir;
 
+void msgwin_init();
 
+void msgwin_finalize();
+
 void msgwin_prepare_msg_tree_view(void);
 
 void msgwin_prepare_status_tree_view(void);
@@ -73,10 +76,19 @@
 
 void msgwin_status_add(gchar const *format, ...);
 
+void msgwin_set_build_info(const gchar *dir, guint file_type_id);
+
 GtkWidget *msgwin_create_message_popup_menu(gint type);
 
 gboolean msgwin_goto_compiler_file_line();
 
+/* try to parse the file and line number where the error occured described in line
+ * and when something useful is found, it stores the line number in *line and the
+ * relevant file with the error in filename.
+ * *line will be -1 if no error was found in string.
+ * filename must be freed unless it is NULL. */
+void msgwin_parse_compiler_error_line(const gchar *string, gchar **filename, gint *line);
+
 gboolean msgwin_goto_messages_file_line();
 
 #endif

Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c	2006-08-14 10:35:57 UTC (rev 713)
+++ trunk/src/search.c	2006-08-14 15:02:52 UTC (rev 714)
@@ -100,7 +100,7 @@
 #define FREE_WIDGET(wid) \
 	if (wid && GTK_IS_WIDGET(wid)) gtk_widget_destroy(wid);
 
-void search_finalise()
+void search_finalize()
 {
 	FREE_WIDGET(widgets.find_dialog);
 	FREE_WIDGET(widgets.replace_dialog);
@@ -812,8 +812,8 @@
 	}
 	else
 	{
-		g_free(find_in_files_dir);
-		find_in_files_dir = g_strdup(dir);
+		g_free(msgwindow.find_in_files_dir);
+		msgwindow.find_in_files_dir = g_strdup(dir);
 		utils_set_up_io_channel(stdout_fd, G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL,
 			search_read_io, NULL);
 		g_child_watch_add(child_pid, search_close_pid, NULL);

Modified: trunk/src/search.h
===================================================================
--- trunk/src/search.h	2006-08-14 10:35:57 UTC (rev 713)
+++ trunk/src/search.h	2006-08-14 15:02:52 UTC (rev 714)
@@ -41,7 +41,7 @@
 
 void search_init();
 
-void search_finalise();
+void search_finalize();
 
 void search_show_find_dialog();
 

Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c	2006-08-14 10:35:57 UTC (rev 713)
+++ trunk/src/utils.c	2006-08-14 15:02:52 UTC (rev 714)
@@ -2128,136 +2128,6 @@
 }
 
 
-/* try to parse the file and line number where the error occured described in line
- * and when something useful is found, it stores the line number in *line and the
- * relevant file with the error in *filename.
- * *line will be -1 if no error was found in string.
- * *filename must be freed unless it is NULL. */
-void utils_parse_compiler_error_line(const gchar *string, gchar **filename, gint *line)
-{
-	gchar *end = NULL;
-	gchar *path;
-	gchar **fields;
-	gchar *pattern;				// pattern to split the error message into some fields
-	guint field_min_len;		// used to detect errors after parsing
-	guint field_idx_line;		// idx of the field where the line is
-	guint field_idx_file;		// idx of the field where the filename is
-	guint skip_dot_slash = 0;	// number of characters to skip at the beginning of the filename
-
-	*filename = NULL;
-	*line = -1;
-
-	if (string == NULL || ! doc_list[app->cur_idx].is_valid ||
-		doc_list[app->cur_idx].file_type == NULL)
-		return;
-
-	switch (doc_list[app->cur_idx].file_type->id)
-	{
-		// only gcc is supported, I don't know any other C(++) compilers and their error messages
-		case GEANY_FILETYPES_C:
-		case GEANY_FILETYPES_CPP:
-		case GEANY_FILETYPES_RUBY:
-		case GEANY_FILETYPES_JAVA:
-		{
-			// empty.h:4: Warnung: type defaults to `int' in declaration of `foo'
-			// empty.c:21: error: conflicting types for `foo'
-			pattern = ":";
-			field_min_len = 4;
-			field_idx_line = 1;
-			field_idx_file = 0;
-			break;
-		}
-		case GEANY_FILETYPES_LATEX:
-		{
-			// ./kommtechnik_2b.tex:18: Emergency stop.
-			pattern = ":";
-			field_min_len = 3;
-			field_idx_line = 1;
-			field_idx_file = 0;
-			break;
-		}
-		case GEANY_FILETYPES_PHP:
-		{
-			// Parse error: parse error, unexpected T_CASE in brace_bug.php on line 3
-			pattern = " ";
-			field_min_len = 11;
-			field_idx_line = 10;
-			field_idx_file = 7;
-			break;
-		}
-		case GEANY_FILETYPES_PERL:
-		{
-			// syntax error at test.pl line 7, near "{
-			pattern = " ";
-			field_min_len = 6;
-			field_idx_line = 5;
-			field_idx_file = 3;
-			break;
-		}
-		// the error output of python and tcl equals
-		case GEANY_FILETYPES_TCL:
-		case GEANY_FILETYPES_PYTHON:
-		{
-			// File "HyperArch.py", line 37, in ?
-			// (file "clrdial.tcl" line 12)
-			pattern = " \"";
-			field_min_len = 6;
-			field_idx_line = 5;
-			field_idx_file = 2;
-			break;
-		}
-		case GEANY_FILETYPES_PASCAL:
-		{
-			// bandit.pas(149,3) Fatal: Syntax error, ";" expected but "ELSE" found
-			pattern = "(";
-			field_min_len = 2;
-			field_idx_line = 1;
-			field_idx_file = 0;
-			break;
-		}
-		case GEANY_FILETYPES_D:
-		{
-			// warning - pi.d(118): implicit conversion of expression (digit) of type int ...
-			pattern = " (";
-			field_min_len = 4;
-			field_idx_line = 3;
-			field_idx_file = 2;
-			break;
-		}
-		default: return;
-	}
-
-	fields = g_strsplit_set(string, pattern, field_min_len);
-
-	// parse the line
-	if (g_strv_length(fields) < field_min_len)
-	{
-		g_strfreev(fields);
-		return;
-	}
-
-	*line = strtol(fields[field_idx_line], &end, 10);
-
-	// if the line could not be read, line is 0 and an error occurred, so we leave
-	if (fields[field_idx_line] == end)
-	{
-		g_strfreev(fields);
-		return;
-	}
-
-	// skip some characters at the beginning of the filename, at the moment only "./"
-	// can be extended if other "trash" is known
-	if (strncmp(fields[field_idx_file], "./", 2) == 0) skip_dot_slash = 2;
-
-	// get the basename of the built file to get the path to look for other files
-	path = g_path_get_dirname(doc_list[app->cur_idx].file_name);
-	*filename = g_strconcat(path, G_DIR_SEPARATOR_S, fields[field_idx_file] + skip_dot_slash, NULL);
-	g_free(path);
-
-	g_strfreev(fields);
-}
-
-
 // returned string must be freed.
 gchar *utils_get_current_time_string()
 {

Modified: trunk/src/utils.h
===================================================================
--- trunk/src/utils.h	2006-08-14 10:35:57 UTC (rev 713)
+++ trunk/src/utils.h	2006-08-14 15:02:52 UTC (rev 714)
@@ -201,13 +201,6 @@
  * before ANSI-C99. With with_route set, it takes strings of the format "#00ff00". */
 gint utils_strtod(const gchar *source, gchar **end, gboolean with_route);
 
-/* try to parse the file and line number where the error occured described in line
- * and when something useful is found, it stores the line number in *line and the
- * relevant file with the error in filename.
- * *line will be -1 if no error was found in string.
- * filename must be freed unless it is NULL. */
-void utils_parse_compiler_error_line(const gchar *string, gchar **filename, gint *line);
-
 // returned string must be freed.
 gchar *utils_get_current_time_string();
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list