aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Peter Seiderer <ps.report@gmx.net>2019-05-08 19:34:27 +0200
committerGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2019-05-18 23:34:59 +0200
commit8e352c32b0beded97a8a5c1e9edc9d618514ee7b (patch)
tree6a458226ec81682986e1994fe5c6b8c8d236abbe
parentdff08793eec131a4d3ba87771f1ed6a8e5a1e294 (diff)
downloadbuildroot-8e352c32b0beded97a8a5c1e9edc9d618514ee7b.tar.gz
buildroot-8e352c32b0beded97a8a5c1e9edc9d618514ee7b.tar.bz2
utils/check-package: warn about utf-8 characters in .mk files
Signed-off-by: Peter Seiderer <ps.report@gmx.net> Tested-by: Titouan Christophe <titouan.christophe@railnova.eu> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
-rw-r--r--utils/checkpackagelib/lib.py13
-rw-r--r--utils/checkpackagelib/lib_mk.py1
2 files changed, 14 insertions, 0 deletions
diff --git a/utils/checkpackagelib/lib.py b/utils/checkpackagelib/lib.py
index 6afe1aabce..c65a2ed939 100644
--- a/utils/checkpackagelib/lib.py
+++ b/utils/checkpackagelib/lib.py
@@ -52,3 +52,16 @@ class TrailingSpace(_CheckFunction):
return ["{}:{}: line contains trailing whitespace"
.format(self.filename, lineno),
text]
+
+class Utf8Characters(_CheckFunction):
+ def is_ascii(self, s):
+ try:
+ return all(ord(c) < 128 for c in s)
+ except TypeError:
+ return False
+
+ def check_line(self, lineno, text):
+ if not self.is_ascii(text):
+ return ["{}:{}: line contains UTF-8 characters"
+ .format(self.filename, lineno),
+ text]
diff --git a/utils/checkpackagelib/lib_mk.py b/utils/checkpackagelib/lib_mk.py
index 00efeb7fb2..9e9a045776 100644
--- a/utils/checkpackagelib/lib_mk.py
+++ b/utils/checkpackagelib/lib_mk.py
@@ -11,6 +11,7 @@ from checkpackagelib.lib import ConsecutiveEmptyLines # noqa: F401
from checkpackagelib.lib import EmptyLastLine # noqa: F401
from checkpackagelib.lib import NewlineAtEof # noqa: F401
from checkpackagelib.lib import TrailingSpace # noqa: F401
+from checkpackagelib.lib import Utf8Characters # noqa: F401
# used in more than one check
start_conditional = ["ifdef", "ifeq", "ifndef", "ifneq"]