Module Name:    src
Committed By:   rillig
Date:           Fri Jan  7 22:08:09 UTC 2022

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

Log Message:
make: remove redundant condition in ParseRawLine

The input buffer is guaranteed to be terminated by '\n'.  This means
that after a '\\', there is no need to check for the end of that buffer.

While here, condense ReadLowLevelLine.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.636 -r1.637 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.636 src/usr.bin/make/parse.c:1.637
--- src/usr.bin/make/parse.c:1.636	Fri Jan  7 21:57:26 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 22:08:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.636 2022/01/07 21:57:26 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.637 2022/01/07 22:08:09 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.636 2022/01/07 21:57:26 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.637 2022/01/07 22:08:09 rillig Exp $");
 
 /*
  * A file being read.
@@ -2320,8 +2320,7 @@ ParseRawLine(IncludedFile *curFile, char
 		}
 
 		ch = *p;
-		if (ch == '\0' ||
-		    (ch == '\\' && p + 1 < buf_end && p[1] == '\0')) {
+		if (ch == '\0' || (ch == '\\' && p[1] == '\0')) {
 			Parse_Error(PARSE_FATAL, "Zero byte read from file");
 			return PRLR_ERROR;
 		}
@@ -2481,17 +2480,10 @@ ReadLowLevelLine(LineKind kind)
 		break;
 	}
 
-	/* Ignore anything after a non-escaped '#' in non-commands. */
 	if (commentLineEnd != NULL && line[0] != '\t')
 		*commentLineEnd = '\0';
-
-	/* If we didn't see a '\\' then the in-situ data is fine. */
-	if (firstBackslash == NULL)
-		return line;
-
-	/* Remove escapes from '\n' and '#' */
-	UnescapeBackslash(line, firstBackslash);
-
+	if (firstBackslash != NULL)
+		UnescapeBackslash(line, firstBackslash);
 	return line;
 }
 

Reply via email to