1 # $NetBSD: varmod-range.mk,v 1.7 2020/11/01 14:36:25 rillig Exp $
3 # Tests for the :range variable modifier, which generates sequences
4 # of integers from the given range.
9 # The :range modifier generates a sequence of integers, one number per
10 # word of the variable expression's value.
11 .if ${a b c:L:range} != "1 2 3"
15 # To preserve spaces in a word, they can be enclosed in quotes, just like
17 .if ${:U first "the second word" third 4 :range} != "1 2 3 4"
21 # The :range modifier takes the number of words from the value of the
22 # variable expression. If that expression is undefined, the range is
23 # undefined as well. This should not come as a surprise.
28 # The :range modifier can be given a parameter, which makes the generated
29 # range independent from the value or the name of the variable expression.
31 # XXX: As of 2020-09-27, the :range=... modifier does not turn the undefined
32 # expression into a defined one. This looks like an oversight.
33 .if "${:range=5}" != ""
37 # Negative ranges don't make sense.
38 # As of 2020-11-01, they are accepted though, using up all available memory.
45 # The :range modifier requires a number as parameter.
47 # Until 2020-11-01, the parser tried to read the 'x' as a number, failed and
48 # stopped there. It then tried to parse the next modifier at that point,
49 # which failed with the message "Unknown modifier".
51 # Since 2020-11-01, the parser issues a more precise "Invalid number" error
53 .if "${:U:range=x}Rest" != "Rest"
59 # The upper limit of the range must always be given in decimal.
60 # This parse error stops at the 'x', trying to parse it as a variable
62 .if "${:U:range=0x0}Rest" != "Rest"
68 # As of 2020-11-01, numeric overflow is not detected.
69 # Since strtoul returns ULONG_MAX in such a case, it is interpreted as a
70 # very large number, consuming all available memory.
71 #.if "${:U:range=18446744073709551619}Rest" != "Rest"
77 # modifier name too short
78 .if "${a b c:L:rang}Rest" != "Rest"
84 # misspelled modifier name
85 .if "${a b c:L:rango}Rest" != "Rest"
91 # modifier name too long
92 .if "${a b c:L:ranger}Rest" != "Rest"