Skip to content

Commit

Permalink
Fixes for OS/2.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Dec 12, 2001
1 parent fce490b commit bd648e8
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 55 deletions.
9 changes: 6 additions & 3 deletions Makefile.o2e
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#### Start of system configuration section. ####

CC = gcc -Zomf
CFLAGS = -I. -O
LDFLAGS = -s -Zcrtdll -Zstack 512
CFLAGS = -I. -O2 -Wall
LDFLAGS = -s -Zcrtdll
LIBS = -ltermcap
O = obj

Expand All @@ -25,14 +25,17 @@ OBJ = main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
output.${O} position.${O} prompt.${O} search.${O} signal.${O} \
tags.${O} ttyin.${O} version.${O} regexp.${O}

all: less.exe lesskey.exe
all: less.exe lesskey.exe scrsize.exe

less.exe: ${OBJ}
${CC} ${OBJ} -o $@ ${LDFLAGS} ${LIBS}

lesskey.exe: lesskey.${O} version.${O}
${CC} lesskey.${O} version.${O} -o $@ ${LDFLAGS}

scrsize.exe: scrsize.c
${CC} ${CFLAGS} -D__ST_MT_ERRNO__ -s -Zmtd -lX11 $<

${OBJ}: defines.h less.h

defines.h: defines.o2
Expand Down
6 changes: 4 additions & 2 deletions NEWS.VER
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,20 @@

* Windows version sets window title.

* Default LESSCHARSET for MS-DOS versions is "dos".
* Default LESSCHARSET for MS-DOS versions is now "dos".

* Fix problems when viewing files with very long lines.

* Fix overstriking in UTF-8 mode, and overstriking tabs.

* Improve horizontal shifting of text using -R option with ANSI color.

* Eliminate some 32-bit file offset dependencies.
* Eliminate some dependencies on file offets being 32 bits.

* Some fixes for EBCDIC systems.

* Some fixes for OS/2 systems.

======================================================================

Major changes between "less" versions 354 and 358
Expand Down
35 changes: 19 additions & 16 deletions defines.o2
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* EDIT_PGM is the name of the (default) editor to be invoked.
*/
#define EDITOR (!SECURE)
#define EDIT_PGM "me"
#define EDIT_PGM "vi"

/*
* TAGS is 1 if you wish to support tag files.
Expand Down Expand Up @@ -201,7 +201,7 @@
#define HAVE_CONST 1

/* Define HAVE_TIME_T if your system supports the "time_t" type. */
#define HAVE_TIME_T 0
#define HAVE_TIME_T 1

/* Define HAVE_STRERROR if you have the strerror() function. */
#define HAVE_STRERROR 1
Expand All @@ -213,22 +213,22 @@
/* Define MUST_DEFINE_ERRNO if you have errno but it is not define
* in errno.h */
#define HAVE_ERRNO 1
#define MUST_DEFINE_ERRNO 1
/* #undef MUST_DEFINE_ERRNO */

/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
#define HAVE_SYS_ERRLIST 1

/* Define HAVE_OSPEED if your termcap library has the ospeed variable */
#define HAVE_OSPEED 0
#define HAVE_OSPEED 1
/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined
* in termcap.h. */
#define MUST_DEFINE_OSPEED 0

/* Define HAVE_LOCALE if you have locale.h and setlocale. */
#define HAVE_LOCALE 0
#define HAVE_LOCALE 1

/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */
#define HAVE_TERMIOS_FUNCS 0
#define HAVE_TERMIOS_FUNCS 1

/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower */
#define HAVE_UPPER_LOWER 1
Expand All @@ -240,38 +240,41 @@
#define HAVE_MEMCPY 1

/* Define if you have the popen function. */
#define HAVE_POPEN 0
#define HAVE_POPEN 1

/* Define if you have the sigsetmask function. */
#define HAVE_SIGSETMASK 0

/* Define if you have the sigprocmask function. */
#define HAVE_SIGPROCMASK 0
#define HAVE_SIGPROCMASK 1

/* Define if you have the sigset_t type and sigemptyset macro */
#define HAVE_SIGSET_T 0
#define HAVE_SIGEMPTYSET 0
#define HAVE_SIGSET_T 1
#define HAVE_SIGEMPTYSET 1

/* Define if you have the stat function. */
#define HAVE_STAT 1

/* Define if you have the strchr function. */
#define HAVE_STRCHR 1

/* Define if you have the strstr function. */
#define HAVE_STRSTR 1

/* Define if you have the system function. */
#define HAVE_SYSTEM 1

/* Define if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1

/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 0
#define HAVE_ERRNO_H 1

/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1

/* Define if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 0
#define HAVE_LIMITS_H 1

/* Define if you have the <stdio.h> header file. */
#define HAVE_STDIO_H 1
Expand All @@ -283,7 +286,7 @@
#define HAVE_STRING_H 1

/* Define if you have the <sys/ioctl.h> header file. */
#define HAVE_SYS_IOCTL_H 0
#define HAVE_SYS_IOCTL_H 1

/* Define if you have the <sys/ptem.h> header file. */
#define HAVE_SYS_PTEM_H 0
Expand All @@ -292,13 +295,13 @@
#define HAVE_SYS_STREAM_H 0

/* Define if you have the <termcap.h> header file. */
#define HAVE_TERMCAP_H 0
#define HAVE_TERMCAP_H 1

/* Define if you have the <termio.h> header file. */
#define HAVE_TERMIO_H 0
#define HAVE_TERMIO_H 1

/* Define if you have the <termios.h> header file. */
#define HAVE_TERMIOS_H 0
#define HAVE_TERMIOS_H 1

/* Define if you have the <time.h> header file. */
#define HAVE_TIME_H 1
Expand Down
12 changes: 12 additions & 0 deletions filename.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#include <modes.h>
#endif
#endif
#if OS2
#include <signal.h>
#endif

#if HAVE_STAT
#include <sys/stat.h>
Expand Down Expand Up @@ -877,7 +880,16 @@ close_altfile(altfilename, filename, pipefd)
if (secure)
return;
if (pipefd != NULL)
{
#if OS2
/*
* The pclose function of OS/2 emx sometimes fails.
* Send SIGINT to the piped process before closing it.
*/
kill(((FILE*)pipefd)->_pid, SIGINT);
#endif
pclose((FILE*) pipefd);
}
if ((lessclose = lgetenv("LESSCLOSE")) == NULL)
return;
gfilename = esc_metachars(filename);
Expand Down
4 changes: 2 additions & 2 deletions less.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
#include <modes.h>
#include <strings.h>
#endif
#if MSDOS_COMPILER==WIN32C
#if MSDOS_COMPILER==WIN32C || OS2
#include <io.h>
#endif
#if MSDOS_COMPILER==DJGPPC
Expand Down Expand Up @@ -190,7 +190,7 @@ typedef off_t POSITION;
#if MSDOS_COMPILER==MSOFTC
#define SET_BINARY(f) _setmode(f, _O_BINARY);
#else
#if MSDOS_COMPILER
#if MSDOS_COMPILER || OS2
#define SET_BINARY(f) setmode(f, O_BINARY)
#else
#define SET_BINARY(f)
Expand Down
5 changes: 3 additions & 2 deletions less.nro.VER
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ Like, TAB, but cycles in the reverse direction thru the matching filenames.
Complete the partial filename to the left of the cursor.
If it matches more than one filename, all matches are entered into
the command line (if they fit).
.IP "^U (Unix) or ESC (MS-DOS)"
.IP "^U (Unix and OS/2) or ESC (MS-DOS)"
Delete the entire command line,
or cancel the command if the command line is empty.
If you have changed your line-kill character in Unix to something
Expand Down Expand Up @@ -1411,7 +1411,8 @@ LINES and COLUMNS environment variables.)
.IP EDITOR
The name of the editor (used for the v command).
.IP HOME
Name of the user's home directory (used to find a lesskey file on Unix systems).
Name of the user's home directory
(used to find a lesskey file on Unix and OS/2 systems).
.IP "HOMEDRIVE, HOMEPATH"
Concatenation of the HOMEDRIVE and HOMEPATH environment variables is
the name of the user's home directory if the HOME variable is not set
Expand Down
5 changes: 5 additions & 0 deletions lsystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ lsystem(cmd, donemsg)
*/
inp = dup(0);
close(0);
#if OS2
/* The __open() system call translates "/dev/tty" to "con". */
if (__open("/dev/tty", OPEN_READ) < 0)
#else
if (open("/dev/tty", OPEN_READ) < 0)
#endif
dup(inp);
#endif

Expand Down
2 changes: 1 addition & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ main(argc, argv)
ifile = get_ifile(FAKE_HELPFILE, ifile);
while (argc-- > 0)
{
#if (MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC) || OS2
#if (MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC)
/*
* Because the "shell" doesn't expand filename patterns,
* treat each argument as a filename pattern rather than
Expand Down
73 changes: 71 additions & 2 deletions screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ extern int fd0;
#endif
#if OS2
#include <sys/signal.h>
#include "pckeys.h"
#endif
#if HAVE_SYS_STREAM_H
#include <sys/stream.h>
Expand All @@ -88,6 +89,7 @@ extern int fd0;

#if OS2
#define DEFAULT_TERM "ansi"
static char *windowid;
#else
#define DEFAULT_TERM "unknown"
#endif
Expand Down Expand Up @@ -712,6 +714,27 @@ scrsize()
_scrsize(s);
sys_width = s[0];
sys_height = s[1];
/*
* When using terminal emulators for XFree86/OS2, the
* _scrsize function does not work well.
* Call the scrsize.exe program to get the window size.
*/
windowid = getenv("WINDOWID");
if (windowid != NULL)
{
FILE *fd = popen("scrsize", "rt");
if (fd != NULL)
{
int w, h;
fscanf(fd, "%i %i", &w, &h);
if (w > 0 && h > 0)
{
sys_width = w;
sys_height = h;
}
pclose(fd);
}
}
}
#else
#ifdef TIOCGWINSZ
Expand Down Expand Up @@ -835,7 +858,7 @@ special_key_str(key)
{
static char tbuf[40];
char *s;
#if MSDOS_COMPILER
#if MSDOS_COMPILER || OS2
static char k_right[] = { '\340', PCK_RIGHT, 0 };
static char k_left[] = { '\340', PCK_LEFT, 0 };
static char k_ctl_right[] = { '\340', PCK_CTL_RIGHT, 0 };
Expand All @@ -852,12 +875,56 @@ special_key_str(key)
static char k_pagedown[] = { '\340', PCK_PAGEDOWN, 0 };
static char k_pageup[] = { '\340', PCK_PAGEUP, 0 };
static char k_f1[] = { '\340', PCK_F1, 0 };
#else
#endif
#if !MSDOS_COMPILER
char *sp = tbuf;
#endif

switch (key)
{
#if OS2
/*
* If windowid is not NULL, assume less is executed in
* the XFree86 environment.
*/
case SK_RIGHT_ARROW:
s = windowid ? ltgetstr("kr", &sp) : k_right;
break;
case SK_LEFT_ARROW:
s = windowid ? ltgetstr("kl", &sp) : k_left;
break;
case SK_UP_ARROW:
s = windowid ? ltgetstr("ku", &sp) : k_up;
break;
case SK_DOWN_ARROW:
s = windowid ? ltgetstr("kd", &sp) : k_down;
break;
case SK_PAGE_UP:
s = windowid ? ltgetstr("kP", &sp) : k_pageup;
break;
case SK_PAGE_DOWN:
s = windowid ? ltgetstr("kN", &sp) : k_pagedown;
break;
case SK_HOME:
s = windowid ? ltgetstr("kh", &sp) : k_home;
break;
case SK_END:
s = windowid ? ltgetstr("@7", &sp) : k_end;
break;
case SK_DELETE:
if (windowid)
{
s = ltgetstr("kD", &sp);
if (s == NULL)
{
tbuf[0] = '\177';
tbuf[1] = '\0';
s = tbuf;
}
} else
s = k_delete;
break;
#endif
#if MSDOS_COMPILER
case SK_RIGHT_ARROW:
s = k_right;
Expand Down Expand Up @@ -886,6 +953,8 @@ special_key_str(key)
case SK_DELETE:
s = k_delete;
break;
#endif
#if MSDOS_COMPILER || OS2
case SK_INSERT:
s = k_insert;
break;
Expand Down
Loading

0 comments on commit bd648e8

Please sign in to comment.