Module Name:    src
Committed By:   rillig
Date:           Sat Oct 17 20:57:08 UTC 2020

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

Log Message:
make(1): extract ParseLine from Parse_File


To generate a diff of this commit:
cvs rdiff -u -r1.380 -r1.381 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.380 src/usr.bin/make/parse.c:1.381
--- src/usr.bin/make/parse.c:1.380	Sat Oct 17 20:51:34 2020
+++ src/usr.bin/make/parse.c	Sat Oct 17 20:57:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.380 2020/10/17 20:51:34 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.381 2020/10/17 20:57:08 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.380 2020/10/17 20:51:34 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.381 2020/10/17 20:57:08 rillig Exp $");
 
 /* types and constants */
 
@@ -3041,6 +3041,46 @@ ParseDependency(char *line)
 	ParseLine_ShellCommand(shellcmd);
 }
 
+static void
+ParseLine(char *line)
+{
+    if (ParseDirective(line))
+	return;
+
+    if (*line == '\t') {
+	ParseLine_ShellCommand(line + 1);
+	return;
+    }
+
+#ifdef SYSVINCLUDE
+    if (IsSysVInclude(line)) {
+	/*
+	 * It's an S3/S5-style "include".
+	 */
+	ParseTraditionalInclude(line);
+	return;
+    }
+#endif
+
+#ifdef GMAKEEXPORT
+    if (strncmp(line, "export", 6) == 0 && ch_isspace(line[6]) &&
+	strchr(line, ':') == NULL) {
+	/*
+	 * It's a Gmake "export".
+	 */
+	ParseGmakeExport(line);
+	return;
+    }
+#endif
+
+    if (ParseVarassign(line))
+	return;
+
+    FinishDependencyGroup();
+
+    ParseDependency(line);
+}
+
 /* Parse a top-level makefile into its component parts, incorporating them
  * into the global dependency graph.
  *
@@ -3066,42 +3106,9 @@ Parse_File(const char *name, int fd)
     curFile->lf = lf;
 
     do {
-	for (; (line = ParseReadLine()) != NULL; ) {
+	while ((line = ParseReadLine()) != NULL) {
 	    DEBUG2(PARSE, "ParseReadLine (%d): '%s'\n", curFile->lineno, line);
-
-	    if (ParseDirective(line))
-		continue;
-
-	    if (*line == '\t') {
-		ParseLine_ShellCommand(line + 1);
-		continue;
-	    }
-
-#ifdef SYSVINCLUDE
-	    if (IsSysVInclude(line)) {
-		/*
-		 * It's an S3/S5-style "include".
-		 */
-		ParseTraditionalInclude(line);
-		continue;
-	    }
-#endif
-#ifdef GMAKEEXPORT
-	    if (strncmp(line, "export", 6) == 0 && ch_isspace(line[6]) &&
-		strchr(line, ':') == NULL) {
-		/*
-		 * It's a Gmake "export".
-		 */
-		ParseGmakeExport(line);
-		continue;
-	    }
-#endif
-	    if (ParseVarassign(line))
-		continue;
-
-	    FinishDependencyGroup();
-
-	    ParseDependency(line);
+	    ParseLine(line);
 	}
 	/*
 	 * Reached EOF, but it may be just EOF of an include file...

Reply via email to