diff options
Diffstat (limited to 'support/splint/scripts/unline.pl')
-rwxr-xr-x | support/splint/scripts/unline.pl | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/support/splint/scripts/unline.pl b/support/splint/scripts/unline.pl index 36a1b524f5..f335dcac87 100755 --- a/support/splint/scripts/unline.pl +++ b/support/splint/scripts/unline.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# Copyright 2012-2020, Alexander Shibakov +# Copyright 2012-2022, Alexander Shibakov # This file is part of SPLinT # # SPLinT is free software: you can redistribute it and/or modify @@ -23,6 +23,7 @@ use Getopt::Long; use Pod::Usage; +use strict; my $man = 0; my $help = 0; @@ -38,10 +39,11 @@ pod2usage(-exitval => 0, -verbose => 2) if $man; open FILE, "$ARGV[0]" or die "Cannot open input file $ARGV[0]\n"; open FILEOUT, ">$ARGV[1]" or die "Cannot open output file $ARGV[1]\n"; +my $prev_space = 1; while (<FILE>) { - $inline = $_; + my $inline = $_; s/^(\#line.*)\n$//g; @@ -51,14 +53,13 @@ while (<FILE>) { } - printf FILEOUT "%s", "$_"; - -# if ( m/^.*\S.*\n$/ ) { - -# printf FILEOUT "%s", "$_"; - -# } - + if ( m/^.*\S.*\n$/ ) { + printf FILEOUT "%s", "$_"; + $prev_space = ''; + } else { # squash multiple blank lines together + printf FILEOUT "\n" if not $prev_space; + $prev_space = 1; + } } __END__ |