From a0ac30ccbf3acb38be1aa65ab2aa780239c4a123 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 10 Jun 2014 06:58:01 -0700 Subject: * txr.c (get_self_path): Fix spelling of GetModuleFileName. Add missing parentheses in expression. (sysroot_init): On Windows, filter progpath to change backslashes to forward slashes. --- ChangeLog | 7 +++++++ txr.c | 13 ++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1bfc552e..4af53990 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-06-10 Kaz Kylheku + + * txr.c (get_self_path): Fix spelling of GetModuleFileName. + Add missing parentheses in expression. + (sysroot_init): On Windows, filter progpath to change + backslashes to forward slashes. + 2014-06-10 Kaz Kylheku * parser.l (yylex_destroy): The FLEX_ version are prefixed with YY_ diff --git a/txr.c b/txr.c index 4b96cc8a..22bc8c4d 100644 --- a/txr.c +++ b/txr.c @@ -51,6 +51,7 @@ #include "debug.h" #include "syslog.h" #include "eval.h" +#include "regex.h" #include "txr.h" const wchli_t *version = wli("89"); @@ -179,12 +180,12 @@ static val get_self_path(void) DWORD nchar; SetLastError(0); - nchar = GetModuleFilename(NULL, self, MAX_PATH); + nchar = GetModuleFileNameW(NULL, self, MAX_PATH); if (nchar == 0 || (nchar == MAX_PATH && - (GetLastError() == ERROR_INSUFFICIENT_BUFFER) || - (self[MAX_PATH - 1] != 0))) + ((GetLastError() == ERROR_INSUFFICIENT_BUFFER) || + (self[MAX_PATH - 1] != 0)))) return nil; return string(self); @@ -224,8 +225,14 @@ static val sysroot(val target) static void sysroot_init(void) { +#if HAVE_WINDOWS_H + val slash = regex_compile(lit("\\\\"), nil); +#endif prot1(&progpath); progpath = get_self_path(); +#if HAVE_WINDOWS_H + progpath = regsub(slash, lit("/"), progpath); +#endif reg_var(intern(lit("stdlib"), user_package), sysroot(lit("share/txr/stdlib"))); } -- cgit v1.2.3