From be11e7a256e2a36096234dd3dae5e6ed731069c9 Mon Sep 17 00:00:00 2001 From: Ron Economos <w6rz@comcast.net> Date: Fri, 8 Mar 2019 19:56:29 +0100 Subject: utils: remove space inserted for empty comment lines from generated code --- gr-utils/python/modtool/tools/util_functions.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'gr-utils/python') diff --git a/gr-utils/python/modtool/tools/util_functions.py b/gr-utils/python/modtool/tools/util_functions.py index 15409eacc3..709c9aeb40 100644 --- a/gr-utils/python/modtool/tools/util_functions.py +++ b/gr-utils/python/modtool/tools/util_functions.py @@ -1,5 +1,5 @@ # -# Copyright 2013, 2018 Free Software Foundation, Inc. +# Copyright 2013, 2018, 2019 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -57,15 +57,32 @@ def remove_pattern_from_file(filename, pattern): def str_to_fancyc_comment(text): """ Return a string as a C formatted comment. """ l_lines = text.splitlines() - outstr = "/* " + l_lines[0] + "\n" + if len(l_lines[0]) == 0: + outstr = "/*\n" + else: + outstr = "/* " + l_lines[0] + "\n" for line in l_lines[1:]: - outstr += " * " + line + "\n" + if len(line) == 0: + outstr += " *\n" + else: + outstr += " * " + line + "\n" outstr += " */\n" return outstr def str_to_python_comment(text): """ Return a string as a Python formatted comment. """ - return re.compile('^', re.MULTILINE).sub('# ', text) + l_lines = text.splitlines() + if len(l_lines[0]) == 0: + outstr = "#\n" + else: + outstr = "# " + l_lines[0] + "\n" + for line in l_lines[1:]: + if len(line) == 0: + outstr += "#\n" + else: + outstr += "# " + line + "\n" + outstr += "#\n" + return outstr def strip_default_values(string): """ Strip default values from a C++ argument list. """ -- cgit v1.2.3