diff options
author | Karl Berry <karl@freefriends.org> | 2016-03-10 23:22:31 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-03-10 23:22:31 +0000 |
commit | 139be648536d5f25096343c01cd7e96a2a663ae4 (patch) | |
tree | 6d6b86f2a5d95b397478bb8988354449f0fef24c /Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser/Entry.pm | |
parent | 5f1f6fa78b0845693569ba5dacdc711bff4aba7f (diff) |
bibtexperllibs (10mar16)
git-svn-id: svn://tug.org/texlive/trunk@39989 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser/Entry.pm')
-rw-r--r-- | Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser/Entry.pm | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser/Entry.pm b/Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser/Entry.pm index b10317c42b4..6986f0a6608 100644 --- a/Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser/Entry.pm +++ b/Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser/Entry.pm @@ -1,6 +1,6 @@ package BibTeX::Parser::Entry; { - $BibTeX::Parser::Entry::VERSION = '0.66'; + $BibTeX::Parser::Entry::VERSION = '0.68'; } use warnings; @@ -15,6 +15,13 @@ sub new { my ($class, $type, $key, $parse_ok, $fieldsref) = @_; my %fields = defined $fieldsref ? %$fieldsref : (); + my $i=0; + foreach my $field (keys %fields) { + if ($field !~ /^_/) { + $fields{_fieldnums}->{$field}=$i; + $i++; + } + } if (defined $type) { $fields{_type} = uc($type); } @@ -79,7 +86,12 @@ sub field { return $self->{ lc( $field ) }; } else { my ($self, $key, $value) = @_; - $self->{ lc( $key ) } = $value; #_sanitize_field($value); + my $field = lc ($key); + $self->{$field} = $value; #_sanitize_field($value); + if (!exists($self->{_fieldnums}->{$field})) { + my $num = scalar keys %{$self->{_fieldnums}}; + $self->{_fieldnums}->{$field} = $num; + } } } @@ -207,6 +219,9 @@ sub raw_bibtex { sub to_string { my $self = shift; my @fields = grep {!/^_/} keys %$self; + @fields = sort { + $self->{_fieldnums}->{$a} <=> + $self->{_fieldnums}->{$b}} @fields; my $result = '@'.$self->type."{".$self->key.",\n"; foreach my $field (@fields) { my $value = $self->field($field); |