Fix for bug where library names could collide

Multiple libraries from one file wouldn't use unique ID.name members.
Now used memory address instead of the name to keep track of which blocks we've visited.
This commit is contained in:
2015-02-20 21:11:00 +11:00
parent 18b1ecff1e
commit a542c8bfc4

View File

@@ -267,7 +267,8 @@ class FilePath:
if recursive and (level > 0) and (block_codes is not None) and (recursive_all is False): if recursive and (level > 0) and (block_codes is not None) and (recursive_all is False):
# prevent from expanding the # prevent from expanding the
# same datablock more then once # same datablock more then once
expand_codes = set() # note: we could *almost* id_name, however this isn't unique for libraries.
expand_addr_visit = set()
# {lib_id: {block_ids... }} # {lib_id: {block_ids... }}
expand_codes_idlib = {} expand_codes_idlib = {}
@@ -286,7 +287,7 @@ class FilePath:
expand_codes_idlib.setdefault(block[b'lib'], set()).add(block[b'name']) expand_codes_idlib.setdefault(block[b'lib'], set()).add(block[b'name'])
return False return False
else: else:
id_name = block[b'id.name'] # id_name = block[b'id.name']
# if we touched this already, don't touch again # if we touched this already, don't touch again
# FIXME, works in some cases but not others # FIXME, works in some cases but not others
@@ -295,9 +296,9 @@ class FilePath:
return False return False
''' '''
len_prev = len(expand_codes) len_prev = len(expand_addr_visit)
expand_codes.add(id_name) expand_addr_visit.add(block.addr_old)
return (len_prev != len(expand_codes)) return (len_prev != len(expand_addr_visit))
def block_expand(block, code): def block_expand(block, code):
assert(block.code == code) assert(block.code == code)
@@ -314,7 +315,7 @@ class FilePath:
if code == b'ID': if code == b'ID':
yield block yield block
else: else:
expand_codes = None expand_addr_visit = None
# set below # set below
expand_codes_idlib = None expand_codes_idlib = None
@@ -384,10 +385,10 @@ class FilePath:
for block in iter_blocks_id(code): for block in iter_blocks_id(code):
yield from FilePath.from_block(block, basedir, extra_info, level) yield from FilePath.from_block(block, basedir, extra_info, level)
# print("A:", expand_codes) # print("A:", expand_addr_visit)
# print("B:", block_codes) # print("B:", block_codes)
if VERBOSE: if VERBOSE:
log_deps.info("%s%s" % (indent_str, set_as_str(expand_codes))) log_deps.info("%s%s" % (indent_str, set_as_str(expand_addr_visit)))
if recursive: if recursive: