aboutsummaryrefslogtreecommitdiffstats
path: root/generator/nanopb_generator.py
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-04-03 20:43:13 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-04-03 20:43:13 +0300
commit88f2dc5810b88f88b516bb6f11fc3cba1c255655 (patch)
tree5b688d8e56262f82c9d9a65f0eaf30a03c562dad /generator/nanopb_generator.py
parent3bcdd49eac3aabcc121173c0023834f8bcf0a3cb (diff)
Improve comment support in .options files.
Update issue 145 Status: FixedInGit
Diffstat (limited to 'generator/nanopb_generator.py')
-rwxr-xr-xgenerator/nanopb_generator.py9
1 files changed, 7 insertions, 2 deletions
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)