From 88f2dc5810b88f88b516bb6f11fc3cba1c255655 Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Fri, 3 Apr 2015 20:43:13 +0300 Subject: Improve comment support in .options files. Update issue 145 Status: FixedInGit --- generator/nanopb_generator.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'generator/nanopb_generator.py') diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py index eebe5404..b1ee04e0 100755 --- a/generator/nanopb_generator.py +++ b/generator/nanopb_generator.py @@ -4,6 +4,7 @@ nanopb_version = "nanopb-0.3.3-dev" import sys +import re try: # Add some dummy imports to keep packaging tools happy. @@ -1164,9 +1165,13 @@ def read_options_file(infile): [(namemask, options), ...] ''' results = [] - for i, line in enumerate(infile): + data = infile.read() + data = re.sub('/\*.*?\*/', '', data, flags = re.MULTILINE) + data = re.sub('//.*?$', '', data, flags = re.MULTILINE) + data = re.sub('#.*?$', '', data, flags = re.MULTILINE) + for i, line in enumerate(data.split('\n')): line = line.strip() - if not line or line.startswith('//') or line.startswith('#'): + if not line: continue parts = line.split(None, 1) -- cgit 1.2.3-korg