diff --git a/man/docgen b/man/docgen index 0223370d..e477e74e 100755 --- a/man/docgen +++ b/man/docgen @@ -317,8 +317,10 @@ def read_wikipages(): line = re.sub('\#.*$', '', line) - if not re.match('^\s*$', line): + if not re.match(r'^\s*$', line): wikipages.append(line) + finally: + f.close() # Add wiki page links @@ -363,7 +365,7 @@ def process_file(filename): current_config_file = None - f = io.open(file, encoding='UTF-8') + f = io.open(filename, encoding='UTF-8') try: param = None @@ -412,6 +414,8 @@ def process_file(filename): # Start of a normal comment param = Parameter() waiting_for_checkparm = False + finally: + f.close() def process_files(path): # Process all C source files. @@ -440,9 +444,11 @@ def print_template(template_file, content): else: line = line.replace("@content", content) stdout(line.rstrip().encode('UTF-8') + b'\n') + finally: + f.close() + +def manpage_output(targets, template_file): -def manpage_output(targets, template_file): - content = "" for t in targets: