diff options
Diffstat (limited to 'rf.pl')
-rw-r--r-- | rf.pl | 29 |
1 files changed, 19 insertions, 10 deletions
@@ -28,7 +28,11 @@ while (<>) { if ($fld eq 'a') { $i++ if not $author_last; push @lines, ".R! $i"; - $refs[$i]{$fld} = $def; + if (defined $refs[$i]{a}) { + $refs[$i]{a} = "; $def"; + } else { + $refs[$i]{a} = $def; + } $author_last = 1; next; } elsif ($fld =~ /[cdnpqtwy]/) { @@ -75,7 +79,7 @@ for (@lines) { # Reference definition if (/^\.R! (\d+)/) { - print fmt($format_list, $1) . "\n"; + print fmt($format_list, $1, 1) . "\n"; next; } @@ -85,13 +89,13 @@ for (@lines) { } sub fmt { - my ($fmt, $i) = @_; + my ($fmt, $i, $full) = @_; my %ref = %{$refs[$i]}; for my $fld (split //, 'acdnpqtwy') { if ($ref{$fld}) { no warnings; my $val = $ref{$fld}; - $val = fmta($val) if $fld eq 'a'; + $val = fmta($val) if $fld eq 'a' and not $full; $fmt =~ s/\{(.*?)%$fld(.*?)}/$1$val$3/g; $fmt =~ s/%$fld/$val/g; } else { @@ -107,13 +111,18 @@ sub fmt { } sub fmta { - my ($name) = @_; - if ($name =~ /(.*?),/) { - return $1; - } else { - $name =~ s/(.*?)\s/$1/; - return $name; + my ($a) = @_; + my $r; + for my $name (split /; /, $a) { + if ($name =~ /(.*?),/) { + $r .= ", $1"; + } else { + $name =~ s/(.*?)\s/$1/; + return ", $name"; + } } + $r =~ s/^, //; + return $r; } sub likeness { |