Skip to content

Commit

Permalink
Fixes for Windows, Linux.
Browse files Browse the repository at this point in the history
Port to DJGPP.
  • Loading branch information
gwsw committed Aug 19, 1996
1 parent 8922cf5 commit 909318f
Show file tree
Hide file tree
Showing 14 changed files with 337 additions and 116 deletions.
40 changes: 23 additions & 17 deletions README.VER
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ Known bugs in this version are in BUGS.
===================
The Microsoft C port for MS-DOS and the Ultra C port
for OS-9 are not currently working.
Until these are fixed, for MS-DOS use Borland C,
Until these are fixed, for MS-DOS use Borland C or DJGPP,
and for OS-9 use Microware C.
If you have fixes for either of these ports,
send them to [email protected].

=======================================================================
INSTALLATION (Unix systems only):

Expand Down Expand Up @@ -54,8 +54,8 @@ INSTALLATION (Unix systems only):
in a public place, type "make install".

The default install destinations are:
Executables (less, lesskey) in /usr/local/bin
Documentation (less.nro, lesskey.nro) in /usr/local/man/man1
Executables (less, lesskey) in /usr/local/bin
Documentation (less.nro, lesskey.nro) in /usr/local/man/man1
If you want to install any of these files elsewhere, define
bindir and/or mandir to the appropriate directories.

Expand All @@ -68,14 +68,16 @@ in double curly brackets {{ like this }}.


=======================================================================
INSTALLATION (MS-DOS systems only)
INSTALLATION (MS-DOS systems only,
with Microsoft C, Borland C, or DJGPP)

1. Move the distributed source to its own directory.
Make sure the source has been converted to have CR-LF rather than
LF as line terminators.
Depending on your compiler, you may need to convert the source
to have CR-LF rather than LF as line terminators.

2. If you are using Microsoft C, rename MAKEFILE.DOS to MAKEFILE.
If you are using Borland C, rename MAKEFILE.BCC to MAKEFILE.
2. If you are using Microsoft C, rename MAKEFILE.DSM to MAKEFILE.
If you are using Borland C, rename MAKEFILE.DSB to MAKEFILE.
If you are using DJGPP, rename MAKEFILE.DSG to MAKEFILE.

3. Look at MAKEFILE to make sure that the definitions for CC and LIBDIR
are correct. CC should be the name of your C compiler and
Expand All @@ -84,7 +86,7 @@ INSTALLATION (MS-DOS systems only)
modify the definitions directly in MAKEFILE, or set your environment
variables CC and/or LIBDIR to override the definitions in MAKEFILE.

4. If you wish, you may edit DEFINES.DOS to remove some optional features.
4. If you wish, you may edit DEFINES.DS 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.
Expand All @@ -104,15 +106,17 @@ INSTALLATION (MS-DOS systems only)


=======================================================================
INSTALLATION (Windows-95 and Windows-NT systems only)
INSTALLATION (Windows-95 and Windows-NT systems only,
with Borland C or Microsoft Visual C++)

1. Move the distributed source to its own directory.

2. Rename Makefile.w32 to Makefile.
2. If you are using Borland C, rename Makefile.wnb to Makefile.
If you are using Microsoft Visual C++, rename Makefile.wnm to Makefile.

3. Check the Makefile to make sure the definitions look ok.

4. If you wish, you may edit defines.w32 to remove some optional features.
4. If you wish, you may edit defines.wn 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.
Expand All @@ -130,15 +134,16 @@ INSTALLATION (Windows-95 and Windows-NT systems only)


=======================================================================
INSTALLATION (OS/2 systems only)
INSTALLATION (OS/2 systems only,
with EMX C)

1. Move the distributed source to its own directory.

2. Rename Makefile.os2 to Makefile.
2. Rename Makefile.o2e to Makefile.

3. Check the Makefile to make sure the definitions look ok.

4. If you wish, you may edit defines.os2 to remove some optional features.
4. If you wish, you may edit defines.o2 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.
Expand All @@ -160,7 +165,8 @@ INSTALLATION (OS/2 systems only)


=======================================================================
INSTALLATION (OS-9 systems only)
INSTALLATION (OS-9 systems only,
with Microware C or Ultra C)

1. Move the distributed source to its own directory.

Expand Down
10 changes: 10 additions & 0 deletions ch.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,16 @@ ch_delbufs()
seekable(f)
int f;
{
#if MSDOS_COMPILER
if (ch_file == fd0 && !isatty(fd0))
{
/*
* In MS-DOS, pipes are seekable. Check for
* standard input, and pretend it is not seekable.
*/
return (0);
}
#endif
return (lseek(f, (off_t)1, 0) != BAD_LSEEK);
}

Expand Down
28 changes: 23 additions & 5 deletions defines.ds
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,21 @@
* This will generally work if your system provides the "popen" function
* and the "echo" shell command.
*/
#ifdef __DJGPP__
#define GLOB 1
#else
#define GLOB 0
#endif

/*
* PIPEC is 1 if you wish to have the "|" command
* which allows the user to pipe data into a shell command.
*/
#ifdef __DJGPP__
#define PIPEC (!SECURE)
#else
#define PIPEC 0
#endif

/*
* LOGFILE is 1 if you wish to allow the -l option (to create log files).
Expand Down Expand Up @@ -133,14 +141,16 @@

/*
* Define MSDOS_COMPILER if compiling for MS-DOS.
* MSOFTC == Microsoft C
* BORLANDC == Turbo/Borland C
*/
#ifdef __DJGPP__
#define MSDOS_COMPILER DJGPPC
#else
#ifdef __BORLANDC__
#define MSDOS_COMPILER BORLANDC
#else
#define MSDOS_COMPILER MSOFTC
#endif
#endif

/*
* Pathname separator character.
Expand Down Expand Up @@ -222,7 +232,11 @@
/* #undef HAVE_RE_COMP */
/* #undef HAVE_REGCMP */
/* #undef HAVE_V8_REGCOMP */
#if MSDOS_COMPILER==DJGPPC
#define HAVE_POSIX_REGCOMP 1
#else
#define NO_REGEX 1
#endif

/* Define HAVE_VOID if your compiler supports the "void" type. */
#define HAVE_VOID 1
Expand All @@ -240,9 +254,9 @@
#define HAVE_FILENO 1

/* Define HAVE_ERRNO if you have the errno variable */
/* Define MUST_DEFINE_ERRNO if you have errno but it is not define
/* Define MUST_DEFINE_ERRNO if you have errno but it is not defined
* in errno.h */
#if MSDOS_COMPILER==MSOFTC
#if MSDOS_COMPILER==MSOFTC || MSDOS_COMPILER==DJGPPC
#define HAVE_ERRNO 1
#define MUST_DEFINE_ERRNO 0
#else
Expand All @@ -269,7 +283,7 @@
#define HAVE_UPPER_LOWER 1

/* Define if you have the _setjmp function. */
#if MSDOS_COMPILER==MSOFTC
#if MSDOS_COMPILER==MSOFTC || MSDOS_COMPILER==DJGPPC
#define HAVE__SETJMP 0
#else
#define HAVE__SETJMP 1
Expand Down Expand Up @@ -327,7 +341,11 @@
#define HAVE_TIME_H 1

/* Define if you have the <unistd.h> header file. */
#if MSDOS_COMPILER==DJGPPC
#define HAVE_UNISTD_H 1
#else
#define HAVE_UNISTD_H 0
#endif

/* Define if you have the <values.h> header file. */
#if MSDOS_COMPILER==MSOFTC
Expand Down
15 changes: 10 additions & 5 deletions edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,17 @@ edit_ifile(ifile)
*/
f = fd0;
chflags |= CH_KEEPOPEN;
#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==WIN32C
/*
* Must switch stdin to BINARY mode.
*/
setmode(f, O_BINARY);
#endif
#if MSDOS_COMPILER==MSOFTC
_setmode(f, _O_BINARY);
SET_BINARY(f);
#if MSDOS_COMPILER==DJGPPC
/*
* Setting stdin to binary by default causes
* Ctrl-C to not raise SIGINT. We must undo
* that side-effect.
*/
__djgpp_set_ctrl_c(1);
#endif
} else if (strcmp(open_filename, FAKE_HELPFILE) == 0)
{
Expand Down Expand Up @@ -714,12 +717,14 @@ use_logfile(filename)
* Overwrite: create the file.
*/
logfile = creat(filename, 0644);
SET_BINARY(logfile);
break;
case 'A': case 'a':
/*
* Append: open the file and seek to the end.
*/
logfile = open(filename, OPEN_APPEND);
SET_BINARY(logfile);
if (lseek(logfile, (off_t)0, 2) == BAD_LSEEK)
{
close(logfile);
Expand Down
49 changes: 47 additions & 2 deletions filename.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
#if MSDOS_COMPILER==WIN32C && !defined(_MSC_VER)
#include <dir.h>
#endif
#if MSDOS_COMPILER==DJGPPC
#include <glob.h>
#include <dir.h>
#include <limits.h>
#define _MAX_PATH PATH_MAX
#endif
#endif
#ifdef _OSK
#include <rbf.h>
Expand Down Expand Up @@ -114,7 +120,17 @@ homefile(filename)
* Look for the file anywhere on search path.
*/
pathname = (char *) calloc(_MAX_PATH, sizeof(char));
_searchenv(filename, "PATH", pathname);
#if MSDOS_COMPILER==DJGPPC
{
char *res = searchpath(filename);
if (res == 0)
*pathname = '\0';
else
strcpy(pathname, res);
}
#else
_searchenv(filename, "PATH", pathname);
#endif
if (*pathname != '\0')
return (pathname);
free(pathname);
Expand Down Expand Up @@ -235,7 +251,7 @@ fcomplete(s)
/*
* Complete the filename "s" by globbing "s*".
*/
#if MSDOS_COMPILER != WIN32C
#if MSDOS_COMPILER && MSDOS_COMPILER != WIN32C && MSDOS_COMPILER != DJGPPC
/*
* But in DOS, we have to glob "s*.*".
* But if the final component of the filename already has
Expand Down Expand Up @@ -431,6 +447,34 @@ lglob(filename)
_fnexplodefree(list);
}
#else
#if MSDOS_COMPILER==DJGPPC
{
size_t cnt;
size_t length;
glob_t glob_results;
char **p;

glob(filename, GLOB_NOCHECK, 0, &glob_results);

/* How much space do we need? */
for (p = glob_results.gl_pathv, cnt = glob_results.gl_pathc;
cnt > 0; p++, cnt--)
length += strlen(*p) + 1;

/* Allocate the space and generate the list. */
gfilename = (char *) ecalloc(length, sizeof(char));
for (p = glob_results.gl_pathv, cnt = glob_results.gl_pathc;
cnt > 0; p++, cnt--)
{
strcat(gfilename, *p);
if (cnt > 1)
strcat(gfilename, " ");
}

free(filename);
globfree(&glob_results);
}
#else
{
FILE *fd;
char *s;
Expand Down Expand Up @@ -471,6 +515,7 @@ lglob(filename)
}
free(filename);
}
#endif
#endif
return (gfilename);
}
Expand Down
16 changes: 14 additions & 2 deletions less.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
*/
#define MSOFTC 1 /* Microsoft C */
#define BORLANDC 2 /* Borland C */
#define WIN32C 3 /* Windows (Borland C) */
#define WIN32C 3 /* Windows (Borland C or Microsoft C) */
#define DJGPPC 4 /* DJGPP C */

/*
* Include the file of compile-time options.
Expand Down Expand Up @@ -93,7 +94,7 @@
#include <modes.h>
#include <strings.h>
#endif
#if MSDOS_COMPILER==WIN32C
#if MSDOS_COMPILER==WIN32C || MSDOS_COMPILER==DJGPPC
#include <io.h>
#endif

Expand Down Expand Up @@ -179,6 +180,17 @@ typedef long POSITION;
#define OPEN_TTYIN() open("/dev/tty", OPEN_READ)
#endif

#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==WIN32C || MSDOS_COMPILER==DJGPPC
#define SET_BINARY(f) setmode(f, O_BINARY)
#else
#if MSDOS_COMPILER==MSOFTC
#define SET_BINARY(f) _setmode(f, _O_BINARY);
#else
#define SET_BINARY(f)
#endif
#endif


#if MSDOS_COMPILER || OS2 || _OSK
#define SHELL_META_QUEST 0
#else
Expand Down
Loading

0 comments on commit 909318f

Please sign in to comment.