| 1 | package IO::BLOB::Pg; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | # Copyright 2000 Mark A. Hershberger | ||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||
| 5 | # This library is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||
| 6 | # modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 7 | require 5.005_03; | |||||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use vars qw($VERSION $DEBUG $IO_CONSTANTS); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | 7 | $VERSION = "0.91"; # $Date: 2002/08/12 06:14:57 $ | |||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 7 | ▶ | use Symbol (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | 7 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | 7 | ▶ | use IO::Handle; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 7 | my $SEEK_SET = &IO::Handle::SEEK_SET; | |||||||||||||||||||||||||||||||
| 18 | 7 | my $SEEK_END = &IO::Handle::SEEK_END; | |||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | sub new | ||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 22 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | my $self = bless Symbol::gensym(), ref($class) || $class; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table0%0/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | 0 | tie *$self, $self; | |||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | return $self->open(@_) ? $self : undef; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | sub open | ||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
open: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 31 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | return $self->new(@_) unless ref($self); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if (@_ == 2) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 35 | 0 | *$self->{dbi} = $_[0]; | |||||||||||||||||||||||||||||||
| 36 | 0 | *$self->{id} = $_[1]; | |||||||||||||||||||||||||||||||
| 37 | } elsif(@_ == 1) { | ||||||||||||||||||||||||||||||||
| 38 | 0 | *$self->{dbi} = $_[0]; | |||||||||||||||||||||||||||||||
| 39 | *$self->{id} = *$self->{dbi}->func(*$self->{dbi}->{pg_INV_READ} | | ||||||||||||||||||||||||||||||||
| 40 | 0 | *$self->{dbi}->{pg_INV_WRITE}, "lo_creat"); | |||||||||||||||||||||||||||||||
| 41 | } else { | ||||||||||||||||||||||||||||||||
| 42 | 0 | croak "open \$DBI[, \$id]"; | |||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||
| 44 | croak "AutoCommit needs to be off" | ||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if *$self->{dbi}->{AutoCommit}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 46 | *$self->{fh} = *$self->{dbi}->func(*$self->{id}, | ||||||||||||||||||||||||||||||||
| 47 | *$self->{dbi}->{pg_INV_READ} | | ||||||||||||||||||||||||||||||||
| 48 | 0 | *$self->{dbi}->{pg_INV_WRITE}, "lo_open"); | |||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | if(not defined *$self->{fh} || not defined *$self->{id}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined *$self->{"fh"} or not defined *$self->{"id"}
MC/DC0%0/2
defined *$self->{"fh"} or not defined *$self->{"id"}
defined *$self->{"fh"}
not defined *$self->{"id"}
Truth table0%0/3
A or not(B)
A= defined *$self->{"fh"}B= not defined *$self->{"id"}
| |||||||||||||||||||||||||||||||||
| 51 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||
| 53 | 0 | *$self->{pos} = 0; | |||||||||||||||||||||||||||||||
| 54 | 0 | *$self->{lno} = 0; | |||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | 0 | $self; | |||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub oid { | ||||||||||||||||||||||||||||||
|
Subroutine
oid: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 60 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 61 | 0 | return *$self->{id}; | |||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub pad { | ||||||||||||||||||||||||||||||
|
Subroutine
pad: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 65 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 66 | 0 | my $old = *$self->{pad}; | |||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | *$self->{pad} = substr($_[0], 0, 1) if @_; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | return "\0" unless defined($old) && length($old); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $old and CORE::length $old
MC/DC0%0/2
defined $old and CORE::length $old
defined $old
CORE::length $old
Truth table0%0/3
A and B
A= defined $oldB= CORE::length $old
| |||||||||||||||||||||||||||||||||
| 69 | 0 | $old; | |||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | sub dump | ||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
dump: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 74 | 0 | require Data::Dumper; | |||||||||||||||||||||||||||||||
| 75 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 76 | 0 | print Data::Dumper->Dump([$self], ['*self']); | |||||||||||||||||||||||||||||||
| 77 | 0 | print Data::Dumper->Dump([*$self{HASH}], ['$self{HASH}']); | |||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||
| 80 | sub TIEHANDLE | ||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
TIEHANDLE: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | print "TIEHANDLE @_\n" if $DEBUG; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | return $_[0] if ref($_[0]); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 84 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||
| 85 | 0 | my $self = bless Symbol::gensym(), $class; | |||||||||||||||||||||||||||||||
| 86 | 0 | $self->open(@_); | |||||||||||||||||||||||||||||||
| 87 | 0 | $self; | |||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | sub DESTROY | ||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | print "DESTROY @_\n" if $DEBUG; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | sub close | ||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
close: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 97 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 98 | *$self->{dbi}->func(*$self->{fh}, 'lo_close') | ||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if defined (*$self->{dbi} && defined *$self->{fh}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
*$self->{'dbi'} && defined *$self->{'fh'}
MC/DC0%0/2
*$self->{'dbi'} && defined *$self->{'fh'}
*$self->{'dbi'}
defined *$self->{'fh'}
Truth table0%0/3
A && B
A= *$self->{'dbi'}B= defined *$self->{'fh'}
| |||||||||||||||||||||||||||||||||
| 100 | 0 | delete *$self->{buf}; | |||||||||||||||||||||||||||||||
| 101 | 0 | delete *$self->{pos}; | |||||||||||||||||||||||||||||||
| 102 | 0 | delete *$self->{lno}; | |||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | 0 | $self; | |||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||
| 107 | sub opened | ||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
opened: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 109 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 110 | 0 | defined *$self->{buf}; | |||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | sub getc | ||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
getc: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 115 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 116 | 0 | my $buf; | |||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | return $buf if $self->read($buf, 1); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 118 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||
| 121 | sub ungetc | ||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
ungetc: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 123 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 124 | 0 | $self->setpos($self->getpos() - 1) | |||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||
| 127 | sub eof | ||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
eof: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 129 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 130 | 0 | my $dbi = *$self->{dbi}; | |||||||||||||||||||||||||||||||
| 131 | 0 | my $id = *$self->{id}; | |||||||||||||||||||||||||||||||
| 132 | 0 | my $tmp = $self->tell; | |||||||||||||||||||||||||||||||
| 133 | 0 | $self->seek(0, 2); | |||||||||||||||||||||||||||||||
| 134 | 0 | my $end = $self->tell; | |||||||||||||||||||||||||||||||
| 135 | 0 | $self->seek($tmp, 0); | |||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||
| 137 | 0 | $end <= $tmp; | |||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||
| 140 | sub print | ||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
print: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 142 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if (defined $\) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if (defined $,) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 145 | 0 | $self->write(join($,, @_).$\); | |||||||||||||||||||||||||||||||
| 146 | } else { | ||||||||||||||||||||||||||||||||
| 147 | 0 | $self->write(join("",@_).$\); | |||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||
| 149 | } else { | ||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if (defined $,) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 151 | 0 | $self->write(join($,, @_)); | |||||||||||||||||||||||||||||||
| 152 | } else { | ||||||||||||||||||||||||||||||||
| 153 | 0 | $self->write(join("",@_)); | |||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||
| 157 | 7 | *printflush = \*print; | |||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||
| 159 | sub printf | ||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
printf: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 161 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | print "PRINTF(@_)\n" if $DEBUG; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 163 | 0 | my $fmt = shift; | |||||||||||||||||||||||||||||||
| 164 | 0 | $self->write(sprintf($fmt, @_)); | |||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | sub seek { | ||||||||||||||||||||||||||||||
|
Subroutine
seek: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 169 | 0 | my($self,$off,$whence) = @_; | |||||||||||||||||||||||||||||||
| 170 | 0 | my $fh = *$self->{fh}; | |||||||||||||||||||||||||||||||
| 171 | 0 | my $pos; | |||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||
| 173 | 0 | $pos = *$self->{dbi}->func($fh, $off, $whence, 'lo_lseek'); | |||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | carp "Error during seek: ", $DBI::errstr | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$DBI::err or not defined $pos
MC/DC0%0/2
$DBI::err or not defined $pos
$DBI::err
not defined $pos
Truth table0%0/3
A or not(B)
A= $DBI::errB= not defined $pos
| |||||||||||||||||||||||||||||||||
| 175 | if $DBI::err || not defined $pos; | ||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if(defined $pos && $pos < 0) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $pos and $pos < 0
MC/DC0%0/2
defined $pos and $pos < 0
defined $pos
$pos < 0
Truth table0%0/3
A and B
A= defined $posB= $pos < 0
| |||||||||||||||||||||||||||||||||
| 178 | 0 | $pos = 0; | |||||||||||||||||||||||||||||||
| 179 | 0 | *$self->{lno} = 0; | |||||||||||||||||||||||||||||||
| 180 | } elsif(defined $pos) { | ||||||||||||||||||||||||||||||||
| 181 | 0 | *$self->{pos} = $pos; | |||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | return 1 if defined $pos; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 184 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | sub _length { | ||||||||||||||||||||||||||||||
|
Subroutine
_length: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 188 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 189 | 0 | my $old = *$self->{pos}; | |||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||
| 191 | 0 | $self->seek(0, 2); | |||||||||||||||||||||||||||||||
| 192 | 0 | my $len = $self->tell; | |||||||||||||||||||||||||||||||
| 193 | 0 | $self->seek($old, 0); | |||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||
| 195 | 0 | return $len; | |||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||
| 197 | 7 | *length = \&_length; | |||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | sub pos { | ||||||||||||||||||||||||||||||
|
Subroutine
pos: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 200 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 201 | 0 | my $old = *$self->{pos}; | |||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | _init_seek_constants() unless defined $SEEK_SET; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | my $pos = shift || 0; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||
| 206 | 0 | my $fh = *$self->{fh}; | |||||||||||||||||||||||||||||||
| 207 | 0 | my $len = $self->_length; | |||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | $pos = $pos > $len ? $len : $pos; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 209 | 0 | *$self->{dbi}->func($fh, $pos, $SEEK_SET, 'lo_lseek'); | |||||||||||||||||||||||||||||||
| 210 | 0 | *$self->{pos} = $pos; | |||||||||||||||||||||||||||||||
| 211 | 0 | *$self->{lno} = 0; | |||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||
| 213 | 0 | $old; | |||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | sub getpos { shift->pos; } | ||||||||||||||||||||||||||||||
|
Subroutine
getpos: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||
| 218 | 7 | *sysseek = \&seek; | |||||||||||||||||||||||||||||||
| 219 | 7 | *setpos = \&pos; | |||||||||||||||||||||||||||||||
| 220 | 7 | *tell = \&getpos; | |||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||
| 224 | sub getline | ||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
getline: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 226 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 227 | 0 | my $fh = *$self->{fh}; | |||||||||||||||||||||||||||||||
| 228 | 0 | my $dbi = *$self->{dbi}; | |||||||||||||||||||||||||||||||
| 229 | 0 | my $len = $self->_length(); | |||||||||||||||||||||||||||||||
| 230 | 0 | my $pos = *$self->{pos}; | |||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | return if $pos >= $len; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 232 | 0 | my $line = ""; | |||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | unless (defined $/) { # slurp | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 235 | 0 | *$self->{pos} = $len; | |||||||||||||||||||||||||||||||
| 236 | 0 | $dbi->func($fh, $line, $len - $pos, 'lo_read'); | |||||||||||||||||||||||||||||||
| 237 | 0 | return $line; | |||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | unless (length $/) { # paragraph mode | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 241 | # XXX slow&lazy implementation using getc() | ||||||||||||||||||||||||||||||||
| 242 | 0 | my $para = ""; | |||||||||||||||||||||||||||||||
| 243 | 0 | my $eol = 0; | |||||||||||||||||||||||||||||||
| 244 | 0 | my $c; | |||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | while (defined($c = $self->getc)) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | if ($c eq "\n") { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 247 | 0 | $eol++; | |||||||||||||||||||||||||||||||
| 248 | } elsif ($eol > 1) { | ||||||||||||||||||||||||||||||||
| 249 | 0 | $self->ungetc($c); | |||||||||||||||||||||||||||||||
| 250 | 0 | last; | |||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||
| 252 | 0 | $para .= $c; | |||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||
| 254 | 0 | return $para; # XXX wantarray | |||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||
| 257 | 0 | my $ret = ""; | |||||||||||||||||||||||||||||||
| 258 | 0 | my $tmp = ""; | |||||||||||||||||||||||||||||||
| 259 | 0 | my $br; | |||||||||||||||||||||||||||||||
| 260 | READ: | ||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | while (($br = $self->read($tmp, 512)) != 0) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 262 | 0 | my $idx = index($tmp, $/); | |||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | if($idx > ($[ - 1)) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 264 | 0 | *$self->{pos} += $idx + length($/) - $br; | |||||||||||||||||||||||||||||||
| 265 | 0 | $self->seek(*$self->{pos}, 0); | |||||||||||||||||||||||||||||||
| 266 | 0 | $ret .= substr($tmp, 0, $idx+length($/)); | |||||||||||||||||||||||||||||||
| 267 | 0 | $. = ++*$self->{lno}; | |||||||||||||||||||||||||||||||
| 268 | 0 | return $ret; | |||||||||||||||||||||||||||||||
| 269 | } else { | ||||||||||||||||||||||||||||||||
| 270 | 0 | $ret .= $tmp; | |||||||||||||||||||||||||||||||
| 271 | 0 | *$self->{pos} += $br | |||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||
| 274 | 0 | $. = ++*$self->{lno}; | |||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||
| 276 | 0 | return $ret; | |||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||
| 279 | sub getlines | ||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
getlines: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | die "getlines() called in scalar context\n" unless wantarray; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 282 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 283 | 0 | my($line, @lines); | |||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | push(@lines, $line) while defined($line = $self->getline); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 285 | 0 | return @lines; | |||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||
| 288 | sub READLINE | ||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
READLINE: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | goto &getlines if wantarray; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 291 | 0 | goto &getline; | |||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||
| 294 | sub input_line_number | ||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
input_line_number: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 296 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 297 | 0 | my $old = *$self->{lno}; | |||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | *$self->{lno} = shift if @_; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||
| 300 | 0 | $old; | |||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | sub truncate { | ||||||||||||||||||||||||||||||
|
Subroutine
truncate: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 304 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | my $len = shift || 0; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||
| 306 | 0 | my $fh = *$self->{fh}; | |||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | if ($self->_length > $len) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 308 | 0 | carp "Not Implemented"; | |||||||||||||||||||||||||||||||
| 309 | # substr($fh, $len) = ''; | ||||||||||||||||||||||||||||||||
| 310 | # *$self->{pos} = $len if $len < *$self->{pos}; | ||||||||||||||||||||||||||||||||
| 311 | } elsif ($self->_length < $len) { | ||||||||||||||||||||||||||||||||
| 312 | 0 | $self->seek(0, $SEEK_END); | |||||||||||||||||||||||||||||||
| 313 | 0 | $self->write($self->pad x ($len - $self->_length)) | |||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||
| 315 | 0 | $self; | |||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||
| 318 | sub read | ||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
read: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 320 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 321 | 0 | my $fh = *$self->{fh}; | |||||||||||||||||||||||||||||||
| 322 | 0 | my $dbi = *$self->{dbi}; | |||||||||||||||||||||||||||||||
| 323 | 0 | my $tbuf = ""; | |||||||||||||||||||||||||||||||
| 324 | 0 | my $len = $_[1]; | |||||||||||||||||||||||||||||||
| 325 | 0 | my $pos = *$self->{pos}; | |||||||||||||||||||||||||||||||
| 326 | 0 | my $rem = $self->_length - $pos; | |||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||
| 328 | 0 | my $nbytes = $dbi->func($fh, $tbuf, $len, "lo_read"); | |||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | if (@_ > 2) { # read offset | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 331 | 0 | substr($_[0],$_[2]) = $tbuf; | |||||||||||||||||||||||||||||||
| 332 | } else { | ||||||||||||||||||||||||||||||||
| 333 | 0 | $_[0] = $tbuf; | |||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||
| 335 | 0 | *$self->{pos} += $nbytes; | |||||||||||||||||||||||||||||||
| 336 | 0 | return $nbytes | |||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||
| 339 | sub write | ||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
write: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 341 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 342 | 0 | my $fh = *$self->{fh}; | |||||||||||||||||||||||||||||||
| 343 | 0 | my $dbi = *$self->{dbi}; | |||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||
| 345 | 0 | my $pos = *$self->{pos}; | |||||||||||||||||||||||||||||||
| 346 | 0 | my $slen = length($_[0]); | |||||||||||||||||||||||||||||||
| 347 | 0 | my $len = $slen; | |||||||||||||||||||||||||||||||
| 348 | 0 | my $off = 0; | |||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | if (@_ > 1) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | $len = $_[1] if $_[1] < $len; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | if (@_ > 2) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | $off = $_[2] || 0; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$_[2] || 0
MC/DC0%0/1
$_[2] || 0
$_[2]
Truth table0%0/2
A
A= $_[2]
| |||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | die "Offset outside file" if $off > $slen; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | if ($off < 0) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 355 | 0 | $off += $slen; | |||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | die "Offset outside file" if $off < 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||
| 358 | 0 | my $rem = $slen - $off; | |||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | $len = $rem if $rem < $len; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||
| 363 | 0 | my $nbytes = $dbi->func($fh, substr($_[0], $off), $len, "lo_write"); | |||||||||||||||||||||||||||||||
| 364 | 0 | *$self->{pos} += $nbytes; | |||||||||||||||||||||||||||||||
| 365 | 0 | $nbytes; | |||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||
| 368 | 7 | *sysread = \&read; | |||||||||||||||||||||||||||||||
| 369 | 7 | *syswrite = \&write; | |||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||
| 371 | sub stat | ||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
stat: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 373 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | return unless $self->opened; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | return 1 unless wantarray; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 376 | 0 | my $len = $self->_length; | |||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||
| 378 | return ( | ||||||||||||||||||||||||||||||||
| 379 | undef, undef, # dev, ino | ||||||||||||||||||||||||||||||||
| 380 | 0 | 0666, # filemode | |||||||||||||||||||||||||||||||
| 381 | 1, # links | ||||||||||||||||||||||||||||||||
| 382 | $>, # user id | ||||||||||||||||||||||||||||||||
| 383 | $), # group id | ||||||||||||||||||||||||||||||||
| 384 | undef, # device id | ||||||||||||||||||||||||||||||||
| 385 | $len, # size | ||||||||||||||||||||||||||||||||
| 386 | undef, # atime | ||||||||||||||||||||||||||||||||
| 387 | undef, # mtime | ||||||||||||||||||||||||||||||||
| 388 | undef, # ctime | ||||||||||||||||||||||||||||||||
| 389 | 512, # blksize | ||||||||||||||||||||||||||||||||
| 390 | int(($len+511)/512) # blocks | ||||||||||||||||||||||||||||||||
| 391 | ); | ||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | sub blocking { | ||||||||||||||||||||||||||||||
|
Subroutine
blocking: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 395 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | my $old = *$self->{blocking} || 0; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
*$self->{'blocking'} || 0
MC/DC0%0/1
*$self->{'blocking'} || 0
*$self->{'blocking'}
Truth table0%0/2
A
A= *$self->{'blocking'}
| |||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | *$self->{blocking} = shift if @_; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 398 | 0 | $old; | |||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | my $notmuch = sub { return }; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||
| 403 | 7 | *fileno = $notmuch; | |||||||||||||||||||||||||||||||
| 404 | 7 | *error = $notmuch; | |||||||||||||||||||||||||||||||
| 405 | 7 | *clearerr = $notmuch; | |||||||||||||||||||||||||||||||
| 406 | 7 | *sync = $notmuch; | |||||||||||||||||||||||||||||||
| 407 | 7 | *flush = $notmuch; | |||||||||||||||||||||||||||||||
| 408 | 7 | *setbuf = $notmuch; | |||||||||||||||||||||||||||||||
| 409 | 7 | *setvbuf = $notmuch; | |||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||
| 411 | 7 | *untaint = $notmuch; | |||||||||||||||||||||||||||||||
| 412 | 7 | *autoflush = $notmuch; | |||||||||||||||||||||||||||||||
| 413 | 7 | *fcntl = $notmuch; | |||||||||||||||||||||||||||||||
| 414 | 7 | *ioctl = $notmuch; | |||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||
| 416 | 7 | *GETC = \&getc; | |||||||||||||||||||||||||||||||
| 417 | 7 | *PRINT = \&print; | |||||||||||||||||||||||||||||||
| 418 | 7 | *PRINTF = \&printf; | |||||||||||||||||||||||||||||||
| 419 | 7 | *READ = \&read; | |||||||||||||||||||||||||||||||
| 420 | 7 | *WRITE = \&write; | |||||||||||||||||||||||||||||||
| 421 | 7 | *CLOSE = \&close; | |||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||
| 423 | 7 | 1; | |||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||
| 425 | __END__ | ||||||||||||||||||||||||||||||||