Files
haikuports/sys-apps/less/patches/less-581.2.patchset
2021-06-09 19:14:01 +02:00

139 lines
3.3 KiB
Plaintext

From f37c832e4c028a392e04ef0e0731d98e39fe7570 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Thu, 29 Jun 2017 17:06:55 +0200
Subject: import fix from previous version
diff --git a/cmdbuf.c b/cmdbuf.c
index 0648aec..7e7cf68 100644
--- a/cmdbuf.c
+++ b/cmdbuf.c
@@ -1401,7 +1401,11 @@ mlist_size(ml)
static char *
histfile_name(VOID_PARAM)
{
+#ifdef __HAIKU__
+ char home[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
+#else
char *home;
+#endif
char *name;
int len;
@@ -1419,6 +1423,13 @@ histfile_name(VOID_PARAM)
if (strcmp(LESSHISTFILE, "") == 0 || strcmp(LESSHISTFILE, "-") == 0)
return (NULL);
+#ifdef __HAIKU__
+ {
+ dev_t volume = dev_for_path("/boot");
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, volume, true, home, sizeof(home)) != B_OK)
+ return (NULL);
+ }
+#else
/* Otherwise, file is in $HOME. */
home = lgetenv("HOME");
if (isnullenv(home))
@@ -1429,6 +1440,7 @@ histfile_name(VOID_PARAM)
#endif
return (NULL);
}
+#endif
len = (int) (strlen(home) + strlen(LESSHISTFILE) + 2);
name = (char *) ecalloc(len, sizeof(char));
SNPRINTF2(name, len, "%s/%s", home, LESSHISTFILE);
diff --git a/configure.ac b/configure.ac
index 7a69398..bf9f78e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -610,11 +610,17 @@ AH_TOP([
* LESSHISTFILE is the filename of the history file
* (in the HOME directory).
*/
+#ifdef __HAIKU__
+# define LESSKEYFILE "less"
+# define LESSKEYFILE_SYS SYSDIR "/sysless"
+# define DEF_LESSKEYINFILE "lesskey"
+# define LESSHISTFILE "lesshst"
+#else
#define LESSKEYFILE ".less"
#define LESSKEYFILE_SYS SYSDIR "/sysless"
#define DEF_LESSKEYINFILE ".lesskey"
#define LESSHISTFILE ".lesshst"
-
+#endif
/* Settings always true on Unix. */
diff --git a/filename.c b/filename.c
index 7c3ccd2..c813a68 100644
--- a/filename.c
+++ b/filename.c
@@ -259,12 +259,23 @@ homefile(filename)
{
char *pathname;
+#ifdef __HAIKU__
+ char path[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
+ dev_t volume = dev_for_path("/boot");
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, volume, true, path, sizeof(path)) != B_OK)
+ return (NULL);
+
+ pathname = dirfile(&path, filename);
+ if (pathname != NULL)
+ return (pathname);
+#else
/*
* Try $HOME/filename.
*/
pathname = dirfile(lgetenv("HOME"), filename);
if (pathname != NULL)
return (pathname);
+#endif
#if OS2
/*
* Try $INIT/filename.
diff --git a/less.h b/less.h
index 7ec58c3..75b5516 100644
--- a/less.h
+++ b/less.h
@@ -100,6 +100,11 @@
#include <floss.h>
#endif
+#ifdef __HAIKU__
+#include <FindDirectory.h>
+#include <StorageDefs.h>
+#endif
+
#if MSDOS_COMPILER==WIN32C || OS2
#include <io.h>
#endif
diff --git a/lesskey.c b/lesskey.c
index 96a4462..912010c 100644
--- a/lesskey.c
+++ b/lesskey.c
@@ -250,8 +250,19 @@ homefile(filename)
char *p;
char *pathname;
+#ifdef __HAIKU__
+ char path[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
+ dev_t volume = dev_for_path("/boot");
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, volume, true, path, sizeof(path)) != B_OK)
+ return (NULL);
+
+ pathname = mkpathname(&path, filename);
+ if (pathname != NULL)
+ return (pathname);
+#else
if ((p = getenv("HOME")) != NULL && *p != '\0')
pathname = mkpathname(p, filename);
+#endif
#if OS2
else if ((p = getenv("INIT")) != NULL && *p != '\0')
pathname = mkpathname(p, filename);
--
2.19.1