Date:2011-05-27 17:40:22 (8 years 5 months ago)
Author:Werner Almesberger
Commit:2386f1f7b501cbfeb8af5536f616c9db3d09365a
Message:prod/doc/hmac.pl: allow self-referential macros (not general recursion)

Files: prod/doc/hmac.pl (3 diffs)

Change Details

prod/doc/hmac.pl
198198    die "NAME parameter is missing" unless defined $name;
199199    $d =~ s/$BM/<MACRO/gi;
200200    $d =~ s|$EM|</MACRO>|gi;
201    $mac{$name} = $d;
201# $mac{$name} = $d;
202    $mac{$name} = &expand_macro_list($d, $name);
202203    $args{$name} = { %arg };
203204    }
204205    else {
...... 
214215# Expand first macro
215216#
216217
217sub expand_macro
218sub expand_macro_list
218219{
219    local ($in) = @_;
220    local ($in, @mac) = @_;
220221    local ($a,$b,$c);
221222    local ($mac, $done, $prm, %arg);
222223
223224    undef $a;
224    for $mac (keys %mac) {
225    for $mac (@mac) {
225226    if ($in =~ /<$mac\b(("[^"]*"|[^>])*)>/is) {
226227        ($a,$b,$c) = ($`,$1,$') if length $` < length $a || !defined $a;
227228    }
...... 
259260    }
260261    return $in;
261262}
263
264
265sub expand_macro
266{
267    local ($in) = @_;
268
269    return &expand_macro_list($in, keys %mac);
270}

Archive Download the corresponding diff file



interactive