summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser.pm
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-12-29 00:16:03 +0000
committerKarl Berry <karl@freefriends.org>2015-12-29 00:16:03 +0000
commitd3c8410c4bf38ea695fb6580785720e426a71a87 (patch)
tree62d8ec81a9b6ca9fc63d53121d29249e9f56d01b /Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser.pm
parentbac237f29f6ca325050af70f4720d1af61c45bbe (diff)
bibtexperllibs (26dec15)
git-svn-id: svn://tug.org/texlive/trunk@39224 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser.pm')
-rw-r--r--Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser.pm64
1 files changed, 59 insertions, 5 deletions
diff --git a/Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser.pm b/Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser.pm
index 8f0ab3a4c49..c7d7a75fc35 100644
--- a/Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser.pm
+++ b/Master/texmf-dist/scripts/bibtexperllibs/BibTeX/Parser.pm
@@ -1,6 +1,6 @@
package BibTeX::Parser;
{
- $BibTeX::Parser::VERSION = '0.65';
+ $BibTeX::Parser::VERSION = '0.66';
}
# ABSTRACT: A pure perl BibTeX parser
use warnings;
@@ -208,6 +208,53 @@ sub _extract_bracketed
}
}
+# Split the $string using $pattern as a delimiter with
+# each part having balanced braces (so "{$pattern}"
+# does NOT split).
+# Return empty list if unmatched braces
+
+sub _split_braced_string {
+ my $string = shift;
+ my $pattern = shift;
+ my @tokens;
+ return () if $string eq '';
+ my $buffer;
+ while (!defined pos $string || pos $string < length $string) {
+ if ( $string =~ /\G(.*?)(\{|$pattern)/cgi ) {
+ my $match = $1;
+ if ( $2 =~ /$pattern/i ) {
+ $buffer .= $match;
+ push @tokens, $buffer;
+ $buffer = "";
+ } elsif ( $2 =~ /\{/ ) {
+ $buffer .= $match . "{";
+ my $numbraces=1;
+ while ($numbraces !=0 && pos $string < length $string) {
+ my $symbol = substr($string, pos $string, 1);
+ $buffer .= $symbol;
+ if ($symbol eq '{') {
+ $numbraces ++;
+ } elsif ($symbol eq '}') {
+ $numbraces --;
+ }
+ pos($string) ++;
+ }
+ if ($numbraces != 0) {
+ return ();
+ }
+ } else {
+ $buffer .= $match;
+ }
+ } else {
+ $buffer .= substr $string, (pos $string || 0);
+ last;
+ }
+ }
+ push @tokens, $buffer if $buffer;
+ return @tokens;
+}
+
+
1; # End of BibTeX::Parser
@@ -220,7 +267,7 @@ BibTeX::Parser - A pure perl BibTeX parser
=head1 VERSION
-version 0.65
+version 0.66
=head1 SYNOPSIS
@@ -279,7 +326,13 @@ Parameters:
Returns the next parsed entry or undef.
-=head2 SEE ALSO
+=head1 NOTES
+
+The fields C<author> and C<editor> are canonized, see
+L<BibTeX::Parser::Author>
+
+
+=head1 SEE ALSO
=over 4
@@ -295,11 +348,12 @@ L<BibTeX::Parser::Author>
=head1 AUTHOR
-Gerhard Gossen <gerhard.gossen@googlemail.com>
+Gerhard Gossen <gerhard.gossen@googlemail.com> and
+Boris Veytsman <boris@varphi.com>
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2013 by Gerhard Gossen.
+This software is copyright (c) 2013-2015 by Gerhard Gossen and Boris Veytsman
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.