blob: 393774fdaef69a5c01b4a722e95e0b47a843df43 [file] [log] [blame]
Martin Roth0ad5fbd2020-12-24 12:06:38 -07001#!/usr/bin/env sh
Patrick Georgi533ec002012-03-07 15:49:07 +01002#
Patrick Georgi7333a112020-05-08 20:48:04 +02003# SPDX-License-Identifier: GPL-2.0-only
4
Patrick Georgi533ec002012-03-07 15:49:07 +01005# DESCR: Check that C labels begin at start-of-line
6
7LC_ALL=C export LC_ALL
Martin Rothe0330532016-03-30 13:56:23 -06008
9# Use git ls-files if the code is in a git repo, otherwise use find.
Alex Thiessen73f19dc2018-01-16 23:05:48 +000010if [ -n "$(command -v git)" ] && \
11 [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
12then
Martin Rothe0330532016-03-30 13:56:23 -060013 FIND_FILES="git ls-files"
14else
15 FIND_FILES="find src"
16fi
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:"