Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make: remove redundant condition in ParseRawLine



details:   https://anonhg.NetBSD.org/src/rev/45a1d68683a2
branches:  trunk
changeset: 359498:45a1d68683a2
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jan 07 22:08:09 2022 +0000

description:
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.

diffstat:

 usr.bin/make/parse.c |  18 +++++-------------
 1 files changed, 5 insertions(+), 13 deletions(-)

diffs (48 lines):

diff -r b961ed48a47a -r 45a1d68683a2 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Fri Jan 07 21:57:26 2022 +0000
+++ b/usr.bin/make/parse.c      Fri Jan 07 22:08:09 2022 +0000
@@ -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 @@
                }
 
                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 @@
                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;
 }
 



Home | Main Index | Thread Index | Old Index