diff options
author | 2010-01-05 11:16:08 +0000 | |
---|---|---|
committer | 2010-01-05 11:16:08 +0000 | |
commit | be385f7ebb390d365497cfed2032bd43d473b66c (patch) | |
tree | 6949a5abcb8faf20c5b8a1e4272763c6e60e2e02 | |
parent | auto-create giveup, so it's defined if we call tally without doing anything. (diff) | |
download | wireguard-openbsd-be385f7ebb390d365497cfed2032bd43d473b66c.tar.xz wireguard-openbsd-be385f7ebb390d365497cfed2032bd43d473b66c.zip |
common pattern, put it there since everything uses Error.
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Error.pm | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Error.pm b/usr.sbin/pkg_add/OpenBSD/Error.pm index d770ae7f7d1..19cc928e51d 100644 --- a/usr.sbin/pkg_add/OpenBSD/Error.pm +++ b/usr.sbin/pkg_add/OpenBSD/Error.pm @@ -1,7 +1,7 @@ # ex:ts=8 sw=4: -# $OpenBSD: Error.pm,v 1.19 2009/11/15 09:53:52 espie Exp $ +# $OpenBSD: Error.pm,v 1.20 2010/01/05 11:16:08 espie Exp $ # -# Copyright (c) 2004 Marc Espie <espie@openbsd.org> +# Copyright (c) 2004-2010 Marc Espie <espie@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -17,6 +17,22 @@ use strict; use warnings; +package OpenBSD::Auto; +sub cache(*&) +{ + my ($sym, $code) = @_; + my $callpkg = caller; + my $actual = sub { + my $self = shift; + if (!defined $self->{$sym}) { + $self->{$sym} = &$code($self); + } + return $self->{$sym}; + }; + no strict 'refs'; + *{$callpkg."::$sym"} = $actual; +} + package OpenBSD::Error; require Exporter; our @ISA=qw(Exporter); |