mirror of
https://github.com/Mbed-TLS/mbedtls-framework.git
synced 2026-08-02 01:07:47 +00:00
c_wrapper_generator: Fixed an edge-case in strip_indentation().
Co-authored-by: Gilles Peskine <[email protected]> Signed-off-by: minosgalanakis <[email protected]>
This commit is contained in:
co-authored by
Gilles Peskine
parent
01343e254c
commit
c6b46474bf
@@ -44,9 +44,9 @@ def strip_indentation(in_str: str, new_lines: int = 1, indent_lv: int = 0) -> st
|
||||
|
||||
# Count empty spaces in beggining of each line. The smallest non-zero entry
|
||||
# will be used to clean up input indentation.
|
||||
_common_indents = min([len(n) for n in re.findall(r'(?m)^ +', in_str)])
|
||||
if _common_indents:
|
||||
_ret_string = re.sub(r'(?m)^ {{{indent}}}'.format(indent=_common_indents),
|
||||
indents = [len(n) for n in re.findall(r'(?m)^ +', in_str)]
|
||||
if indents:
|
||||
_ret_string = re.sub(r'(?m)^ {{{indent}}}'.format(indent=min(indents)),
|
||||
'', _ret_string)
|
||||
if indent_lv:
|
||||
_ret_string = '\n'.join([' ' * indent_lv * 4 + s
|
||||
|
||||
Reference in New Issue
Block a user