From owner-svn-ports-head@freebsd.org Fri Jun 17 14:58:37 2016 Return-Path: Delivered-To: svn-ports-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 61C1CA78211; Fri, 17 Jun 2016 14:58:37 +0000 (UTC) (envelope-from mat@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 324B31361; Fri, 17 Jun 2016 14:58:37 +0000 (UTC) (envelope-from mat@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5HEwaUE045666; Fri, 17 Jun 2016 14:58:36 GMT (envelope-from mat@FreeBSD.org) Received: (from mat@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5HEwam4045665; Fri, 17 Jun 2016 14:58:36 GMT (envelope-from mat@FreeBSD.org) Message-Id: <201606171458.u5HEwam4045665@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mat set sender to mat@FreeBSD.org using -f From: Mathieu Arnold Date: Fri, 17 Jun 2016 14:58:36 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r417014 - head/Tools/scripts X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 14:58:37 -0000 Author: mat Date: Fri Jun 17 14:58:36 2016 New Revision: 417014 URL: https://svnweb.freebsd.org/changeset/ports/417014 Log: Refactor a bit. Sponsored by: Absolight Modified: head/Tools/scripts/indent_make_if.pl Modified: head/Tools/scripts/indent_make_if.pl ============================================================================== --- head/Tools/scripts/indent_make_if.pl Fri Jun 17 13:44:39 2016 (r417013) +++ head/Tools/scripts/indent_make_if.pl Fri Jun 17 14:58:36 2016 (r417014) @@ -8,8 +8,15 @@ use warnings; my $extension = '.orig'; my $oldargv = q{}; +my $spaces = 2; my $indent; my $argvout; + +sub dotindent { + my $amount = shift; + return '.' . (' ' x ($spaces * $amount)); +} + LINE: while (<>) { # For each file, save a .orig backup. @@ -21,19 +28,19 @@ LINE: while (<>) { ($backup = $extension) =~ s/[*]/$ARGV/g; } rename $ARGV, $backup; - open $argvout, '>', $ARGV; + open $argvout, '>', $ARGV or die "Error for $ARGV: $!"; $oldargv = $ARGV; $indent = 0; } if (/^[.]\s*(?:if|for)/o) { # if/for -> indent and increase indent - s/^[.]\s*/"." . " " x $indent/oe; + s/^[.]\s*/dotindent($indent)/oe; $indent++; } elsif (/^[.]\s*end(?:if|for)/o) { # endif/endfor -> decrease indent and indent $indent--; - s/^[.]\s*/"." . " " x $indent/oe; + s/^[.]\s*/dotindent($indent)/oe; } elsif (/^[.]\s*(?:else|elif)/o) { # else/elif -> indent one level down - s/^[.]\s*/"." . " " x ($indent - 1)/oe; + s/^[.]\s*/dotindent($indent-1)/oe; } } continue {