citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit a1484816d6ab0e1a014390d804b5c6f69469218d
parent 504965f8d21b584ee80e87bb4cc9cf609408e7df
Author: Kyle Milz <kyle@windows.krwm.net>
Date:   Sun,  1 Jan 2017 20:53:32 -0800

src/inst: add win32 compat bits for early setup

Diffstat:
Msrc/inst_main.cc | 17+++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/inst_main.cc b/src/inst_main.cc @@ -13,11 +13,18 @@ // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // +#include "inst_frontend.h" // InstFrontend + #include <cstring> // strcmp + +#ifdef _WIN32 +#include <windows.h> +#include <Shlwapi.h> // PathFindFileNameA +#else /* _WIN32 */ #include <err.h> #include <libgen.h> // basename +#endif /* _WIN32 */ -#include "inst_frontend.h" // InstFrontend int main(int argc, char *argv[]) @@ -26,12 +33,18 @@ main(int argc, char *argv[]) char *base_name; bool is_citrun_inst = false; +#ifdef _WIN32 + // XXX: error checking + base_name = PathFindFileNameA(argv[0]); +#else /* _WIN32 */ // Protect against argv[0] being an absolute path. if ((base_name = basename(argv[0])) == NULL) err(1, "basename"); +#endif /* _WIN32 */ // Switch tool mode if we're called as 'citrun_inst'. - if (std::strcmp(base_name, "citrun_inst") == 0) + if ((std::strcmp(base_name, "citrun_inst") == 0) || + (std::strcmp(base_name, "citrun_inst.exe") == 0)) is_citrun_inst = true; // Always re-search PATH for binary name (in non citrun_inst case).