Patrick Georgi | 533ec00 | 2012-03-07 15:49:07 +0100 | [diff] [blame] | 1 | #!/bin/sh |
Patrick Georgi | 533ec00 | 2012-03-07 15:49:07 +0100 | [diff] [blame] | 2 | # |
Patrick Georgi | 7333a11 | 2020-05-08 20:48:04 +0200 | [diff] [blame] | 3 | # SPDX-License-Identifier: GPL-2.0-only |
| 4 | |
Patrick Georgi | 533ec00 | 2012-03-07 15:49:07 +0100 | [diff] [blame] | 5 | # DESCR: Check that C labels begin at start-of-line |
| 6 | |
| 7 | LC_ALL=C export LC_ALL |
Martin Roth | e033053 | 2016-03-30 13:56:23 -0600 | [diff] [blame] | 8 | |
| 9 | # Use git ls-files if the code is in a git repo, otherwise use find. |
Alex Thiessen | 73f19dc | 2018-01-16 23:05:48 +0000 | [diff] [blame] | 10 | if [ -n "$(command -v git)" ] && \ |
| 11 | [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ] |
| 12 | then |
Martin Roth | e033053 | 2016-03-30 13:56:23 -0600 | [diff] [blame] | 13 | FIND_FILES="git ls-files" |
| 14 | else |
| 15 | FIND_FILES="find src" |
| 16 | fi |
| 17 | |
| 18 | ${FIND_FILES} | \ |
| 19 | grep "^src/.*\.[csS]$" | \ |
| 20 | xargs grep -Hn '^[[:space:]][[:space:]]*[a-z][a-z]*:[[:space:]]*$' | \ |
| 21 | grep -v "[^a-z_]default:" |