Provide error message for extract regex
Print the GError message if the users filetype extract regex does not compile.
This commit is contained in:
parent
cb72e1d85f
commit
a625955a43
@ -971,6 +971,7 @@ static GeanyFiletype *filetypes_detect_from_file_internal(const gchar *utf8_file
|
|||||||
gint i;
|
gint i;
|
||||||
GRegex *ft_regex;
|
GRegex *ft_regex;
|
||||||
GMatchInfo *match;
|
GMatchInfo *match;
|
||||||
|
GError *regex_error = NULL;
|
||||||
|
|
||||||
/* try to find a shebang and if found use it prior to the filename extension
|
/* try to find a shebang and if found use it prior to the filename extension
|
||||||
* also checks for <?xml */
|
* also checks for <?xml */
|
||||||
@ -980,7 +981,7 @@ static GeanyFiletype *filetypes_detect_from_file_internal(const gchar *utf8_file
|
|||||||
|
|
||||||
/* try to extract the filetype using a regex capture */
|
/* try to extract the filetype using a regex capture */
|
||||||
ft_regex = g_regex_new(file_prefs.extract_filetype_regex,
|
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, ®ex_error);
|
||||||
if (ft_regex != NULL)
|
if (ft_regex != NULL)
|
||||||
{
|
{
|
||||||
for (i = 0; ft == NULL && lines[i] != NULL; i++)
|
for (i = 0; ft == NULL && lines[i] != NULL; i++)
|
||||||
@ -998,6 +999,11 @@ static GeanyFiletype *filetypes_detect_from_file_internal(const gchar *utf8_file
|
|||||||
}
|
}
|
||||||
g_regex_unref(ft_regex);
|
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)
|
if (ft != NULL)
|
||||||
return ft;
|
return ft;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user