/usr/share/perl5/GO/Handlers/abstract_prolog_writer.pm is in libgo-perl 0.15-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | package GO::Handlers::abstract_prolog_writer;
use base qw(GO::Handlers::base Exporter);
use strict;
sub out {
my $self = shift;
$self->print("@_");
}
sub cmt {
my $self = shift;
my $cmt = shift;
$self->out(" % $cmt") if $cmt;
return;
}
sub prologquote {
my $s = shift;
my $force = shift;
if (ref($s)) {
if (ref($s) ne 'HASH') {
sprintf("[%s]",
join(',',map{prologquote($_)} @$s));
}
else {
my @keys = keys %$s;
if (@keys == 1) {
my $functor = $keys[0];
my $args = $s->{$functor};
sprintf("$functor(%s)",
join(', ', map {prologquote($_)} @$args));
}
else {
warn "@keys != 1 - ignoring";
}
}
}
else {
$s = '' unless defined $s;
if ($s =~ /^[\-]?[0-9]+$/ && !$force) {
return $s;
}
$s =~ s/\'/\'\'/g;
"'$s'";
}
}
sub nl {
shift->print("\n");
}
sub fact {
my $self = shift;
my $pred = shift;
my @args = @{shift||[]};
my $cmt = shift;
$self->out(sprintf("$pred(%s).",
join(', ', map {prologquote($_)} @args)));
$self->cmt($cmt);
$self->nl;
}
# ensure all fields are quoted
sub factq {
my $self = shift;
my $pred = shift;
my @args = @{shift||[]};
my $cmt = shift;
$self->out(sprintf("$pred(%s).",
join(', ', map {prologquote($_,1)} @args)));
$self->cmt($cmt);
$self->nl;
}
1;
|