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: fix typo in manual page, add more tests f...



details:   https://anonhg.NetBSD.org/src/rev/8af6ff98b2ac
branches:  trunk
changeset: 1022633:8af6ff98b2ac
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jul 30 22:16:09 2021 +0000

description:
make: fix typo in manual page, add more tests for the new ':On'

diffstat:

 usr.bin/make/make.1                              |   4 +-
 usr.bin/make/unit-tests/varmod-order-numeric.exp |  17 ++++-
 usr.bin/make/unit-tests/varmod-order-numeric.mk  |  92 ++++++++++++++++++++++-
 usr.bin/make/var.c                               |   8 +-
 4 files changed, 109 insertions(+), 12 deletions(-)

diffs (184 lines):

diff -r 929ed24ca619 -r 8af6ff98b2ac usr.bin/make/make.1
--- a/usr.bin/make/make.1       Fri Jul 30 22:07:14 2021 +0000
+++ b/usr.bin/make/make.1       Fri Jul 30 22:16:09 2021 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: make.1,v 1.297 2021/07/30 19:55:22 sjg Exp $
+.\"    $NetBSD: make.1,v 1.298 2021/07/30 22:16:09 rillig Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"    from: @(#)make.1        8.4 (Berkeley) 3/19/94
 .\"
-.Dd July 30, 2020
+.Dd July 30, 2021
 .Dt MAKE 1
 .Os
 .Sh NAME
diff -r 929ed24ca619 -r 8af6ff98b2ac usr.bin/make/unit-tests/varmod-order-numeric.exp
--- a/usr.bin/make/unit-tests/varmod-order-numeric.exp  Fri Jul 30 22:07:14 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-order-numeric.exp  Fri Jul 30 22:16:09 2021 +0000
@@ -1,1 +1,16 @@
-exit status 0
+make: Bad modifier ":Oxn" for variable "NUMBERS"
+make: "varmod-order-numeric.mk" line 32: Malformed conditional (${NUMBERS:Oxn})
+make: Bad modifier ":typo" for variable "NUMBERS"
+make: "varmod-order-numeric.mk" line 45: Malformed conditional (${NUMBERS:On_typo})
+make: "varmod-order-numeric.mk" line 54: Unknown modifier "_typo"
+make: "varmod-order-numeric.mk" line 54: Malformed conditional (${NUMBERS:Onr_typo})
+make: "varmod-order-numeric.mk" line 63: Unknown modifier "_typo"
+make: "varmod-order-numeric.mk" line 63: Malformed conditional (${NUMBERS:Orn_typo})
+make: "varmod-order-numeric.mk" line 75: Missing argument for ".error"
+make: "varmod-order-numeric.mk" line 83: Unknown modifier "r"
+make: "varmod-order-numeric.mk" line 83: Malformed conditional (${NUMBERS:Onrr})
+make: Bad modifier ":Orrn" for variable "NUMBERS"
+make: "varmod-order-numeric.mk" line 94: Malformed conditional (${NUMBERS:Orrn})
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
diff -r 929ed24ca619 -r 8af6ff98b2ac usr.bin/make/unit-tests/varmod-order-numeric.mk
--- a/usr.bin/make/unit-tests/varmod-order-numeric.mk   Fri Jul 30 22:07:14 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-order-numeric.mk   Fri Jul 30 22:16:09 2021 +0000
@@ -1,18 +1,100 @@
-# $NetBSD: varmod-order-numeric.mk,v 1.1 2021/07/30 19:55:22 sjg Exp $
+# $NetBSD: varmod-order-numeric.mk,v 1.2 2021/07/30 22:16:09 rillig Exp $
 #
 # Tests for the :On variable modifier, which returns the words, sorted in
 # ascending numeric order.
 
-NUMBERS=       3 5 7 1 42 -42 1M 1k
+# This list contains only 32-bit numbers since the make code needs to conform
+# to C90, which does not provide integer types larger than 32 bit.  It uses
+# 'long long' by default, but that type is overridable if necessary.
+# To get 53-bit integers even in C90, it would be possible to switch to
+# 'double' instead, but that would allow floating-point numbers as well, which
+# is out of scope for this variable modifier.
+NUMBERS=       3 5 7 1 42 -42 5K -3m 1M 1k -2G
 
-.if ${NUMBERS:On} != "-42 1 3 5 7 42 1k 1M"
+.if ${NUMBERS:On} != "-2G -3m -42 1 3 5 7 42 1k 5K 1M"
 .  error ${NUMBERS:On}
 .endif
 
-.if ${NUMBERS:Orn} != "1M 1k 42 7 5 3 1 -42"
+.if ${NUMBERS:Orn} != "1M 5K 1k 42 7 5 3 1 -42 -3m -2G"
 .  error ${NUMBERS:Orn}
 .endif
 
+# Both ':Onr' and ':Orn' have the same effect.
+.if ${NUMBERS:Onr} != "1M 5K 1k 42 7 5 3 1 -42 -3m -2G"
+.  error ${NUMBERS:Onr}
+.endif
+
+# Shuffling numerically doesn't make sense, so don't allow 'x' and 'n' to be
+# combined.
+#
+# expect-text: Bad modifier ":Oxn" for variable "NUMBERS"
+# expect+1: Malformed conditional (${NUMBERS:Oxn})
+.if ${NUMBERS:Oxn}
+.  error
+.else
+.  error
+.endif
+
+# Extra characters after ':On' are detected and diagnosed.
+# TODO: Add line number information to the "Bad modifier" diagnostic.
+# TODO: Use uniform diagnostics for ':On' and ':Onr'.
+# TODO: Fix the misleading ':typo' in the diagnostic.
+# TODO: The '_' is already wrong but does not occur in the diagnostic.
+#
+# expect-text: Bad modifier ":typo" for variable "NUMBERS"
+.if ${NUMBERS:On_typo}
+.  error
+.else
+.  error
+.endif
+
+# Extra characters after ':Onr' are detected and diagnosed.
+#
+# expect+1: Unknown modifier "_typo"
+.if ${NUMBERS:Onr_typo}
+.  error
+.else
+.  error
+.endif
+
+# Extra characters after ':Orn' are detected and diagnosed.
+#
+# expect+1: Unknown modifier "_typo"
+.if ${NUMBERS:Orn_typo}
+.  error
+.else
+.  error
+.endif
+
+# Repeating the 'n' is not supported.  In the typical use cases, the sorting
+# criteria are fixed, not computed, therefore allowing this redundancy does
+# not make sense.
+#
+# TODO: This repetition is not diagnosed.
+.if ${NUMBERS:Onn}
+.  error
+.else
+.  error
+.endif
+
+# Repeating the 'r' is not supported as well, for the same reasons as above.
+#
+# expect+1: Unknown modifier "r"
+.if ${NUMBERS:Onrr}
+.  error
+.else
+.  error
+.endif
+
+# Repeating the 'r' is not supported as well, for the same reasons as above.
+#
+# TODO: Use uniform diagnostics for ':Onrr' and ':Orrn'.
+#
+# expect-text: Bad modifier ":Orrn" for variable "NUMBERS"
+.if ${NUMBERS:Orrn}
+.  error
+.else
+.  error
+.endif
 
 all:
-       @:;
diff -r 929ed24ca619 -r 8af6ff98b2ac usr.bin/make/var.c
--- a/usr.bin/make/var.c        Fri Jul 30 22:07:14 2021 +0000
+++ b/usr.bin/make/var.c        Fri Jul 30 22:16:09 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.939 2021/07/30 19:55:22 sjg Exp $    */
+/*     $NetBSD: var.c,v 1.940 2021/07/30 22:16:09 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.939 2021/07/30 19:55:22 sjg Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.940 2021/07/30 22:16:09 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -3311,7 +3311,7 @@
        b = num_val(*(const char *const *)sb);
        return (a > b) ? 1 : (b > a) ? -1 : 0;
 }
-    
+
 static int
 num_cmp_desc(const void *sa, const void *sb)
 {
@@ -3321,7 +3321,7 @@
        b = num_val(*(const char *const *)sb);
        return (a > b) ? -1 : (b > a) ? 1 : 0;
 }
-    
+
 static int
 str_cmp_asc(const void *a, const void *b)
 {



Home | Main Index | Thread Index | Old Index