From: espie Date: Tue, 20 Jun 2023 14:50:05 +0000 (+0000) Subject: tweak fragment handling error messages a bit X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a67807ea72a8d42d30e5fc4a34481d39558d3cb8;p=openbsd tweak fragment handling error messages a bit don't pass parameters we don't need --- diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm index a3954a504a2..dbcf5eb0b21 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgCreate.pm,v 1.191 2023/06/13 09:07:17 espie Exp $ +# $OpenBSD: PkgCreate.pm,v 1.192 2023/06/20 14:50:05 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie # @@ -1125,10 +1125,10 @@ sub print($self) package OpenBSD::PkgCreate; our @ISA = qw(OpenBSD::AddCreateDelete); -sub handle_fragment($self, $state, $old, $not, $frag, $, $, $msg) +sub handle_fragment($self, $state, $old, $not, $frag, $location) { my $def = $frag; - if ($state->{subst}->has_fragment($def, $frag, $msg)) { + if ($state->{subst}->has_fragment($state, $def, $frag, $location)) { return undef if defined $not; } else { return undef unless defined $not; @@ -1185,7 +1185,7 @@ sub read_fragments($self, $state, $plist, $filename) if ($l =~ m/^(\!)?\%\%(.*)\%\%$/) { $self->record_fragment($plist, $1, $2, $file); - if (my $f2 = $self->handle_fragment($state, $file, $1, $2, $l, $cont, $filename)) { + if (my $f2 = $self->handle_fragment($state, $file, $1, $2, $filename)) { push(@$stack, $file); $file = $f2; } diff --git a/usr.sbin/pkg_add/OpenBSD/Subst.pm b/usr.sbin/pkg_add/OpenBSD/Subst.pm index e8934115fbd..be0a9fe3693 100644 --- a/usr.sbin/pkg_add/OpenBSD/Subst.pm +++ b/usr.sbin/pkg_add/OpenBSD/Subst.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Subst.pm,v 1.20 2023/06/13 09:07:17 espie Exp $ +# $OpenBSD: Subst.pm,v 1.21 2023/06/20 14:50:06 espie Exp $ # # Copyright (c) 2008 Marc Espie # @@ -91,18 +91,19 @@ sub copy($self, $srcname, $destname) return $dest; } -sub has_fragment($self, $def, $frag, $msg) +sub has_fragment($self, $state, $def, $frag, $location) { my $v = $self->value($def); if (!defined $v) { - die "Error: unknown fragment $frag in $msg"; + $state->fatal("Unknown fragment #1 in #2", + $frag, $location); } elsif ($v == 1) { return 1; } elsif ($v == 0) { return 0; } else { - die "Incorrect define for $frag in $msg"; + $state->fatal("Invalid fragment define #1=#2", $frag, $v); } }