From 893ca8b65447f541d94f08047ca67529039da97b Mon Sep 17 00:00:00 2001 From: Pascal Obry Date: Mon, 9 Dec 2013 12:12:21 +0100 Subject: [PATCH] Allow 'and then not' and 'or else not' as the single line content. --- regtests/andthennot.adb | 24 ++++++++++++++++++++++++ regtests/makefile | 2 ++ regtests/out27.out | 1 + src/style_checker.adb | 12 +++++++++++- 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 regtests/andthennot.adb create mode 100644 regtests/out27.out diff --git a/regtests/andthennot.adb b/regtests/andthennot.adb new file mode 100644 index 0000000..514800e --- /dev/null +++ b/regtests/andthennot.adb @@ -0,0 +1,24 @@ + +procedure AndThenNot is +begin + if Toto and then not + True + then + null; + end if; + + if Toto + and then not + True + then + null; + end if; + + if Toto + or else not + True + then + null; + end if; + +end AndThenNot; diff --git a/regtests/makefile b/regtests/makefile index a81bc58..6583efe 100644 --- a/regtests/makefile +++ b/regtests/makefile @@ -44,6 +44,7 @@ run_tests: -../style_checker -Hw withuse3.adb > out24.res 2>&1 -../style_checker -Hw withuse4.adb > out25.res 2>&1 -../style_checker -Hw aspect.adb > out26.res 2>&1 + -../style_checker -Hw -o andthennot.adb > out27.res 2>&1 check_results: echo "### regressions follows" @@ -74,6 +75,7 @@ check_results: -diff -wc out24.out out24.res || echo $$? >> out_status.res -diff -wc out25.out out25.res || echo $$? >> out_status.res -diff -wc out26.out out26.res || echo $$? >> out_status.res + -diff -wc out27.out out27.res || echo $$? >> out_status.res test ! -e out_status.res clean: diff --git a/regtests/out27.out b/regtests/out27.out new file mode 100644 index 0000000..483c286 --- /dev/null +++ b/regtests/out27.out @@ -0,0 +1 @@ +andthennot.adb:4: 'not' operator at end of line diff --git a/src/style_checker.adb b/src/style_checker.adb index 51e3a4d..c090ddd 100644 --- a/src/style_checker.adb +++ b/src/style_checker.adb @@ -455,7 +455,7 @@ procedure Style_Checker is procedure Check_Operator_EOL is I : constant Natural := First_Non_Blank; - L : constant Natural := Line'Length - I; + L : constant Natural := Line'Length - I + 1; function Get_Operator return String; -- Returns EOL operaror of empty line if not found @@ -478,6 +478,16 @@ procedure Style_Checker is elsif L > 2 and then Line (Line'Last - 2 .. Line'Last) = " or" then return Line (Line'Last - 1 .. Line'Last); + elsif L = 11 + and then Line (Line'Last - 10 .. Line'Last) = "or else not" + then + return ""; + + elsif L = 12 + and then Line (Line'Last - 11 .. Line'Last) = "and then not" + then + return ""; + elsif L > 3 and then (Line (Line'Last - 3 .. Line'Last) = " not" or else Line (Line'Last - 3 .. Line'Last) = " and" -- 2.11.4.GIT