| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: varmod-to-separator.mk,v 1.3 2020/08/31 19:58:21 rillig Exp $ | | 1 | # $NetBSD: varmod-to-separator.mk,v 1.4 2020/11/01 11:50:11 rillig Exp $ |
2 | # | | 2 | # |
3 | # Tests for the :ts variable modifier, which joins the words of the variable | | 3 | # Tests for the :ts variable modifier, which joins the words of the variable |
4 | # using an arbitrary character as word separator. | | 4 | # using an arbitrary character as word separator. |
5 | | | 5 | |
6 | WORDS= one two three four five six | | 6 | WORDS= one two three four five six |
7 | | | 7 | |
8 | # The words are separated by a single space, just as usual. | | 8 | # The words are separated by a single space, just as usual. |
9 | .if ${WORDS:ts } != "one two three four five six" | | 9 | .if ${WORDS:ts } != "one two three four five six" |
10 | . warning Space as separator does not work. | | 10 | . warning Space as separator does not work. |
11 | .endif | | 11 | .endif |
12 | | | 12 | |
13 | # The separator can be an arbitrary character, for example a comma. | | 13 | # The separator can be an arbitrary character, for example a comma. |
14 | .if ${WORDS:ts,} != "one,two,three,four,five,six" | | 14 | .if ${WORDS:ts,} != "one,two,three,four,five,six" |
| @@ -85,31 +85,51 @@ WORDS= one two three four five six | | | @@ -85,31 +85,51 @@ WORDS= one two three four five six |
85 | . warning The separator \n does not produce a newline. | | 85 | . warning The separator \n does not produce a newline. |
86 | .endif | | 86 | .endif |
87 | | | 87 | |
88 | # The separator can be \t, which is a tab. | | 88 | # The separator can be \t, which is a tab. |
89 | .if ${WORDS:[1..3]:ts\t} != "one two three" | | 89 | .if ${WORDS:[1..3]:ts\t} != "one two three" |
90 | . warning The separator \t does not produce a tab. | | 90 | . warning The separator \t does not produce a tab. |
91 | .endif | | 91 | .endif |
92 | | | 92 | |
93 | # The separator can be given as octal number. | | 93 | # The separator can be given as octal number. |
94 | .if ${WORDS:[1..3]:ts\012:tu} != "ONE${.newline}TWO${.newline}THREE" | | 94 | .if ${WORDS:[1..3]:ts\012:tu} != "ONE${.newline}TWO${.newline}THREE" |
95 | . warning The separator \012 is not interpreted in octal ASCII. | | 95 | . warning The separator \012 is not interpreted in octal ASCII. |
96 | .endif | | 96 | .endif |
97 | | | 97 | |
| | | 98 | # The octal number can have as many digits as it wants. |
| | | 99 | .if ${WORDS:[1..2]:ts\000000000000000000000000012:tu} != "ONE${.newline}TWO" |
| | | 100 | . warning The separator \012 cannot have many leading zeroes. |
| | | 101 | .endif |
| | | 102 | |
| | | 103 | # The value of the separator character must not be outside the value space |
| | | 104 | # for an unsigned character though. |
| | | 105 | .if ${WORDS:[1..3]:ts\400:tu} |
| | | 106 | . warning The separator \400 is accepted even though it is out of bounds. |
| | | 107 | .else |
| | | 108 | . warning The separator \400 is accepted even though it is out of bounds. |
| | | 109 | .endif |
| | | 110 | |
98 | # The separator can be given as hexadecimal number. | | 111 | # The separator can be given as hexadecimal number. |
99 | .if ${WORDS:[1..3]:ts\xa:tu} != "ONE${.newline}TWO${.newline}THREE" | | 112 | .if ${WORDS:[1..3]:ts\xa:tu} != "ONE${.newline}TWO${.newline}THREE" |
100 | . warning The separator \xa is not interpreted in hexadecimal ASCII. | | 113 | . warning The separator \xa is not interpreted in hexadecimal ASCII. |
101 | .endif | | 114 | .endif |
102 | | | 115 | |
| | | 116 | # The hexadecimal number must be in the range of an unsigned char. |
| | | 117 | .if ${WORDS:[1..3]:ts\x100:tu} |
| | | 118 | . warning The separator \x100 is accepted even though it is out of bounds. |
| | | 119 | .else |
| | | 120 | . warning The separator \x100 is accepted even though it is out of bounds. |
| | | 121 | .endif |
| | | 122 | |
103 | # In the :t modifier, the :t must be followed by any of A, l, s, u. | | 123 | # In the :t modifier, the :t must be followed by any of A, l, s, u. |
104 | .if ${WORDS:tx} != "anything" | | 124 | .if ${WORDS:tx} != "anything" |
105 | . info This line is not reached because of the malformed condition. | | 125 | . info This line is not reached because of the malformed condition. |
106 | . info If this line were reached, it would be visible in the -dcpv log. | | 126 | . info If this line were reached, it would be visible in the -dcpv log. |
107 | .endif | | 127 | .endif |
108 | .info Parsing continues here. | | 128 | .info Parsing continues here. |
109 | | | 129 | |
110 | # After the backslash, only n, t, an octal number, or x and a hexadecimal | | 130 | # After the backslash, only n, t, an octal number, or x and a hexadecimal |
111 | # number are allowed. | | 131 | # number are allowed. |
112 | .if ${WORDS:t\X} != "anything" | | 132 | .if ${WORDS:t\X} != "anything" |
113 | . info This line is not reached. | | 133 | . info This line is not reached. |
114 | .endif | | 134 | .endif |
115 | .info Parsing continues here. | | 135 | .info Parsing continues here. |