Don't make tags for /dev/null in diff files but for the new file instead
Based on a patch by Yang Hong, thanks. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5893 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
d501e1ccda
commit
5ee037bfc0
@ -16,6 +16,9 @@
|
|||||||
tagmanager/tm_workspace.c:
|
tagmanager/tm_workspace.c:
|
||||||
Create temporary files used for generating global tags files in the
|
Create temporary files used for generating global tags files in the
|
||||||
system directory for temp files.
|
system directory for temp files.
|
||||||
|
* tagmanager/diff.c:
|
||||||
|
Don't make tags for /dev/null in diff files but for the new file
|
||||||
|
instead (Based on a patch by Yang Hong, thanks).
|
||||||
|
|
||||||
|
|
||||||
2011-08-15 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
|
2011-08-15 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
|
||||||
|
@ -31,58 +31,90 @@ static kindOption DiffKinds [] = {
|
|||||||
{ TRUE, 'f', "function", "functions"}
|
{ TRUE, 'f', "function", "functions"}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
DIFF_DELIM_MINUS = 0,
|
||||||
|
DIFF_DELIM_PLUS
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char *DiffDelims[2] = {
|
||||||
|
"--- ",
|
||||||
|
"+++ "
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FUNCTION DEFINITIONS
|
* FUNCTION DEFINITIONS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static const unsigned char *stripAbsolute (const unsigned char *filename)
|
||||||
|
{
|
||||||
|
const unsigned char *tmp;
|
||||||
|
|
||||||
|
/* strip any absolute path */
|
||||||
|
if (*filename == '/' || *filename == '\\')
|
||||||
|
{
|
||||||
|
boolean skipSlash = TRUE;
|
||||||
|
|
||||||
|
tmp = (const unsigned char*) strrchr ((const char*) filename, '/');
|
||||||
|
if (tmp == NULL)
|
||||||
|
{ /* if no / is contained try \ in case of a Windows filename */
|
||||||
|
tmp = (const unsigned char*) strrchr ((const char*) filename, '\\');
|
||||||
|
if (tmp == NULL)
|
||||||
|
{ /* last fallback, probably the filename doesn't contain a path, so take it */
|
||||||
|
tmp = filename;
|
||||||
|
skipSlash = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* skip the leading slash or backslash */
|
||||||
|
if (skipSlash)
|
||||||
|
tmp++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tmp = filename;
|
||||||
|
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
static void findDiffTags (void)
|
static void findDiffTags (void)
|
||||||
{
|
{
|
||||||
vString *filename = vStringNew ();
|
vString *filename = vStringNew ();
|
||||||
const unsigned char *line, *tmp;
|
const unsigned char *line, *tmp;
|
||||||
|
int delim = DIFF_DELIM_MINUS;
|
||||||
|
|
||||||
while ((line = fileReadLine ()) != NULL)
|
while ((line = fileReadLine ()) != NULL)
|
||||||
{
|
{
|
||||||
const unsigned char* cp = line;
|
const unsigned char* cp = line;
|
||||||
boolean skipSlash = FALSE;
|
|
||||||
|
|
||||||
if (strncmp((const char*) cp, "--- ", (size_t) 4) == 0)
|
if (strncmp ((const char*) cp, DiffDelims[delim], 4u) == 0)
|
||||||
{
|
{
|
||||||
cp += 4;
|
cp += 4;
|
||||||
if (isspace ((int) *cp)) continue;
|
if (isspace ((int) *cp)) continue;
|
||||||
|
/* when original filename is /dev/null use the new one instead */
|
||||||
/* strip any absolute path */
|
if (delim == DIFF_DELIM_MINUS &&
|
||||||
if (*cp == '/' || *cp == '\\')
|
strncmp ((const char*) cp, "/dev/null", 9u) == 0 &&
|
||||||
|
(cp[9] == 0 || isspace (cp[9])))
|
||||||
{
|
{
|
||||||
skipSlash = TRUE;
|
delim = DIFF_DELIM_PLUS;
|
||||||
tmp = (const unsigned char*) strrchr((const char*) cp, '/');
|
continue;
|
||||||
if (tmp == NULL)
|
|
||||||
{ /* if no / is contained try \ in case of a Windows filename */
|
|
||||||
tmp = (const unsigned char*) strrchr((const char*) cp, '\\');
|
|
||||||
if (tmp == NULL)
|
|
||||||
{ /* last fallback, probably the filename doesn't contain a path, so take it */
|
|
||||||
if (cp[0] != 0)
|
|
||||||
{
|
|
||||||
tmp = cp;
|
|
||||||
skipSlash = FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
tmp = cp;
|
tmp = stripAbsolute (cp);
|
||||||
|
|
||||||
if (tmp != NULL)
|
if (tmp != NULL)
|
||||||
{
|
{
|
||||||
if (skipSlash) tmp++; /* skip the leading slash or backslash */
|
|
||||||
while (! isspace(*tmp) && *tmp != '\0')
|
while (! isspace(*tmp) && *tmp != '\0')
|
||||||
{
|
{
|
||||||
vStringPut(filename, *tmp);
|
vStringPut(filename, *tmp);
|
||||||
tmp++;
|
tmp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
vStringTerminate(filename);
|
vStringTerminate(filename);
|
||||||
makeSimpleTag (filename, DiffKinds, K_FUNCTION);
|
makeSimpleTag (filename, DiffKinds, K_FUNCTION);
|
||||||
vStringClear (filename);
|
vStringClear (filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* restore default delim */
|
||||||
|
delim = DIFF_DELIM_MINUS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vStringDelete (filename);
|
vStringDelete (filename);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user