From: Richard Purdie Date: Tue, 7 Sep 2010 13:33:53 +0000 (+0100) Subject: bitbake/codeparser: Deal with functions with trailing whitespace X-Git-Tag: yocto-4.0~44288 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=647713050b091e55497aee5647b6d0d0abc08411;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git bitbake/codeparser: Deal with functions with trailing whitespace Signed-off-by: Richard Purdie --- diff --git a/bitbake/lib/bb/codeparser.py b/bitbake/lib/bb/codeparser.py index 951bd47b88f..7d40835cb84 100644 --- a/bitbake/lib/bb/codeparser.py +++ b/bitbake/lib/bb/codeparser.py @@ -15,7 +15,14 @@ except ImportError: def check_indent(codestr): """If the code is indented, add a top level piece of code to 'remove' the indentation""" - if codestr[0] is " " or codestr[0] is " ": + i = 0 + while codestr[i] in ["\n", " ", " "]: + i = i + 1 + + if i == 0: + return codestr + + if codestr[i-1] is " " or codestr[i-1] is " ": return "if 1:\n" + codestr return codestr