From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Shevchenko Date: Mon, 04 Jun 2018 12:49:28 +0300 Subject: [U-Boot] [RFC PATCH] moveconfig: add a second pass for empty #if/#endif blocks In-Reply-To: <20180604092745.22468-1-judge.packham@gmail.com> References: <20180604092745.22468-1-judge.packham@gmail.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Mon, 2018-06-04 at 21:27 +1200, Chris Packham wrote: > Moveconfig already attempts to remove empty #if/#endif blocks when > there > is a matching CONFIG_ being moved. Add a second pass which covers > files > without a match. > + pattern = r'^\s*#\s*if.*$\n^\s*#\s*endif.*$\n*' Any reason not to use re.compile() ? > + with open(header_path) as f: > + data = f.read() > + > + new_data = re.sub(pattern, '\n', data, flags=re.M) -- Andy Shevchenko Intel Finland Oy