diff --git a/CMakeLists.txt b/CMakeLists.txt index f432754..238c2ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,7 @@ elseif(BISON_VERSION VERSION_LESS 3.0) endif() ## 3. External components -find_package(Boost 1.48 REQUIRED regex) +find_package(Boost 1.48 REQUIRED regex system filesystem) find_package(LLVM REQUIRED CONFIG) add_definitions( diff --git a/main.cpp b/main.cpp index 4e86ca4..1b94c3c 100644 --- a/main.cpp +++ b/main.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -53,12 +54,12 @@ int main(int argc, char **argv) { parser.parse(); boost::regex namere("^(.+)\\.mc$"); - std::string outputname; + std::string outputname = boost::filesystem::path(inputname).filename().native(); - if (boost::regex_match(inputname, namere)) { - outputname = boost::regex_replace(inputname, namere, "$1.bc"); + if (boost::regex_match(outputname, namere)) { + outputname = boost::regex_replace(outputname, namere, "$1.bc"); } else { - outputname = inputname + ".bc"; + outputname = outputname + ".bc"; } if (!program.emit(&emitter)) return 1;