summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2005-08-05 10:36:54 +0000
committerMarc Espie <espie@cvs.openbsd.org>2005-08-05 10:36:54 +0000
commitc58e0ca9e9d4ba8ac7d0c761b2b7cf6abc5fe014 (patch)
tree3537783e20b216cb29618f9df113db6ff2dd751c
parentad105b0f5c3ba2cb01cd15fb48188315da8b7a41 (diff)
expose the algorithm used for splitting names, so that ArcCheck will be
able to use it.
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Ustar.pm28
1 files changed, 16 insertions, 12 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Ustar.pm b/usr.sbin/pkg_add/OpenBSD/Ustar.pm
index 8417e254111..ded435faed8 100644
--- a/usr.sbin/pkg_add/OpenBSD/Ustar.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Ustar.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Ustar.pm,v 1.33 2005/08/05 10:03:10 espie Exp $
+# $OpenBSD: Ustar.pm,v 1.34 2005/08/05 10:36:53 espie Exp $
#
# Copyright (c) 2002-2004 Marc Espie <espie@openbsd.org>
#
@@ -166,23 +166,27 @@ sub next
return $result;
}
-sub mkheader
+sub split_name
{
- my ($entry, $type) = @_;
- my ($name, $prefix);
- $name = $entry->{name};
- if (length($name) <= MAXFILENAME) {
- $prefix = '';
- } elsif (length($name) > MAXFILENAME+MAXPREFIX+1) {
- die "Can't fit such a name $name\n";
- } else {
- $prefix = '';
- while (length($name) > MAXFILENAME && $name =~ m/^(.*?\/)(.*)$/) {
+ my $name = shift;
+ my $prefix = '';
+
+ my $l = length $name;
+ if ($l > MAXFILENAME && $l <= MAXFILENAME+MAXPREFIX+1) {
+ while (length($name) > MAXFILENAME &&
+ $name =~ m/^(.*?\/)(.*)$/) {
$prefix .= $1;
$name = $2;
}
$prefix =~ s|/$||;
}
+ return ($prefix, $name);
+}
+
+sub mkheader
+{
+ my ($entry, $type) = @_;
+ my ($prefix, $name) = split_name($entry->{name});
my $linkname = $entry->{linkname};
my $size = $entry->{size};
if (!$entry->isFile()) {