Module Name:    src
Committed By:   rillig
Date:           Mon Jul 27 23:56:15 UTC 2020

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

Log Message:
make(1): document and reorder ApplyModifiersState


To generate a diff of this commit:
cvs rdiff -u -r1.349 -r1.350 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.349 src/usr.bin/make/var.c:1.350
--- src/usr.bin/make/var.c:1.349	Mon Jul 27 23:37:37 2020
+++ src/usr.bin/make/var.c	Mon Jul 27 23:56:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.349 2020/07/27 23:37:37 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.350 2020/07/27 23:56:15 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.349 2020/07/27 23:37:37 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.350 2020/07/27 23:56:15 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.349 2020/07/27 23:37:37 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.350 2020/07/27 23:56:15 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2036,16 +2036,24 @@ VarStrftime(const char *fmt, int zulu, t
     return bmake_strdup(buf);
 }
 
+/* The ApplyModifier functions all work in the same way.
+ * They parse the modifier (often until the next colon) and store the
+ * updated position for the parser into st->next.
+ * They take the st->val and generate st->newVal from it.
+ * On success, they set st->termc to *st->next, redundantly.
+ * On failure, many of them update st->missing_delim.
+ */
 typedef struct {
-    /* const parameters */
     int startc;			/* '\0' or '{' or '(' */
     int endc;
     Var *v;
     GNode *ctxt;
     VarEvalFlags eflags;
 
-    /* read-write */
-    char *val;
+    char *val;			/* The value of the expression before the
+				 * modifier is applied */
+    char *newVal;		/* The new value after applying the modifier
+				 * to the expression */
     const char *next;		/* The position where parsing continues
 				 * after the current modifier. */
     char termc;			/* Character which terminated scan */
@@ -2058,8 +2066,6 @@ typedef struct {
 				 * usual behaviour of treating it as
 				 * several space-separated words). */
 
-    /* result */
-    char *newVal;		/* New value to return */
 } ApplyModifiersState;
 
 /* we now have some modifiers with long names */
@@ -3070,7 +3076,7 @@ ApplyModifiers(char *val, const char * c
 {
     ApplyModifiersState st = {
 	startc, endc, v, ctxt, eflags,
-	val, tstr, '\0', '\0', ' ', FALSE, NULL
+	val, NULL, NULL, '\0', '\0', ' ', FALSE
     };
 
     const char *p = tstr;

Reply via email to