diff -c -r -N less-321.orig/ch.c less-321/ch.c
*** less-321.orig/ch.c	Mon Jul  8 19:28:00 1996
--- less-321/ch.c	Mon Jul 22 14:14:10 1996
***************
*** 763,768 ****
--- 763,783 ----
  	return (ch_flags);
  }
  
+ #if MSDOS_COMPILER && MSDOS_COMPILER != WIN32C
+ 
+ /*
+  * Return the file handle for the current file.
+  * Currently, only defined for native MS-DOS systems,
+  * and used only under that OS.
+  */
+ 	public int
+ ch_getfile()
+ {
+ 	return (ch_file);
+ }
+ 
+ #endif
+ 
  #if 0
  	public void
  ch_dump(struct filestate *fs)
diff -c -r -N less-321.orig/defines.dos less-321/defines.dos
*** less-321.orig/defines.dos	Tue May 21 22:27:14 1996
--- less-321/defines.dos	Tue Jul 16 11:08:36 1996
***************
*** 91,105 ****
  /*
   * 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		0
  
  /*
   * PIPEC is 1 if you wish to have the "|" command
   * which allows the user to pipe data into a shell command.
   */
  #define	PIPEC		0
  
  /*
   * LOGFILE is 1 if you wish to allow the -l option (to create log files).
--- 91,113 ----
  /*
   * 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 (or any other means of expanding filenames).
   */
+ #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).
***************
*** 135,146 ****
--- 143,159 ----
   * Define MSDOS_COMPILER if compiling for MS-DOS.
   *  MSOFTC == Microsoft C
   *  BORLANDC == Turbo/Borland C
+  *  DJGPPC == DJGPP port of GCC
   */
+ #ifdef __DJGPP__
+ #define	MSDOS_COMPILER		DJGPPC
+ #else
  #ifdef __BORLANDC__
  #define	MSDOS_COMPILER		BORLANDC
  #else
  #define	MSDOS_COMPILER		MSOFTC
  #endif
+ #endif
  
  /*
   * Pathname separator character.
***************
*** 222,228 ****
--- 235,245 ----
  /* #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
***************
*** 240,248 ****
  #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 
   * in errno.h */
! #if MSDOS_COMPILER==MSOFTC
  #define HAVE_ERRNO 1
  #define MUST_DEFINE_ERRNO 0
  #else
--- 257,265 ----
  #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 defined
   * in errno.h */
! #if MSDOS_COMPILER==MSOFTC || MSDOS_COMPILER==DJGPPC
  #define HAVE_ERRNO 1
  #define MUST_DEFINE_ERRNO 0
  #else
***************
*** 269,275 ****
  #define HAVE_UPPER_LOWER 1
  
  /* Define if you have the _setjmp function.  */
! #if MSDOS_COMPILER==MSOFTC
  #define HAVE__SETJMP	0
  #else
  #define HAVE__SETJMP	1
--- 286,292 ----
  #define HAVE_UPPER_LOWER 1
  
  /* Define if you have the _setjmp function.  */
! #if MSDOS_COMPILER==MSOFTC || MSDOS_COMPILER==DJGPPC
  #define HAVE__SETJMP	0
  #else
  #define HAVE__SETJMP	1
***************
*** 327,333 ****
--- 344,354 ----
  #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
diff -c -r -N less-321.orig/edit.c less-321/edit.c
*** less-321.orig/edit.c	Wed Jul 10 20:59:18 1996
--- less-321/edit.c	Tue Jul 16 11:12:04 1996
***************
*** 266,276 ****
  		 */
  		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);
--- 266,284 ----
  		 */
  		f = fd0;
  		chflags |= CH_KEEPOPEN;
! #if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==WIN32C || MSDOS_COMPILER==DJGPPC
  		/*
  		 * Must switch stdin to BINARY mode.
  		 */
  		setmode(f, O_BINARY);
+ #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
  #endif
  #if MSDOS_COMPILER==MSOFTC
  		_setmode(f, _O_BINARY);
***************
*** 647,653 ****
  	register int answer;
  	PARG parg;
  
! 	if (ch_getflags() & CH_CANSEEK)
  		/*
  		 * Can't currently use a log file on a file that can seek.
  		 */
--- 655,661 ----
  	register int answer;
  	PARG parg;
  
! 	if (NOT_IN_PIPE)
  		/*
  		 * Can't currently use a log file on a file that can seek.
  		 */
***************
*** 687,698 ****
--- 695,712 ----
  		 * Overwrite: create the file.
  		 */
  		logfile = creat(filename, 0644);
+ #if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
+ 		setmode(logfile, O_BINARY);
+ #endif
  		break;
  	case 'A': case 'a':
  		/*
  		 * Append: open the file and seek to the end.
  		 */
  		logfile = open(filename, OPEN_APPEND);
+ #if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
+ 		setmode(logfile, O_BINARY);
+ #endif
  		if (lseek(logfile, (off_t)0, 2) == BAD_LSEEK)
  		{
  			close(logfile);
diff -c -r -N less-321.orig/filename.c less-321/filename.c
*** less-321.orig/filename.c	Wed Jun  5 18:52:44 1996
--- less-321/filename.c	Tue Jul 16 11:12:04 1996
***************
*** 36,41 ****
--- 36,47 ----
  #if MSDOS_COMPILER==WIN32C
  #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>
***************
*** 114,120 ****
--- 120,136 ----
  	 * Look for the file anywhere on search path.
  	 */
  	pathname = (char *) calloc(_MAX_PATH, sizeof(char));
+ #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);
***************
*** 229,235 ****
  	/*
  	 * Complete the filename "s" by globbing "s*".
  	 */
! #if MSDOS_COMPILER
  	/*
  	 * But in DOS, we have to glob "s*.*".
  	 * But if the final component of the filename already has
--- 245,251 ----
  	/*
  	 * Complete the filename "s" by globbing "s*".
  	 */
! #if MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC
  	/*
  	 * But in DOS, we have to glob "s*.*".
  	 * But if the final component of the filename already has
***************
*** 425,430 ****
--- 441,473 ----
  	_fnexplodefree(list);
  }
  #else
+ #if MSDOS_COMPILER==DJGPPC
+ {
+ 	size_t cnt, 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; 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; p++, cnt--)
+ 	{
+ 		strcat(gfilename, *p);
+ 		if (cnt > 1)
+ 			strcat(gfilename, " ");
+ 	}
+ 
+ 	free(filename);
+ 	globfree(&glob_results);
+ }
+ #else
  {
  	FILE *fd;
  	char *s;
***************
*** 465,470 ****
--- 508,514 ----
  	}
  	free(filename);
  }
+ #endif
  #endif
  	return (gfilename);
  }
diff -c -r -N less-321.orig/less.h less-321/less.h
*** less-321.orig/less.h	Tue Jul 16 21:59:34 1996
--- less-321/less.h	Tue Jul 16 16:16:58 1996
***************
*** 35,40 ****
--- 35,41 ----
  #define	MSOFTC		1	/* Microsoft C */
  #define	BORLANDC	2	/* Borland C */
  #define	WIN32C		3	/* Windows (Borland C) */
+ #define	DJGPPC		4	/* DJGPP port of GCC */
  
  /*
   * Include the file of compile-time options.
***************
*** 93,99 ****
  #include <modes.h>
  #include <strings.h>
  #endif
! #if MSDOS_COMPILER==WIN32C
  #include <io.h>
  #endif
  
--- 94,100 ----
  #include <modes.h>
  #include <strings.h>
  #endif
! #if MSDOS_COMPILER==WIN32C || MSDOS_COMPILER==DJGPPC
  #include <io.h>
  #endif
  
***************
*** 183,188 ****
--- 184,205 ----
  #define	SHELL_META_QUEST 0
  #else
  #define	SHELL_META_QUEST 1
+ #endif
+ 
+ /*
+  * How to test for a pipe.
+  * It seems unjustified to make Less think pipes aren't seekable
+  * under DOS.  On MS-DOS, a pipe is a file, so is seekable.
+  * Instead of testing if the input is seekable, check if `stdin'
+  * is a device (if it is, then it cannot be a pipe under DOS).
+  * This will allow to use logfiles on pipes, although some of the
+  * file material might not get to the logfile, because Less still
+  * uses `lseek'.
+  */
+ #if MSDOS_COMPILER==MSOFTC || MSDOS_COMPILER==DJGPPC
+ #define NOT_IN_PIPE (ch_getfile() != fd0 || isatty(fd0))
+ #else
+ #define NOT_IN_PIPE (ch_getflags() & CH_CANSEEK)
  #endif
  
  /*
diff -c -r -N less-321.orig/lsystem.c less-321/lsystem.c
*** less-321.orig/lsystem.c	Tue Apr 30 17:50:34 1996
--- less-321/lsystem.c	Tue Jul 16 11:12:04 1996
***************
*** 132,138 ****
--- 132,148 ----
  	system(p);
  	free(p);
  #else
+ #if MSDOS_COMPILER==DJGPPC
+ 	/*
+ 	 * We don't need to catch signals of the child (it
+ 	 * also makes trouble with some DPMI servers).
+ 	 */
+ 	__djgpp_exception_toggle();
  	system(cmd);
+ 	__djgpp_exception_toggle();
+ #else
+ 	system(cmd);
+ #endif
  #endif
  
  #if HAVE_DUP
diff -c -r -N less-321.orig/main.c less-321/main.c
*** less-321.orig/main.c	Mon Jul  8 20:49:06 1996
--- less-321/main.c	Tue Jul 16 11:54:14 1996
***************
*** 163,169 ****
  		ifile = get_ifile(FAKE_HELPFILE, ifile);
  	while (argc-- > 0)
  	{
! #if MSDOS_COMPILER || OS2
  		/*
  		 * Because the "shell" doesn't expand filename patterns,
  		 * treat each argument as a filename pattern rather than
--- 163,169 ----
  		ifile = get_ifile(FAKE_HELPFILE, ifile);
  	while (argc-- > 0)
  	{
! #if (MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC) || OS2
  		/*
  		 * Because the "shell" doesn't expand filename patterns,
  		 * treat each argument as a filename pattern rather than
***************
*** 345,351 ****
  	deinit();
  	flush();
  	raw_mode(0);
! #if MSDOS_COMPILER
  	/* 
  	 * If we don't close 2, we get some garbage from
  	 * 2's buffer when it flushes automatically.
--- 345,351 ----
  	deinit();
  	flush();
  	raw_mode(0);
! #if MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC
  	/* 
  	 * If we don't close 2, we get some garbage from
  	 * 2's buffer when it flushes automatically.
diff -c -r -N less-321.orig/makefile.dj less-321/makefile.dj
*** less-321.orig/makefile.dj	Thu Jan  1 00:00:00 1970
--- less-321/makefile.dj	Tue Jul 16 15:54:30 1996
***************
*** 0 ****
--- 1,70 ----
+ # Makefile for less under DJGPP v2.0 or later.
+ 
+ #### Start of system configuration section. ####
+ 
+ srcdir = .
+ VPATH = .
+ 
+ CC = gcc
+ 
+ CFLAGS = -O2
+ CFLAGS_COMPILE_ONLY = -c
+ LDFLAGS = -s
+ O=o
+ 
+ LIBS =
+ 
+ #### End of system configuration section. ####
+ 
+ SUBSHELL = command >nul /c
+ 
+ # This rule allows us to supply the necessary -D options
+ # in addition to whatever the user asks for.
+ .c.o:
+ 	${CC} -I. ${CFLAGS_COMPILE_ONLY} ${CPPFLAGS} ${CFLAGS} $<
+ 
+ OBJ =	main.${O} screen.${O} brac.${O} ch.${O} charset.${O} cmdbuf.${O} \
+ 	command.${O} decode.${O} edit.${O} filename.${O} forwback.${O} \
+ 	help.${O} ifile.${O} input.${O} jump.${O} line.${O} linenum.${O} \
+ 	lsystem.${O} mark.${O} optfunc.${O} option.${O} opttbl.${O} os.${O} \
+ 	output.${O} position.${O} prompt.${O} search.${O} signal.${O} \
+ 	tags.${O} ttyin.${O} version.${O}
+ 
+ all: less lesskey
+ 
+ less: ${OBJ}
+ 	${CC} ${LDFLAGS} -o $@ ${OBJ} ${LIBS}
+ 
+ lesskey: lesskey.${O} version.${O}
+ 	${CC} ${LDFLAGS} -o $@ lesskey.${O} version.${O}
+ 
+ defines.h: defines.dos
+ 	update $< $@
+ 
+ ${OBJ}: less.h defines.h funcs.h
+ 
+ info:
+ install-info:
+ dvi:
+ check:
+ installcheck:
+ 
+ TAGS:
+ 	etags *.c *.h
+ 
+ #	command > funcs.h /c mkfuncs
+ newfuncs:
+ 	redir -o funcs.h gawk -f mkfuncs.awk ${OBJ:.${O}=.c}
+ 
+ clean:
+ 	${SUBSHELL} for %%f in (*.${O} less lesskey *.exe) do if exist %%f del %%f
+ 
+ mostlyclean: clean
+ 
+ distclean: clean
+ 	if not exist makefile.dj ren makefile makefile.dj
+ 	if not exist defines.dos ren defines.h defines.dos
+ 	${SUBSHELL} for %%f in (Makefile defines.h) do if exist %%f del %%f
+ 
+ realclean: distclean
+ 	if exist TAGS del TAGS
diff -c -r -N less-321.orig/optfunc.c less-321/optfunc.c
*** less-321.orig/optfunc.c	Wed Apr 24 05:00:44 1996
--- less-321/optfunc.c	Mon Jul 15 19:08:08 1996
***************
*** 74,79 ****
--- 74,80 ----
  extern int ul_fg_color, ul_bg_color;
  extern int so_fg_color, so_bg_color;
  extern int bl_fg_color, bl_bg_color;
+ extern int fd0;
  #endif
  
  
***************
*** 99,105 ****
  		namelogfile = s;
  		break;
  	case TOGGLE:
! 		if (ch_getflags() & CH_CANSEEK)
  		{
  			error("Input is not a pipe", NULL_PARG);
  			return;
--- 100,106 ----
  		namelogfile = s;
  		break;
  	case TOGGLE:
! 		if (NOT_IN_PIPE)
  		{
  			error("Input is not a pipe", NULL_PARG);
  			return;
diff -c -r -N less-321.orig/os.c less-321/os.c
*** less-321.orig/os.c	Mon Jun 10 17:01:42 1996
--- less-321/os.c	Mon Jul 22 14:14:10 1996
***************
*** 91,97 ****
  {
  	register int n;
  
! #if MSDOS_COMPILER
  	if (kbhit())
  	{
  		int c;
--- 91,97 ----
  {
  	register int n;
  
! #if MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC
  	if (kbhit())
  	{
  		int c;
***************
*** 120,125 ****
--- 120,142 ----
  
  	flush();
  	reading = 1;
+ #if MSDOS_COMPILER==DJGPPC
+ 	if (isatty (fd))
+ 	{
+ 		/* Don't try reading from a TTY until a character is
+ 		 * available, because that makes some background programs
+ 		 * believe DOS is busy in a way that prevents those
+ 		 * programs from working while `Less' waits.
+ 		 */
+ 		fd_set readfds;
+ 
+ 		FD_ZERO(&readfds);
+ 		FD_SET(fd, &readfds);
+ 		if (select(fd+1, &readfds, 0, 0, 0) == -1)
+ 			return (-1);
+ 	}
+ #endif
+ 
  	n = read(fd, buf, len);
  	reading = 0;
  	if (n < 0)
diff -c -r -N less-321.orig/output.c less-321/output.c
*** less-321.orig/output.c	Thu Jul 11 18:45:38 1996
--- less-321/output.c	Tue Jul 16 11:12:02 1996
***************
*** 153,159 ****
  		return;
  	}
  #else
! #if MSDOS_COMPILER==BORLANDC
  	if (is_tty && any_display)
  	{
  		*ob = '\0';
--- 153,159 ----
  		return;
  	}
  #else
! #if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
  	if (is_tty && any_display)
  	{
  		*ob = '\0';
diff -c -r -N less-321.orig/readme less-321/readme
*** less-321.orig/readme	Thu Jul 18 21:28:14 1996
--- less-321/readme	Mon Jul 22 10:06:12 1996
***************
*** 72,81 ****
  
  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.
  
  2. If you are using Microsoft C, rename MAKEFILE.DOS to MAKEFILE.
     If you are using Borland C, rename MAKEFILE.BCC 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
--- 72,82 ----
  
  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 (DJGPP doesn't require this).
  
  2. If you are using Microsoft C, rename MAKEFILE.DOS to MAKEFILE.
     If you are using Borland C, rename MAKEFILE.BCC to MAKEFILE.
+    If you are using DJGPP, rename MAKEFILE.DJ 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
***************
*** 83,88 ****
--- 84,91 ----
     reside.  If these definitions need to be changed, you can either 
     modify the definitions directly in MAKEFILE, or set your environment 
     variables CC and/or LIBDIR to override the definitions in MAKEFILE.
+ 
+    (For DJGPP, CC is already set to `gcc' and LIBDIR is not used.)
  
  4. If you wish, you may edit DEFINES.DOS to remove some optional features.
     If you choose not to include some features in your version, you may
diff -c -r -N less-321.orig/screen.c less-321/screen.c
*** less-321.orig/screen.c	Wed Jul 10 19:50:44 1996
--- less-321/screen.c	Tue Jul 16 16:05:12 1996
***************
*** 37,44 ****
  #if MSDOS_COMPILER==MSOFTC
  #include <graph.h>
  #else
! #if MSDOS_COMPILER==BORLANDC
  #include <conio.h>
  #else
  #if MSDOS_COMPILER==WIN32C
  #include <windows.h>
--- 37,47 ----
  #if MSDOS_COMPILER==MSOFTC
  #include <graph.h>
  #else
! #if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
  #include <conio.h>
+ #if MSDOS_COMPILER==DJGPPC
+ #include <pc.h>
+ #endif
  #else
  #if MSDOS_COMPILER==WIN32C
  #include <windows.h>
***************
*** 112,123 ****
  #define	SETCOLORS(fg,bg)	_settextcolor(fg); _setbkcolor(bg);
  #endif
  
! #if MSDOS_COMPILER==BORLANDC
  static unsigned short *whitescreen;
  #define _settextposition(y,x)   gotoxy(x,y)
  #define _clearscreen(m)         clrscr()
  #define _outtext(s)             cputs(s)
  #define	SETCOLORS(fg,bg)	textcolor(fg); textbackground(bg);
  #endif
  
  #if MSDOS_COMPILER==WIN32C
--- 115,127 ----
  #define	SETCOLORS(fg,bg)	_settextcolor(fg); _setbkcolor(bg);
  #endif
  
! #if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
  static unsigned short *whitescreen;
  #define _settextposition(y,x)   gotoxy(x,y)
  #define _clearscreen(m)         clrscr()
  #define _outtext(s)             cputs(s)
  #define	SETCOLORS(fg,bg)	textcolor(fg); textbackground(bg);
+ #define _GCLEARSCREEN
  #endif
  
  #if MSDOS_COMPILER==WIN32C
***************
*** 550,556 ****
--- 554,564 ----
  	LSIGNAL(SIGINT, SIG_IGN);
  #endif
  	erase_char = '\b';
+ #if MSDOS_COMPILER==DJGPPC
+ 	kill_char = CONTROL('u');
+ #else
  	kill_char = '\033'; /* ESC */
+ #endif
  	werase_char = CONTROL('W');
  #endif
  #endif
***************
*** 612,618 ****
  		sc_width = w.numtextcols;
  	}
  #else
! #if MSDOS_COMPILER==BORLANDC
  	{
  		struct text_info w;
  		gettextinfo(&w);
--- 620,626 ----
  		sc_width = w.numtextcols;
  	}
  #else
! #if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
  	{
  		struct text_info w;
  		gettextinfo(&w);
***************
*** 674,680 ****
--- 682,692 ----
   		sc_height = ltgetnum("li");
  #endif
  	if (sc_height <= 0)
+ #if MSDOS_COMPILER
+ 		sc_height = 25;
+ #else
  		sc_height = 24;
+ #endif
  
  	if (sc_width > 0)
  		;
***************
*** 795,800 ****
--- 807,814 ----
  	'\340','\117',0,		A_GOEND,		/* end */
  	'\340','\073',0,		A_HELP,			/* F1 */
  	'\340','\022',0,		A_EXAMINE,		/* Alt-E */
+ 	'\340','\115',0,		A_RSHIFT,		/* RghtArrow */
+ 	'\340','\113',0,		A_LSHIFT,		/* LeftArrow */
  	0
  };
  static int sz_kfcmdtable = sizeof(kfcmdtable) - 1;
***************
*** 982,993 ****
  	sy_fg_color = _gettextcolor();
  	get_clock();
  #else
! #if MSDOS_COMPILER==BORLANDC
      {
  	struct text_info w;
  	gettextinfo(&w);
  	sy_bg_color = (w.attribute >> 4) & 0x0F;
  	sy_fg_color = (w.attribute >> 0) & 0x0F;
      }
  #else
  #if MSDOS_COMPILER==WIN32C
--- 996,1016 ----
  	sy_fg_color = _gettextcolor();
  	get_clock();
  #else
! #if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
      {
  	struct text_info w;
  	gettextinfo(&w);
  	sy_bg_color = (w.attribute >> 4) & 0x0F;
  	sy_fg_color = (w.attribute >> 0) & 0x0F;
+ 
+ 	/*
+ 	 * If we are in a pipe, set stdout to binary mode, since
+ 	 * we are reading files in binary mode also.  This way,
+ 	 * the output will be identical to input.
+ 	 */
+ 	if (!isatty(1))
+ 		setmode(1, O_BINARY);
+ 
      }
  #else
  #if MSDOS_COMPILER==WIN32C
***************
*** 1452,1458 ****
  	_scrolltextwindow(_GSCROLLDOWN);
  	_settextposition(1,1);
  #else
! #if MSDOS_COMPILER==BORLANDC
  	movetext(1,1, sc_width,sc_height-1, 1,2);
  	gotoxy(1,1);
  	clreol();
--- 1475,1481 ----
  	_scrolltextwindow(_GSCROLLDOWN);
  	_settextposition(1,1);
  #else
! #if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
  	movetext(1,1, sc_width,sc_height-1, 1,2);
  	gotoxy(1,1);
  	clreol();
***************
*** 1518,1523 ****
--- 1541,1547 ----
   * This screen is used to create a "flash" effect, by displaying it
   * briefly and then switching back to the normal screen.
   * {{ Yuck!  There must be a better way to get a visual bell. }}
+  * (  In DJGPP, there is!  :-)
   */
  	static void
  create_flash()
***************
*** 1586,1591 ****
--- 1610,1618 ----
  		return;
  	tputs(sc_visual_bell, sc_height, putchr);
  #else
+ #if MSDOS_COMPILER==DJGPPC
+ 	ScreenVisualBell();
+ #else
  #if MSDOS_COMPILER==MSOFTC
  	/*
  	 * Create a flash screen on the second video page.
***************
*** 1645,1650 ****
--- 1672,1678 ----
  #endif
  #endif
  #endif
+ #endif
  }
  
  /*
***************
*** 1735,1741 ****
  	_settextwindow(top, left, bot, right);
  	_settextposition(tpos.row, tpos.col);
  #else
! #if MSDOS_COMPILER==BORLANDC
  	flush();
  	clreol();
  #else
--- 1763,1769 ----
  	_settextwindow(top, left, bot, right);
  	_settextposition(tpos.row, tpos.col);
  #else
! #if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
  	flush();
  	clreol();
  #else
***************
*** 1769,1775 ****
--- 1797,1820 ----
  {
  	lower_left();
  #if MSDOS_COMPILER
+ #if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
+ 	{
+ 	   unsigned char save_attr;
+ 	   struct text_info txinfo;
+ 
+ 	   /* Clear bottom, but with the background color of the text
+ 	      window, not with background of stand-out color, so the the
+ 	      bottom line stays stand-out only to the extent of prompt.  */
+ 	   gettextinfo(&txinfo);
+ 	   save_attr = txinfo.attribute;
+ 	   lower_left();
+ 	   textbackground(nm_bg_color);
+ 	   clear_eol();
+ 	   textbackground(save_attr >> 4);
+ 	}
+ #else
  	clear_eol();
+ #endif
  #else
  	if (below_mem)
  		tputs(sc_eos_clear, 1, putchr);
***************
*** 1917,1924 ****
  	_outtext(" ");
  	_settextposition(tpos.row, tpos.col-1);
  #else
! #if MSDOS_COMPILER==BORLANDC
! 	cputs("\b");
  #else
  #if MSDOS_COMPILER==WIN32C
          COORD cpos;
--- 1962,1969 ----
  	_outtext(" ");
  	_settextposition(tpos.row, tpos.col-1);
  #else
! #if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
! 	cputs("\b \b");
  #else
  #if MSDOS_COMPILER==WIN32C
          COORD cpos;
***************
*** 1958,1964 ****
  		row = tpos.row;
  		col = tpos.col;
  #else
! #if MSDOS_COMPILER==BORLANDC
  		row = wherey();
  		col = wherex();
  #else
--- 2003,2009 ----
  		row = tpos.row;
  		col = tpos.col;
  #else
! #if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
  		row = wherey();
  		col = wherex();
  #else
diff -c -r -N less-321.orig/signal.c less-321/signal.c
*** less-321.orig/signal.c	Tue Apr  9 20:30:22 1996
--- less-321/signal.c	Tue Jul 16 11:12:02 1996
***************
*** 63,68 ****
--- 63,77 ----
  #endif
  	LSIGNAL(SIGINT, u_interrupt);
  	sigs |= S_INTERRUPT;
+ #if MSDOS_COMPILER==DJGPPC
+ 	/*
+ 	 * If a keyboard has been hit, it must be Ctrl-C
+ 	 * (as opposed to Ctrl-Break), so consume it.
+ 	 * (Otherwise, Less will beep when it sees Ctrl-C from keyboard.)
+ 	 */
+ 	if (kbhit())
+ 		getkey();
+ #endif
  	if (reading)
  		intread();
  }
diff -c -r -N less-321.orig/ttyin.c less-321/ttyin.c
*** less-321.orig/ttyin.c	Thu Jul 18 21:23:56 1996
--- less-321/ttyin.c	Thu Jul 18 21:23:56 1996
***************
*** 66,71 ****
--- 66,78 ----
  	 fd0 = dup(0);
  	 close(0);
  	 tty = OPEN_TTYIN();
+ #if MSDOS_COMPILER==DJGPPC
+ 	/*
+ 	 * Setting stdin to binary causes Ctrl-C to not
+ 	 * raise SIGINT.  We must undo that side-effect.
+ 	 */
+ 	(void) __djgpp_set_ctrl_c(1);
+ #endif
  #else
  	/*
  	 * Try /dev/tty.
***************
*** 103,109 ****
  
  	do
  	{
! #if MSDOS_COMPILER
  		/*
  		 * In raw read, we don't see ^C so look here for it.
  		 */
--- 110,116 ----
  
  	do
  	{
! #if MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC
  		/*
  		 * In raw read, we don't see ^C so look here for it.
  		 */
