From a7ad9fb30fd4ac0c1d2940d39b518719b5343ce3 Mon Sep 17 00:00:00 2001 From: Pascal Obry Date: Thu, 17 Jan 2008 15:22:48 +0100 Subject: [PATCH] Do not check special script headers starting with #!. --- regtests/makefile | 2 ++ regtests/out14.out | 2 ++ regtests/script.sh | 8 ++++++++ src/style_checker.adb | 3 +++ 4 files changed, 15 insertions(+) create mode 100644 regtests/out14.out create mode 100644 regtests/script.sh diff --git a/regtests/makefile b/regtests/makefile index 30f65f0..e719aee 100644 --- a/regtests/makefile +++ b/regtests/makefile @@ -20,6 +20,7 @@ run_tests: -../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 + -../style_checker -H script.sh > out14.res 2>&1 check_results: echo "### regressions follows" @@ -37,6 +38,7 @@ check_results: -diff -wc out11.out out11.res || echo $$? >> out_status.res -diff -wc out12.out out12.res || echo $$? >> out_status.res -diff -wc out13.out out13.res || echo $$? >> out_status.res + -diff -wc out14.out out14.res || echo $$? >> out_status.res test ! -e out_status.res clean: diff --git a/regtests/out14.out b/regtests/out14.out new file mode 100644 index 0000000..e02d3d0 --- /dev/null +++ b/regtests/out14.out @@ -0,0 +1,2 @@ +script.sh:5: 2 spaces after # +script.sh:8: 2 spaces after # diff --git a/regtests/script.sh b/regtests/script.sh new file mode 100644 index 0000000..0809bd0 --- /dev/null +++ b/regtests/script.sh @@ -0,0 +1,8 @@ +#! /bin/sh + +gnat make -P whatever + +# Copy executable + +cp whatever ~/bin +#!end of script diff --git a/src/style_checker.adb b/src/style_checker.adb index 97341f9..51a0792 100644 --- a/src/style_checker.adb +++ b/src/style_checker.adb @@ -356,6 +356,9 @@ procedure Style_Checker is and then I + C'Length - 1 <= Line'Last and then Line (I .. I + C'Length - 1) = C and then Line (Line'Last - C'Length + 1 .. Line'Last) /= C + and then (Line (I .. I + 1) /= "#!" + or else File_Reader.Line (Checker.File) > 1) + -- Do no check script headers then for K in I + C'Length .. I + C'Length + N - 1 loop if Line (K) /= ' ' then -- 2.11.4.GIT