summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-09-17 15:28:10 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-09-17 15:28:10 -0700
commit5c42f89768dfb9e7ea6df820cdb1ae367d1f9fdd (patch)
treed2651317d0933ca27ad2c81a82ce1c9338ed1224
parent78613fe61e8d4e16bfa914cc6b7b341def705de6 (diff)
downloadtxr-5c42f89768dfb9e7ea6df820cdb1ae367d1f9fdd.tar.gz
txr-5c42f89768dfb9e7ea6df820cdb1ae367d1f9fdd.tar.bz2
txr-5c42f89768dfb9e7ea6df820cdb1ae367d1f9fdd.zip
linenoise: use USERPROFILE for home dir on Cygnal.
* linenoise/linenoise.c (get_home): New static function. (edit_in_editor): Call get_home instead of getenv("HOME").
-rw-r--r--linenoise/linenoise.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c
index 950a1aa2..225fcb8d 100644
--- a/linenoise/linenoise.c
+++ b/linenoise/linenoise.c
@@ -58,6 +58,9 @@
#if HAVE_POLL
#include <poll.h>
#endif
+#ifdef __CYGWIN__
+#include <sys/utsname.h>
+#endif
#include "linenoise.h"
#ifdef __cplusplus
@@ -1606,6 +1609,20 @@ static void tr(char *s, int find, int rep)
*s = rep;
}
+static const char *get_home(void)
+{
+#ifdef __CYGWIN__
+ struct utsname un;
+
+ if (uname(&un) >= 0) {
+ if (strncmp(un.sysname, "CYGNAL", 6) == 0)
+ return getenv("USERPROFILE");
+ }
+#endif
+ return getenv("HOME");
+}
+
+
static void edit_in_editor(lino_t *l) {
const char *templ = ".linotmpXXXXXX";
FILE *fo = 0;
@@ -1613,7 +1630,7 @@ static void edit_in_editor(lino_t *l) {
char path[128];
if (ed) {
- char *ho = getenv("HOME");
+ const char *ho = get_home();
int fd;
#if HAVE_MKSTEMPS
const char *suffix = l->suffix ? l->suffix : "";