mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-11-21 10:31:25 +00:00
Don't search for filenames given on cmdline in the include path.
This commit is contained in:
parent
a9917d3ea8
commit
023a415a14
@ -31,7 +31,7 @@ def process_input_files(filenames, options):
|
||||
programs = []
|
||||
|
||||
for filename in options.filenames:
|
||||
program = load_program(filename, symtab, include_path)
|
||||
program = load_program(filename, symtab, include_path, include_file=False)
|
||||
if options.debug:
|
||||
print(symtab)
|
||||
programs.append(program)
|
||||
|
@ -101,7 +101,7 @@ class Parser(object):
|
||||
while self.scanner.consume('include'):
|
||||
filename = self.scanner.token
|
||||
self.scanner.scan()
|
||||
program = load_program(filename, self.symtab, self.include_path)
|
||||
program = load_program(filename, self.symtab, self.include_path, include_file=True)
|
||||
includes.append(program)
|
||||
while self.scanner.on('typedef', 'const'):
|
||||
if self.scanner.on('typedef'):
|
||||
@ -480,12 +480,13 @@ class Parser(object):
|
||||
# - - - -
|
||||
|
||||
|
||||
def load_program(filename, symtab, include_path):
|
||||
def load_program(filename, symtab, include_path, include_file=False):
|
||||
import os
|
||||
for include_dir in include_path:
|
||||
if os.path.exists(os.path.join(include_dir, filename)):
|
||||
filename = os.path.join(include_dir, filename)
|
||||
break
|
||||
if include_file:
|
||||
for include_dir in include_path:
|
||||
if os.path.exists(os.path.join(include_dir, filename)):
|
||||
filename = os.path.join(include_dir, filename)
|
||||
break
|
||||
text = open(filename).read()
|
||||
parser = Parser(symtab, text, filename, include_path)
|
||||
program = parser.program()
|
||||
|
Loading…
Reference in New Issue
Block a user