Skip to content

Commit

Permalink
Provide error message for extract regex
Browse files Browse the repository at this point in the history
Print the GError message if the users filetype extract regex does
not compile.
  • Loading branch information
elextr committed Nov 14, 2011
1 parent cb72e1d commit a625955
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/filetypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,7 @@ static GeanyFiletype *filetypes_detect_from_file_internal(const gchar *utf8_file
gint i;
GRegex *ft_regex;
GMatchInfo *match;
GError *regex_error = NULL;

/* try to find a shebang and if found use it prior to the filename extension
* also checks for <?xml */
Expand All @@ -980,7 +981,7 @@ static GeanyFiletype *filetypes_detect_from_file_internal(const gchar *utf8_file

/* try to extract the filetype using a regex capture */
ft_regex = g_regex_new(file_prefs.extract_filetype_regex,
G_REGEX_RAW | G_REGEX_MULTILINE, 0, NULL);
G_REGEX_RAW | G_REGEX_MULTILINE, 0, &regex_error);
if (ft_regex != NULL)
{
for (i = 0; ft == NULL && lines[i] != NULL; i++)
Expand All @@ -998,6 +999,11 @@ static GeanyFiletype *filetypes_detect_from_file_internal(const gchar *utf8_file
}
g_regex_unref(ft_regex);
}
else if (regex_error != NULL)
{
geany_debug("Filetype extract regex ignored: %s", regex_error->message);
g_error_free(regex_error);
}
if (ft != NULL)
return ft;

Expand Down

0 comments on commit a625955

Please sign in to comment.