From b6e30ab90dd6f9272c5d655d318d04220802c17f Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Sun, 6 Sep 2026 15:40:48 +0900 Subject: [PATCH 1/7] Add OS/2 kLIBC support kLIBC is the successor of EMX, and now is being maintained as LIBCn at https://github.com/bitwiseworks/libc Generated defines.o2k from the result of configure on OS/2 kLIBC. --- Makefile.o2k | 60 +++++++ configure.ac | 13 ++ defines.o2k | 497 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 570 insertions(+) create mode 100644 Makefile.o2k create mode 100644 defines.o2k diff --git a/Makefile.o2k b/Makefile.o2k new file mode 100644 index 00000000..01563b48 --- /dev/null +++ b/Makefile.o2k @@ -0,0 +1,60 @@ +# Makefile for less. +# OS/2 version, for klibc+gcc compiler + +#### Start of system configuration section. #### + +PREFIX = /@unixroot/usr/local +BINDIR = ${PREFIX}/bin +LIBEXECDIR = ${PREFIX}/libexecdir +SYSDIR = ${PREFIX}/etc + +CC = gcc +CFLAGS = -g -O2 -Wall -I. \ + -DBINDIR=\"${BINDIR}\" -DLIBEXECDIR=\"${LIBEXECDIR}\" \ + -DSYSDIR=\"${SYSDIR}\" +LDFLAGS = -Zhigh-mem -Wl,-static +LIBS = -lncurses +O = o + +#### End of system configuration section. #### + +.SUFFIXES: .c .${O} + +# This rule allows us to supply the necessary -D options +# in addition to whatever the user asks for. +.c.${O}: + ${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $< + +OBJ = \ + main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \ + command.${O} cvt.${O} decode.${O} edit.${O} evar.${O} filename.${O} forwback.${O} \ + help.${O} ifile.${O} input.${O} jump.${O} \ + line.${O} linenum.${O} lmsg.$(O) \ + lsystem.${O} mark.${O} optfunc.${O} option.${O} opttbl.${O} os.${O} \ + output.${O} pattern.${O} position.${O} prompt.${O} search.${O} signal.${O} \ + tags.${O} ttyin.${O} version.${O} xbuf.${O} + +OBJ += lesskey_parse.${O} + +.PHONY: all clean + +all: less.exe lessecho.exe + +less.exe: ${OBJ} + ${CC} ${LDFLAGS} -o $@ ${OBJ} ${LIBS} + +lessecho.exe: lessecho.${O} version.${O} + ${CC} ${LDFLAGS} -o $@ lessecho.${O} version.${O} ${LIBS} + +${OBJ}: less.h funcs.h defines.h lang.h lmsg.h lessmsg.inc pattern.h xbuf.h + +charset.$(O): compose.uni ubin.uni wide.uni +screen.${O} ttyin.${O}: pckeys.h + +defines.h: defines.o2k + copy defines.o2k defines.h + +clean: + -del *.exe + -del *.$(O) + -del defines.h diff --git a/configure.ac b/configure.ac index 9b1899f3..9fbbc4e0 100644 --- a/configure.ac +++ b/configure.ac @@ -638,6 +638,19 @@ AH_TOP([ * Pathname separator character. */ #define PATHNAME_SEP "\\" +#elif defined(__OS2__) +/* + * Define MSDOS_COMPILER if compiling under Microsoft C. + */ +#define MSDOS_COMPILER 0 + +/* + * Pathname separator character. + */ +#define PATHNAME_SEP "\\" + +/* Settings always true on OS/2. */ +#define OS2 1 #else /* * Define MSDOS_COMPILER if compiling under Microsoft C. diff --git a/defines.o2k b/defines.o2k new file mode 100644 index 00000000..4392be01 --- /dev/null +++ b/defines.o2k @@ -0,0 +1,497 @@ +/* + * Copyright (C) 1984-2026 Mark Nudelman + * + * 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, see the README file. + */ + + +/* OS/2 kLIBC definition file for less. */ +/* + * This file has 2 sections: + * User preferences. + * Settings always true for the emx compiler for OS/2 systems. + */ + +/* User preferences. */ + +/* + * SECURE is 1 if you wish to disable a bunch of features in order to + * be safe to run by unprivileged users. + * SECURE_COMPILE is set by the --with-secure configure option. + */ +#define SECURE SECURE_COMPILE + +/* + * SHELL_ESCAPE is 1 if you wish to allow shell escapes. + * (This is possible only if your system supplies the system() function.) + */ +#define SHELL_ESCAPE (!SECURE) + +/* + * EXAMINE is 1 if you wish to allow examining files by name from within less. + */ +#define EXAMINE (!SECURE) + +/* + * TAB_COMPLETE_FILENAME is 1 if you wish to allow the TAB key + * to complete filenames at prompts. + */ +#define TAB_COMPLETE_FILENAME (!SECURE) + +/* + * CMD_HISTORY is 1 if you wish to allow keys to cycle through + * previous commands at prompts. + */ +#define CMD_HISTORY 1 + +/* + * HILITE_SEARCH is 1 if you wish to have search targets to be + * displayed in standout mode. + */ +#define HILITE_SEARCH 1 + +/* + * EDITOR is 1 if you wish to allow editor invocation (the "v" command). + * (This is possible only if your system supplies the system() function.) + * EDIT_PGM is the name of the (default) editor to be invoked. + */ +#define EDITOR (!SECURE) + +/* + * TAGS is 1 if you wish to support tag files. + */ +#define TAGS (!SECURE) + +/* + * USERFILE is 1 if you wish to allow a .lesskey or .less file to specify + * user-defined key bindings. + */ +#define USERFILE (!SECURE) + +/* + * GLOB is 1 if you wish to have shell metacharacters expanded in filenames. + * This will generally work if your system provides the "popen" function + * and the "echo" shell command. + */ +#define GLOB (!SECURE) + +/* + * PIPEC is 1 if you wish to have the "|" command + * which allows the user to pipe data into a shell command. + */ +#define PIPEC (!SECURE && HAVE_POPEN) + +/* + * LOGFILE is 1 if you wish to allow the -o option (to create log files). + */ +#define LOGFILE (!SECURE) + +/* + * OSC8_LINK is 1 if you wish to allow the ^O^O and related commands + * (to open OSC8 hyperlinks). + */ +#define OSC8_LINK 1 + +/* + * GNU_OPTIONS is 1 if you wish to support the GNU-style command + * line options --help and --version. + */ +#define GNU_OPTIONS 1 + +/* + * ONLY_RETURN is 1 if you want RETURN to be the only input which + * will continue past an error message. + * Otherwise, any key will continue past an error message. + */ +#define ONLY_RETURN 0 + +/* + * 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 + * (in the HOME directory). + * LESSHISTFILE is the filename of the history file + * (in the HOME directory). + */ +#define LESSKEYFILE ".less" +#define LESSKEYFILE_SYS SYSDIR "sysless" +#define DEF_LESSKEYINFILE ".lesskey" +#define LESSKEYINFILE_SYS SYSDIR "syslesskey" +#define LESSHISTFILE ".lesshst" + +/* Settings always true for the emx compiler for OS/2 systems. */ +#define OS2 1 + +/* + * Pathname separator character. + */ +#define PATHNAME_SEP "\\" + +#define MSDOS_COMPILER 0 + +/* Settings always true on Unix. */ + +/* + * The value returned from tgetent on success. + * Some HP-UX systems return 0 on success. + */ +#define TGETENT_OK 1 + +/* + * HAVE_ANSI_PROTOS is 1 if your compiler supports ANSI function prototypes. + */ +#define HAVE_ANSI_PROTOS 1 + +/* + * HAVE_SYS_TYPES_H is 1 if your system has . + */ +#define HAVE_SYS_TYPES_H 1 + +/* + * Define if you have the header file. + */ +/* #undef HAVE_SGSTAT_H */ + +/* + * HAVE_PERROR is 1 if your system has the perror() call. + * (Actually, if it has sys_errlist, sys_nerr and errno.) + */ +#define HAVE_PERROR 1 + +/* + * HAVE_TIME is 1 if your system has the time() call. + */ +#define HAVE_TIME 1 + +/* + * HAVE_SHELL is 1 if your system supports a SHELL command interpreter. + */ +#define HAVE_SHELL 1 + +/* + * Default shell metacharacters and meta-escape character. + */ +#define DEF_METACHARS "; *?\t\n'\"()<>[]|&^`#\\$%=~{}," +#define DEF_METAESCAPE "\\" + +/* + * HAVE_DUP is 1 if your system has the dup() call. + */ +#define HAVE_DUP 1 + +/* Define to 1 if you have the memcpy() function. */ +#define HAVE_MEMCPY 1 + +/* Define to 1 if you have the strchr() function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the strstr() function. */ +#define HAVE_STRSTR 1 + +/* Define to 1 to support reading lesskey source files (not just binary). */ +#define HAVE_LESSKEYSRC 1 + +/* + * Sizes of various buffers. + */ +#if 0 /* old sizes for small memory machines */ +#define CMDBUF_SIZE 512 /* Buffer for multichar commands */ +#define UNGOT_SIZE 100 /* Max chars to unget() */ +#define LINEBUF_SIZE 1024 /* Max size of line in input file */ +#define OUTBUF_SIZE 1024 /* Output buffer */ +#define PROMPT_SIZE 200 /* Max size of prompt string */ +#define TERMBUF_SIZE 2048 /* Termcap buffer for tgetent */ +#define TERMSBUF_SIZE 1024 /* Buffer to hold termcap strings */ +#define TAGLINE_SIZE 512 /* Max size of line in tags file */ +#define TABSTOP_MAX 32 /* Max number of custom tab stops */ +#define LINENUM_POOL 200 /* Size of line number pool */ +#else /* more reasonable sizes for modern machines */ +#define CMDBUF_SIZE 2048 /* Buffer for multichar commands */ +#define UNGOT_SIZE 200 /* Max chars to unget() */ +#define LINEBUF_SIZE 1024 /* Initial max size of line in input file */ +#define OUTBUF_SIZE 1024 /* Output buffer */ +#define PROMPT_SIZE 2048 /* Max size of prompt string */ +#define TERMBUF_SIZE 2048 /* Termcap buffer for tgetent */ +#define TERMSBUF_SIZE 1024 /* Buffer to hold termcap strings */ +#define TAGLINE_SIZE 1024 /* Max size of line in tags file */ +#define TABSTOP_MAX 128 /* Max number of custom tab stops */ +#define LINENUM_POOL 1024 /* Size of line number pool */ +#endif + +/* Define as the return type of signal handlers (int or void). */ +#define RETSIGTYPE void + +/* Settings automatically determined by configure. */ + + +/* Define EDIT_PGM to your editor. */ +#define EDIT_PGM "vi" + +/* Define HAVE_CONST if your compiler supports the "const" modifier. */ +#define HAVE_CONST 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_CTYPE_H 1 + +/* Define HAVE_ERRNO if you have the errno variable. */ +#define HAVE_ERRNO 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the 'fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define HAVE_FILENO if you have the fileno() macro. */ +#define HAVE_FILENO 1 + +/* Define to 1 if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* GNU regex library */ +/* #undef HAVE_GNU_REGEX */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define HAVE_LOCALE if you have locale.h and setlocale. */ +#define HAVE_LOCALE 1 + +/* Define to 1 if you have the 'nanosleep' function. */ +#define HAVE_NANOSLEEP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSESW_TERMCAP_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NCURSES_TERMCAP_H 1 + +/* Define HAVE_OSPEED if your termcap library has the ospeed variable. */ +#define HAVE_OSPEED 1 + +/* PCRE (Perl-compatible regular expression) library */ +/* #undef HAVE_PCRE */ + +/* PCRE2 (Perl-compatible regular expression) library */ +/* #undef HAVE_PCRE2 */ + +/* Define to 1 if you have the 'poll' function. */ +/* #undef HAVE_POLL */ + +/* Define to 1 if you have the 'popen' function. */ +#define HAVE_POPEN 1 + +/* POSIX regcomp() and regex.h */ +#define HAVE_POSIX_REGCOMP 1 + +/* Define to 1 if you have the 'realpath' function. */ +#define HAVE_REALPATH 1 + +/* System V regcmp() */ +/* #undef HAVE_REGCMP */ + +/* */ +/* #undef HAVE_REGEXEC2 */ + +/* BSD re_comp() */ +/* #undef HAVE_RE_COMP */ + +/* Define HAVE_SETTABLE_ERRNO if the errno variable can be assigned to. */ +#define HAVE_SETTABLE_ERRNO 1 + +/* Define HAVE_SIGEMPTYSET if you have the sigemptyset macro. */ +#define HAVE_SIGEMPTYSET 1 + +/* Define to 1 if you have the 'sigprocmask' function. */ +#define HAVE_SIGPROCMASK 1 + +/* Define HAVE_SIGSETJMP if you have sigsetjmp and siglongjmp. */ +#define HAVE_SIGSETJMP 1 + +/* Define to 1 if you have the 'sigsetmask' function. */ +#define HAVE_SIGSETMASK 1 + +/* Define to 1 if the system has the type 'sigset_t'. */ +#define HAVE_SIGSET_T 1 + +/* Define to 1 if you have the 'snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define to 1 if you have the 'stat' function. */ +#define HAVE_STAT 1 + +/* Define HAVE_STAT_INO if your struct stat has st_ino and st_dev. */ +#define HAVE_STAT_INO 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STDCKDINT_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define HAVE_STRERROR if you have the strerror() function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the 'strsignal' function. */ +#define HAVE_STRSIGNAL 1 + +/* Define to 1 if you have the 'system' function. */ +#define HAVE_SYSTEM 1 + +/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable. */ +#define HAVE_SYS_ERRLIST 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_STREAM_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERMCAP_H */ + +/* Define HAVE_TERMINFO if you have the terminfo library. */ +/* #undef HAVE_TERMINFO */ + +/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr. */ +#define HAVE_TERMIOS_FUNCS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TIME_H 1 + +/* Define HAVE_TIME_T if your system supports the "time_t" type. */ +#define HAVE_TIME_T 1 + +/* Define HAVE_TPARM2 if your terminfo library supports tparm with 2 + parameters. */ +/* #undef HAVE_TPARM2 */ + +/* Define HAVE_TPARM8 if your terminfo library supports tparm with 8 + parameters. */ +/* #undef HAVE_TPARM8 */ + +/* Define HAVE_TPARM9 if your terminfo library supports tparm with 9 + parameters. */ +/* #undef HAVE_TPARM9 */ + +/* Define to 1 if you have the 'ttyname' function. */ +#define HAVE_TTYNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower. */ +#define HAVE_UPPER_LOWER 1 + +/* Define to 1 if you have the 'usleep' function. */ +#define HAVE_USLEEP 1 + +/* Henry Spencer V8 regcomp() and regexp.h */ +/* #undef HAVE_V8_REGCOMP */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_VALUES_H */ + +/* Define HAVE_VOID if your compiler supports the "void" type. */ +#define HAVE_VOID 1 + +/* Define to 1 if you have the '_setjmp' function. */ +#define HAVE__SETJMP 1 + +/* Define MUST_DEFINE_ERRNO if you have errno but it is not defined in + errno.h. */ +/* #undef MUST_DEFINE_ERRNO */ + +/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined in + termcap.h. */ +#define MUST_DEFINE_OSPEED 1 + +/* pattern matching is supported, but without metacharacters. */ +/* #undef NO_REGEX */ + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "less" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "less 1" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "less" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1" + +/* Define SECURE_COMPILE=1 to build a secure version of less. */ +#define SECURE_COMPILE 0 + +/* Define to 1 if the 'S_IS*' macros in do not work properly. */ +/* #undef STAT_MACROS_BROKEN */ + +/* Define to 1 if all of the C89 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ +#define STDC_HEADERS 1 + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef _FILE_OFFSET_BITS */ + +/* Define to 1 on platforms where this makes off_t a 64-bit type. */ +/* #undef _LARGE_FILES */ + +/* Number of bits in time_t, on hosts where this is settable. */ +/* #undef _TIME_BITS */ + +/* Define to 1 on platforms where this makes time_t a 64-bit type. */ +/* #undef __MINGW_USE_VC2005_COMPAT */ + +/* Define to empty if 'const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to 'long int' if does not define. */ +/* #undef off_t */ + +/* Define as 'unsigned int' if doesn't define. */ +/* #undef size_t */ From 4a2a0fcb0c7bc220b6fe849054d2b8569fd27a04 Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Sun, 6 Sep 2026 15:43:20 +0900 Subject: [PATCH 2/7] Fix compilation on OS/2 kLIBC __open() was removed on OS/2 kLIBC. --- ttyin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ttyin.c b/ttyin.c index 4d7573d7..f9241644 100644 --- a/ttyin.c +++ b/ttyin.c @@ -51,7 +51,7 @@ public lbool is_lesstest(void) #if !MSDOS_COMPILER static int open_tty_device(constant char* dev) { -#if OS2 +#if OS2 && !defined(__KLIBC__) /* The __open() system call translates "/dev/tty" to "con". */ return __open(dev, OPEN_READ, 0); #else From 14142692efda9a14aa0b4eb953701c52ae384441 Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Sun, 6 Sep 2026 15:50:12 +0900 Subject: [PATCH 3/7] Implement raw read on OS/2 kLIBC OS/2 kLIBC does not support terminal attributes. Because of this, read() cannot read 1 byte by 1 byte. So use a kLIBC specific funciton. --- ttyin.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ttyin.c b/ttyin.c index f9241644..ef07077a 100644 --- a/ttyin.c +++ b/ttyin.c @@ -213,7 +213,7 @@ public int getchr_timeout(unsigned long timeout_ms) do { flush(); -#if !LESS_IREAD_TTY +#if !LESS_IREAD_TTY || defined(__KLIBC__) /* * In raw read, we don't see ^C so look here for it. */ @@ -223,6 +223,8 @@ public int getchr_timeout(unsigned long timeout_ms) return (READ_INTR); #endif c = WIN32getch(); +#elif defined(__KLIBC__) + c = _read_kbd(0, 1, 0); #else c = getch(); #endif From 17f0488b69e7f7494a777fbaeeddbffc90d9dd40 Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Sun, 6 Sep 2026 15:52:01 +0900 Subject: [PATCH 4/7] Implement scroll down with native APIs on OS/2 kLIBC OS/2 does not provide ansi escapes to scroll down. Repainting whenever scrolling down is slow and causes visual confusion. --- screen.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/screen.c b/screen.c index e71b4a02..9734156f 100644 --- a/screen.c +++ b/screen.c @@ -50,6 +50,11 @@ extern int fd0; #else +#ifdef __KLIBC__ +#define INCL_VIO +#include +#endif + #if HAVE_SYS_IOCTL_H #include #endif @@ -1741,6 +1746,7 @@ static void get_term_info(void) sc_addline = t1; else sc_addline = cheaper(t1, t2, ""); +#ifndef __KLIBC__ if (*sc_addline == '\0') { /* @@ -1748,6 +1754,7 @@ static void get_term_info(void) */ no_back_scroll = TRUE; } +#endif } /* @@ -2238,7 +2245,13 @@ public void add_line(void) { assert_interactive(); #if !MSDOS_COMPILER +#ifndef __KLIBC__ ltputs(sc_addline, sc_height, putchr); +#else + flush(); + VioScrollDn(0, 0, sc_height - 1, sc_width - 1, 1, (PBYTE) "\x20\x07", 0); + VioSetCurPos(0, 0, 0); +#endif #else flush(); #if MSDOS_COMPILER==MSOFTC From f2ebea306d3678808fe6e5643f88c34b7038d743 Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Sun, 6 Sep 2026 15:55:54 +0900 Subject: [PATCH 5/7] Fix warnings on OS/2 kLIBC --- filename.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filename.c b/filename.c index c74875ec..bb7d8832 100644 --- a/filename.c +++ b/filename.c @@ -649,7 +649,7 @@ public char * lglob(constant char *afilename) * The globbing function returns a list of names. */ size_t length; - char *p; + char *p = NULL; /* Make compiler happy. */ char *qfilename; DECL_GLOB_LIST(list) From 01d4d522fe5fab3345301a26c54c9c3ce5acec8d Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Sun, 6 Sep 2026 15:59:15 +0900 Subject: [PATCH 6/7] Disable a code path for ttyname() on OS/2 kLIBC ttyname() on OS/2 kLIBC is a dummy function. --- ttyin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ttyin.c b/ttyin.c index ef07077a..bb641d95 100644 --- a/ttyin.c +++ b/ttyin.c @@ -81,7 +81,7 @@ public int open_tty(void) if (fd < 0) fd = open_tty_device("/dev/tty"); #endif -#if HAVE_TTYNAME +#if HAVE_TTYNAME && !defined(__KLIBC__) if (fd < 0) { constant char *dev = ttyname(2); From 84427b15310db0ddd7c4abbbc4de0aa6322121d9 Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Sun, 6 Sep 2026 21:36:42 +0900 Subject: [PATCH 7/7] Update README for OS/2 kLIBC build --- README | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/README b/README index 1ef9a094..15c4d77b 100644 --- a/README +++ b/README @@ -165,7 +165,7 @@ INSTALLATION (MS-DOS systems only, ======================================================================= INSTALLATION (OS/2 systems only, - with EMX C) + with EMX C or kLIBC C) 1. Move the distributed source to its own directory. @@ -173,18 +173,21 @@ INSTALLATION (OS/2 systems only, 3. Check the Makefile to make sure the definitions look ok. -4. If you wish, you may edit defines.o2 to remove some optional features. +4. If you wish, you may edit defines.o2 for EMX or defines.o2k for kLIBC + to remove some optional features. If you choose not to include some features in your version, you may wish to edit the manual page less.man and the help page help.c to remove the descriptions of the features which you are removing. -5. Type "make" and watch the fun. +5. Type "make" and watch the fun. Ensure that shell used by make should be + cmd.exe compatible. 6. If the make succeeds, it will generate the programs "less.exe" and "lesskey.exe" in your current directory. Test the generated programs. -7. Make sure you have the emx runtime installed. You need the emx DLLs - emx.dll and emxlibcs.dll and also the termcap database, termcap.dat. +7. Make sure you have the emx runtime or kLIBC runtime installed. You need + the emx DLLs emx.dll and emxlibcs.dll for EMX, or libcn0.dll for kLIBC, + and also the termcap database, termcap.dat. Make sure you have termcap.dat either in the default location or somewhere in a directory listed in the PATH or INIT environment variables. @@ -194,6 +197,10 @@ INSTALLATION (OS/2 systems only, your PATH. scrsize.exe is required only if you use a terminal emulator such as xterm or rxvt. +9. For kLIBC, if you want to use configure, + type "sh ./configure", "make", and "make install" with setting + MAKESHELL=sh.exe. + =======================================================================