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: sync comment about duplicated code with r...



details:   https://anonhg.NetBSD.org/src/rev/1c696df11254
branches:  trunk
changeset: 959517:1c696df11254
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Feb 16 16:14:27 2021 +0000

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

diffstat:

 usr.bin/make/var.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r 97257af70227 -r 1c696df11254 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Tue Feb 16 15:30:26 2021 +0000
+++ b/usr.bin/make/var.c        Tue Feb 16 16:14:27 2021 +0000
@@ -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,



Home | Main Index | Thread Index | Old Index