OK, I got it wrong. Let's try again:
N=2 # fill in number of characters to drop from the right
:0
* 1^1 VAR ?? .
* $ -$N^0
{
NEWLENGTH = $=
DOTSTRING = .
INCLUDERC = .builddotstringrc
# after all calls to .builddotstringrc are done and DOTSTRING is redefined,
# we are back in the main rcfile:
:0
* $ VAR ?? ^^\/$DOTSTRING
{ ret = $MATCH }
}
:0E
{ LOG="\$VAR is too short to drop $N characters.
" }
# and here is .builddotstringrc as likewise fixed
# Add periods to $DOTSTRING until is it $NEWLENGTH characters long.
:0
* $ $NEWLENGTH^0
* -1^1 DOTSTRING ?? .
{
DOTSTRING = .$DOTSTRING
INCLUDERC = $_
}
| Yecch.
That hasn't changed. Again, this code is ugly in any case and inoperative
if the variable to truncate contains any embedded newlines.