Skip to content

Commit 96f9a1c

Browse files
authored
Merge pull request #3931 from masatake/make--adjust-endline
Make: fix wrong end fields for targets having macros on the same line
2 parents 6c5cba0 + de0ce15 commit 96f9a1c

File tree

5 files changed

+25
-2
lines changed

5 files changed

+25
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--sort=no
2+
--fields=+ne
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target input.mak /^target: macro = 1$/;" t line:2 end:2
2+
macro input.mak /^target: macro = 1$/;" m line:2
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#
2+
target: macro = 1

main/entry.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,7 @@ extern void setTagEndLine(tagEntryInfo *tag, unsigned long endLine)
16251625
{
16261626
error (WARNING,
16271627
"given end line (%lu) for the tag (%s) in the file (%s) is smaller than its start line: %lu",
1628-
tag->lineNumber,
1628+
endLine,
16291629
tag->name,
16301630
tag->inputFileName,
16311631
tag->lineNumber);

parsers/make.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,20 @@ static void endTargets (intArray *targets, unsigned long lnum)
221221
intArrayClear (targets);
222222
}
223223

224+
static bool isTheLastTargetOnTheSameLine (intArray *current_targets,
225+
unsigned long line)
226+
{
227+
if (!intArrayIsEmpty (current_targets))
228+
{
229+
int r = intArrayLast (current_targets);
230+
tagEntryInfo *e = getEntryInCorkQueue (r);
231+
if (e && e->lineNumber == line)
232+
return true;
233+
}
234+
235+
return false;
236+
}
237+
224238
static void findMakeTags (void)
225239
{
226240
stringList *identifiers = stringListNew ();
@@ -300,7 +314,10 @@ static void findMakeTags (void)
300314
newMacro (stringListItem (identifiers, 0), false, appending);
301315

302316
in_value = true;
303-
endTargets (current_targets, getInputLineNumber () - 1);
317+
unsigned long curline = getInputLineNumber ();
318+
unsigned long adj = isTheLastTargetOnTheSameLine (current_targets,
319+
curline)? 0: 1;
320+
endTargets (current_targets, curline - adj);
304321
appending = false;
305322
}
306323
else if (variable_possible && isIdentifier (c))

0 commit comments

Comments
 (0)