| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: varmod-to-separator.mk,v 1.4 2020/11/01 11:50:11 rillig Exp $ | | 1 | # $NetBSD: varmod-to-separator.mk,v 1.5 2020/11/01 13:28:50 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" |
| @@ -110,29 +110,56 @@ WORDS= one two three four five six | | | @@ -110,29 +110,56 @@ WORDS= one two three four five six |
110 | | | 110 | |
111 | # The separator can be given as hexadecimal number. | | 111 | # The separator can be given as hexadecimal number. |
112 | .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" |
113 | . warning The separator \xa is not interpreted in hexadecimal ASCII. | | 113 | . warning The separator \xa is not interpreted in hexadecimal ASCII. |
114 | .endif | | 114 | .endif |
115 | | | 115 | |
116 | # The hexadecimal number must be in the range of an unsigned char. | | 116 | # The hexadecimal number must be in the range of an unsigned char. |
117 | .if ${WORDS:[1..3]:ts\x100:tu} | | 117 | .if ${WORDS:[1..3]:ts\x100:tu} |
118 | . warning The separator \x100 is accepted even though it is out of bounds. | | 118 | . warning The separator \x100 is accepted even though it is out of bounds. |
119 | .else | | 119 | .else |
120 | . warning The separator \x100 is accepted even though it is out of bounds. | | 120 | . warning The separator \x100 is accepted even though it is out of bounds. |
121 | .endif | | 121 | .endif |
122 | | | 122 | |
| | | 123 | # Negative numbers are not allowed for the separator character. |
| | | 124 | .if ${WORDS:[1..3]:ts\-300:tu} |
| | | 125 | . warning The separator \-300 is accepted even though it is negative. |
| | | 126 | .else |
| | | 127 | . warning The separator \-300 is accepted even though it is negative. |
| | | 128 | .endif |
| | | 129 | |
| | | 130 | # The character number is interpreted as octal number by default. |
| | | 131 | # The digit '8' is not an octal digit though. |
| | | 132 | .if ${1 2 3:L:ts\8:tu} |
| | | 133 | . warning The separator \8 is accepted even though it is not octal. |
| | | 134 | .else |
| | | 135 | . warning The separator \8 is accepted even though it is not octal. |
| | | 136 | .endif |
| | | 137 | |
| | | 138 | # Trailing characters after the octal character number are rejected. |
| | | 139 | .if ${1 2 3:L:ts\100L} |
| | | 140 | . warning The separator \100L is accepted even though it contains an 'L'. |
| | | 141 | .else |
| | | 142 | . warning The separator \100L is accepted even though it contains an 'L'. |
| | | 143 | .endif |
| | | 144 | |
| | | 145 | # Trailing characters after the hexadecimal character number are rejected. |
| | | 146 | .if ${1 2 3:L:ts\x40g} |
| | | 147 | . warning The separator \x40g is accepted even though it contains a 'g'. |
| | | 148 | .else |
| | | 149 | . warning The separator \x40g is accepted even though it contains a 'g'. |
| | | 150 | .endif |
| | | 151 | |
| | | 152 | |
123 | # In the :t modifier, the :t must be followed by any of A, l, s, u. | | 153 | # In the :t modifier, the :t must be followed by any of A, l, s, u. |
124 | .if ${WORDS:tx} != "anything" | | 154 | .if ${WORDS:tx} != "anything" |
125 | . info This line is not reached because of the malformed condition. | | 155 | . info This line is not reached because of the malformed condition. |
126 | . info If this line were reached, it would be visible in the -dcpv log. | | 156 | . info If this line were reached, it would be visible in the -dcpv log. |
127 | .endif | | 157 | .endif |
128 | .info Parsing continues here. | | | |
129 | | | 158 | |
130 | # After the backslash, only n, t, an octal number, or x and a hexadecimal | | 159 | # After the backslash, only n, t, an octal number, or x and a hexadecimal |
131 | # number are allowed. | | 160 | # number are allowed. |
132 | .if ${WORDS:t\X} != "anything" | | 161 | .if ${WORDS:t\X} != "anything" |
133 | . info This line is not reached. | | 162 | . info This line is not reached. |
134 | .endif | | 163 | .endif |
135 | .info Parsing continues here. | | | |
136 | | | 164 | |
137 | all: | | 165 | all: |
138 | @:; | | | |