3 * Copyright (c) 2000-2001, Darren Hiebert
5 * This source code is released for free distribution under the terms of the
6 * GNU General Public License.
8 * This module contains functions for generating tags for diff files (based on Sh parser).
14 #include "general.h" /* must always come first */
30 static kindOption DiffKinds
[] = {
31 { TRUE
, 'f', "function", "functions"}
35 * FUNCTION DEFINITIONS
38 static void findDiffTags (void)
40 vString
*filename
= vStringNew ();
41 const unsigned char *line
, *tmp
;
43 while ((line
= fileReadLine ()) != NULL
)
45 const unsigned char* cp
= line
;
46 boolean skipSlash
= FALSE
;
48 if (strncmp((const char*) cp
, "--- ", (size_t) 4) == 0)
51 if (isspace ((int) *cp
)) continue;
53 /* strip any absolute path */
54 if (*cp
== '/' || *cp
== '\\')
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 */
76 if (skipSlash
) tmp
++; /* skip the leading slash or backslash */
77 while (! isspace(*tmp
) && *tmp
!= '\0')
79 vStringPut(filename
, *tmp
);
82 vStringTerminate(filename
);
83 makeSimpleTag (filename
, DiffKinds
, K_FUNCTION
);
84 vStringClear (filename
);
88 vStringDelete (filename
);
91 extern parserDefinition
* DiffParser (void)
93 static const char *const patterns
[] = { "*.diff", "*.patch", NULL
};
94 static const char *const extensions
[] = { "diff", NULL
};
95 parserDefinition
* const def
= parserNew ("Diff");
96 def
->kinds
= DiffKinds
;
97 def
->kindCount
= KIND_COUNT (DiffKinds
);
98 def
->patterns
= patterns
;
99 def
->extensions
= extensions
;
100 def
->parser
= findDiffTags
;
104 /* vi:set tabstop=8 shiftwidth=4: */