Show relative paths in diff filename tags.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3951 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2009-07-10 15:57:12 +00:00
parent a6a847f4e7
commit 746a8d5834
2 changed files with 36 additions and 26 deletions

View File

@ -5,6 +5,8 @@
scrolling with the arrow keys. scrolling with the arrow keys.
* src/keybindings.c, src/keybindings.h, src/search.c, src/search.h: * src/keybindings.c, src/keybindings.h, src/search.c, src/search.h:
Add 'Mark All' keybinding. Add 'Mark All' keybinding.
* tagmanager/diff.c:
Show relative paths in diff filename tags.
2009-07-09 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> 2009-07-09 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>

View File

@ -24,11 +24,11 @@
* DATA DEFINITIONS * DATA DEFINITIONS
*/ */
typedef enum { typedef enum {
K_FUNCTION K_FUNCTION
} diffKind; } diffKind;
static kindOption DiffKinds [] = { static kindOption DiffKinds [] = {
{ TRUE, 'f', "function", "functions"} { TRUE, 'f', "function", "functions"}
}; };
/* /*
@ -37,32 +37,40 @@ static kindOption DiffKinds [] = {
static void findDiffTags (void) static void findDiffTags (void)
{ {
vString *filename = vStringNew (); vString *filename = vStringNew ();
const unsigned char *line, *tmp; const unsigned char *line, *tmp;
while ((line = fileReadLine ()) != NULL) while ((line = fileReadLine ()) != NULL)
{ {
const unsigned char* cp = line; const unsigned char* cp = line;
boolean skipSlash = TRUE; boolean skipSlash = FALSE;
if (strncmp((const char*) cp, "--- ", (size_t) 4) == 0) if (strncmp((const char*) cp, "--- ", (size_t) 4) == 0)
{ {
cp += 4; cp += 4;
if (isspace ((int) *cp)) continue; if (isspace ((int) *cp)) continue;
tmp = (const unsigned char*) strrchr((const char*) cp, '/'); /* strip any absolute path */
if (tmp == NULL) if (*cp == '/' || *cp == '\\')
{ /* if no / is contained try \ in case of a Windows filename */ {
tmp = (const unsigned char*) strrchr((const char*) cp, '\\'); skipSlash = TRUE;
tmp = (const unsigned char*) strrchr((const char*) cp, '/');
if (tmp == NULL) if (tmp == NULL)
{ /* last fallback, probably the filename doesn't contain a path, so take it */ { /* if no / is contained try \ in case of a Windows filename */
if (strlen((const char*) cp) > 0) tmp = (const unsigned char*) strrchr((const char*) cp, '\\');
{ if (tmp == NULL)
tmp = cp; { /* last fallback, probably the filename doesn't contain a path, so take it */
skipSlash = FALSE; if (strlen((const char*) cp) > 0)
{
tmp = cp;
skipSlash = FALSE;
}
} }
} }
} }
else
tmp = cp;
if (tmp != NULL) if (tmp != NULL)
{ {
if (skipSlash) tmp++; /* skip the leading slash or backslash */ if (skipSlash) tmp++; /* skip the leading slash or backslash */
@ -77,20 +85,20 @@ static void findDiffTags (void)
} }
} }
} }
vStringDelete (filename); vStringDelete (filename);
} }
extern parserDefinition* DiffParser (void) extern parserDefinition* DiffParser (void)
{ {
static const char *const patterns [] = { "*.diff", "*.patch", NULL }; static const char *const patterns [] = { "*.diff", "*.patch", NULL };
static const char *const extensions [] = { "diff", NULL }; static const char *const extensions [] = { "diff", NULL };
parserDefinition* const def = parserNew ("Diff"); parserDefinition* const def = parserNew ("Diff");
def->kinds = DiffKinds; def->kinds = DiffKinds;
def->kindCount = KIND_COUNT (DiffKinds); def->kindCount = KIND_COUNT (DiffKinds);
def->patterns = patterns; def->patterns = patterns;
def->extensions = extensions; def->extensions = extensions;
def->parser = findDiffTags; def->parser = findDiffTags;
return def; return def;
} }
/* vi:set tabstop=8 shiftwidth=4: */ /* vi:set tabstop=8 shiftwidth=4: */