Skip to content

Commit a7ea4a7

Browse files
committed
Make: fill end: fields for "define ..."
Signed-off-by: Masatake YAMATO <[email protected]>
1 parent 0673dac commit a7ea4a7

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
--extras=+r
2-
--fields=+r
2+
--fields=+re

Units/parser-make.r/make.include.d/expected.tags

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $(wildcard *.h) input.mk /^include $(1) $* Z0 $(shell) $(wildcard *.h) $(SHELL)$
77
A input.mk /^include A$/;" I roles:included
88
B input.mk /^sinclude B$/;" I roles:optional
99
C input.mk /^-include C$/;" I roles:optional
10-
D input.mk /^define D$/;" m roles:def
10+
D input.mk /^define D$/;" m roles:def end:11
1111
F input.mk /^include F G H$/;" I roles:included
1212
G input.mk /^include F G H$/;" I roles:included
1313
H input.mk /^include F G H$/;" I roles:included

parsers/make.c

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "make.h"
1919

20+
#include "entry.h"
2021
#include "kind.h"
2122
#include "parse.h"
2223
#include "read.h"
@@ -106,12 +107,12 @@ static bool isSpecialTarget (vString *const name)
106107
return true;
107108
}
108109

109-
static void makeSimpleMakeTag (vString *const name, makeKind kind)
110+
static int makeSimpleMakeTag (vString *const name, makeKind kind)
110111
{
111112
if (!isLanguageEnabled (getInputLanguage ()))
112-
return;
113+
return CORK_NIL;
113114

114-
makeSimpleTag (name, kind);
115+
return makeSimpleTag (name, kind);
115116
}
116117

117118
static void makeSimpleMakeRefTag (const vString* const name, const int kind,
@@ -133,12 +134,13 @@ static void newTarget (vString *const name)
133134
makeSimpleMakeTag (name, K_TARGET);
134135
}
135136

136-
static void newMacro (vString *const name, bool with_define_directive, bool appending)
137+
static int newMacro (vString *const name, bool with_define_directive, bool appending)
137138
{
139+
int r = CORK_NIL;
138140
subparser *s;
139141

140142
if (!appending)
141-
makeSimpleMakeTag (name, K_MACRO);
143+
r = makeSimpleMakeTag (name, K_MACRO);
142144

143145
foreachSubparser(s, false)
144146
{
@@ -148,6 +150,8 @@ static void newMacro (vString *const name, bool with_define_directive, bool appe
148150
m->newMacroNotify (m, vStringValue(name), with_define_directive, appending);
149151
leaveSubparser();
150152
}
153+
154+
return r;
151155
}
152156

153157
static void valueFound (vString *const name)
@@ -210,7 +214,7 @@ static void findMakeTags (void)
210214
{
211215
stringList *identifiers = stringListNew ();
212216
bool newline = true;
213-
bool in_define = false;
217+
int current_macro = CORK_NIL;
214218
bool in_value = false;
215219
bool in_rule = false;
216220
bool variable_possible = true;
@@ -296,13 +300,18 @@ static void findMakeTags (void)
296300

297301
if (stringListCount (identifiers) == 1)
298302
{
299-
if (in_define && ! strcmp (vStringValue (name), "endef"))
300-
in_define = false;
301-
else if (in_define)
303+
if ((current_macro != CORK_NIL) && ! strcmp (vStringValue (name), "endef"))
304+
{
305+
tagEntryInfo *e = getEntryInCorkQueue(current_macro);
306+
307+
current_macro = CORK_NIL;
308+
if (e)
309+
e->extensionFields.endLine = getInputLineNumber ();
310+
}
311+
else if (current_macro != CORK_NIL)
302312
skipLine ();
303313
else if (! strcmp (vStringValue (name), "define"))
304314
{
305-
in_define = true;
306315
c = skipToNonWhite (nextChar ());
307316
vStringClear (name);
308317
/* all remaining characters on the line are the name -- even spaces */
@@ -315,7 +324,7 @@ static void findMakeTags (void)
315324
ungetcToInputFile (c);
316325
vStringStripTrailing (name);
317326

318-
newMacro (name, true, false);
327+
current_macro = newMacro (name, true, false);
319328
}
320329
else if (! strcmp (vStringValue (name), "export"))
321330
stringListClear (identifiers);
@@ -376,5 +385,6 @@ extern parserDefinition* MakefileParser (void)
376385
def->extensions = extensions;
377386
def->aliases = aliases;
378387
def->parser = findMakeTags;
388+
def->useCork = CORK_QUEUE;
379389
return def;
380390
}

0 commit comments

Comments
 (0)