Neither will match more than a single token in the workspace. If the $~ does not
match a single token, the LHS does not match, and the RHS is not called.
There are two ways to circumvent this problem. One alternative is to make the $~
always look up only a single token:
R $~X $* $@ no $1 is not in X
Here, the $* will matchth e .com. Then $~X will correctly look up only the single
token hostC, and correctly not find it.
A second alternative is to invert the logic of the test, and use the $= prefix only when
multiple tokens are in the workspace:
R $=X $@ yes $1 is in X
R $* $@ no $1 is not in X
Here, we first check to see whether the multitokened workspace is in the class $=X,
and return yes if it is. Otherwise, we know it is not in the class.
22.2.3 Back Up and Retry
Multitoken matching operators, such as $+, always try to match the least that they
can (?§18.6.2 on page 660). Sucha simple-minded approachcould lead to problems
in matching (or not matching) classes in the LHS. However, the ability of sendmail to
back up and retry alleviates this problem. For example, consider the following five
tokens in the workspace:
"A" "." "B" "." "C"
and consider the following LHS rule:
R $+ . $=X $*
This is the Title of the Book, eMatter Edition
Copyright ?© 2007 O??™Reilly & Associates, Inc. All rights reserved.
866 | Chapter 22: The C and F (Class Macro) Configuration Commands
Because the $+ tries to match the minimum, it first matches only the A in the workspace.
Pages:
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527