31
31
{ TRUE, 'f', "function", "functions"}
39
static const char *DiffDelims[2] = {
35
45
* FUNCTION DEFINITIONS
48
static const unsigned char *stripAbsolute (const unsigned char *filename)
50
const unsigned char *tmp;
52
/* strip any absolute path */
53
if (*filename == '/' || *filename == '\\')
55
boolean skipSlash = TRUE;
57
tmp = (const unsigned char*) strrchr ((const char*) filename, '/');
59
{ /* if no / is contained try \ in case of a Windows filename */
60
tmp = (const unsigned char*) strrchr ((const char*) filename, '\\');
62
{ /* last fallback, probably the filename doesn't contain a path, so take it */
68
/* skip the leading slash or backslash */
38
78
static void findDiffTags (void)
40
80
vString *filename = vStringNew ();
41
81
const unsigned char *line, *tmp;
82
int delim = DIFF_DELIM_MINUS;
43
84
while ((line = fileReadLine ()) != NULL)
45
86
const unsigned char* cp = line;
46
boolean skipSlash = FALSE;
48
if (strncmp((const char*) cp, "--- ", (size_t) 4) == 0)
88
if (strncmp ((const char*) cp, DiffDelims[delim], 4u) == 0)
51
91
if (isspace ((int) *cp)) continue;
53
/* strip any absolute path */
54
if (*cp == '/' || *cp == '\\')
92
/* when original filename is /dev/null use the new one instead */
93
if (delim == DIFF_DELIM_MINUS &&
94
strncmp ((const char*) cp, "/dev/null", 9u) == 0 &&
95
(cp[9] == 0 || isspace (cp[9])))
57
tmp = (const unsigned char*) strrchr((const char*) cp, '/');
59
{ /* if no / is contained try \ in case of a Windows filename */
60
tmp = (const unsigned char*) strrchr((const char*) cp, '\\');
62
{ /* last fallback, probably the filename doesn't contain a path, so take it */
63
if (strlen((const char*) cp) > 0)
97
delim = DIFF_DELIM_PLUS;
101
tmp = stripAbsolute (cp);
76
if (skipSlash) tmp++; /* skip the leading slash or backslash */
77
105
while (! isspace(*tmp) && *tmp != '\0')
79
107
vStringPut(filename, *tmp);
82
111
vStringTerminate(filename);
83
112
makeSimpleTag (filename, DiffKinds, K_FUNCTION);
84
113
vStringClear (filename);
116
/* restore default delim */
117
delim = DIFF_DELIM_MINUS;
88
120
vStringDelete (filename);