summaryrefslogtreecommitdiffstats
path: root/parser.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-07-27 22:51:30 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-07-27 22:51:30 -0700
commit7d6188b2576b611552ab17dd3f27e8a308cc6c86 (patch)
tree9cae147e191ec11323e78865fdb05f4f3f562f19 /parser.c
parent10f3603aa0d19b165f33b39abc4b183057e93f3d (diff)
downloadtxr-7d6188b2576b611552ab17dd3f27e8a308cc6c86.tar.gz
txr-7d6188b2576b611552ab17dd3f27e8a308cc6c86.tar.bz2
txr-7d6188b2576b611552ab17dd3f27e8a308cc6c86.zip
Check for Cygnal when deciding where user home is.
* parser.c (get_home_path): Do not try HOME first and then USERPROFILE. If running on Cygnal, use strictly USERPROFILE, and do not fall back on HOME. In all other situations, try the HOME variable only.
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/parser.c b/parser.c
index 6589bd47..aca71939 100644
--- a/parser.c
+++ b/parser.c
@@ -37,6 +37,9 @@
#include <errno.h>
#include "config.h"
#include ALLOCA_H
+#ifdef __CYGWIN__
+#include <sys/utsname.h>
+#endif
#include "lib.h"
#include "signal.h"
#include "unwind.h"
@@ -644,31 +647,18 @@ static val read_eval_ret_last(val env, val counter,
return t;
}
-#ifdef __CYGWIN__
static val get_home_path(void)
{
- val path_exists_p = intern(lit("path-exists-p"), user_package);
-
- {
- val posixy_home = getenv_wrap(lit("HOME"));
- if (funcall1(path_exists_p, posixy_home))
- return posixy_home;
- }
+#ifdef __CYGWIN__
+ struct utsname un;
- {
- val windowsy_home = getenv_wrap(lit("USERPROFILE"));
- if (funcall1(path_exists_p, windowsy_home))
- return windowsy_home;
+ if (uname(&un) >= 0) {
+ if (strncmp(un.sysname, "CYGNAL", 6) == 0)
+ return getenv_wrap(lit("USERPROFILE"));
}
-
- return nil;
-}
-#else
-static val get_home_path(void)
-{
+#endif
return getenv_wrap(lit("HOME"));
}
-#endif
val repl(val bindings, val in_stream, val out_stream)
{