Module Name:    src
Committed By:   rillig
Date:           Sat Jan  8 22:24:20 UTC 2022

Modified Files:
        src/usr.bin/make: parse.c
        src/usr.bin/make/unit-tests: opt-debug-parse.exp opt-debug-parse.mk

Log Message:
make: fix line number in debug log after returning from a file

The parser returns to the next line, not to the current line.


To generate a diff of this commit:
cvs rdiff -u -r1.640 -r1.641 src/usr.bin/make/parse.c
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/opt-debug-parse.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-debug-parse.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.640 src/usr.bin/make/parse.c:1.641
--- src/usr.bin/make/parse.c:1.640	Sat Jan  8 21:28:59 2022
+++ src/usr.bin/make/parse.c	Sat Jan  8 22:24:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.640 2022/01/08 21:28:59 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.641 2022/01/08 22:24:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.640 2022/01/08 21:28:59 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.641 2022/01/08 22:24:20 rillig Exp $");
 
 /*
  * A file being read.
@@ -2263,7 +2263,7 @@ ParseEOF(void)
 
 	curFile = CurFile();
 	DEBUG2(PARSE, "ParseEOF: returning to file %s, line %d\n",
-	    curFile->name.str, curFile->lineno);
+	    curFile->name.str, curFile->readLines + 1);
 
 	SetParseFile(curFile->name.str);
 	return true;

Index: src/usr.bin/make/unit-tests/opt-debug-parse.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-parse.exp:1.4 src/usr.bin/make/unit-tests/opt-debug-parse.exp:1.5
--- src/usr.bin/make/unit-tests/opt-debug-parse.exp:1.4	Sat Jan  8 22:13:43 2022
+++ src/usr.bin/make/unit-tests/opt-debug-parse.exp	Sat Jan  8 22:24:20 2022
@@ -3,14 +3,14 @@ SetFilenameVars: ${.PARSEDIR} = `<curdir
 Parsing line 17: .info trace with multi-line .for loop head
 make: "opt-debug-parse.mk" line 17: trace with multi-line .for loop head
 	in .include from opt-debug-parse.mk:18
-ParseEOF: returning to file opt-debug-parse.mk, line 18
+ParseEOF: returning to file opt-debug-parse.mk, line 19
 SetFilenameVars: ${.PARSEDIR} = `<curdir>' ${.PARSEFILE} = `opt-debug-parse.mk'
-Parsing line 23: .include "/dev/null"
+Parsing line 24: .include "/dev/null"
 Parse_PushInput: file /dev/null, line 1
 SetFilenameVars: ${.PARSEDIR} = `/dev' ${.PARSEFILE} = `null'
 SetFilenameVars: ${.INCLUDEDFROMDIR} = `<curdir>' ${.INCLUDEDFROMFILE} = `opt-debug-parse.mk'
-ParseEOF: returning to file opt-debug-parse.mk, line 23
+ParseEOF: returning to file opt-debug-parse.mk, line 25
 SetFilenameVars: ${.PARSEDIR} = `<curdir>' ${.PARSEFILE} = `opt-debug-parse.mk'
-Parsing line 25: .MAKEFLAGS: -d0
+Parsing line 26: .MAKEFLAGS: -d0
 ParseDependency(.MAKEFLAGS: -d0)
 exit status 0

Index: src/usr.bin/make/unit-tests/opt-debug-parse.mk
diff -u src/usr.bin/make/unit-tests/opt-debug-parse.mk:1.3 src/usr.bin/make/unit-tests/opt-debug-parse.mk:1.4
--- src/usr.bin/make/unit-tests/opt-debug-parse.mk:1.3	Sat Jan  8 22:13:43 2022
+++ src/usr.bin/make/unit-tests/opt-debug-parse.mk	Sat Jan  8 22:24:20 2022
@@ -1,4 +1,4 @@
-# $NetBSD: opt-debug-parse.mk,v 1.3 2022/01/08 22:13:43 rillig Exp $
+# $NetBSD: opt-debug-parse.mk,v 1.4 2022/01/08 22:24:20 rillig Exp $
 #
 # Tests for the -dp command line option, which adds debug logging about
 # makefile parsing.
@@ -16,10 +16,11 @@
     value
 .info trace with multi-line .for loop head
 .endfor
-# FIXME: The .exp file says 'in .include from opt-debug-parse.mk:19', which is
+# FIXME: The .exp file says 'in .include from opt-debug-parse.mk:18', which is
 # completely wrong.  It should rather say 'in .for loop from :13'.
 
-# XXX: The debug log should return to "line 24" instead of "line 23".
+# Before parse.c 1.461 from 2022-01-08, the debug log said it returned to
+# the line of the '.include' instead of the line following it.
 .include "/dev/null"
 
 .MAKEFLAGS: -d0

Reply via email to