Replace doc-comments with '/* *' comments to show there's no build
[geany-mirror.git] / tagmanager / diff.c
blob6f66f99b4ccaaafba81281b9fc31227cf90b4601
1 /*
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).
9 */
12 * INCLUDE FILES
14 #include "general.h" /* must always come first */
16 #include <ctype.h>
17 #include <string.h>
19 #include "parse.h"
20 #include "read.h"
21 #include "vstring.h"
24 * DATA DEFINITIONS
26 typedef enum {
27 K_FUNCTION
28 } diffKind;
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)
50 cp += 4;
51 if (isspace ((int) *cp)) continue;
53 /* strip any absolute path */
54 if (*cp == '/' || *cp == '\\')
56 skipSlash = TRUE;
57 tmp = (const unsigned char*) strrchr((const char*) cp, '/');
58 if (tmp == NULL)
59 { /* if no / is contained try \ in case of a Windows filename */
60 tmp = (const unsigned char*) strrchr((const char*) cp, '\\');
61 if (tmp == NULL)
62 { /* last fallback, probably the filename doesn't contain a path, so take it */
63 if (strlen((const char*) cp) > 0)
65 tmp = cp;
66 skipSlash = FALSE;
71 else
72 tmp = cp;
74 if (tmp != NULL)
76 if (skipSlash) tmp++; /* skip the leading slash or backslash */
77 while (! isspace(*tmp) && *tmp != '\0')
79 vStringPut(filename, *tmp);
80 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;
101 return def;
104 /* vi:set tabstop=8 shiftwidth=4: */