From 49a5b5bc21b20a1407f693d2fd8b56172f868dcf Mon Sep 17 00:00:00 2001 From: Schrijvers Luc Date: Fri, 30 Jun 2017 08:01:31 +0200 Subject: [PATCH] less: add recipe for 493 (#1484) * 493 isn't recommended yet --- sys-apps/less/less-493.recipe | 65 ++ sys-apps/less/patches/less-493.patchset | 767 ++++++++++++++++++++++++ 2 files changed, 832 insertions(+) create mode 100644 sys-apps/less/less-493.recipe create mode 100644 sys-apps/less/patches/less-493.patchset diff --git a/sys-apps/less/less-493.recipe b/sys-apps/less/less-493.recipe new file mode 100644 index 000000000..f8805de60 --- /dev/null +++ b/sys-apps/less/less-493.recipe @@ -0,0 +1,65 @@ +SUMMARY="A free, open-source file pager" +DESCRIPTION="GNU 'less' is a program similar to 'more', but which allows \ +backward movement in the file as well as forward movement. Also, 'less' \ +does not have to read the entire input file before starting, so with \ +large input files it starts up faster than text editors like 'vi'. +Less uses 'termcap' (or 'terminfo' on some systems), so it can run on a \ +variety of terminals. There is even limited support for hardcopy terminals." +HOMEPAGE="http://www.greenwoodsoftware.com/less/" +COPYRIGHT="1984-2015 Mark Nudelman" +LICENSE="GNU GPL v3" +REVISION="1" +SOURCE_URI="http://www.greenwoodsoftware.com/less/less-$portVersion.tar.gz" +CHECKSUM_SHA256="8b818f58ebf90f566e3c6be6c06209e245c9018c754d0d338bb925ea2f240d73" +PATCHES="less-$portVersion.patchset" +ADDITIONAL_FILES="sysless.in" + +ARCHITECTURES="?x86_gcc2 ?x86 ?x86_64" + +PROVIDES=" + less = $portVersion + cmd:less + cmd:lessecho + cmd:lesskey + " +REQUIRES=" + haiku$secondaryArchSuffix + lib:libncurses$secondaryArchSuffix + " + +BUILD_REQUIRES=" + haiku${secondaryArchSuffix}_devel + devel:libncurses$secondaryArchSuffix + " +BUILD_PREREQUIRES=" + cmd:gcc$secondaryArchSuffix + cmd:make + cmd:ld$secondaryArchSuffix + cmd:autoconf + cmd:aclocal + " + +GLOBAL_WRITABLE_FILES=" + settings/etc/sysless.src keep-old + settings/etc/sysless keep-old + " + +BUILD() +{ + autoconf + runConfigure ./configure --with-editor=nano \ + --sysconfdir=$settingsDir/etc + make +} + +INSTALL() +{ + make install + + syslessDir=$settingsDir/etc + mkdir $syslessDir + cp "$portDir/additional-files/sysless.in" \ + "$syslessDir/sysless.src" + $binDir/lesskey -o "$syslessDir/sysless" \ + "$syslessDir/sysless.src" +} diff --git a/sys-apps/less/patches/less-493.patchset b/sys-apps/less/patches/less-493.patchset new file mode 100644 index 000000000..d3eb011d6 --- /dev/null +++ b/sys-apps/less/patches/less-493.patchset @@ -0,0 +1,767 @@ +From 472def0946da114d06dd847ea7e3b88aeeb0ed07 Mon Sep 17 00:00:00 2001 +From: Jerome Duval +Date: Thu, 29 Jun 2017 17:06:55 +0200 +Subject: import fix from previous version + + +diff --git a/cmdbuf.c b/cmdbuf.c +index 3df0bac..e757b1e 100644 +--- a/cmdbuf.c ++++ b/cmdbuf.c +@@ -74,16 +74,16 @@ struct mlist + /* + * These are the various command histories that exist. + */ +-struct mlist mlist_search = ++struct mlist mlist_search = + { &mlist_search, &mlist_search, &mlist_search, NULL, 0 }; + public void *ml_search = (void *) &mlist_search; + +-struct mlist mlist_examine = ++struct mlist mlist_examine = + { &mlist_examine, &mlist_examine, &mlist_examine, NULL, 0 }; + public void *ml_examine = (void *) &mlist_examine; + + #if SHELL_ESCAPE || PIPEC +-struct mlist mlist_shell = ++struct mlist mlist_shell = + { &mlist_shell, &mlist_shell, &mlist_shell, NULL, 0 }; + public void *ml_shell = (void *) &mlist_shell; + #endif +@@ -394,7 +394,7 @@ cmd_right() + char *pr; + char *ncp; + int width; +- ++ + if (*cp == '\0') + { + /* Already at the end of the line. */ +@@ -428,7 +428,7 @@ cmd_left() + { + char *ncp; + int width, bswidth; +- ++ + if (cp <= cmdbuf) + { + /* Already at the beginning of the line */ +@@ -459,14 +459,14 @@ cmd_ichar(cs, clen) + int clen; + { + char *s; +- ++ + if (strlen(cmdbuf) + clen >= sizeof(cmdbuf)-1) + { + /* No room in the command buffer for another char. */ + bell(); + return (CC_ERROR); + } +- ++ + /* + * Make room for the new character (shift the tail of the buffer right). + */ +@@ -526,7 +526,7 @@ cmd_erase() + */ + updown_match = -1; + cmd_repaint(cp); +- ++ + /* + * We say that erasing the entire command string causes us + * to abort the current command, if CF_QUIT_ON_ERASE is set. +@@ -663,7 +663,7 @@ cmd_updown(action) + { + constant char *s; + struct mlist *ml; +- ++ + if (curr_mlist == NULL) + { + /* +@@ -728,7 +728,7 @@ cmd_addhist(mlist, cmd, modified) + { + #if CMD_HISTORY + struct mlist *ml; +- ++ + /* + * Don't save a trivial command. + */ +@@ -800,7 +800,7 @@ cmd_edit(c) + #else + #define not_in_completion() + #endif +- ++ + /* + * See if the char is indeed a line-editing command. + */ +@@ -911,7 +911,7 @@ cmd_istr(str) + char *s; + int action; + char *endline = str + strlen(str); +- ++ + for (s = str; *s != '\0'; ) + { + char *os = s; +@@ -943,7 +943,7 @@ delimit_word() + constant char *esc = get_meta_escape(); + int esclen = (int) strlen(esc); + #endif +- ++ + /* + * Move cursor to end of word. + */ +@@ -1016,7 +1016,7 @@ delimit_word() + + /* + * Set things up to enter completion mode. +- * Expand the word under the cursor into a list of filenames ++ * Expand the word under the cursor into a list of filenames + * which start with that word, and set tk_text to that list. + */ + static void +@@ -1024,7 +1024,7 @@ init_compl() + { + char *word; + char c; +- ++ + /* + * Get rid of any previous tk_text. + */ +@@ -1113,8 +1113,8 @@ cmd_complete(action) + if (!in_completion || action == EC_EXPAND) + { + /* +- * Expand the word under the cursor and +- * use the first word in the expansion ++ * Expand the word under the cursor and ++ * use the first word in the expansion + * (or the entire expansion if we're doing EC_EXPAND). + */ + init_compl(); +@@ -1146,13 +1146,13 @@ cmd_complete(action) + */ + tk_trial = next_compl(action, tk_trial); + } +- ++ + /* + * Remove the original word, or the previous trial completion. + */ + while (cp > tk_ipoint) + (void) cmd_erase(); +- ++ + if (tk_trial == NULL) + { + /* +@@ -1183,9 +1183,9 @@ cmd_complete(action) + goto fail; + } + } +- ++ + return (CC_OK); +- ++ + fail: + in_completion = 0; + bell(); +@@ -1266,7 +1266,7 @@ cmd_char(c) + literal = 0; + return (cmd_ichar(cmd_mbc_buf, len)); + } +- ++ + /* + * See if it is a line-editing character. + */ +@@ -1282,7 +1282,7 @@ cmd_char(c) + break; + } + } +- ++ + /* + * Insert the char into the command buffer. + */ +@@ -1352,10 +1352,14 @@ mlist_size(ml) + static char * + histfile_name() + { ++#ifdef __HAIKU__ ++ char home[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH]; ++#else + char *home; ++#endif + char *name; + int len; +- ++ + /* See if filename is explicitly specified by $LESSHISTFILE. */ + name = lgetenv("LESSHISTFILE"); + if (name != NULL && *name != '\0') +@@ -1370,6 +1374,13 @@ histfile_name() + 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 (home == NULL || *home == '\0') +@@ -1380,6 +1391,7 @@ histfile_name() + #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 383f840..8bf3e39 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -5,7 +5,7 @@ + # You may distribute under the terms of either the GNU General Public + # License or the Less License, as specified in the README file. + # +-# For more information about less, or for information on how to ++# For more information about less, or for information on how to + # contact the author, see the README file. + + # Autoconf initialization. +@@ -237,10 +237,10 @@ AH_TEMPLATE([SECURE_COMPILE], + # Checks for identifiers. + AC_TYPE_OFF_T + AC_MSG_CHECKING(for void) +-AC_TRY_COMPILE(, [void *foo = 0;], ++AC_TRY_COMPILE(, [void *foo = 0;], + [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VOID)], [AC_MSG_RESULT(no)]) + AC_MSG_CHECKING(for const) +-AC_TRY_COMPILE(, [const int foo = 0;], ++AC_TRY_COMPILE(, [const int foo = 0;], + [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CONST)], [AC_MSG_RESULT(no)]) + AC_MSG_CHECKING(for time_t) + AC_TRY_COMPILE([#include ], [time_t t = 0;], +@@ -306,7 +306,7 @@ AC_TRY_LINK([ + [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)], [AC_MSG_RESULT(no)]) + + AC_MSG_CHECKING(for sys_errlist) +-AC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;], ++AC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;], + [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)], [AC_MSG_RESULT(no)]) + + AC_CHECK_TYPES([sigset_t],,,[#include ]) +@@ -322,13 +322,13 @@ AC_MSG_CHECKING(for errno) + AC_TRY_LINK([ + #if HAVE_ERRNO_H + #include +-#endif], [static int x; x = errno;], ++#endif], [static int x; x = errno;], + [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO) have_errno=yes]) + if test $have_errno = no; then + AC_TRY_LINK([ + #if HAVE_ERRNO_H + #include +-#endif], [extern int errno; static int x; x = errno;], ++#endif], [extern int errno; static int x; x = errno;], + [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_ERRNO) AC_DEFINE(MUST_DEFINE_ERRNO)], + [AC_MSG_RESULT(no)]) + fi +@@ -363,7 +363,7 @@ AC_TRY_LINK([ + #endif], [ospeed = 0;], + [AC_MSG_RESULT(yes - in termcap.h); AC_DEFINE(HAVE_OSPEED) have_ospeed=yes]) + if test $have_ospeed = no; then +-AC_TRY_LINK(, [extern short ospeed; ospeed = 0;], ++AC_TRY_LINK(, [extern short ospeed; ospeed = 0;], + [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_OSPEED) AC_DEFINE(MUST_DEFINE_OSPEED)], + [AC_MSG_RESULT(no)]) + fi +@@ -379,7 +379,7 @@ AC_ARG_WITH(no-float, + [ --with-no-float Do not use floating point], + WANT_NO_FLOAT=1, WANT_NO_FLOAT=0) + if test $WANT_NO_FLOAT = 0; then +- AC_TRY_LINK(, [double f1 = 12.5; double f2 = f1*f1/2.5;], ++ AC_TRY_LINK(, [double f1 = 12.5; double f2 = f1*f1/2.5;], + [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT)], [AC_MSG_RESULT(no)]) + else + AC_MSG_RESULT(disabled by user) +@@ -433,21 +433,21 @@ fi + + if test $have_regex = no; then + if test $WANT_REGEX = auto -o $WANT_REGEX = pcre; then +-AC_CHECK_LIB(pcre, pcre_compile, ++AC_CHECK_LIB(pcre, pcre_compile, + [AC_DEFINE(HAVE_PCRE) LIBS="$LIBS -lpcre" have_regex=yes; supported_regex="$supported_regex pcre"], []) + fi + fi + + if test $have_regex = no; then + if test $WANT_REGEX = auto -o $WANT_REGEX = gnu; then +-AC_CHECK_LIB(c, re_compile_pattern, ++AC_CHECK_LIB(c, re_compile_pattern, + [AC_DEFINE(HAVE_GNU_REGEX) have_regex=yes; supported_regex="$supported_regex gnu"], []) + fi + fi + + if test $have_regex = no; then + if test $WANT_REGEX = auto -o $WANT_REGEX = regcmp; then +-AC_CHECK_FUNC(regcmp, ++AC_CHECK_FUNC(regcmp, + [AC_DEFINE(HAVE_REGCMP) have_regex=yes; supported_regex="$supported_regex regcmp"],[]) + fi + fi +@@ -463,7 +463,7 @@ fi + + if test $have_regex = no && test -f ${srcdir}/regexp.c; then + if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp-local; then +-AC_MSG_RESULT(using V8 regcomp -- local source); AC_DEFINE(HAVE_V8_REGCOMP) ++AC_MSG_RESULT(using V8 regcomp -- local source); AC_DEFINE(HAVE_V8_REGCOMP) + supported_regex="$supported_regex regcomp-local" + AC_DEFINE(HAVE_REGEXEC2) REGEX_O='regexp.$(O)' AC_SUBST(REGEX_O) have_regex=yes + fi +@@ -538,7 +538,7 @@ AH_TOP([ + #define CMD_HISTORY 1 + + /* +- * HILITE_SEARCH is 1 if you wish to have search targets to be ++ * HILITE_SEARCH is 1 if you wish to have search targets to be + * displayed in standout mode. + */ + #define HILITE_SEARCH 1 +@@ -556,7 +556,7 @@ AH_TOP([ + #define TAGS (!SECURE) + + /* +- * USERFILE is 1 if you wish to allow a .less file to specify ++ * USERFILE is 1 if you wish to allow a .less file to specify + * user-defined key bindings. + */ + #define USERFILE (!SECURE) +@@ -593,19 +593,25 @@ AH_TOP([ + #define ONLY_RETURN 0 + + /* +- * LESSKEYFILE is the filename of the default lesskey output file ++ * LESSKEYFILE is the filename of the default lesskey output file + * (in the HOME directory). + * LESSKEYFILE_SYS is the filename of the system-wide lesskey output file. +- * DEF_LESSKEYINFILE is the filename of the default lesskey input ++ * DEF_LESSKEYINFILE is the filename of the default lesskey input + * (in the HOME directory). + * 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. */ + +@@ -662,7 +668,7 @@ AH_TOP([ + #define DEF_METACHARS "; *?\t\n'\"()<>[]|&^`#\\$%=~" + #define DEF_METAESCAPE "\\" + +-/* ++/* + * HAVE_DUP is 1 if your system has the dup() call. + */ + #define HAVE_DUP 1 +diff --git a/filename.c b/filename.c +index a153207..8a32d6b 100644 +--- a/filename.c ++++ b/filename.c +@@ -168,7 +168,7 @@ shell_quote(s) + if (esclen == 0) + { + /* +- * We've got a metachar, but this shell ++ * We've got a metachar, but this shell + * doesn't support escape chars. Use quotes. + */ + use_quotes = 1; +@@ -266,12 +266,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. +@@ -324,7 +335,7 @@ fexpand(s) + (c) == '#' ? old_ifile : NULL_IFILE) + + /* +- * Make one pass to see how big a buffer we ++ * Make one pass to see how big a buffer we + * need to allocate for the expanded string. + */ + n = 0; +@@ -422,8 +433,8 @@ fcomplete(s) + /* + * But in DOS, we have to glob "s*.*". + * But if the final component of the filename already has +- * a dot in it, just do "s*". +- * (Thus, "FILE" is globbed as "FILE*.*", ++ * a dot in it, just do "s*". ++ * (Thus, "FILE" is globbed as "FILE*.*", + * but "FILE.A" is globbed as "FILE.A*"). + */ + { +@@ -535,8 +546,8 @@ readfd(fd) + int ch; + char *buf; + char *p; +- +- /* ++ ++ /* + * Make a guess about how many chars in the string + * and allocate a buffer to hold it. + */ +@@ -592,7 +603,7 @@ shellcmd(cmd) + char *esccmd; + + /* +- * Read the output of <$SHELL -c cmd>. ++ * Read the output of <$SHELL -c cmd>. + * Escape any metacharacters in the command. + */ + esccmd = shell_quote(cmd); +@@ -696,7 +707,7 @@ lglob(filename) + char *pathname; + char *qpathname; + DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle) +- ++ + GLOB_FIRST_NAME(filename, &fnd, handle); + if (GLOB_FIRST_FAILED(handle)) + { +@@ -840,7 +851,7 @@ num_pct_s(lessopen) + } + + /* +- * See if we should open a "replacement file" ++ * See if we should open a "replacement file" + * instead of the file we're about to open. + */ + public char * +@@ -859,7 +870,7 @@ open_altfile(filename, pf, pfd) + #if HAVE_FILENO + int returnfd = 0; + #endif +- ++ + if (!use_lessopen || secure) + return (NULL); + ch_ungetchar(-1); +@@ -868,7 +879,7 @@ open_altfile(filename, pf, pfd) + while (*lessopen == '|') + { + /* +- * If LESSOPEN starts with a |, it indicates ++ * If LESSOPEN starts with a |, it indicates + * a "pipe preprocessor". + */ + #if !HAVE_FILENO +@@ -923,7 +934,7 @@ open_altfile(filename, pf, pfd) + /* + * Pipe is empty. + * If more than 1 pipe char was specified, +- * the exit status tells whether the file itself ++ * the exit status tells whether the file itself + * is empty, or if there is no alt file. + * If only one pipe char, just assume no alt file. + */ +@@ -966,7 +977,7 @@ close_altfile(altfilename, filename, pipefd) + FILE *fd; + char *cmd; + int len; +- ++ + if (secure) + return; + if (pipefd != NULL) +@@ -982,7 +993,7 @@ close_altfile(altfilename, filename, pipefd) + } + if ((lessclose = lgetenv("LESSCLOSE")) == NULL) + return; +- if (num_pct_s(lessclose) > 2) ++ if (num_pct_s(lessclose) > 2) + { + error("Invalid LESSCLOSE variable", NULL_PARG); + return; +@@ -996,7 +1007,7 @@ close_altfile(altfilename, filename, pipefd) + pclose(fd); + #endif + } +- ++ + /* + * Is the specified file a directory? + */ +@@ -1047,7 +1058,7 @@ bad_file(filename) + { + static char is_a_dir[] = " is a directory"; + +- m = (char *) ecalloc(strlen(filename) + sizeof(is_a_dir), ++ m = (char *) ecalloc(strlen(filename) + sizeof(is_a_dir), + sizeof(char)); + strcpy(m, filename); + strcat(m, is_a_dir); +@@ -1103,7 +1114,7 @@ filesize(f) + } + + /* +- * ++ * + */ + public char * + shell_coption() +diff --git a/less.h b/less.h +index 69576bb..de486a0 100644 +--- a/less.h ++++ b/less.h +@@ -100,6 +100,11 @@ + #include + #endif + ++#ifdef __HAIKU__ ++#include ++#include ++#endif ++ + #if MSDOS_COMPILER==WIN32C || OS2 + #include + #endif +@@ -305,7 +310,7 @@ struct scrpos + /* + * A mark is an ifile (input file) plus a position within the file. + */ +-struct mark ++struct mark + { + IFILE m_ifile; + struct scrpos m_scrpos; +@@ -331,7 +336,7 @@ struct wchar_range + LWCHAR first, last; + }; + +-struct wchar_range_table ++struct wchar_range_table + { + struct wchar_range *table; + int count; +diff --git a/lesskey.c b/lesskey.c +index 686f6e4..8a8dc7e 100644 +--- a/lesskey.c ++++ b/lesskey.c +@@ -11,7 +11,7 @@ + /* + * lesskey [-o output] [input] + * +- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ++ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Make a .less file. + * If no input file is specified, standard input is used. +@@ -21,9 +21,9 @@ + * key bindings. Basically any sequence of 1 to MAX_CMDLEN + * keystrokes may be bound to an existing less function. + * +- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ++ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * +- * The input file is an ascii file consisting of a ++ * The input file is an ascii file consisting of a + * sequence of lines of the form: + * string action [chars] + * +@@ -37,14 +37,14 @@ + * to specify a character by its octal value. + * 4. A backslash followed by b, e, n, r or t + * to specify \b, ESC, \n, \r or \t, respectively. +- * 5. Any character (other than those mentioned above) preceded ++ * 5. Any character (other than those mentioned above) preceded + * by a \ to specify the character itself (characters which + * must be preceded by \ include ^, \, and whitespace. + * "action" is the name of a "less" action, from the table below. + * "chars" is an optional sequence of characters which is treated + * as keyboard input after the command is executed. + * +- * Blank lines and lines which start with # are ignored, ++ * Blank lines and lines which start with # are ignored, + * except for the special control lines: + * #command Signals the beginning of the command + * keys section. +@@ -55,7 +55,7 @@ + * #stop Stops command parsing in less; + * causes all default keys to be disabled. + * +- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ++ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * The output file is a non-ascii file, consisting of a header, + * one or more sections, and a trailer. +@@ -63,7 +63,7 @@ + * and the section data. Normally there are three sections: + * CMD_SECTION Definition of command keys. + * EDIT_SECTION Definition of editing keys. +- * END_SECTION A special section header, with no ++ * END_SECTION A special section header, with no + * length word or section data. + * + * Section data consists of zero or more byte sequences of the form: +@@ -77,7 +77,7 @@ + * If action is ORed with A_EXTRA, the action byte is followed + * by the null-terminated "chars" string. + * +- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ++ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + */ + + #include "less.h" +@@ -90,7 +90,7 @@ struct cmdname + int cn_action; + }; + +-struct cmdname cmdnames[] = ++struct cmdname cmdnames[] = + { + { "back-bracket", A_B_BRACKET }, + { "back-line", A_B_LINE }, +@@ -156,7 +156,7 @@ struct cmdname cmdnames[] = + { NULL, 0 } + }; + +-struct cmdname editnames[] = ++struct cmdname editnames[] = + { + { "back-complete", EC_B_COMPLETE }, + { "backspace", EC_BACKSPACE }, +@@ -194,14 +194,14 @@ struct table vartable; + struct table *currtable = &cmdtable; + + char fileheader[] = { +- C0_LESSKEY_MAGIC, +- C1_LESSKEY_MAGIC, +- C2_LESSKEY_MAGIC, ++ C0_LESSKEY_MAGIC, ++ C1_LESSKEY_MAGIC, ++ C2_LESSKEY_MAGIC, + C3_LESSKEY_MAGIC + }; + char filetrailer[] = { +- C0_END_LESSKEY_MAGIC, +- C1_END_LESSKEY_MAGIC, ++ C0_END_LESSKEY_MAGIC, ++ C1_END_LESSKEY_MAGIC, + C2_END_LESSKEY_MAGIC + }; + char cmdsection[1] = { CMD_SECTION }; +@@ -248,8 +248,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); +@@ -440,7 +451,7 @@ tstr(pp, xlate) + /* FALLTHRU */ + default: + /* +- * Backslash followed by any other char ++ * Backslash followed by any other char + * just means that char. + */ + *pp = p+1; +@@ -476,7 +487,7 @@ tstr(pp, xlate) + skipsp(s) + char *s; + { +- while (*s == ' ' || *s == '\t') ++ while (*s == ' ' || *s == '\t') + s++; + return (s); + } +@@ -598,7 +609,7 @@ fputint(fd, val) + + if (val >= KRADIX*KRADIX) + { +- fprintf(stderr, "error: integer too big (%d > %d)\n", ++ fprintf(stderr, "error: integer too big (%d > %d)\n", + val, KRADIX*KRADIX); + exit(1); + } +@@ -788,7 +799,7 @@ main(argc, argv) + char *path = getenv("HOMEPATH"); + if (drive != NULL && path != NULL) + { +- char *env = (char *) calloc(strlen(drive) + ++ char *env = (char *) calloc(strlen(drive) + + strlen(path) + 6, sizeof(char)); + strcpy(env, "HOME="); + strcat(env, drive); +@@ -867,7 +878,7 @@ main(argc, argv) + fputbytes(out, (char *)edittable.buffer, edittable.pbuffer-edittable.buffer); + + /* Environment variable section */ +- fputbytes(out, varsection, sizeof(varsection)); ++ fputbytes(out, varsection, sizeof(varsection)); + fputint(out, vartable.pbuffer - vartable.buffer); + fputbytes(out, (char *)vartable.buffer, vartable.pbuffer-vartable.buffer); + +-- +2.7.0 +