From b7b4834e1f93b8d31dacaa6139741dc7261265aa Mon Sep 17 00:00:00 2001 From: Lex Trotman Date: Tue, 11 Nov 2008 09:27:49 +0000 Subject: [PATCH] Symbol fixes to .h and .hpp filetype prototypes git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/branches/build-system@3204 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 14 ++++++++++++++ src/filetypes.c | 11 +++++++---- src/symbols.c | 17 ++++++++++++----- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index b72f9e2b..22e3854d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2008-11-11 Lex Trotman + + fix tagmanager interaction with H and HPP filetypes + + * src/filetypes.c + fix h and hpp filetype names to pretend to be c and c++ for tags + purposes + filetypes_detect_from_file_internal() modified to detect C++ anywhere + between -*- and another -*- + * src/symbols.c + add GEANY_FILETYPES_H and GEANY_FILETYPES_HPP as alternates where ever + GEANY_FILETYPES_C and GEANY_FILETYPES_CPP occur + + 2008-11-10 Lex Trotman Prototype C and CPP header filetypes, also detects .h or no extension diff --git a/src/filetypes.c b/src/filetypes.c index f6a88576..9e4917a5 100644 --- a/src/filetypes.c +++ b/src/filetypes.c @@ -92,7 +92,7 @@ static void init_builtin_filetypes(void) #define CH ft = filetypes[GEANY_FILETYPES_H]; ft->lang = 0; - ft->name = g_strdup("H"); + ft->name = g_strdup("C"); ft->title = g_strdup_printf(_("%s header file"), "C"); ft->extension = g_strdup("h"); ft->pattern = utils_strv_new("*.h", NULL); @@ -115,7 +115,7 @@ static void init_builtin_filetypes(void) #define HPP ft = filetypes[GEANY_FILETYPES_HPP]; ft->lang = 1; - ft->name = g_strdup("H++"); + ft->name = g_strdup("C++"); ft->title = g_strdup_printf(_("%s header file"), "C++"); ft->extension = g_strdup("hpp"); ft->pattern = utils_strv_new("*.h", "*.hpp", "*.hxx", "*.h++", "*.hh", NULL); @@ -804,8 +804,11 @@ static GeanyFiletype *filetypes_detect_from_file_internal(const gchar *utf8_file id = FILETYPE_ID(ft); if (id == GEANY_FILETYPES_H || id == GEANY_FILETYPES_NONE) { - if (strstr(line, "-*-C++-*-")) - ft = filetypes[GEANY_FILETYPES_HPP]; + char *c; + if (c=strstr(line, "-*-")) /* look for C++ between -*- es */ + if (c=strstr(c,"C++")) + if (strstr(c,"-*-")) + ft = filetypes[GEANY_FILETYPES_HPP]; } return ft; } diff --git a/src/symbols.c b/src/symbols.c index d4e48b54..4ca4caab 100644 --- a/src/symbols.c +++ b/src/symbols.c @@ -118,7 +118,8 @@ void symbols_global_tags_loaded(gint file_type_idx) gint tag_type; /* load ignore list for C/C++ parser */ - if ((file_type_idx == GEANY_FILETYPES_C || file_type_idx == GEANY_FILETYPES_CPP) && + if ((file_type_idx == GEANY_FILETYPES_C || file_type_idx == GEANY_FILETYPES_CPP + || file_type_idx == GEANY_FILETYPES_H || file_type_idx == GEANY_FILETYPES_HPP ) && c_tags_ignore == NULL) { load_c_ignore_tags(); @@ -138,9 +139,11 @@ void symbols_global_tags_loaded(gint file_type_idx) switch (file_type_idx) { case GEANY_FILETYPES_CPP: + case GEANY_FILETYPES_HPP: symbols_global_tags_loaded(GEANY_FILETYPES_C); /* load C global tags */ /* no C++ tagfile yet */ return; + case GEANY_FILETYPES_H: case GEANY_FILETYPES_C: tag_type = GTF_C; break; case GEANY_FILETYPES_PASCAL:tag_type = GTF_PASCAL; break; case GEANY_FILETYPES_PHP: tag_type = GTF_PHP; break; @@ -232,6 +235,8 @@ const gchar *symbols_get_context_separator(gint ft_id) switch (ft_id) { case GEANY_FILETYPES_C: /* for C++ .h headers or C structs */ + case GEANY_FILETYPES_H: + case GEANY_FILETYPES_HPP: case GEANY_FILETYPES_CPP: case GEANY_FILETYPES_GLSL: /* for structs */ /*case GEANY_FILETYPES_RUBY:*/ /* not sure what to use atm*/ @@ -1025,11 +1030,13 @@ int symbols_generate_global_tags(int argc, char **argv, gboolean want_preprocess return 1; } /* load ignore list for C/C++ parser */ - if (ft->id == GEANY_FILETYPES_C || ft->id == GEANY_FILETYPES_CPP) - load_c_ignore_tags(); + if (ft->id == GEANY_FILETYPES_C || ft->id == GEANY_FILETYPES_CPP + || ft->id == GEANY_FILETYPES_H || ft->id == GEANY_FILETYPES_HPP ) + load_c_ignore_tags(); - if (want_preprocess && (ft->id == GEANY_FILETYPES_C || ft->id == GEANY_FILETYPES_CPP)) - command = g_strdup_printf("%s %s", pre_process, NVL(getenv("CFLAGS"), "")); + if (want_preprocess && (ft->id == GEANY_FILETYPES_C || ft->id == GEANY_FILETYPES_CPP + || ft->id == GEANY_FILETYPES_H || ft->id == GEANY_FILETYPES_HPP )) + command = g_strdup_printf("%s %s", pre_process, NVL(getenv("CFLAGS"), "")); else command = NULL; /* don't preprocess */