Revision: 883 http://svn.sourceforge.net/geany/?rev=883&view=rev Author: eht16 Date: 2006-10-11 12:45:40 -0700 (Wed, 11 Oct 2006)
Log Message: ----------- Added simple parser for filetype Diff to create tags for each patched file in a diff file.
Modified Paths: -------------- trunk/ChangeLog trunk/src/filetypes.c trunk/src/treeviews.c trunk/tagmanager/Makefile.am trunk/tagmanager/makefile.win32 trunk/tagmanager/parsers.h
Added Paths: ----------- trunk/tagmanager/diff.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-10-11 16:42:46 UTC (rev 882) +++ trunk/ChangeLog 2006-10-11 19:45:40 UTC (rev 883) @@ -2,8 +2,13 @@
* src/keyfile.c, src/geany.h: Removed hard limit of session files. * doc/geany.docbook: Updated section about session files limit. + * tagmanager/makefile.win32, tagmanager/Makefile.am, + tagmanager/parsers.h, tagmanager/diff.c, src/filetypes.c, + src/treeviews.c: Added simple parser for filetype Diff to create + tags for each patched file in a diff file.
+ 2006-10-10 Enrico Tröger enrico.troeger@uvena.de
* src/document.c: Connect only once to the "sci-notify" signal.
Modified: trunk/src/filetypes.c =================================================================== --- trunk/src/filetypes.c 2006-10-11 16:42:46 UTC (rev 882) +++ trunk/src/filetypes.c 2006-10-11 19:45:40 UTC (rev 883) @@ -610,7 +610,7 @@ filetypes[GEANY_FILETYPES_DIFF]->item = NULL; filetypes[GEANY_FILETYPES_DIFF]->lang = -2; filetypes[GEANY_FILETYPES_DIFF]->name = g_strdup("Diff"); - filetypes[GEANY_FILETYPES_DIFF]->has_tags = FALSE; + filetypes[GEANY_FILETYPES_DIFF]->has_tags = TRUE; filetypes[GEANY_FILETYPES_DIFF]->title = g_strdup(_("Diff file")); filetypes[GEANY_FILETYPES_DIFF]->extension = g_strdup("diff"); filetypes[GEANY_FILETYPES_DIFF]->pattern = g_new0(gchar*, 3);
Modified: trunk/src/treeviews.c =================================================================== --- trunk/src/treeviews.c 2006-10-11 16:42:46 UTC (rev 882) +++ trunk/src/treeviews.c 2006-10-11 19:45:40 UTC (rev 883) @@ -70,6 +70,12 @@
switch (doc_list[idx].file_type->id) { + case GEANY_FILETYPES_DIFF: + { + gtk_tree_store_append(doc_list[idx].tag_store, &(tv.tag_function), NULL); + gtk_tree_store_set(doc_list[idx].tag_store, &(tv.tag_function), 0, _("Files"), -1); + break; + } case GEANY_FILETYPES_DOCBOOK: { gtk_tree_store_append(doc_list[idx].tag_store, &(tv.tag_function), NULL);
Modified: trunk/tagmanager/Makefile.am =================================================================== --- trunk/tagmanager/Makefile.am 2006-10-11 16:42:46 UTC (rev 882) +++ trunk/tagmanager/Makefile.am 2006-10-11 19:45:40 UTC (rev 883) @@ -29,6 +29,7 @@ c.c\ conf.c\ css.c\ + diff.c\ docbook.c\ fortran.c\ make.c\
Added: trunk/tagmanager/diff.c =================================================================== --- trunk/tagmanager/diff.c (rev 0) +++ trunk/tagmanager/diff.c 2006-10-11 19:45:40 UTC (rev 883) @@ -0,0 +1,96 @@ +/* +* +* Copyright (c) 2000-2001, Darren Hiebert +* +* This source code is released for free distribution under the terms of the +* GNU General Public License. +* +* This module contains functions for generating tags for diff files (based on Sh parser). +*/ + +/* +* INCLUDE FILES +*/ +#include "general.h" /* must always come first */ + +#include <ctype.h> +#include <string.h> + +#include "parse.h" +#include "read.h" +#include "vstring.h" + +/* +* DATA DEFINITIONS +*/ +typedef enum { + K_FUNCTION +} diffKind; + +static kindOption DiffKinds [] = { + { TRUE, 'f', "function", "functions"} +}; + +/* +* FUNCTION DEFINITIONS +*/ + +static void findDiffTags (void) +{ + vString *filename = vStringNew (); + const unsigned char *line, *tmp; + + while ((line = fileReadLine ()) != NULL) + { + const unsigned char* cp = line; + boolean skipSlash = TRUE; + + if (strncmp((const char*) cp, "--- ", (size_t) 4) == 0) + { + cp += 4; + if (isspace ((int) *cp)) continue; + + tmp = strrchr(cp, '/'); + if (tmp == NULL) + { // if no / is contained try \ in case of a Windows filename + tmp = strrchr(cp, '\'); + if (tmp == NULL) + { // last fallback, probably the filename doesn't contain a path, so take it + if (strlen(cp) > 0) + { + tmp = cp; + skipSlash = FALSE; + } + } + } + if (tmp != NULL) + { + if (skipSlash) tmp++; // skip the leading slash or backslash + while (! isspace(*tmp) && *tmp != '\0') + { + vStringPut(filename, *tmp); + tmp++; + } + vStringTerminate(filename); + makeSimpleTag (filename, DiffKinds, K_FUNCTION); + vStringClear (filename); + } + } + } + vStringDelete (filename); +} + +extern parserDefinition* DiffParser (void) +{ + static const char *const patterns [] = { "*.diff", "*.patch", NULL }; + static const char *const extensions [] = { "diff", NULL }; + parserDefinition* const def = parserNew ("Diff"); + def->kinds = DiffKinds; + def->kindCount = KIND_COUNT (DiffKinds); + def->patterns = patterns; + def->extensions = extensions; + def->parser = findDiffTags; + return def; +} + +/* vi:set tabstop=8 shiftwidth=4: */
Modified: trunk/tagmanager/makefile.win32 =================================================================== --- trunk/tagmanager/makefile.win32 2006-10-11 16:42:46 UTC (rev 882) +++ trunk/tagmanager/makefile.win32 2006-10-11 19:45:40 UTC (rev 883) @@ -32,7 +32,7 @@ clean: -$(RM) deps.mak *.o $(COMPLIB)
-$(COMPLIB): args.o c.o fortran.o make.o conf.o pascal.o perl.o php.o \ +$(COMPLIB): args.o c.o fortran.o make.o conf.o pascal.o perl.o php.o diff.o \ python.o regex.o sh.o ctags.o entry.o get.o keyword.o options.o parse.o \ read.o sort.o strlist.o latex.o docbook.o tcl.o ruby.o asm.o sql.o css.o vstring.o tm_workspace.o tm_work_object.o \ tm_source_file.o tm_project.o tm_tag.o tm_symbol.o tm_file_entry.o \
Modified: trunk/tagmanager/parsers.h =================================================================== --- trunk/tagmanager/parsers.h 2006-10-11 16:42:46 UTC (rev 882) +++ trunk/tagmanager/parsers.h 2006-10-11 19:45:40 UTC (rev 883) @@ -34,7 +34,8 @@ ShParser, \ DParser, \ FortranParser, \ - FeriteParser + FeriteParser, \ + DiffParser
/* langType of each parser @@ -58,6 +59,7 @@ 17 DParser 18 FortranParser 19 FeriteParser +20 DiffParser */ #endif /* _PARSERS_H */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.