Kaydet (Commit) 8d6ae11c authored tarafından Nick Treleaven's avatar Nick Treleaven

Applied patch from Josef Whiter to parse 'Entering directory' build

messages so that subsequent error messages are handled correctly
(thanks).
Assume gcc-style error messages when filetype is not set.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1149 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst a6f6c721
......@@ -3,6 +3,11 @@
* src/ui_utils.c:
Don't use gtk_rc_get_style() in ui_update_tab_status() because it
can cause an invalid memory read on some systems.
* src/build.c, src/build.h, src/msgwindow.c, src/msgwindow.h:
Applied patch from Josef Whiter to parse 'Entering directory' build
messages so that subsequent error messages are handled correctly
(thanks).
Assume gcc-style error messages when filetype is not set.
2006-12-26 Nick Treleaven <nick.treleaven@btinternet.com>
......
......@@ -685,7 +685,7 @@ static gboolean build_iofunc(GIOChannel *ioc, GIOCondition cond, gpointer data)
if (cond & (G_IO_IN | G_IO_PRI))
{
//GIOStatus s;
gchar *msg;
gchar *msg, *dir = NULL;
while (g_io_channel_read_line(ioc, &msg, NULL, NULL, NULL) && msg)
{
......@@ -694,11 +694,18 @@ static gboolean build_iofunc(GIOChannel *ioc, GIOCondition cond, gpointer data)
color = (GPOINTER_TO_INT(data)) ? COLOR_DARK_RED : COLOR_BLACK;
g_strstrip(msg);
if (strstr(msg, "Entering directory") != NULL) {
if (dir != NULL)
g_free(dir);
build_parse_make_dir(msg, &dir);
}
if (app->pref_editor_use_indicators)
{
gchar *filename;
gint line;
msgwin_parse_compiler_error_line(msg, &filename, &line);
msgwin_parse_compiler_error_line(msg, dir, &filename, &line);
if (line != -1 && filename != NULL)
{
gint idx = document_find_by_filename(filename, FALSE);
......@@ -711,6 +718,9 @@ static gboolean build_iofunc(GIOChannel *ioc, GIOCondition cond, gpointer data)
g_free(msg);
}
if (dir != NULL)
g_free(dir);
}
if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL))
return FALSE;
......@@ -719,6 +729,43 @@ static gboolean build_iofunc(GIOChannel *ioc, GIOCondition cond, gpointer data)
}
gboolean build_parse_make_dir(gchar *string, gchar **prefix)
{
gchar *pos, *input;
*prefix = NULL;
input = g_strdup(string);
if (input == NULL)
return FALSE;
if ((pos = strstr(input, "Entering directory")) != NULL)
{
gsize len = strlen(input);
//get the start of the path
pos = strstr(input, "/");
if (pos == NULL) {
g_free(input);
return FALSE;
}
//kill the ' at the end of the path
input[len-1] = '\0';
//duplicate
*prefix = g_strdup(pos);
g_free(input);
return TRUE;
}
g_free(input);
return FALSE;
}
#ifndef G_OS_WIN32
static void show_build_result_message(gboolean failure)
{
......
......@@ -74,6 +74,8 @@ GPid build_view_tex_file(gint idx, gint mode);
GPid build_run_cmd(gint idx);
gboolean build_parse_make_dir(gchar *string, gchar **prefix);
void build_menu_update(gint idx);
BuildMenuItems *build_get_menu_items(gint filetype_id);
......@@ -106,4 +108,5 @@ on_build_arguments_activate (GtkMenuItem *menuitem,
void
on_build_next_error (GtkMenuItem *menuitem,
gpointer user_data);
#endif
......@@ -416,6 +416,32 @@ void msgwin_menu_add_common_items(GtkMenu *menu)
}
/* look back up from the current path and find the directory we came from */
static gboolean
find_prev_build_dir(GtkTreePath *cur, GtkTreeModel *model, gchar **prefix)
{
GtkTreeIter iter;
*prefix = NULL;
while (gtk_tree_path_prev(cur))
{
if (gtk_tree_model_get_iter(model, &iter, cur))
{
gchar *string;
gtk_tree_model_get(model, &iter, 1, &string, -1);
if (string != NULL && build_parse_make_dir(string, prefix))
{
g_free(string);
return TRUE;
}
g_free(string);
}
}
return FALSE;
}
gboolean msgwin_goto_compiler_file_line()
{
GtkTreeIter iter;
......@@ -442,8 +468,17 @@ gboolean msgwin_goto_compiler_file_line()
{
gint line;
gint idx;
gchar *filename;
msgwin_parse_compiler_error_line(string, &filename, &line);
gchar *filename, *dir;
GtkTreePath *path;
path = gtk_tree_model_get_path(model, &iter);
find_prev_build_dir(path, model, &dir);
gtk_tree_path_free(path);
msgwin_parse_compiler_error_line(string, dir, &filename, &line);
if (dir != NULL)
g_free(dir);
if (filename != NULL && line > -1)
{
gchar *utf8_filename = utils_get_utf8_from_locale(filename);
......@@ -533,22 +568,21 @@ static void parse_file_line(ParseData *data, gchar **filename, gint *line)
* 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)
void msgwin_parse_compiler_error_line(const gchar *string, const gchar *dir, gchar **filename, gint *line)
{
ParseData data = {string, build_info.dir, NULL, 0, 0, 0};
*filename = NULL;
*line = -1;
g_return_if_fail(build_info.dir != NULL);
if (dir != NULL)
data.dir = dir;
g_return_if_fail(build_info.dir != NULL || dir != NULL);
if (string == NULL) return;
switch (build_info.file_type_id)
{
case GEANY_FILETYPES_ALL:
{
return;
}
case GEANY_FILETYPES_PHP:
{
// Parse error: parse error, unexpected T_CASE in brace_bug.php on line 3
......@@ -668,6 +702,7 @@ void msgwin_parse_compiler_error_line(const gchar *string, gchar **filename, gin
case GEANY_FILETYPES_LATEX:
// ./kommtechnik_2b.tex:18: Emergency stop.
case GEANY_FILETYPES_MAKE: // Assume makefile is building with gcc
case GEANY_FILETYPES_ALL:
default: // The default is a GNU gcc type error
{
// don't accidently find libtool versions x:y:x and think it is a file name
......
......@@ -79,7 +79,7 @@ void msgwin_menu_add_common_items(GtkMenu *menu);
gboolean msgwin_goto_compiler_file_line();
void msgwin_parse_compiler_error_line(const gchar *string, gchar **filename, gint *line);
void msgwin_parse_compiler_error_line(const gchar *string, const gchar *dir, gchar **filename, gint *line);
gboolean msgwin_goto_messages_file_line();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment