From: Tom Rini Date: Sun, 24 Jul 2016 11:19:09 -0400 Subject: [U-Boot] [PATCH 1/4] tools: moveconfig: trim garbage lines after header cleanups In-Reply-To: <1469369859-14277-2-git-send-email-yamada.masahiro@socionext.com> References: <1469369859-14277-1-git-send-email-yamada.masahiro@socionext.com> <1469369859-14277-2-git-send-email-yamada.masahiro@socionext.com> Message-ID: <20160724151909.GU14698@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Sun, Jul 24, 2016 at 11:17:36PM +0900, Masahiro Yamada wrote: > The tools/moveconfig.py has a feature to cleanup #define/#undef's > of moved config options, but I want this tool to do a better job. > > For example, when we are moving CONFIG_FOO and its define is > surrounded by #ifdef ... #endif, like follows: > > #ifdef CONFIG_BAR > # define CONFIG_FOO > #endif > > The header cleanup will leave empty #ifdef ... #endif: > > #ifdef CONFIG_BAR > #endif > > Likewise, if a define line between two blank lines > > > #define CONFIG_FOO > > ... is deleted, the result of the clean-up will be successive empty > lines, which is a coding-style violation. Thanks! This is mildly annoying to find/fixup with regex, which is how I usually do it. A few comments / questions: [snip] > + # remove empty #ifdef ... #endif, successive blank lines > + pattern_ifdef = re.compile(r'#\s*if(def|ndef)?\s') It starts to get complex to catch if defined/elif defined cases, so we should just leave that to manual review, yes? > + pattern_endif = re.compile(r'#\s*endif\s') > + pattern_blank = re.compile(r'^\s*$') The last pattern will catch multiple blank lines, right? -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: