Module Name:    src
Committed By:   rillig
Date:           Sun Dec 27 10:04:32 UTC 2020

Modified Files:
        src/usr.bin/make: for.c

Log Message:
make(1): add error handling for .for loop items

Right now, Var_Subst always returns VPR_OK, even if there had been parse
errors or evaluation errors.  If that is no longer true, the errors will
be reported properly.


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/usr.bin/make/for.c

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/for.c
diff -u src/usr.bin/make/for.c:1.120 src/usr.bin/make/for.c:1.121
--- src/usr.bin/make/for.c:1.120	Sat Dec 19 13:31:37 2020
+++ src/usr.bin/make/for.c	Sun Dec 27 10:04:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.120 2020/12/19 13:31:37 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.121 2020/12/27 10:04:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -60,7 +60,7 @@
 #include "make.h"
 
 /*	"@(#)for.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: for.c,v 1.120 2020/12/19 13:31:37 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.121 2020/12/27 10:04:32 rillig Exp $");
 
 static int forLevel = 0;	/* Nesting level */
 
@@ -206,8 +206,12 @@ For_Eval(const char *line)
 
 	{
 		char *items;
-		(void)Var_Subst(p, VAR_GLOBAL, VARE_WANTRES, &items);
-		/* TODO: handle errors */
+		if (Var_Subst(p, VAR_GLOBAL, VARE_WANTRES, &items) != VPR_OK) {
+			Parse_Error(PARSE_FATAL, "Error in .for loop items");
+			f->items.len = 0;
+			goto done;
+		}
+
 		f->items = Str_Words(items, FALSE);
 		free(items);
 
@@ -233,6 +237,7 @@ For_Eval(const char *line)
 		}
 	}
 
+done:
 	accumFor = f;
 	forLevel = 1;
 	return 1;

Reply via email to