diff options
author | 2006-07-31 16:27:21 +0000 | |
---|---|---|
committer | 2006-07-31 16:27:21 +0000 | |
commit | 4acb318eb36c25e060dcd43cc62f3f494affd9d8 (patch) | |
tree | 04b420ca4d0a1b0e54fb1a5365fb8c6a3672c4ef | |
parent | sync (diff) | |
download | wireguard-openbsd-4acb318eb36c25e060dcd43cc62f3f494affd9d8.tar.xz wireguard-openbsd-4acb318eb36c25e060dcd43cc62f3f494affd9d8.zip |
add missing licence info.
use strict/warning where applicable, and fix relevant warnings.
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Getopt.pm | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Getopt.pm b/usr.sbin/pkg_add/OpenBSD/Getopt.pm index e0ef4b11efb..2f67f0f64ac 100644 --- a/usr.sbin/pkg_add/OpenBSD/Getopt.pm +++ b/usr.sbin/pkg_add/OpenBSD/Getopt.pm @@ -1,8 +1,30 @@ +# ex:ts=8 sw=4: +# $OpenBSD: Getopt.pm,v 1.3 2006/07/31 16:27:21 espie Exp $ +# +# Copyright (c) 2006 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 +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# +# This is inspired by Getopt::Std, except for the ability to invoke subs +# on options. +# package OpenBSD::Getopt; require Exporter; +use strict; +use warnings; -@ISA = qw(Exporter); -@EXPORT = qw(getopts); +our @ISA = qw(Exporter); +our @EXPORT = qw(getopts); sub handle_option { @@ -12,6 +34,9 @@ sub handle_option if (defined $hash->{$opt} and ref($hash->{$opt}) eq 'CODE') { &{$hash->{$opt}}($params); } else { + no strict "refs"; + no strict "vars"; + ${"opt_$opt"} = $params; push(@EXPORT, "\$opt_$opt"); $hash->{$opt} = $params; @@ -32,7 +57,7 @@ sub getopts($;$) last; } my ($opt, $other) = ($1, $2); - if ($args =~ m/\Q$opt\E(\:)?/) { + if ($args =~ m/\Q$opt\E(\:?)/) { if ($1 eq ':') { if ($other eq '') { die "no argument for option -$opt" unless @ARGV; |