| @@ -1,33 +1,34 @@ | | | @@ -1,33 +1,34 @@ |
1 | # $Id: modmisc.mk,v 1.13 2020/07/19 15:16:22 rillig Exp $ | | 1 | # $Id: modmisc.mk,v 1.14 2020/07/19 17:24:22 rillig Exp $ |
2 | # | | 2 | # |
3 | # miscellaneous modifier tests | | 3 | # miscellaneous modifier tests |
4 | | | 4 | |
5 | # do not put any dirs in this list which exist on some | | 5 | # do not put any dirs in this list which exist on some |
6 | # but not all target systems - an exists() check is below. | | 6 | # but not all target systems - an exists() check is below. |
7 | path=:/bin:/tmp::/:.:/no/such/dir:. | | 7 | path=:/bin:/tmp::/:.:/no/such/dir:. |
8 | # strip cwd from path. | | 8 | # strip cwd from path. |
9 | MOD_NODOT=S/:/ /g:N.:ts: | | 9 | MOD_NODOT=S/:/ /g:N.:ts: |
10 | # and decorate, note that $'s need to be doubled. Also note that | | 10 | # and decorate, note that $'s need to be doubled. Also note that |
11 | # the modifier_variable can be used with other modifiers. | | 11 | # the modifier_variable can be used with other modifiers. |
12 | MOD_NODOTX=S/:/ /g:N.:@d@'$$d'@ | | 12 | MOD_NODOTX=S/:/ /g:N.:@d@'$$d'@ |
13 | # another mod - pretend it is more interesting | | 13 | # another mod - pretend it is more interesting |
14 | MOD_HOMES=S,/home/,/homes/, | | 14 | MOD_HOMES=S,/home/,/homes/, |
15 | MOD_OPT=@d@$${exists($$d):?$$d:$${d:S,/usr,/opt,}}@ | | 15 | MOD_OPT=@d@$${exists($$d):?$$d:$${d:S,/usr,/opt,}}@ |
16 | MOD_SEP=S,:, ,g | | 16 | MOD_SEP=S,:, ,g |
17 | | | 17 | |
18 | all: modvar modvarloop modsysv mod-HTE emptyvar undefvar | | 18 | all: modvar modvarloop modsysv mod-HTE emptyvar undefvar |
19 | all: mod-S mod-C mod-at-varname mod-at-resolve mod-at-dollar | | 19 | all: mod-S mod-C mod-at-varname mod-at-resolve mod-at-dollar |
20 | all: mod-subst-dollar mod-loop-dollar | | 20 | all: mod-subst-dollar mod-loop-dollar |
| | | 21 | all: mod-C-limits |
21 | | | 22 | |
22 | modsysv: | | 23 | modsysv: |
23 | @echo "The answer is ${libfoo.a:L:libfoo.a=42}" | | 24 | @echo "The answer is ${libfoo.a:L:libfoo.a=42}" |
24 | | | 25 | |
25 | modvar: | | 26 | modvar: |
26 | @echo "path='${path}'" | | 27 | @echo "path='${path}'" |
27 | @echo "path='${path:${MOD_NODOT}}'" | | 28 | @echo "path='${path:${MOD_NODOT}}'" |
28 | @echo "path='${path:S,home,homes,:${MOD_NODOT}}'" | | 29 | @echo "path='${path:S,home,homes,:${MOD_NODOT}}'" |
29 | @echo "path=${path:${MOD_NODOTX}:ts:}" | | 30 | @echo "path=${path:${MOD_NODOTX}:ts:}" |
30 | @echo "path=${path:${MOD_HOMES}:${MOD_NODOTX}:ts:}" | | 31 | @echo "path=${path:${MOD_HOMES}:${MOD_NODOTX}:ts:}" |
31 | | | 32 | |
32 | .for d in ${path:${MOD_SEP}:N.} /usr/xbin | | 33 | .for d in ${path:${MOD_SEP}:N.} /usr/xbin |
33 | path_$d?= ${d:${MOD_OPT}:${MOD_HOMES}}/ | | 34 | path_$d?= ${d:${MOD_OPT}:${MOD_HOMES}}/ |
| @@ -123,13 +124,21 @@ mod-subst-dollar: | | | @@ -123,13 +124,21 @@ mod-subst-dollar: |
123 | # Demonstrate that it is possible to generate dollar characters using the | | 124 | # Demonstrate that it is possible to generate dollar characters using the |
124 | # :@ modifier. | | 125 | # :@ modifier. |
125 | # | | 126 | # |
126 | # These are edge cases that could have resulted in a parse error as well | | 127 | # These are edge cases that could have resulted in a parse error as well |
127 | # since the $@ at the end could have been interpreted as a variable, which | | 128 | # since the $@ at the end could have been interpreted as a variable, which |
128 | # would mean a missing closing @ delimiter. | | 129 | # would mean a missing closing @ delimiter. |
129 | mod-loop-dollar: | | 130 | mod-loop-dollar: |
130 | @echo $@:${:U1:@word@${word}$@:Q}: | | 131 | @echo $@:${:U1:@word@${word}$@:Q}: |
131 | @echo $@:${:U2:@word@$${word}$$@:Q}: | | 132 | @echo $@:${:U2:@word@$${word}$$@:Q}: |
132 | @echo $@:${:U3:@word@$$${word}$$$@:Q}: | | 133 | @echo $@:${:U3:@word@$$${word}$$$@:Q}: |
133 | @echo $@:${:U4:@word@$$$${word}$$$$@:Q}: | | 134 | @echo $@:${:U4:@word@$$$${word}$$$$@:Q}: |
134 | @echo $@:${:U5:@word@$$$$${word}$$$$$@:Q}: | | 135 | @echo $@:${:U5:@word@$$$$${word}$$$$$@:Q}: |
135 | @echo $@:${:U6:@word@$$$$$${word}$$$$$$@:Q}: | | 136 | @echo $@:${:U6:@word@$$$$$${word}$$$$$$@:Q}: |
| | | 137 | |
| | | 138 | mod-C-limits: |
| | | 139 | @echo $@:00-ok:${:U1 23 456:C,..,\0\0,:Q} |
| | | 140 | @echo $@:11-missing:${:U1 23 456:C,..,\1\1,:Q} |
| | | 141 | @echo $@:11-ok:${:U1 23 456:C,(.).,\1\1,:Q} |
| | | 142 | @echo $@:22-missing:${:U1 23 456:C,..,\2\2,:Q} |
| | | 143 | @echo $@:22-missing:${:U1 23 456:C,(.).,\2\2,:Q} |
| | | 144 | @echo $@:22-ok:${:U1 23 456:C,(.)(.),\2\2,:Q} |