buildcommands: Detect duplicate strings when generating static string ids

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-11-18 03:13:31 -05:00
parent b3e8429b54
commit 9db0bec792
1 changed files with 4 additions and 1 deletions

View File

@ -69,10 +69,13 @@ STATIC_STRING_MIN = 2
class HandleStaticStrings:
def __init__(self):
self.static_strings = []
self.found_strings = {}
self.ctr_dispatch = { '_DECL_STATIC_STR': self.decl_static_str }
def decl_static_str(self, req):
msg = req.split(None, 1)[1]
self.static_strings.append(msg)
if msg not in self.found_strings:
self.found_strings[msg] = 1
self.static_strings.append(msg)
def update_data_dictionary(self, data):
data['static_strings'] = { i + STATIC_STRING_MIN: s
for i, s in enumerate(self.static_strings) }