Module Name:    src
Committed By:   rillig
Date:           Sun Jan  2 02:57:39 UTC 2022

Modified Files:
        src/usr.bin/make: cond.c parse.c
        src/usr.bin/make/unit-tests: cond-token-number.mk

Log Message:
make: clean up nitpicks

In ParseWord, the expressions '*p' and 'ch' are the same.

In ParseDependencyTargetWord, clean up a wordy comment and join two
conditions.

In the test cond-token-number, clarify that make doesn't convert from
hex to decimal but only from hex to internal representation.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.321 -r1.322 src/usr.bin/make/cond.c
cvs rdiff -u -r1.618 -r1.619 src/usr.bin/make/parse.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-token-number.mk

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/cond.c
diff -u src/usr.bin/make/cond.c:1.321 src/usr.bin/make/cond.c:1.322
--- src/usr.bin/make/cond.c:1.321	Thu Dec 30 02:14:55 2021
+++ src/usr.bin/make/cond.c	Sun Jan  2 02:57:39 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.321 2021/12/30 02:14:55 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.322 2022/01/02 02:57:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.321 2021/12/30 02:14:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.322 2022/01/02 02:57:39 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -225,7 +225,7 @@ ParseWord(const char **pp, bool doEval)
 			break;
 		if ((ch == '&' || ch == '|') && paren_depth == 0)
 			break;
-		if (*p == '$') {
+		if (ch == '$') {
 			/*
 			 * Parse the variable expression and install it as
 			 * part of the argument if it's valid. We tell
@@ -248,7 +248,7 @@ ParseWord(const char **pp, bool doEval)
 			paren_depth++;
 		else if (ch == ')' && --paren_depth < 0)
 			break;
-		Buf_AddByte(&argBuf, *p);
+		Buf_AddByte(&argBuf, ch);
 		p++;
 	}
 

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.618 src/usr.bin/make/parse.c:1.619
--- src/usr.bin/make/parse.c:1.618	Sun Jan  2 02:39:55 2022
+++ src/usr.bin/make/parse.c	Sun Jan  2 02:57:39 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.618 2022/01/02 02:39:55 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.619 2022/01/02 02:57:39 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.618 2022/01/02 02:39:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.619 2022/01/02 02:57:39 rillig Exp $");
 
 /*
  * Structure for a file being read ("included file")
@@ -884,8 +884,7 @@ ParseDependencyTargetWord(char **pp, con
 		if (*cp == '$') {
 			/*
 			 * Must be a dynamic source (would have been expanded
-			 * otherwise), so call the Var module to parse the
-			 * puppy so we can safely advance beyond it.
+			 * otherwise).
 			 *
 			 * There should be no errors in this, as they would
 			 * have been discovered in the initial Var_Subst and
@@ -1790,9 +1789,8 @@ MaybeSubMake(const char *cmd)
 		if (*p == '.')	/* Accept either ${.MAKE} or ${MAKE}. */
 			p++;
 
-		if (strncmp(p, "MAKE", 4) == 0)
-			if (p[4] == endc)
-				return true;
+		if (strncmp(p, "MAKE", 4) == 0 && p[4] == endc)
+			return true;
 	}
 	return false;
 }

Index: src/usr.bin/make/unit-tests/cond-token-number.mk
diff -u src/usr.bin/make/unit-tests/cond-token-number.mk:1.6 src/usr.bin/make/unit-tests/cond-token-number.mk:1.7
--- src/usr.bin/make/unit-tests/cond-token-number.mk:1.6	Mon Dec 27 18:54:19 2021
+++ src/usr.bin/make/unit-tests/cond-token-number.mk	Sun Jan  2 02:57:39 2022
@@ -1,4 +1,4 @@
-# $NetBSD: cond-token-number.mk,v 1.6 2021/12/27 18:54:19 rillig Exp $
+# $NetBSD: cond-token-number.mk,v 1.7 2022/01/02 02:57:39 rillig Exp $
 #
 # Tests for number tokens in .if conditions.
 #
@@ -78,7 +78,7 @@
 .  error
 .endif
 
-# Make can do radix conversion from hex to decimal.
+# Make can do radix conversion from hex.
 HEX=	dead
 .if 0x${HEX} == 57005
 .else

Reply via email to