blob: 36d2581974e6d0b26943c094f7ca3ebf59f52dab [file] [log] [blame]
Patrick Georgi533ec002012-03-07 15:49:07 +01001#!/bin/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:"