summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2010-01-17 11:56:47 +0000
committerMarc Espie <espie@cvs.openbsd.org>2010-01-17 11:56:47 +0000
commit258318262be98e0ddd4150f1ecc227504b388a2f (patch)
tree6a0cc2213e8887c7473c2eb0fc94d3a9c1a5c4bc
parentfb493e4c4938fb654314bfedf205e6090e9d1427 (diff)
use Carp directly, it it very inexpensive actually, since it's been rewritten
to be just a very small stub that loads Carp::Heavy on demand. Also, stop wrapping messages in "Expected", doesn't give us anything. Finally, make RequiredBy calls be carp, so that we actually know where they fail...
-rw-r--r--usr.sbin/pkg_add/OpenBSD/CollisionReport.pm6
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Error.pm28
-rw-r--r--usr.sbin/pkg_add/OpenBSD/RequiredBy.pm11
3 files changed, 21 insertions, 24 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm b/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm
index 6b5a96ddd40..3b6c0601555 100644
--- a/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm
+++ b/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: CollisionReport.pm,v 1.31 2010/01/14 19:35:55 espie Exp $
+# $OpenBSD: CollisionReport.pm,v 1.32 2010/01/17 11:56:46 espie Exp $
#
# Copyright (c) 2003-2006 Marc Espie <espie@openbsd.org>
#
@@ -99,9 +99,9 @@ sub collision_report($$)
my $d = $old->new($destdir.$item);
if ($d->equals($old)) {
- $state->errsay("(same checksum)");
+ $state->errsay(" (same checksum)");
} else {
- $state->errsay("(different checksum)");
+ $state->errsay(" (different checksum)");
}
} else {
$state->errsay("");
diff --git a/usr.sbin/pkg_add/OpenBSD/Error.pm b/usr.sbin/pkg_add/OpenBSD/Error.pm
index b6fba6d2817..14db4a55164 100644
--- a/usr.sbin/pkg_add/OpenBSD/Error.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Error.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Error.pm,v 1.21 2010/01/09 14:49:53 espie Exp $
+# $OpenBSD: Error.pm,v 1.22 2010/01/17 11:56:46 espie Exp $
#
# Copyright (c) 2004-2010 Marc Espie <espie@openbsd.org>
#
@@ -73,7 +73,7 @@ our ($FileName, $Line, $FullMessage);
my @signal_name = ();
-sub Carp::croak;
+use Carp;
sub fillup_names
{
@@ -182,8 +182,7 @@ sub Unlink
sub Fatal
{
- require Carp;
- Carp::croak "Expected: @_";
+ croak @_;
}
sub Warn
@@ -215,12 +214,10 @@ sub warn
sub fatal
{
my $self = shift;
- require Carp;
if (defined $self->{pkgname}) {
- Carp::croak("Expected: ", $self->{pkgname}, ':', @_);
- } else {
- Carp::croak("Expected: ", @_);
- }
+ unshift @_, $self->{pkgname}, ':';
+ }
+ croak @_;
}
sub print
@@ -286,13 +283,13 @@ sub dienow
{
my ($error, $handler) = @_;
if ($error) {
- if ($error =~ m/^(Expected\:\s+)?(.*?)(?:\s+at\s+(.*)\s+line\s+(\d+)\.?)?$/o) {
- local $_ = $2;
- $FileName = $3;
- $Line = $4;
+ if ($error =~ m/^(.*?)(?:\s+at\s+(.*)\s+line\s+(\d+)\.?)?$/o) {
+ local $_ = $1;
+ $FileName = $2;
+ $Line = $3;
$FullMessage = $error;
- $handler->exec($error, $1, $2, $3, $4);
+ $handler->exec($error, '', $1, $2, $3);
} else {
die "Fatal error: can't parse $error";
}
@@ -308,8 +305,7 @@ sub try(&@)
sub throw
{
- require Carp;
- Carp::croak "Expected: @_";
+ croak @_;
}
diff --git a/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm b/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm
index 8d61ddc9703..e758eb155f7 100644
--- a/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm
+++ b/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: RequiredBy.pm,v 1.18 2009/12/28 21:27:03 espie Exp $
+# $OpenBSD: RequiredBy.pm,v 1.19 2010/01/17 11:56:46 espie Exp $
#
# Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org>
#
@@ -20,6 +20,7 @@ use warnings;
package OpenBSD::RequirementList;
use OpenBSD::PackageInfo;
+use Carp;
sub fill_entries
{
@@ -29,7 +30,7 @@ sub fill_entries
if (-f $self->{filename}) {
open(my $fh, '<', $self->{filename}) or
- die "Problem opening required list: ",
+ croak "Problem opening required list: ",
$self->{filename}, ": $!";
my $_;
while(<$fh>) {
@@ -53,17 +54,17 @@ sub synch
if (!unlink $self->{filename}) {
if ($self->{nonempty}) {
- die "Can't erase $self->{filename}: $!";
+ croak "Can't erase $self->{filename}: $!";
}
}
if (%{$self->{entries}}) {
open(my $fh, '>', $self->{filename}) or
- die "Can't write $self->{filename}: $!";
+ croak "Can't write $self->{filename}: $!";
while (my ($k, $v) = each %{$self->{entries}}) {
print $fh "$k\n";
}
close($fh) or
- die "Write to $self->{filename} didn't work: $!";
+ croak "Write to $self->{filename} didn't work: $!";
$self->{nonempty} = 1;
} else {
$self->{nonempty} = 0;