[U-Boot] [PATCH 1/4] tools: moveconfig: trim garbage lines after header cleanups

Tom Rini trini at konsulko.com
Sun Jul 24 17:19:09 CEST 2016


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
> 
>   <blank line>
>   #define CONFIG_FOO
>   <blank lines.
> 
> ... 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: <http://lists.denx.de/pipermail/u-boot/attachments/20160724/5ce3b785/attachment.sig>


More information about the U-Boot mailing list