-
Notifications
You must be signed in to change notification settings - Fork 0
/
ctags-5.8.patch
230 lines (221 loc) · 7.13 KB
/
ctags-5.8.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
diff -rc ctags-5.8/EXTENDING.html ctags-5.8.new/EXTENDING.html
*** ctags-5.8/EXTENDING.html Thu Oct 12 12:26:40 2006
--- ctags-5.8.new/EXTENDING.html Mon Nov 26 15:42:59 2012
***************
*** 382,386 ****
--- 382,426 ----
}
</pre>
+ <h2>Integration with GNU GLOBAL</h2>
+
+ <p>
+ All ctags parsers are already GNU GLOBAL's parsers as it is.
+ Regarding the preparation procedure, please see 'FAQ' file in GNU GLOBAL package.
+ </p>
+
+ <p>
+ To generate reference tags, please use makeSimpleReferenceTag() function
+ instead of makeSimpleTag(). This function does not influence the output
+ of Exuberant Ctags without --gtags option.
+ </p>
+ <p>
+ If a parser supports reference tags, then you can use global command like follows:
+ <pre>
+ $ gtags # invokes Exuberant Ctags internally
+ $ global -x func
+ 100 util/tools.c func() {
+ $ global -xr func
+ 250 src/main.c if (func() == 0) {
+ 350 src/etc.c int a = func();
+ </pre>
+
+ <dl>
+ <dt>global -x name<dd>print definition tags
+ <dt>global -xr name<dd>print reference tags which are defined
+ <dt>global -xs name<dd>print reference tags which are not defined
+ </dl>
+ </p>
+
+ <p>
+ GNU GLOBAL is a source code tagging system that works the same way
+ across diverse environments (emacs, vi, less, bash, web browser, etc).
+ The feature of it is an ability to treat not only definitions but
+ also references. Please see the following site for the detail.
+ <blockquote>
+ http://www.gnu.org/software/global/
+ </blockquote>
+ </p>
+
</body>
</html>
diff -rc ctags-5.8/ctags.1 ctags-5.8.new/ctags.1
*** ctags-5.8/ctags.1 Fri Jul 10 07:03:54 2009
--- ctags-5.8.new/ctags.1 Mon Nov 26 14:32:44 2012
***************
*** 510,515 ****
--- 510,520 ----
before the first file name. [Ignored in etags mode]
.TP 5
+ .B \-\-gtags
+ Print a type string at the head of each tag record of cross reference file.
+ This option is used to integrate this program into GNU GLOBAL.
+
+ .TP 5
.B \-\-help
Prints to standard output a detailed usage description, and then exits.
diff -rc ctags-5.8/entry.c ctags-5.8.new/entry.c
*** ctags-5.8/entry.c Thu Oct 12 12:26:40 2006
--- ctags-5.8.new/entry.c Tue Dec 4 13:24:03 2012
***************
*** 643,655 ****
{
const char *const line =
readSourceLine (TagFile.vLine, tag->filePosition, NULL);
! int length;
if (Option.tagFileFormat == 1)
! length = fprintf (TagFile.fp, "%-16s %4lu %-16s ", tag->name,
tag->lineNumber, tag->sourceFileName);
else
! length = fprintf (TagFile.fp, "%-16s %-10s %4lu %-16s ", tag->name,
tag->kindName, tag->lineNumber, tag->sourceFileName);
length += writeCompactSourceLine (TagFile.fp, line);
--- 643,657 ----
{
const char *const line =
readSourceLine (TagFile.vLine, tag->filePosition, NULL);
! int length = 0;
+ if (Option.gtags == 1)
+ length += fprintf(TagFile.fp, "%c ", tag->type);
if (Option.tagFileFormat == 1)
! length += fprintf (TagFile.fp, "%-16s %4lu %-16s ", tag->name,
tag->lineNumber, tag->sourceFileName);
else
! length += fprintf (TagFile.fp, "%-16s %-10s %4lu %-16s ", tag->name,
tag->kindName, tag->lineNumber, tag->sourceFileName);
length += writeCompactSourceLine (TagFile.fp, line);
***************
*** 809,814 ****
--- 811,818 ----
extern void makeTagEntry (const tagEntryInfo *const tag)
{
Assert (tag->name != NULL);
+ if (Option.gtags == 0 && tag->type == GTAGS_REFERENCE)
+ return;
if (tag->name [0] == '\0')
error (WARNING, "ignoring null tag in %s", vStringValue (File.name));
else
***************
*** 842,847 ****
--- 846,852 ----
e->filePosition = getInputFilePosition ();
e->sourceFileName = getSourceFileTagPath ();
e->name = name;
+ e->type = GTAGS_DEFINITION;
}
/* vi:set tabstop=4 shiftwidth=4: */
diff -rc ctags-5.8/entry.h ctags-5.8.new/entry.h
*** ctags-5.8/entry.h Thu Oct 12 12:26:40 2006
--- ctags-5.8.new/entry.h Mon Nov 26 14:56:17 2012
***************
*** 24,30 ****
* MACROS
*/
#define WHOLE_FILE -1L
!
/*
* DATA DECLARATIONS
*/
--- 24,31 ----
* MACROS
*/
#define WHOLE_FILE -1L
! #define GTAGS_DEFINITION 'D'
! #define GTAGS_REFERENCE 'R'
/*
* DATA DECLARATIONS
*/
***************
*** 65,70 ****
--- 66,72 ----
const char *name; /* name of the tag */
const char *kindName; /* kind of tag */
char kind; /* single character representation of kind */
+ char type; /* single character representation of type for gtags */
struct {
const char* access;
const char* fileScope;
diff -rc ctags-5.8/options.c ctags-5.8.new/options.c
*** ctags-5.8/options.c Wed Sep 5 11:00:44 2007
--- ctags-5.8.new/options.c Tue Dec 4 13:26:06 2012
***************
*** 148,153 ****
--- 148,154 ----
FALSE, /* --tag-relative */
FALSE, /* --totals */
FALSE, /* --line-directives */
+ FALSE, /* --gtags */
#ifdef DEBUG
0, 0 /* -D, -b */
#endif
***************
*** 224,229 ****
--- 225,233 ----
#else
{0," Force output of specified tag file format [2]."},
#endif
+ {1," --gtags"},
+ {1," Print a type string for gtags at the head of each tag."},
+ {1," This option is valid only with the -x option."},
{1," --help"},
{1," Print this option summary."},
{1," --if0=[yes|no]"},
***************
*** 1398,1403 ****
--- 1402,1408 ----
{ "file-scope", &Option.include.fileScope, FALSE },
{ "file-tags", &Option.include.fileNames, FALSE },
{ "filter", &Option.filter, TRUE },
+ { "gtags", &Option.gtags, FALSE },
{ "if0", &Option.if0, FALSE },
{ "kind-long", &Option.kindLong, TRUE },
{ "line-directives",&Option.lineDirectives, FALSE },
diff -rc ctags-5.8/options.h ctags-5.8.new/options.h
*** ctags-5.8/options.h Wed Sep 5 11:00:44 2007
--- ctags-5.8.new/options.h Sun Nov 25 09:31:22 2012
***************
*** 108,113 ****
--- 108,114 ----
boolean tagRelative; /* --tag-relative file paths relative to tag file */
boolean printTotals; /* --totals print cumulative statistics */
boolean lineDirectives; /* --linedirectives process #line directives */
+ boolean gtags /* --gtags print a type string for gtags */
#ifdef DEBUG
long debugLevel; /* -D debugging output */
unsigned long breakLine;/* -b source line at which to call lineBreak() */
diff -rc ctags-5.8/parse.c ctags-5.8.new/parse.c
*** ctags-5.8/parse.c Tue Jul 31 14:35:33 2007
--- ctags-5.8.new/parse.c Mon Nov 26 14:56:58 2012
***************
*** 53,58 ****
--- 53,74 ----
}
}
+ extern void makeSimpleReferenceTag (
+ const vString* const name, kindOption* const kinds, const int kind)
+ {
+ if (kinds [kind].enabled && name != NULL && vStringLength (name) > 0)
+ {
+ tagEntryInfo e;
+ initTagEntry (&e, vStringValue (name));
+
+ e.kindName = kinds [kind].name;
+ e.kind = kinds [kind].letter;
+ e.type = GTAGS_REFERENCE;
+
+ makeTagEntry (&e);
+ }
+ }
+
/*
* parserDescription mapping management
*/