Fixed a bug where return carraiges would offset line number calculations (close #180)

pull/194/head
David Pokora 6 years ago
parent 0891f9a8a5
commit ad4fc1b510
No known key found for this signature in database
GPG Key ID: 3CED48D1BB21BDD7
  1. 6
      slither/solc_parsing/slitherSolc.py

@ -89,7 +89,7 @@ class SlitherSolc(Slither):
if 'sourcePaths' in data_loaded: if 'sourcePaths' in data_loaded:
for sourcePath in data_loaded['sourcePaths']: for sourcePath in data_loaded['sourcePaths']:
if os.path.isfile(sourcePath): if os.path.isfile(sourcePath):
with open(sourcePath, encoding='utf8') as f: with open(sourcePath, encoding='utf8', newline='') as f:
source_code = f.read() source_code = f.read()
self.source_code[sourcePath] = source_code self.source_code[sourcePath] = source_code
@ -152,13 +152,13 @@ class SlitherSolc(Slither):
self._source_units[sourceUnit] = name self._source_units[sourceUnit] = name
if os.path.isfile(name) and not name in self.source_code: if os.path.isfile(name) and not name in self.source_code:
with open(name, encoding='utf8') as f: with open(name, encoding='utf8', newline='') as f:
source_code = f.read() source_code = f.read()
self.source_code[name] = source_code self.source_code[name] = source_code
else: else:
lib_name = os.path.join('node_modules', name) lib_name = os.path.join('node_modules', name)
if os.path.isfile(lib_name) and not name in self.source_code: if os.path.isfile(lib_name) and not name in self.source_code:
with open(lib_name, encoding='utf8') as f: with open(lib_name, encoding='utf8', newline='') as f:
source_code = f.read() source_code = f.read()
self.source_code[name] = source_code self.source_code[name] = source_code

Loading…
Cancel
Save