line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TeX::Encode::BibTeX; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '2.008'; # VERSION |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
66
|
use 5.008; |
|
3
|
|
|
|
|
12
|
|
6
|
3
|
|
|
3
|
|
15
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
69
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#use AutoLoader qw(AUTOLOAD); |
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
16
|
use TeX::Encode; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1135
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = qw(Encode::Encoding); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__PACKAGE__->Define(qw(BibTeX bibtex)); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# encode($self, $string [,$check]) |
17
|
|
|
|
|
|
|
sub encode |
18
|
|
|
|
|
|
|
{ |
19
|
0
|
|
|
0
|
1
|
|
my( undef, $string, $check ) = @_; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my $tex = ""; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
pos($string) = 0; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
for($string) |
26
|
|
|
|
|
|
|
{ |
27
|
0
|
|
|
|
|
|
while(1) { |
28
|
0
|
0
|
|
|
|
|
last if pos($_) == length($_); |
29
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
/\G($TeX::Encode::charmap::BIBTEX_RESERVED_RE)/gc and ($tex .= $TeX::Encode::charmap::BIBTEX_RESERVED{$1}, next); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# BibTeX requires extra braces around any LaTeX mark-up |
33
|
|
|
|
|
|
|
# (we assume anything we substitute with will be BibTeX-safe) |
34
|
0
|
0
|
|
|
|
|
/\G($TeX::Encode::charmap::CHAR_MAP_RE)/gc and ($tex .= '{'.$TeX::Encode::charmap::CHAR_MAP{$1}.'}', next); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# basic unreserved characters |
37
|
0
|
0
|
|
|
|
|
/\G([\sa-zA-Z0-9\.,:;'"\(\)=\-\/\[\]\*\+]+)/gc and ($tex .= $1, next); |
38
|
0
|
0
|
|
|
|
|
/\G([\x00-\x7e])/gc and ($tex .= $1, next); |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
/\G(.)/gc and ($tex .= '?', next); |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
Carp::confess "Shouldn't happen"; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
return $tex; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# encode_url($self, $string [,$check]) |
50
|
|
|
|
|
|
|
sub encode_url |
51
|
|
|
|
|
|
|
{ |
52
|
0
|
|
|
0
|
1
|
|
my( undef, $str, $check ) = @_; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# replace braces/slash (URL???) and underscore with their URI escape points |
55
|
0
|
|
|
|
|
|
$str =~ s/([\{\}\\_])/sprintf("%%%02x",ord($1))/seg; |
|
0
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$str =~ s/(%)/$TeX::Encode::charmap::BIBTEX_RESERVED{$1}/sg; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
return $str; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# decode($octets [,$check]) |
62
|
|
|
|
|
|
|
sub decode |
63
|
|
|
|
|
|
|
{ |
64
|
0
|
|
|
0
|
1
|
|
return &TeX::Encode::decode; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
1
|
|
sub perlio_ok { 0 } |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
__END__ |