Module Name:    src
Committed By:   rillig
Date:           Sat Dec 19 17:54:29 UTC 2020

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

Log Message:
make(1): extract ParseSkippedBranches from ParseReadLine


To generate a diff of this commit:
cvs rdiff -u -r1.500 -r1.501 src/usr.bin/make/parse.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/parse.c
diff -u src/usr.bin/make/parse.c:1.500 src/usr.bin/make/parse.c:1.501
--- src/usr.bin/make/parse.c:1.500	Sat Dec 19 17:49:11 2020
+++ src/usr.bin/make/parse.c	Sat Dec 19 17:54:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.500 2020/12/19 17:49:11 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.501 2020/12/19 17:54:29 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.500 2020/12/19 17:49:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.501 2020/12/19 17:54:29 rillig Exp $");
 
 /* types and constants */
 
@@ -2865,6 +2865,32 @@ ParseGetLine(GetLineMode mode)
 }
 
 static Boolean
+ParseSkippedBranches(void)
+{
+	char *line;
+
+	while ((line = ParseGetLine(GLM_DOT)) != NULL) {
+		if (Cond_EvalLine(line) == COND_PARSE)
+			break;
+		/*
+		 * TODO: Check for typos in .elif directives
+		 * such as .elsif or .elseif.
+		 *
+		 * This check will probably duplicate some of
+		 * the code in ParseLine.  Most of the code
+		 * there cannot apply, only ParseVarassign and
+		 * ParseDependency can, and to prevent code
+		 * duplication, these would need to be called
+		 * with a flag called onlyCheckSyntax.
+		 *
+		 * See directive-elif.mk for details.
+		 */
+	}
+
+	return line != NULL;
+}
+
+static Boolean
 ParseForLoop(const char *line)
 {
 	int rval;
@@ -2923,24 +2949,7 @@ ParseReadLine(void)
 		 */
 		switch (Cond_EvalLine(line)) {
 		case COND_SKIP:
-			while ((line = ParseGetLine(GLM_DOT)) != NULL) {
-				if (Cond_EvalLine(line) == COND_PARSE)
-					break;
-				/*
-				 * TODO: Check for typos in .elif directives
-				 * such as .elsif or .elseif.
-				 *
-				 * This check will probably duplicate some of
-				 * the code in ParseLine.  Most of the code
-				 * there cannot apply, only ParseVarassign and
-				 * ParseDependency can, and to prevent code
-				 * duplication, these would need to be called
-				 * with a flag called onlyCheckSyntax.
-				 *
-				 * See directive-elif.mk for details.
-				 */
-			}
-			if (line == NULL)
+			if (!ParseSkippedBranches())
 				return NULL;
 			continue;
 		case COND_PARSE:

Reply via email to