Patrick Georgi | 533ec00 | 2012-03-07 15:49:07 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # This file is part of the coreboot project. |
| 3 | # |
| 4 | # Copyright (C) 2012 Patrick Georgi <patrick@georgi-clan.de> |
Martin Roth | e033053 | 2016-03-30 13:56:23 -0600 | [diff] [blame] | 5 | # Copyright (C) 2016 Google Inc. |
Patrick Georgi | 533ec00 | 2012-03-07 15:49:07 +0100 | [diff] [blame] | 6 | # |
| 7 | # This program is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation; version 2 of the License. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | # |
Patrick Georgi | 533ec00 | 2012-03-07 15:49:07 +0100 | [diff] [blame] | 16 | # DESCR: Check that C labels begin at start-of-line |
| 17 | |
| 18 | LC_ALL=C export LC_ALL |
Martin Roth | e033053 | 2016-03-30 13:56:23 -0600 | [diff] [blame] | 19 | |
| 20 | # Use git ls-files if the code is in a git repo, otherwise use find. |
| 21 | if [ -n "$(command -v git)" ] && [ -d .git ]; then |
| 22 | FIND_FILES="git ls-files" |
| 23 | else |
| 24 | FIND_FILES="find src" |
| 25 | fi |
| 26 | |
| 27 | ${FIND_FILES} | \ |
| 28 | grep "^src/.*\.[csS]$" | \ |
| 29 | xargs grep -Hn '^[[:space:]][[:space:]]*[a-z][a-z]*:[[:space:]]*$' | \ |
| 30 | grep -v "[^a-z_]default:" |