From c1c7380a9ac17390bb2b03c032c1f7757333bdbc Mon Sep 17 00:00:00 2001 From: rillig Date: Sat, 19 Dec 2020 12:24:46 +0000 Subject: [PATCH] make(1): fix line numbers in .for loops (since 2007-01-01) --- usr.bin/make/parse.c | 8 ++++---- usr.bin/make/unit-tests/directive-for-lines.exp | 12 ++++++------ usr.bin/make/unit-tests/directive-for-lines.mk | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index 70de20210ac8..dceb171272a2 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.493 2020/12/19 10:57:17 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.494 2020/12/19 12:24:46 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -117,7 +117,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.493 2020/12/19 10:57:17 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.494 2020/12/19 12:24:46 rillig Exp $"); /* types and constants */ @@ -2814,8 +2814,8 @@ ParseGetLine(GetLineMode mode) if (line_end == line || firstComment == line) { if (res == PRLR_EOF) return NULL; - /* Parse another line */ - continue; + if (mode != PARSE_RAW) + continue; } /* We now have a line of data */ diff --git a/usr.bin/make/unit-tests/directive-for-lines.exp b/usr.bin/make/unit-tests/directive-for-lines.exp index faf02672ca01..a54c5cbb6ba6 100644 --- a/usr.bin/make/unit-tests/directive-for-lines.exp +++ b/usr.bin/make/unit-tests/directive-for-lines.exp @@ -1,9 +1,9 @@ -make: "directive-for-lines.mk" line 12: expect 18 -make: "directive-for-lines.mk" line 12: expect 18 -make: "directive-for-lines.mk" line 14: expect 24 -make: "directive-for-lines.mk" line 12: expect 18 -make: "directive-for-lines.mk" line 12: expect 18 -make: "directive-for-lines.mk" line 14: expect 24 +make: "directive-for-lines.mk" line 18: expect 18 +make: "directive-for-lines.mk" line 18: expect 18 +make: "directive-for-lines.mk" line 24: expect 24 +make: "directive-for-lines.mk" line 18: expect 18 +make: "directive-for-lines.mk" line 18: expect 18 +make: "directive-for-lines.mk" line 24: expect 24 make: no target to make. make: stopped in unit-tests diff --git a/usr.bin/make/unit-tests/directive-for-lines.mk b/usr.bin/make/unit-tests/directive-for-lines.mk index 2e4b5289834e..4dbae6d125c6 100644 --- a/usr.bin/make/unit-tests/directive-for-lines.mk +++ b/usr.bin/make/unit-tests/directive-for-lines.mk @@ -1,11 +1,11 @@ -# $NetBSD: directive-for-lines.mk,v 1.1 2020/12/19 12:14:59 rillig Exp $ +# $NetBSD: directive-for-lines.mk,v 1.2 2020/12/19 12:24:46 rillig Exp $ # # Tests for the line numbers that are reported in .for loops. # -# Since 2007-01-01 21:47:32 (git 4d3c468f96e1080e4d3cca8cc39067a73af14fbb), -# parse.c 1.127, the line numbers for the .info directives and error messages -# inside .for loops have been wrong since ParseGetLine skips empty lines, even -# when collecting the lines for the .for loop body. +# Between 2007-01-01 (git 4d3c468f96e1080e, parse.c 1.127) and 2020-12-19 +# (parse.c 1.494), the line numbers for the .info directives and error +# messages inside .for loops had been wrong since ParseGetLine skipped empty +# lines, even when collecting the lines for the .for loop body. .for outer in a b