summaryrefslogtreecommitdiffstats
path: root/txr.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-06-10 06:58:01 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-06-10 06:58:01 -0700
commita0ac30ccbf3acb38be1aa65ab2aa780239c4a123 (patch)
treeea695106442fb0e107613bcc8eb671dedd3b85ce /txr.c
parentf4a58d4b385de1cc75c2049b49a6aa5a93be2989 (diff)
downloadtxr-a0ac30ccbf3acb38be1aa65ab2aa780239c4a123.tar.gz
txr-a0ac30ccbf3acb38be1aa65ab2aa780239c4a123.tar.bz2
txr-a0ac30ccbf3acb38be1aa65ab2aa780239c4a123.zip
* 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.
Diffstat (limited to 'txr.c')
-rw-r--r--txr.c13
1 files changed, 10 insertions, 3 deletions
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")));
}