|
Packit |
209faa |
# Copyright 2015 The Kyua Authors.
|
|
Packit |
209faa |
# All rights reserved.
|
|
Packit |
209faa |
#
|
|
Packit |
209faa |
# Redistribution and use in source and binary forms, with or without
|
|
Packit |
209faa |
# modification, are permitted provided that the following conditions are
|
|
Packit |
209faa |
# met:
|
|
Packit |
209faa |
#
|
|
Packit |
209faa |
# * Redistributions of source code must retain the above copyright
|
|
Packit |
209faa |
# notice, this list of conditions and the following disclaimer.
|
|
Packit |
209faa |
# * Redistributions in binary form must reproduce the above copyright
|
|
Packit |
209faa |
# notice, this list of conditions and the following disclaimer in the
|
|
Packit |
209faa |
# documentation and/or other materials provided with the distribution.
|
|
Packit |
209faa |
# * Neither the name of Google Inc. nor the names of its contributors
|
|
Packit |
209faa |
# may be used to endorse or promote products derived from this software
|
|
Packit |
209faa |
# without specific prior written permission.
|
|
Packit |
209faa |
#
|
|
Packit |
209faa |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
Packit |
209faa |
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
Packit |
209faa |
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
Packit |
209faa |
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
Packit |
209faa |
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
Packit |
209faa |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
Packit |
209faa |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
Packit |
209faa |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
Packit |
209faa |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
Packit |
209faa |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
Packit |
209faa |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
209faa |
|
|
Packit |
209faa |
function warn(msg) {
|
|
Packit |
209faa |
print FILENAME "[" FNR "]: " msg > "/dev/stderr"
|
|
Packit |
209faa |
error = 1
|
|
Packit |
209faa |
}
|
|
Packit |
209faa |
|
|
Packit |
209faa |
BEGIN {
|
|
Packit |
209faa |
skip = 0
|
|
Packit |
209faa |
error = 0
|
|
Packit |
209faa |
}
|
|
Packit |
209faa |
|
|
Packit |
209faa |
/CHECK_STYLE_DISABLE/ {
|
|
Packit |
209faa |
skip = 1
|
|
Packit |
209faa |
next
|
|
Packit |
209faa |
}
|
|
Packit |
209faa |
|
|
Packit |
209faa |
/CHECK_STYLE_ENABLE/ {
|
|
Packit |
209faa |
skip = 0
|
|
Packit |
209faa |
next
|
|
Packit |
209faa |
}
|
|
Packit |
209faa |
|
|
Packit |
209faa |
/CHECK_STYLE_(ENABLE|DISABLE)/ {
|
|
Packit |
209faa |
next
|
|
Packit |
209faa |
}
|
|
Packit |
209faa |
|
|
Packit |
209faa |
{
|
|
Packit |
209faa |
if (skip)
|
|
Packit |
209faa |
next
|
|
Packit |
209faa |
|
|
Packit |
209faa |
if (length > 80 && NF > 1)
|
|
Packit |
209faa |
warn("Line too long to fit on screen")
|
|
Packit |
209faa |
}
|
|
Packit |
209faa |
|
|
Packit |
209faa |
/^ *\t+/ {
|
|
Packit |
209faa |
if (! match(FILENAME, "Makefile"))
|
|
Packit |
209faa |
warn("Tab character used for indentation");
|
|
Packit |
209faa |
}
|
|
Packit |
209faa |
|
|
Packit |
209faa |
/[ \t]+$/ {
|
|
Packit |
209faa |
warn("Trailing spaces or tabs");
|
|
Packit |
209faa |
}
|
|
Packit |
209faa |
|
|
Packit |
209faa |
/^#![^ ]/ {
|
|
Packit |
209faa |
warn("Missing space after #!");
|
|
Packit |
209faa |
}
|
|
Packit |
209faa |
|
|
Packit |
209faa |
END {
|
|
Packit |
209faa |
if (skip)
|
|
Packit |
209faa |
warn("Missing CHECK_STYLE_ENABLE");
|
|
Packit |
209faa |
if (error)
|
|
Packit |
209faa |
exit 1
|
|
Packit |
209faa |
}
|