diff --git a/src/filetypes.c b/src/filetypes.c index e55b496b..844894b6 100644 --- a/src/filetypes.c +++ b/src/filetypes.c @@ -962,7 +962,8 @@ static GeanyFiletype *find_shebang(const gchar *utf8_filename, const gchar *line } -/* Detect the filetype checking for a shebang, then filename extension. */ +/* Detect the filetype checking for a shebang, then filename extension. + * @lines: an strv of the lines to scan (must containing at least one line) */ static GeanyFiletype *filetypes_detect_from_file_internal(const gchar *utf8_filename, gchar **lines) { @@ -970,7 +971,6 @@ static GeanyFiletype *filetypes_detect_from_file_internal(const gchar *utf8_file gint i; GRegex *ft_regex; GMatchInfo *match; - GError *regerr = NULL; /* try to find a shebang and if found use it prior to the filename extension * also checks for editor->sci, i); } + lines[i] = NULL; ft = filetypes_detect_from_file_internal(doc->file_name, lines); for (i = 0; i < GEANY_FILETYPE_SEARCH_LINES; ++i) { @@ -1052,10 +1045,9 @@ GeanyFiletype *filetypes_detect_from_document(GeanyDocument *doc) GeanyFiletype *filetypes_detect_from_file(const gchar *utf8_filename) { gchar line[1024]; - gchar *lines[GEANY_FILETYPE_SEARCH_LINES]; + gchar *lines[2]; FILE *f; gchar *locale_name = utils_get_locale_from_utf8(utf8_filename); - gint i; f = g_fopen(locale_name, "r"); g_free(locale_name); @@ -1064,11 +1056,8 @@ GeanyFiletype *filetypes_detect_from_file(const gchar *utf8_filename) if (fgets(line, sizeof(line), f) != NULL) { fclose(f); - for (i = 0; i < GEANY_FILETYPE_SEARCH_LINES; ++i) - { - lines[i] = NULL; - } lines[0] = line; + lines[1] = NULL; return filetypes_detect_from_file_internal(utf8_filename, lines); } fclose(f);