Skip to contentSkip to conversation

scripts: checkincludes: add exit message for no duplicates found

PATCH Superseded Cheah Kok Cheong 2 participants 3 messages Dec 18, 2016 – Dec 20, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts: checkincludes: add exit message for no duplicates found

If no duplicates found, inform user.

---
 scripts/checkincludes.pl | 13 +++++++++++++
 1 file changed, 13 insertions(+)
scripts/checkincludes.pl +13 -0
index 97b2c61..2bf234c 100755
@@ -37,6 +37,13 @@ if ($#ARGV >= 1) {
 	}
 }
 
+my $dup_counter = 0;
+
+sub nodup_count {
+	++$dup_counter;
+	return;
+}
+
 foreach my $file (@ARGV) {
 	open(my $f, '<', $file)
 	    or die "Cannot open $file: $!.\n";
@@ -57,6 +64,7 @@ foreach my $file (@ARGV) {
 		foreach my $filename (keys %includedfiles) {
 			if ($includedfiles{$filename} > 1) {
 				print "$file: $filename is included more than once.\n";
+				nodup_count();
 			}
 		}
 		next;
@@ -73,6 +81,7 @@ foreach my $file (@ARGV) {
 					if ($includedfiles{$filename} > 1) {
 						$includedfiles{$filename}--;
 						$dups++;
+						nodup_count();
 					} else {
 						print {$f} $_;
 					}
@@ -87,3 +96,7 @@ foreach my $file (@ARGV) {
 	}
 	close($f);
 }
+
+if ($dup_counter == 0) {
+	print "No duplicate includes found.\n";
+}
Signature · 1 line
2.7.4
#1 lore raw
Quoted 12 lines · Cheah Kok Cheong

If no duplicates found, inform user.

---
 scripts/checkincludes.pl | 13 +++++++++++++
 1 file changed, 13 insertions(+)
scripts/checkincludes.pl +0 -0
index 97b2c61..2bf234c 100755

scripts/checkincludes.pl if ($#ARGV >= 1) { · line 45

Quoted 9 lines
scripts/checkincludes.pl +6 -0
@@ -37,6 +37,13 @@ if ($#ARGV >= 1) {
 	}
 }
 
+my $dup_counter = 0;
+
+sub nodup_count {
+	++$dup_counter;
+	return;
+}

I don't think it's necessary to have a function only to increment a variable.

Michal

#2 lore raw
Quoted 26 lines · Michal Marek
Quoted 12 lines · Cheah Kok Cheong

If no duplicates found, inform user.

---
 scripts/checkincludes.pl | 13 +++++++++++++
 1 file changed, 13 insertions(+)
scripts/checkincludes.pl +0 -0
index 97b2c61..2bf234c 100755

scripts/checkincludes.pl if ($#ARGV >= 1) { · line 45

Quoted 9 lines
scripts/checkincludes.pl +6 -0
@@ -37,6 +37,13 @@ if ($#ARGV >= 1) {
 	}
 }
 
+my $dup_counter = 0;
+
+sub nodup_count {
+	++$dup_counter;
+	return;
+}

I don't think it's necessary to have a function only to increment a variable.

Quoted 1 line

Michal

Sorry do you mean the subroutine is not required and the "variable" is best placed inside directly?

Thanks.
CheahKC