Module Name:    src
Committed By:   rillig
Date:           Sat Aug  8 13:31:24 UTC 2020

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

Log Message:
make(1): improve documentation of Var_Parse and reorder conditions


To generate a diff of this commit:
cvs rdiff -u -r1.428 -r1.429 src/usr.bin/make/var.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/var.c
diff -u src/usr.bin/make/var.c:1.428 src/usr.bin/make/var.c:1.429
--- src/usr.bin/make/var.c:1.428	Sat Aug  8 13:27:42 2020
+++ src/usr.bin/make/var.c	Sat Aug  8 13:31:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.428 2020/08/08 13:27:42 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.429 2020/08/08 13:31:24 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.428 2020/08/08 13:27:42 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.429 2020/08/08 13:31:24 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.428 2020/08/08 13:27:42 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.429 2020/08/08 13:31:24 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3273,7 +3273,7 @@ VarIsDynamic(GNode *ctxt, const char *va
  *	freePtr		OUT: Non-NULL if caller should free *freePtr
  *
  * Results:
- *	The (possibly-modified) value of the variable or var_Error if the
+ *	The value of the variable expression or var_Error if the
  *	specification is invalid. The length of the specification is
  *	placed in *lengthPtr (for invalid specifications, this is just
  *	2...?).
@@ -3281,8 +3281,7 @@ VarIsDynamic(GNode *ctxt, const char *va
  *	should pass to free() to free memory used by the result.
  *
  * Side Effects:
- *	None.
- *
+ *	Any effects from the modifiers, such as :!cmd! or ::=value.
  *-----------------------------------------------------------------------
  */
 /* coverity[+alloc : arg-*4] */
@@ -3292,9 +3291,9 @@ Var_Parse(const char * const str, GNode 
 {
     const char	*tstr;		/* Pointer into str */
     Boolean 	 haveModifier;	/* TRUE if have modifiers for the variable */
-    char	 startc;	/* Starting character when variable in parens
+    char	 startc;	/* Starting character if variable in parens
 				 * or braces */
-    char	 endc;		/* Ending character when variable in parens
+    char	 endc;		/* Ending character if variable in parens
 				 * or braces */
     Boolean	 dynamic;	/* TRUE if the variable is local and we're
 				 * expanding it in a non-local context. This
@@ -3378,7 +3377,7 @@ Var_Parse(const char * const str, GNode 
 		if (--depth == 0)
 		    break;
 	    }
-	    if (depth == 1 && *tstr == ':')
+	    if (*tstr == ':' && depth == 1)
 		break;
 	    /* A variable inside a variable, expand. */
 	    if (*tstr == '$') {

Reply via email to