Module Name:    src
Committed By:   rillig
Date:           Tue Feb 16 16:14:27 UTC 2021

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

Log Message:
make: sync comment about duplicated code with reality

There are only very few places in var.c that contain really duplicate
code anymore.

There is still lots of _almost_ duplicate, for example the code for
parsing variable modifiers.  It differs subtly in behavior:

*   The modifiers ':M' and ':N' use '$$' to escape a '$' sign, while
    almost all other modifiers use '\$' for this purpose.

*   The modifiers ':M', ':N', ':S', ':@' and several others parse
    balanced parentheses and braces, allowing '(' to '}' to match.
    The modifiers ':D' and ':U' only treat the end character special but
    not the other 3 of '(){}'.

*   When parsing the modifier ':S' but not evaluating it, the code for
    nested variable expressions is parsed differently from when it is in
    evaluation mode (VARE_WANTRES).  This applies to an outer ':S'
    modifier and an inner ':D' or ':M' modifier.

Since these inconsistencies affect the behavior in edge cases and some
users of make might depend on it, they cannot be fixed by
behavior-preserving refactorings.


To generate a diff of this commit:
cvs rdiff -u -r1.826 -r1.827 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.826 src/usr.bin/make/var.c:1.827
--- src/usr.bin/make/var.c:1.826	Mon Feb 15 18:23:32 2021
+++ src/usr.bin/make/var.c	Tue Feb 16 16:14:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.826 2021/02/15 18:23:32 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.827 2021/02/16 16:14:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -120,7 +120,8 @@
  *
  *	Var_Dump	Print out all variables defined in the given scope.
  *
- * XXX: There's a lot of duplication in these functions.
+ * XXX: There's a lot of almost duplicate code in these functions that only
+ *  differs in subtle details that are not mentioned in the manual page.
  */
 
 #include <sys/stat.h>
@@ -139,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.826 2021/02/15 18:23:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.827 2021/02/16 16:14:27 rillig Exp $");
 
 typedef enum VarFlags {
 	VAR_NONE	= 0,

Reply via email to