devtools: check wrong svg include in patches

Message ID 20181031110548.31184-1-thomas@monjalon.net (mailing list archive)
State Superseded, archived
Headers
Series devtools: check wrong svg include in patches |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Thomas Monjalon Oct. 31, 2018, 11:05 a.m. UTC
  Including svg files with the svg extension is a common mistake:
	.. figure:: example.svg
must be
	.. figure:: example.*
So it will work also when building pdf doc with figures converted
to png files.

A check is added in checkpatches.sh.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>

PS: it seems this check is not working. Arnon, I need your help please.
Cc: Arnon Warshavsky <arnon@qwilt.com>
---
 devtools/checkpatches.sh | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

Arnon Warshavsky Oct. 31, 2018, 3:46 p.m. UTC | #1
Hi Thomas

Glad the function gets to be reused :)
Now that it has more than one consumer apparently the function
check_forbidden_additions() cannot be fed by stdin.
I got it working with 3 changes:

1. call the awk script with $tmpinput as a parameter instead of stdin. This
aligns with Neils changes from previous version
2. Escaped the spaces from the regex , as the awk script uses spaces to
tell multiple forbidden expressions apart (which now I see sucks ...),
    and added an extra backslash
3. call the function with no parameters (not needed anymore)

        awk -v FOLDERS="lib drivers" \
                -v EXPRESSIONS="rte_panic\\\( rte_exit\\\(" \
                -v RET_ON_FAIL=1 \
-               -f $(dirname $(readlink -e $0))/check-forbidden-tokens.awk -
+               -f $(dirname $(readlink -e $0))/check-forbidden-tokens.awk
*$tmpinput*
+
+       awk -v FOLDERS='doc' \
+               -v EXPRESSIONS='*::[[:space:]]*[^[:space:]]*\\\.svg*' \
+               -v RET_ON_FAIL=1 \
+               -f $(dirname $(readlink -e $0))/check-forbidden-tokens.awk
*$tmpinput*

        ! $verbose || printf '\nChecking forbidden tokens additions:\n'
-       report=$(check_forbidden_additions *<"$tmpinput"*)
+       report=$(check_forbidden_additions)

thanks
/Arnon
  
Thomas Monjalon Oct. 31, 2018, 3:51 p.m. UTC | #2
Hi Arnon,

31/10/2018 16:46, Arnon Warshavsky:
> Hi Thomas
> 
> Glad the function gets to be reused :)
> Now that it has more than one consumer apparently the function
> check_forbidden_additions() cannot be fed by stdin.
> I got it working with 3 changes:

Thanks for the help

> 1. call the awk script with $tmpinput as a parameter instead of stdin. This
> aligns with Neils changes from previous version
> 2. Escaped the spaces from the regex , as the awk script uses spaces to
> tell multiple forbidden expressions apart (which now I see sucks ...),
>     and added an extra backslash

Are you sure we need an extra backslash?
Note that I am using single quotes.
I thought we need only 2 backslashes in this case.

> 3. call the function with no parameters (not needed anymore)
> 
>         awk -v FOLDERS="lib drivers" \
>                 -v EXPRESSIONS="rte_panic\\\( rte_exit\\\(" \
>                 -v RET_ON_FAIL=1 \
> -               -f $(dirname $(readlink -e $0))/check-forbidden-tokens.awk -
> +               -f $(dirname $(readlink -e $0))/check-forbidden-tokens.awk
> *$tmpinput*
> +
> +       awk -v FOLDERS='doc' \
> +               -v EXPRESSIONS='*::[[:space:]]*[^[:space:]]*\\\.svg*' \
> +               -v RET_ON_FAIL=1 \
> +               -f $(dirname $(readlink -e $0))/check-forbidden-tokens.awk
> *$tmpinput*
> 
>         ! $verbose || printf '\nChecking forbidden tokens additions:\n'
> -       report=$(check_forbidden_additions *<"$tmpinput"*)
> +       report=$(check_forbidden_additions)
  
Arnon Warshavsky Oct. 31, 2018, 3:55 p.m. UTC | #3
> >     and added an extra backslash
>
> Are you sure we need an extra backslash?
> Note that I am using single quotes.
> I thought we need only 2 backslashes in this case.
>

You are right.
Its only required with double quotes
  

Patch

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index bf3114f95..e69b5bc34 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -50,6 +50,12 @@  check_forbidden_additions() {
 		-v EXPRESSIONS="rte_panic\\\( rte_exit\\\(" \
 		-v RET_ON_FAIL=1 \
 		-f $(dirname $(readlink -e $0))/check-forbidden-tokens.awk -
+	# svg figures must be included with wildcard extension
+	# because of png conversion for pdf docs
+	awk -v FOLDERS='doc' \
+		-v EXPRESSIONS=':: *[^ ]*\\.svg' \
+		-v RET_ON_FAIL=1 \
+		-f $(dirname $(readlink -e $0))/check-forbidden-tokens.awk -
 }
 
 number=0