From 818682ea9a0b13c16f57cb29ed5e885b83d030ba Mon Sep 17 00:00:00 2001 From: Pascal Obry Date: Tue, 6 Sep 2011 16:07:53 +0200 Subject: [PATCH] Do not check copyright pattern for older years. Add regression test. --- regtests/copyright.ads | 2 +- regtests/makefile | 3 ++- regtests/out13.out | 8 ++++---- src/style_checker.adb | 6 +++++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/regtests/copyright.ads b/regtests/copyright.ads index 1b0cfec..a9bc154 100644 --- a/regtests/copyright.ads +++ b/regtests/copyright.ads @@ -1,4 +1,4 @@ - +-- Copyright (C) 2000-2001, John Doe -- Copyright (C) 2000-2005, Pascal Obry -- Copyright (C) 2000-2005 Pascal Obry -- Copyright (C) 2000 - 2005, Pascal Obry diff --git a/regtests/makefile b/regtests/makefile index 40d6658..cf53457 100644 --- a/regtests/makefile +++ b/regtests/makefile @@ -23,9 +23,10 @@ run_tests: -../style_checker -A -m 2 hello.e > out11.res 2>&1 -../style_checker header1.adb header2.adb header3.adb > out12.tmp 2>&1 sed 's,$(YEAR),2010,g' out12.tmp > out12.res + sed 's,2005,$(YEAR),g' copyright.ads > copyright2.ads -../style_checker -S -cY -H \ -cf'Copyright \(C\) 2\d\d\d-2\d\d\d, (Pascal Obry|Qwerty)' \ - copyright.ads > out13.res 2>&1 + copyright2.ads > out13.res 2>&1 -../style_checker -H script.sh > out14.res 2>&1 -../style_checker -d -cY pck.ads > out15.res 2>&1 -../style_checker -d -cY main.c > out16.res 2>&1 diff --git a/regtests/out13.out b/regtests/out13.out index 4879207..6897054 100644 --- a/regtests/out13.out +++ b/regtests/out13.out @@ -1,4 +1,4 @@ -copyright.ads:3: copyright line not matching expected pattern -copyright.ads:4: copyright line not matching expected pattern -copyright.ads:5: copyright line not matching expected pattern -copyright.ads:6: copyright line not matching expected pattern +copyright2.ads:3: copyright line not matching expected pattern +copyright2.ads:4: copyright line not matching expected pattern +copyright2.ads:5: copyright line not matching expected pattern +copyright2.ads:6: copyright line not matching expected pattern diff --git a/src/style_checker.adb b/src/style_checker.adb index 2e6cea8..765d92d 100644 --- a/src/style_checker.adb +++ b/src/style_checker.adb @@ -282,6 +282,7 @@ procedure Style_Checker is procedure Check_Copyright is use Text_IO; + C_Year : constant Boolean := Fixed.Index (Line, Current_Year) /= 0; Co_Start : Natural := 0; Cp_Start : Natural := Fixed.Index (Line, " Copyright"); begin @@ -312,9 +313,12 @@ procedure Style_Checker is end if; end if; - -- Check that the copyright year follow the given regexp + -- Check that the copyright year follow the given regexp only if we + -- have found the current copyright year. This is important as + -- previous copyright on a source could be with another format. if Cp_Start /= 0 + and then C_Year and then Checker.Lang.Get_Copyright_Pattern /= "" then declare -- 2.11.4.GIT