summaryrefslogtreecommitdiffstats
path: root/linenoise
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
commitc4bd0b39b115ca384f4f2704ae233171f5d62566 (patch)
treed2651317d0933ca27ad2c81a82ce1c9338ed1224 /linenoise
parent848e713f8fd84af478d9d2c31661b50081ee136b (diff)
downloadtxr-c4bd0b39b115ca384f4f2704ae233171f5d62566.tar.gz
txr-c4bd0b39b115ca384f4f2704ae233171f5d62566.tar.bz2
txr-c4bd0b39b115ca384f4f2704ae233171f5d62566.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").
Diffstat (limited to 'linenoise')
-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 : "";