44import sys
55import argparse
66from logging import Logger , basicConfig , getLogger
7- from os import getenv , environ
7+ from os import getenv , environ , pathsep
88from pathlib import Path
99from typing import List , Set , Optional
1010
@@ -18,11 +18,8 @@ class Expander:
1818
1919 include_guard = re .compile ('#.*ATCODER_[A-Z_]*_HPP' )
2020
21- def __init__ (self , lib_paths : List [Path ] = None ):
22- if lib_paths :
23- self .lib_paths = lib_paths
24- else :
25- self .lib_paths = [Path .cwd ()]
21+ def __init__ (self , lib_paths : List [Path ]):
22+ self .lib_paths = lib_paths
2623
2724 included = set () # type: Set[str]
2825
@@ -84,13 +81,14 @@ def expand(self, source: str) -> str:
8481 parser .add_argument ('--lib' , help = 'Path to Atcoder Library' )
8582 opts = parser .parse_args ()
8683
87- lib_path = Path . cwd ()
84+ lib_paths = []
8885 if opts .lib :
89- lib_path = Path (opts .lib )
90- elif 'CPLUS_INCLUDE_PATH' in environ :
91- lib_path = Path (environ ['CPLUS_INCLUDE_PATH' ])
92-
93- expander = Expander ([lib_path ])
86+ lib_paths .append (Path (opts .lib ))
87+ if 'CPLUS_INCLUDE_PATH' in environ :
88+ lib_paths .extend (
89+ map (Path , filter (None , environ ['CPLUS_INCLUDE_PATH' ].split (pathsep ))))
90+ lib_paths .append (Path .cwd ())
91+ expander = Expander (lib_paths )
9492 source = open (opts .source ).read ()
9593 output = expander .expand (source )
9694
0 commit comments