ctags.rb 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/ext/extconf.rb +1 -1
  4. data/ext/vendor/ctags/Tmain/input-encoding-option.d/tags-expected.txt +1 -0
  5. data/ext/vendor/ctags/Tmain/interactive-mode.d/run.sh +4 -1
  6. data/ext/vendor/ctags/Tmain/json-output-format.d/input.go +4 -0
  7. data/ext/vendor/ctags/Tmain/json-output-format.d/stdout-expected.txt +10 -2
  8. data/ext/vendor/ctags/Tmain/list-pseudo-tags.d/stdout-expected.txt +1 -0
  9. data/ext/vendor/ctags/Tmain/output-encoding-option.d/tags-expected.txt +1 -0
  10. data/ext/vendor/ctags/Tmain/output-format-option.d/run.sh +1 -1
  11. data/ext/vendor/ctags/Tmain/output-format-option.d/stdout-expected.txt +1 -1
  12. data/ext/vendor/ctags/Tmain/output-input-field-with-no-escape.d/run.sh +20 -0
  13. data/ext/vendor/ctags/Tmain/output-input-field-with-no-escape.d/stdout-expected.txt +6 -0
  14. data/ext/vendor/ctags/Tmain/ptag-kind-desc.d/stdout-expected.txt +2 -0
  15. data/ext/vendor/ctags/Tmain/tags-pseudo-tags.d/stdout-expected.txt +1 -0
  16. data/ext/vendor/ctags/Tmain/utils.sh +12 -2
  17. data/ext/vendor/ctags/Units/parser-php.r/php-full-qualified-tags-no-esc.d/args.ctags +4 -0
  18. data/ext/vendor/ctags/Units/parser-php.r/php-full-qualified-tags-no-esc.d/expected.tags +6 -0
  19. data/ext/vendor/ctags/Units/parser-php.r/php-full-qualified-tags-no-esc.d/input.php +10 -0
  20. data/ext/vendor/ctags/docs/contributions.rst +1 -0
  21. data/ext/vendor/ctags/docs/format.rst +13 -0
  22. data/ext/vendor/ctags/docs/interactive-mode.rst +61 -0
  23. data/ext/vendor/ctags/docs/news.rst +16 -1
  24. data/ext/vendor/ctags/docs/output-format.rst +1 -0
  25. data/ext/vendor/ctags/docs/output-xref.rst +10 -0
  26. data/ext/vendor/ctags/main/entry.c +6 -10
  27. data/ext/vendor/ctags/main/entry.h +1 -1
  28. data/ext/vendor/ctags/main/field.c +163 -72
  29. data/ext/vendor/ctags/main/field.h +4 -2
  30. data/ext/vendor/ctags/main/fmt.c +2 -2
  31. data/ext/vendor/ctags/main/main.c +5 -5
  32. data/ext/vendor/ctags/main/options.c +6 -3
  33. data/ext/vendor/ctags/main/parse.c +1 -1
  34. data/ext/vendor/ctags/main/ptag.c +4 -0
  35. data/ext/vendor/ctags/main/ptag.h +1 -0
  36. data/ext/vendor/ctags/main/writer-ctags.c +110 -34
  37. data/ext/vendor/ctags/main/writer-etags.c +11 -8
  38. data/ext/vendor/ctags/main/writer-json.c +18 -8
  39. data/ext/vendor/ctags/main/writer-xref.c +4 -2
  40. data/ext/vendor/ctags/main/writer.c +38 -11
  41. data/ext/vendor/ctags/main/writer.h +19 -7
  42. data/lib/ctags/universal.rb +1 -1
  43. data/lib/ctags/version.rb +1 -1
  44. metadata +10 -2
@@ -55,7 +55,8 @@ typedef enum eFieldType { /* extension field content control */
55
55
 
56
56
  typedef const char* (* renderEscaped) (const tagEntryInfo *const tag,
57
57
  const char *value,
58
- vString * buffer);
58
+ vString * buffer,
59
+ bool *rejected);
59
60
  typedef bool (* isValueAvailable) (const struct sTagEntryInfo *const tag);
60
61
 
61
62
  #define FIELD_LETTER_NO_USE '\0'
@@ -99,7 +100,8 @@ extern void printFields (int language);
99
100
  extern bool isFieldRenderable (fieldType type);
100
101
 
101
102
  extern bool doesFieldHaveValue (fieldType type, const tagEntryInfo *tag);
102
- extern const char* renderFieldEscaped (writerType writer, fieldType type, const tagEntryInfo *tag, int index);
103
+ extern const char* renderFieldEscaped (writerType writer, fieldType type, const tagEntryInfo *tag, int index,
104
+ bool *rejected);
103
105
 
104
106
  extern void initFieldDescs (void);
105
107
  extern int countFields (void);
@@ -60,7 +60,7 @@ static int printTagField (fmtSpec* fspec, MIO* fp, const tagEntryInfo * tag)
60
60
 
61
61
  if (isCommonField (ftype))
62
62
  /* TODO: Don't use WRITER_XREF directly */
63
- str = renderFieldEscaped (WRITER_XREF, ftype, tag, NO_PARSER_FIELD);
63
+ str = renderFieldEscaped (WRITER_XREF, ftype, tag, NO_PARSER_FIELD, NULL);
64
64
  else
65
65
  {
66
66
  unsigned int findex;
@@ -76,7 +76,7 @@ static int printTagField (fmtSpec* fspec, MIO* fp, const tagEntryInfo * tag)
76
76
  else if (isFieldEnabled (tag->parserFields [findex].ftype))
77
77
  /* TODO: Don't use WRITER_XREF directly */
78
78
  str = renderFieldEscaped (WRITER_XREF, tag->parserFields [findex].ftype,
79
- tag, findex);
79
+ tag, findex, NULL);
80
80
  }
81
81
 
82
82
  if (str == NULL)
@@ -516,17 +516,17 @@ void interactiveLoop (cookedArgs *args, void *user CTAGS_ATTR_UNUSED)
516
516
  goto next;
517
517
  }
518
518
 
519
- if (!strcmp ("list-parsers", json_string_value (command))) {
520
- /* todo */
521
- } else if (!strcmp ("generate-tags", json_string_value (command))) {
519
+ if (!strcmp ("generate-tags", json_string_value (command))) {
522
520
  json_int_t size = -1;
523
521
  const char *filename;
524
522
 
525
- if (json_unpack (request, "{s?I ss}", "size", &size, "filename", &filename) == -1) {
523
+ if (json_unpack (request, "{ss}", "filename", &filename) == -1) {
526
524
  error (FATAL, "invalid generate-tags request");
527
525
  goto next;
528
526
  }
529
527
 
528
+ json_unpack (request, "{sI}", "size", &size);
529
+
530
530
  openTagFile ();
531
531
  if (size == -1) { /* read from disk */
532
532
  createTagsForEntry (filename);
@@ -614,7 +614,7 @@ extern int main (int argc CTAGS_ATTR_UNUSED, char **argv)
614
614
 
615
615
  setErrorPrinter (stderrDefaultErrorPrinter, NULL);
616
616
  setMainLoop (batchMakeTags, NULL);
617
- setTagWriter (WRITER_CTAGS);
617
+ setTagWriter (WRITER_U_CTAGS);
618
618
 
619
619
  setCurrentDirectory ();
620
620
  setExecutableName (*argv++);
@@ -360,12 +360,12 @@ static optionDescription LongOptionDescription [] = {
360
360
  {1," The encoding to write the tag file in. Defaults to UTF-8 if --input-encoding"},
361
361
  {1," is specified, otherwise no conversion is performed."},
362
362
  #endif
363
- {0," --output-format=ctags|etags|xref"
363
+ {0," --output-format=u-ctags|e-ctags|etags|xref"
364
364
  #ifdef HAVE_JANSSON
365
365
  "|json"
366
366
  #endif
367
367
  },
368
- {0," Specify the output format. [ctags]"},
368
+ {0," Specify the output format. [u-ctags]"},
369
369
  {1," --param-<LANG>=name:argument"},
370
370
  {1," Set <LANG> specific parameter. Available parameters can be listed with --list-params."},
371
371
  {0," --pattern-length-limit=N"},
@@ -763,6 +763,7 @@ static void setXrefMode (void)
763
763
  static void setJsonMode (void)
764
764
  {
765
765
  enablePtag (PTAG_JSON_OUTPUT_VERSION, true);
766
+ enablePtag (PTAG_OUTPUT_MODE, false);
766
767
  setTagWriter (WRITER_JSON);
767
768
  }
768
769
  #endif
@@ -2090,8 +2091,10 @@ static void processOutputFormat (const char *const option CTAGS_ATTR_UNUSED,
2090
2091
  if (parameter [0] == '\0')
2091
2092
  error (FATAL, "no output format name supplied for \"%s\"", option);
2092
2093
 
2093
- if (strcmp (parameter, "ctags") == 0)
2094
+ if (strcmp (parameter, "u-ctags") == 0)
2094
2095
  ;
2096
+ else if (strcmp (parameter, "e-ctags") == 0)
2097
+ setTagWriter (WRITER_E_CTAGS);
2095
2098
  else if (strcmp (parameter, "etags") == 0)
2096
2099
  setEtagsMode ();
2097
2100
  else if (strcmp (parameter, "xref") == 0)
@@ -2436,7 +2436,7 @@ extern bool parseFileWithMio (const char *const fileName, MIO *mio)
2436
2436
  tagFileResized = createTagsWithXcmd (fileName, language, mio)? true: tagFileResized;
2437
2437
  #endif
2438
2438
 
2439
- teardownWriter (fileName);
2439
+ tagFileResized = teardownWriter (fileName)? true: tagFileResized;
2440
2440
 
2441
2441
  if (Option.filter && ! Option.interactive)
2442
2442
  closeTagFile (tagFileResized);
@@ -160,6 +160,10 @@ static ptagDesc ptagDescs [] = {
160
160
  "the letters, names and descriptions of kinds in a parser",
161
161
  ptagMakeKindDescriptions,
162
162
  false },
163
+ { true, "TAG_OUTPUT_MODE",
164
+ "the output mode: u-ctags or e-ctags",
165
+ ptagMakeCtagsOutputMode,
166
+ true },
163
167
  };
164
168
 
165
169
  extern bool makePtagIfEnabled (ptagType type, void *data)
@@ -35,6 +35,7 @@ typedef enum ePtagType { /* pseudo tag content control */
35
35
  #endif
36
36
  PTAG_KIND_SEPARATOR,
37
37
  PTAG_KIND_DESCRIPTION,
38
+ PTAG_OUTPUT_MODE,
38
39
  PTAG_COUNT
39
40
  } ptagType;
40
41
 
@@ -17,33 +17,73 @@
17
17
  #include "writer.h"
18
18
 
19
19
 
20
- static int writeCtagsEntry (MIO * mio, const tagEntryInfo *const tag, void *data CTAGS_ATTR_UNUSED);
21
- static int writeCtagsPtagEntry (MIO * mio, const ptagDesc *desc,
20
+ static int writeCtagsEntry (tagWriter *writer CTAGS_ATTR_UNUSED,
21
+ MIO * mio, const tagEntryInfo *const tag);
22
+ static int writeCtagsPtagEntry (tagWriter *writer CTAGS_ATTR_UNUSED,
23
+ MIO * mio, const ptagDesc *desc,
22
24
  const char *const fileName,
23
25
  const char *const pattern,
24
- const char *const parserName, void *data CTAGS_ATTR_UNUSED);
26
+ const char *const parserName);
27
+ static void buildCtagsFqTagCache (tagWriter *writer CTAGS_ATTR_UNUSED, tagEntryInfo *const tag);
25
28
 
26
- tagWriter ctagsWriter = {
29
+ struct rejection {
30
+ bool rejectedInThisRendering;
31
+ bool rejectedInThisInput;
32
+ };
33
+
34
+ tagWriter uCtagsWriter = {
27
35
  .writeEntry = writeCtagsEntry,
28
36
  .writePtagEntry = writeCtagsPtagEntry,
29
37
  .preWriteEntry = NULL,
30
38
  .postWriteEntry = NULL,
39
+ .buildFqTagCache = buildCtagsFqTagCache,
31
40
  .useStdoutByDefault = false,
32
41
  };
33
42
 
34
- static const char* escapeFieldValue (const tagEntryInfo * tag, fieldType ftype)
43
+ static void *beginECtagsFile (tagWriter *writer, MIO * mio)
35
44
  {
36
- return renderFieldEscaped (ctagsWriter.type, ftype, tag, NO_PARSER_FIELD);
45
+ static struct rejection rej;
46
+
47
+ rej.rejectedInThisInput = false;;
48
+
49
+ return &rej;
50
+ }
51
+
52
+ static bool endECTagsFile (tagWriter *writer, MIO * mio, const char* filename)
53
+ {
54
+ struct rejection *rej = writer->private;
55
+ return rej->rejectedInThisInput;
56
+ }
57
+
58
+ tagWriter eCtagsWriter = {
59
+ .writeEntry = writeCtagsEntry,
60
+ .writePtagEntry = writeCtagsPtagEntry,
61
+ .preWriteEntry = beginECtagsFile,
62
+ .postWriteEntry = endECTagsFile,
63
+ .buildFqTagCache = buildCtagsFqTagCache,
64
+ .useStdoutByDefault = false,
65
+ };
66
+
67
+ static const char* escapeFieldValue (tagWriter *writer, const tagEntryInfo * tag, fieldType ftype)
68
+ {
69
+ bool *reject = NULL;
70
+
71
+ if (writer->private)
72
+ {
73
+ struct rejection * rej = writer->private;
74
+ reject = &rej->rejectedInThisRendering;
75
+ }
76
+ return renderFieldEscaped (writer->type, ftype, tag, NO_PARSER_FIELD, reject);
37
77
  }
38
78
 
39
- static int renderExtensionFieldMaybe (int xftype, const tagEntryInfo *const tag, char sep[2], MIO *mio)
79
+ static int renderExtensionFieldMaybe (tagWriter *writer, int xftype, const tagEntryInfo *const tag, char sep[2], MIO *mio)
40
80
  {
41
81
  if (isFieldEnabled (xftype) && doesFieldHaveValue (xftype, tag))
42
82
  {
43
83
  int len;
44
84
  len = mio_printf (mio, "%s\t%s:%s", sep,
45
85
  getFieldName (xftype),
46
- escapeFieldValue (tag, xftype));
86
+ escapeFieldValue (writer, tag, xftype));
47
87
  sep[0] = '\0';
48
88
  return len;
49
89
  }
@@ -51,11 +91,18 @@ static int renderExtensionFieldMaybe (int xftype, const tagEntryInfo *const tag,
51
91
  return 0;
52
92
  }
53
93
 
54
- static int addParserFields (MIO * mio, const tagEntryInfo *const tag)
94
+ static int addParserFields (tagWriter *writer, MIO * mio, const tagEntryInfo *const tag)
55
95
  {
56
96
  unsigned int i;
57
97
  unsigned int ftype;
58
98
  int length = 0;
99
+ bool *reject = NULL;
100
+
101
+ if (writer->private)
102
+ {
103
+ struct rejection *rej = writer->private;
104
+ reject = &rej->rejectedInThisRendering;
105
+ }
59
106
 
60
107
  for (i = 0; i < tag->usedParserFields; i++)
61
108
  {
@@ -65,16 +112,16 @@ static int addParserFields (MIO * mio, const tagEntryInfo *const tag)
65
112
 
66
113
  length += mio_printf(mio, "\t%s:%s",
67
114
  getFieldName (ftype),
68
- renderFieldEscaped (ctagsWriter.type,
69
- tag->parserFields [i].ftype, tag, i));
115
+ renderFieldEscaped (writer->type,
116
+ tag->parserFields [i].ftype, tag, i, reject));
70
117
  }
71
118
  return length;
72
119
  }
73
120
 
74
- static int writeLineNumberEntry (MIO * mio, const tagEntryInfo *const tag)
121
+ static int writeLineNumberEntry (tagWriter *writer, MIO * mio, const tagEntryInfo *const tag)
75
122
  {
76
123
  if (Option.lineDirectives)
77
- return mio_printf (mio, "%s", escapeFieldValue (tag, FIELD_LINE_NUMBER));
124
+ return mio_printf (mio, "%s", escapeFieldValue (writer, tag, FIELD_LINE_NUMBER));
78
125
  else
79
126
  return mio_printf (mio, "%lu", tag->lineNumber);
80
127
  }
@@ -92,7 +139,7 @@ static int file_puts (const char* s, void *data)
92
139
  return mio_puts (fp, s);
93
140
  }
94
141
 
95
- static int addExtensionFields (MIO *mio, const tagEntryInfo *const tag)
142
+ static int addExtensionFields (tagWriter *writer, MIO *mio, const tagEntryInfo *const tag)
96
143
  {
97
144
  bool isKindKeyEnabled = isFieldEnabled (FIELD_KIND_KEY);
98
145
  bool isScopeEnabled = isFieldEnabled (FIELD_SCOPE_KEY);
@@ -135,14 +182,14 @@ static int addExtensionFields (MIO *mio, const tagEntryInfo *const tag)
135
182
  sep [0] = '\0';
136
183
  }
137
184
 
138
- length += renderExtensionFieldMaybe (FIELD_LANGUAGE, tag, sep, mio);
185
+ length += renderExtensionFieldMaybe (writer, FIELD_LANGUAGE, tag, sep, mio);
139
186
 
140
187
  if (isFieldEnabled (FIELD_SCOPE))
141
188
  {
142
189
  const char* k = NULL, *v = NULL;
143
190
 
144
- k = escapeFieldValue (tag, FIELD_SCOPE_KIND_LONG);
145
- v = escapeFieldValue (tag, FIELD_SCOPE);
191
+ k = escapeFieldValue (writer, tag, FIELD_SCOPE_KIND_LONG);
192
+ v = escapeFieldValue (writer, tag, FIELD_SCOPE);
146
193
  if (k && v)
147
194
  {
148
195
  length += mio_printf (mio, scopeFmt, sep, scopeKey, k, v);
@@ -155,7 +202,7 @@ static int addExtensionFields (MIO *mio, const tagEntryInfo *const tag)
155
202
  length += mio_printf (mio, "%s\t%s:%s:%s", sep,
156
203
  getFieldName (FIELD_TYPE_REF),
157
204
  tag->extensionFields.typeRef [0],
158
- escapeFieldValue (tag, FIELD_TYPE_REF));
205
+ escapeFieldValue (writer, tag, FIELD_TYPE_REF));
159
206
  sep [0] = '\0';
160
207
  }
161
208
 
@@ -166,14 +213,14 @@ static int addExtensionFields (MIO *mio, const tagEntryInfo *const tag)
166
213
  sep [0] = '\0';
167
214
  }
168
215
 
169
- length += renderExtensionFieldMaybe (FIELD_INHERITANCE, tag, sep, mio);
170
- length += renderExtensionFieldMaybe (FIELD_ACCESS, tag, sep, mio);
171
- length += renderExtensionFieldMaybe (FIELD_IMPLEMENTATION, tag, sep, mio);
172
- length += renderExtensionFieldMaybe (FIELD_SIGNATURE, tag, sep, mio);
173
- length += renderExtensionFieldMaybe (FIELD_ROLE, tag, sep, mio);
174
- length += renderExtensionFieldMaybe (FIELD_EXTRA, tag, sep, mio);
175
- length += renderExtensionFieldMaybe (FIELD_XPATH, tag, sep, mio);
176
- length += renderExtensionFieldMaybe (FIELD_END, tag, sep, mio);
216
+ length += renderExtensionFieldMaybe (writer, FIELD_INHERITANCE, tag, sep, mio);
217
+ length += renderExtensionFieldMaybe (writer, FIELD_ACCESS, tag, sep, mio);
218
+ length += renderExtensionFieldMaybe (writer, FIELD_IMPLEMENTATION, tag, sep, mio);
219
+ length += renderExtensionFieldMaybe (writer, FIELD_SIGNATURE, tag, sep, mio);
220
+ length += renderExtensionFieldMaybe (writer, FIELD_ROLE, tag, sep, mio);
221
+ length += renderExtensionFieldMaybe (writer, FIELD_EXTRA, tag, sep, mio);
222
+ length += renderExtensionFieldMaybe (writer, FIELD_XPATH, tag, sep, mio);
223
+ length += renderExtensionFieldMaybe (writer, FIELD_END, tag, sep, mio);
177
224
 
178
225
  return length;
179
226
  }
@@ -183,14 +230,26 @@ static int writePatternEntry (MIO *mio, const tagEntryInfo *const tag)
183
230
  return makePatternStringCommon (tag, file_putc, file_puts, mio);
184
231
  }
185
232
 
186
- static int writeCtagsEntry (MIO * mio, const tagEntryInfo *const tag, void *data CTAGS_ATTR_UNUSED)
233
+ static int writeCtagsEntry (tagWriter *writer,
234
+ MIO * mio, const tagEntryInfo *const tag)
187
235
  {
236
+ long origin = 0;
237
+
238
+ if (writer->private)
239
+ {
240
+ struct rejection *rej = writer->private;
241
+
242
+ origin = mio_tell (mio);
243
+ rej->rejectedInThisRendering = false;
244
+
245
+ }
246
+
188
247
  int length = mio_printf (mio, "%s\t%s\t",
189
- escapeFieldValue (tag, FIELD_NAME),
190
- escapeFieldValue (tag, FIELD_INPUT_FILE));
248
+ escapeFieldValue (writer, tag, FIELD_NAME),
249
+ escapeFieldValue (writer, tag, FIELD_INPUT_FILE));
191
250
 
192
251
  if (tag->lineNumberEntry)
193
- length += writeLineNumberEntry (mio, tag);
252
+ length += writeLineNumberEntry (writer, mio, tag);
194
253
  else if (tag->pattern)
195
254
  length += mio_printf(mio, "%s", tag->pattern);
196
255
  else
@@ -198,19 +257,30 @@ static int writeCtagsEntry (MIO * mio, const tagEntryInfo *const tag, void *data
198
257
 
199
258
  if (includeExtensionFlags ())
200
259
  {
201
- length += addExtensionFields (mio, tag);
202
- length += addParserFields (mio, tag);
260
+ length += addExtensionFields (writer, mio, tag);
261
+ length += addParserFields (writer, mio, tag);
203
262
  }
204
263
 
205
264
  length += mio_printf (mio, "\n");
206
265
 
266
+ if (writer->private
267
+ && ((struct rejection *)(writer->private))->rejectedInThisRendering)
268
+ {
269
+ mio_seek (mio, origin, SEEK_SET);
270
+
271
+ /* Truncation is needed. */
272
+ ((struct rejection *)(writer->private))->rejectedInThisInput = true;
273
+
274
+ length = 0;
275
+ }
207
276
  return length;
208
277
  }
209
278
 
210
- static int writeCtagsPtagEntry (MIO * mio, const ptagDesc *desc,
279
+ static int writeCtagsPtagEntry (tagWriter *writer CTAGS_ATTR_UNUSED,
280
+ MIO * mio, const ptagDesc *desc,
211
281
  const char *const fileName,
212
282
  const char *const pattern,
213
- const char *const parserName, void *data CTAGS_ATTR_UNUSED)
283
+ const char *const parserName)
214
284
  {
215
285
  return parserName
216
286
 
@@ -223,3 +293,9 @@ static int writeCtagsPtagEntry (MIO * mio, const ptagDesc *desc,
223
293
  OPT(fileName), OPT(pattern));
224
294
  #undef OPT
225
295
  }
296
+
297
+ static void buildCtagsFqTagCache (tagWriter *writer CTAGS_ATTR_UNUSED, tagEntryInfo *const tag)
298
+ {
299
+ escapeFieldValue (writer, tag, FIELD_SCOPE_KIND_LONG);
300
+ escapeFieldValue (writer, tag, FIELD_SCOPE);
301
+ }
@@ -20,9 +20,9 @@
20
20
  #include "writer.h"
21
21
 
22
22
 
23
- static int writeEtagsEntry (MIO * mio, const tagEntryInfo *const tag, void *data);
24
- static void *beginEtagsFile (MIO * mio);
25
- static void endEtagsFile (MIO * mio, const char* filename, void *data);
23
+ static int writeEtagsEntry (tagWriter *writer, MIO * mio, const tagEntryInfo *const tag);
24
+ static void *beginEtagsFile (tagWriter *writer, MIO * mio);
25
+ static bool endEtagsFile (tagWriter *writer, MIO * mio, const char* filename);
26
26
 
27
27
  tagWriter etagsWriter = {
28
28
  .writeEntry = writeEtagsEntry,
@@ -40,7 +40,7 @@ struct sEtags {
40
40
 
41
41
 
42
42
 
43
- static void *beginEtagsFile (MIO *mio)
43
+ static void *beginEtagsFile (tagWriter *writer CTAGS_ATTR_UNUSED, MIO *mio)
44
44
  {
45
45
  static struct sEtags etags = { NULL, NULL, 0, NULL };
46
46
 
@@ -50,10 +50,11 @@ static void *beginEtagsFile (MIO *mio)
50
50
  return &etags;
51
51
  }
52
52
 
53
- static void endEtagsFile (MIO *mainfp, const char *filename, void *data)
53
+ static bool endEtagsFile (tagWriter *writer,
54
+ MIO *mainfp, const char *filename)
54
55
  {
55
56
  const char *line;
56
- struct sEtags *etags = data;
57
+ struct sEtags *etags = writer->private;
57
58
 
58
59
  mio_printf (mainfp, "\f\n%s,%ld\n", filename, (long) etags->byteCount);
59
60
  abort_if_ferror (mainfp);
@@ -73,12 +74,14 @@ static void endEtagsFile (MIO *mainfp, const char *filename, void *data)
73
74
  etags->mio = NULL;
74
75
  etags->name = NULL;
75
76
  }
77
+ return false;
76
78
  }
77
79
 
78
- static int writeEtagsEntry (MIO * mio, const tagEntryInfo *const tag, void *data)
80
+ static int writeEtagsEntry (tagWriter *writer,
81
+ MIO * mio, const tagEntryInfo *const tag)
79
82
  {
80
83
  int length;
81
- struct sEtags *etags = data;
84
+ struct sEtags *etags = writer->private;
82
85
 
83
86
  mio = etags->mio;
84
87
 
@@ -24,12 +24,14 @@
24
24
  #endif
25
25
 
26
26
 
27
- static int writeJsonEntry (MIO * mio, const tagEntryInfo *const tag, void *data CTAGS_ATTR_UNUSED);
27
+ static int writeJsonEntry (tagWriter *writer CTAGS_ATTR_UNUSED,
28
+ MIO * mio, const tagEntryInfo *const tag);
28
29
 
29
- static int writeJsonPtagEntry (MIO * mio, const ptagDesc *desc,
30
+ static int writeJsonPtagEntry (tagWriter *writer CTAGS_ATTR_UNUSED,
31
+ MIO * mio, const ptagDesc *desc,
30
32
  const char *const fileName,
31
33
  const char *const pattern,
32
- const char *const parserName, void *data CTAGS_ATTR_UNUSED);
34
+ const char *const parserName);
33
35
 
34
36
  tagWriter jsonWriter = {
35
37
  .writeEntry = writeJsonEntry,
@@ -42,7 +44,7 @@ tagWriter jsonWriter = {
42
44
 
43
45
  static json_t* escapeFieldValue (const tagEntryInfo * tag, fieldType ftype)
44
46
  {
45
- const char *str = renderFieldEscaped (jsonWriter.type, ftype, tag, NO_PARSER_FIELD);
47
+ const char *str = renderFieldEscaped (jsonWriter.type, ftype, tag, NO_PARSER_FIELD, NULL);
46
48
  if (str)
47
49
  return json_string (str);
48
50
  else
@@ -111,14 +113,21 @@ static void addExtensionFields (json_t *response, const tagEntryInfo *const tag)
111
113
  renderExtensionFieldMaybe (k, tag, response);
112
114
  }
113
115
 
114
- static int writeJsonEntry (MIO * mio, const tagEntryInfo *const tag, void *data CTAGS_ATTR_UNUSED)
116
+ static int writeJsonEntry (tagWriter *writer CTAGS_ATTR_UNUSED,
117
+ MIO * mio, const tagEntryInfo *const tag)
115
118
  {
119
+ const char *pattern = tag->pattern;
120
+ if (!pattern)
121
+ {
122
+ pattern = makePatternString (tag);
123
+ }
124
+
116
125
  json_t *response = json_pack ("{ss ss ss ss}",
117
126
  "_type", "tag",
118
127
  "name", tag->name,
119
128
  "path", tag->sourceFileName,
120
129
  /* --extra=f option can generates a tag with NULL pattern. */
121
- "pattern", tag->pattern? tag->pattern: ""
130
+ "pattern", pattern? pattern: ""
122
131
  );
123
132
 
124
133
  if (includeExtensionFlags ())
@@ -136,10 +145,11 @@ static int writeJsonEntry (MIO * mio, const tagEntryInfo *const tag, void *data
136
145
  return length;
137
146
  }
138
147
 
139
- static int writeJsonPtagEntry (MIO * mio, const ptagDesc *desc,
148
+ static int writeJsonPtagEntry (tagWriter *writer CTAGS_ATTR_UNUSED,
149
+ MIO * mio, const ptagDesc *desc,
140
150
  const char *const fileName,
141
151
  const char *const pattern,
142
- const char *const parserName, void *data CTAGS_ATTR_UNUSED)
152
+ const char *const parserName)
143
153
  {
144
154
  #define OPT(X) ((X)?(X):"")
145
155
  json_t *response;