pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/url2pkg pkgtools/url2pkg: refactor variable a...
details: https://anonhg.NetBSD.org/pkgsrc/rev/d58bcd1d09fb
branches: trunk
changeset: 378460:d58bcd1d09fb
user: rillig <rillig%pkgsrc.org@localhost>
date: Sun Apr 08 20:13:54 2018 +0000
description:
pkgtools/url2pkg: refactor variable alignment code
The new code is more expressive and uses fewer magic numbers.
diffstat:
pkgtools/url2pkg/Makefile | 3 ++-
pkgtools/url2pkg/files/url2pkg.pl | 12 ++++++------
2 files changed, 8 insertions(+), 7 deletions(-)
diffs (48 lines):
diff -r e1684f7cd77d -r d58bcd1d09fb pkgtools/url2pkg/Makefile
--- a/pkgtools/url2pkg/Makefile Sun Apr 08 19:41:39 2018 +0000
+++ b/pkgtools/url2pkg/Makefile Sun Apr 08 20:13:54 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.87 2018/01/07 11:20:18 rillig Exp $
+# $NetBSD: Makefile,v 1.88 2018/04/08 20:13:54 rillig Exp $
PKGNAME= url2pkg-2.29
CATEGORIES= pkgtools
@@ -22,6 +22,7 @@
SUBST_CLASSES+= up
SUBST_STAGE.up= do-configure
+SUBST_MESSAGE.up= Replacing variable placeholders
SUBST_FILES.up= url2pkg.pl MakeMaker.pm
SUBST_SED.up= -e 's,@MAKE@,'${MAKE:Q}',g'
SUBST_SED.up+= -e 's,@PERL@,${PERL5},g'
diff -r e1684f7cd77d -r d58bcd1d09fb pkgtools/url2pkg/files/url2pkg.pl
--- a/pkgtools/url2pkg/files/url2pkg.pl Sun Apr 08 19:41:39 2018 +0000
+++ b/pkgtools/url2pkg/files/url2pkg.pl Sun Apr 08 20:13:54 2018 +0000
@@ -1,5 +1,5 @@
#! @PERL@
-# $NetBSD: url2pkg.pl,v 1.35 2018/01/07 11:20:18 rillig Exp $
+# $NetBSD: url2pkg.pl,v 1.36 2018/04/08 20:13:55 rillig Exp $
#
# Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -76,15 +76,15 @@
my $width = 0;
foreach my $var (@{$vars}) {
- my $len = length($var->[0]);
+ my $varname = $var->[0];
+ my $len = (length("$varname= ") + 7) & -8;
$width = ($len > $width) ? $len : $width;
}
foreach my $var (@{$vars}) {
- my $len = length($var->[0]) + 1;
- my $adjlen = (($width + 1 + 1) + 7) &-8;
- my $ntabs = (7 + $adjlen - $len) / 8;
- printf $f ("%s=%s%s\n", $var->[0], "\t" x $ntabs, $var->[1]);
+ my ($varname, $varvalue) = @$var;
+ my $ntabs = ($width - length("$varname=") + 7) / 8;
+ printf $f ("%s=%s%s\n", $varname, "\t" x $ntabs, $varvalue);
}
printf $f ("\n");
}
Home |
Main Index |
Thread Index |
Old Index