2016-03-19  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/filesubr.c (deep_remove_dir) [__DJGPP__]:  On Win2K and WinXP
	an attempt to delete a not empty directory sets errno to ENOTEMPTY
	but on plain DOS and Win98SE it is set to EACCES and for this value
	the code does not check.

	* djgpp/djgpp.h [__DJGPP__]:  New function return_to_starting_directory
	called by atexit to return to the starting directory when the program
	finishes.

	* src/import.c (import) [__MSDOS__]:  Do not try to unlink a file before
	it has been closed.


2015-12-24  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* doc/cvs.texinfo:  Add mandatory argument to @sp.

	* doc/cvs.1:  Remove undefinded date from cvs(1) header.

	* diff/diff3.c (output_diff3):  Pass compilation with -Wformat-security.

	* lib/getline.c (getline):  Replace return type from int to ssize_t.

	* lib/getline.h:  Replace return type from int to ssize_t.

	* src/login.c (password_entry_operation):  Create ~/.cvspass at login
	if it does not exists.

	* src/logmsg.c (do_editor):  Add newline to string.

	* src/main.c (usage):  Pass compilation with -Wformat-security.

	* src/rcs.c (apply_rcs_changes):  Mallformed RCS revision (delete after
	the end of input file, or overlayed deleted regions) screws output file
	image size computation.  This leads to write attempt after the allocated
	memory opening hiden memory corruption driven by CVS server.

	* src/server.c (check_repository_password):  Prevent CVS from chrashing
	in the case that crypt(3) fails returning NULL pointer.

	* src/subr.c (xmalloc):  Pass compilation with -Wformat-security.


2015-12-15  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/update.c (merge_file, join_file):  Bug fix for merge.  Do not
	check for -kb to decide if merge is impossible.  This means ignore -kb.
	If merge is successfull delete backup file.


2015-12-12  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/client.c (make_bufs_from_fds) [__DJGPP__]:  Do not call close_on_exec.


2015-12-03  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/client.c (send_file_names):  Pacifiy compiler.


2015-01-10  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/run.c:  Pacifiy compiler.


2012-10-17  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/subpipe.h:  Declaration of new functions: init_subprocess_with_pipe,
	create_subprocess_with_pipe, end_of_output_subprocess_with_pipe and
	reap_subprocess_with_pipe.

	* src/subpipe.c:  Definition of new functions: init_subprocess_with_pipe,
	create_subprocess_with_pipe, end_of_output_subprocess_with_pipe and
	reap_subprocess_with_pipe.


2012-09-22  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* lib/system.h [__DJGPP__]:  New macro IS_TMPDIR defined.  Checks if
	tmpdir environment variable points to an existing directory.
	For all other systems this is a no-op.

	* src/main.c (main):  Use IS_TMPDIR to check for valid tmpdir.


2012-09-05  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/mkmodules.c (init) [USE_DJGPP_GDBM]:  Use .db extension for gdbm
	data base files or .pag extension for ndbm data base files.


2012-09-04  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/myndbm.c [USE_DJGPP_GDBM]:  Implementation of djgpp_gdbm_open
	as replacement for dbm_open.

	* src/cvs.h [MY_NDBM]:  If USE_DJGPP_GDBM defined redifine dbm_open
	to djgpp_gdbm_open.


2012-08-18  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* djgpp/djgpp.h [__DJGPP__]:  New macro SYSTEM_INITIALIZE defined.
	New function djgpp_cvs_init to set __opendir_flags and to adjust
	argv[0].

	* src/main.c [__DJGPP__]:  Include djgpp.h.
	(main):  Use SYSTEM_INITIALIZE to perform DJGPP specific initializations.


2012-08-17  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* lib/system.h [__DJGPP__]:  New macro STRIP_EXTENSION defined.
	For all other systems this is a no-op.


2012-08-14  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* lib/system.h [__DJGPP__]:  Redefine _setmode to setmode and _fileno
	to fileno.


2012-08-13  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/rcs.c (RCS_checkin):  Use S_ISLNK only if defined.


2012-08-11  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/run.c [HAVE_WORKING_VFORK, HAVE_WORKING_FORK]:  If both macros
	are undefined define USE_SPAWN.
	[USE_SPAWN]:  Include process.h for spawn().
	(run_exec) [USE_SPAWN]:  If the operating system does neither provide
	fork() nor vfork() use spawn() to run the subprocess.

	* src/main.c (main):  For -d option use CANONICALIZE_PATH to change
	backslashes to slashes in repository path.

	* src/logmsg.c (do_editor) [__DJGPP__]:  If "edit" is used as editor
	convert slashes to backslashes in the file path.


2012-08-05  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/import.c (add_rcs_file):  Call xreadlink only if S_ISLNK
	is defined.

	* src/recurse.c (start_recursion):  Use CANONICALIZE_PATH to change
	backslashes to slashes in module path.


2012-08-04  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* lib/system.h [__DJGPP__]:  New macros CANONICALIZE_PATH and IS_ROOT
	defined.  For all other systems these are no-ops.

	* src/checkout.c (checkout_proc):  Use IS_ROOT to check if directory
	is a root directory and do not add a trailing slash.
	(checkout):  Use CANONICALIZE_PATH to change backslashes to slashes in
	module path.

	* lib/stripslash.c: (strip_trailing_slashes):  Use IS_ROOT to inhibit
	stripping last slash from root making it relative (e.g.:X:/).


2012-08-03  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/checkout.c (findslash):  Use ISDIRSEP to check for backslash or
	slash instead of using hardcoded slash.


2012-07-30  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* lib/system.h [__DJGPP__]:  New macro STRIP_ACCESS_MODE defined.
	For all other systems this is a no-op.

	* src/subr.c (isabsolute):  Use STRIP_ACCESS_MODE to strip access
	mode from path before testing if path is absolute.


2012-07-29  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/update.c (join_file):  Pacify compiler.

	* src/filesubr.c [__DJGPP__, __DJGPP_MINOR__]:  New function readlink
	returns EINVAL if compiled with djdev203.
	(xreadlink) [__DJGPP__]:  Always compiled for DJGPP.


2012-07-21  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/ignore.c (ignore_directory) [__DJGPP__]:  Ignore case during
	dirname compare.


2012-07-20  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* src/filesubr.c (xresolvepath) [__DJGPP__]:  Check for both slash
	and backslash.
	(get_homedir) [__DJGPP__]:  If HOME not set use /dev/env/DJDIR
	as default.

	* src/root.c (parse_cvsroot):  Use isabsolute to check for DOS paths.


2012-07-16  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* lib/getopt.c (_getopt_internal):  Replace argv[0] with program_name.


2012-07-15  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* diff/diff3.c (undotlines, output_diff3_merge):  Pacify compiler.

	* diff/util.c (begin_output):  Pacify compiler.

	* diff/side.c (print_half_line):  Pacify compiler.

	* contrib/cvs2vendor.sh:  Use $TMPDIR or $TMP or $TEMP or "." as
	default temporary directory.

	* contrib/debug_check_log.sh: Use $TMPDIR or $TMP or $TEMP or "." as
	default temporary directory.

	* contrib/rcs-to-cvs.sh: Use $TMPDIR or $TMP or $TEMP or "." as
	default temporary directory.

	* contrib/rcs2log.sh: Use $TMPDIR or $TMP or $TEMP or "." as default
	temporary directory.

	* contrib/rcs2sccs.sh: Use $TMPDIR or $TMP or $TEMP or "." as default
	temporary directory.


2012-07-14  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* diff/binary-io.h:  Added to provide SET_BINARY definition.

	* diff/diff.c:  Include binary-io.h.
	(diff_run):  If file is not STDOUT support changing file mode to
	O_BINARY using SET_BINARY and use CANONICALIZE_PATH to canonicalize
	the passed file names.
	(compare_files):  If file is not STDIN support changing file mode to
	O_BINARY using SET_BINARY.

	* diff/io.c:  Include binary-io.h.
	(sip, read_files):  Use SET_BINARY and UNSET_BINARY to change file
	mode.

	* lib/system.h [__DJGPP__]:  New macro CANONICALIZE_PATH defined.
	For all other systems this is a no-op.

	* diff/diff3.c (main):  Use CANONICALIZE_PATH to canonicalize the
	passed file names.


2012-07-14  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* lib/stripslash.c:  Include "system.h".
	(strip_trailing_slashes):  Use ISDIRSEP to check for last directory
	separator.

	* lib/system.h [FILENAMES_CASE_INSENSITIVE]:  DJGPP specific definition
	of ISDIRSEP, ISABSOLUTE and FOLD_FN_CHAR macros.


2012-01-18  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* lib/progname.c [MSDOS]:  Define new macro GET_LAST_SLASH to find
	the last directory separator character.  On DOS-like systems these
	are slash, backslash or colon.  For POSIX this is simple a slash.

	* lib/tempname.c:  New macro HAVE_DIFFERENT_TMPDIR.  Value depends on
	if the OS is posix or not.
	(direxists):  Use ISSLASH to check for the OS dependent directory
	separator character.  Use HAVE_DIFFERENT_TMPDIR to check for TMP and
	TEMP too, if none of them are defined or do not point to an existing
	directory default to the current directory.

	* lib/wcrtomb.c [__DJGPP__]:  Define EILSEQ if not defined.

	* diff/cmp.c (main):  Use CANONICALIZE_PATH to canonicalize the passed
	file names.
	(main):  Use STRIP_EXTENSION to strip path and extension from argv[0].

	* diff/diff.c (main):  Use STRIP_EXTENSION to strip path and extension
	from argv[0].
	(main):  Use CANONICALIZE_PATH to canonicalize the passed file names.

	* diff/sdiff.c (main):  Use CANONICALIZE_PATH to canonicalize the passed
	file names.
	(main):  Use STRIP_EXTENSION to strip path and extension from argv[0].
	(temporary_file) [HAVE_LFN_SUPPORT]:  Use HAVE_LFN_SUPPORT to
	determinate at run time the temp file pattern to be used.




diff -aprNU5 cvs-1.11.23.orig/contrib/cvs2vendor.sh cvs-1.11.23/contrib/cvs2vendor.sh
--- cvs-1.11.23.orig/contrib/cvs2vendor.sh	2005-07-12 15:53:54 +0200
+++ cvs-1.11.23/contrib/cvs2vendor.sh	2016-03-19 14:02:52 +0100
@@ -46,14 +46,16 @@ if [ $# -ne 2 ]; then
 	exit 2
 fi
 tsrcdir=$1
 tdstdir=$2
 
-revfile=/tmp/cvs2vendor_$$_rev
+: ${TMPDIR=${TMP=${TEMP=.}}}
+
+revfile=${TMPDIR}/cvs2vendor_$$_rev
 rm -f $revfile
 
-commentfile=/tmp/cvs2vendor_$$_comment
+commentfile=${TMPDIR}/cvs2vendor_$$_comment
 rm -f $commentfile
 
 if sort -k 1,1 /dev/null 2>/dev/null
 then sort_each_field='-k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9'
 else sort_each_field='+0 +1 +2 +3 +4 +5 +6 +7 +8'
diff -aprNU5 cvs-1.11.23.orig/contrib/debug_check_log.sh cvs-1.11.23/contrib/debug_check_log.sh
--- cvs-1.11.23.orig/contrib/debug_check_log.sh	2005-07-12 15:55:24 +0200
+++ cvs-1.11.23/contrib/debug_check_log.sh	2016-03-19 14:02:52 +0100
@@ -22,10 +22,12 @@
 # Contributed by Derek R. Price <derek.price@openavenue.com>
 #
 
 
 
+: ${TMPDIR=${TMP=${TEMP=.}}}
+
 usage ()
 {
 	echo "\
 usage: $0 [-afh] [file...]
 
@@ -97,61 +99,61 @@ process_check_log ()
 	dcl_exprfiles=""
 	if grep '^\*\* or: $' <$1 >/dev/null; then
 		# file contains a second regex
 		if test $dcl_dofirst -eq 1; then
 			# get the first pattern
-			sed -ne '/^\*\* expected: $/,/^\*\* or: $/p' <$1 >/tmp/dcle$$
-			dcl_exprfiles="$dcl_exprfiles /tmp/dcle$$"
+			sed -ne '/^\*\* expected: $/,/^\*\* or: $/p' <$1 >${TMPDIR}/dcle$$
+			dcl_exprfiles="$dcl_exprfiles ${TMPDIR}/dcle$$"
 		fi
 		if test $dcl_doalternate -eq 1; then
 			# get the alternate pattern
-			sed -ne '/^\*\* or: $/,/^\*\* got: $/p' <$1 >/tmp/dclo$$
-			dcl_exprfiles="$dcl_exprfiles /tmp/dclo$$"
+			sed -ne '/^\*\* or: $/,/^\*\* got: $/p' <$1 >${TMPDIR}/dclo$$
+			dcl_exprfiles="$dcl_exprfiles ${TMPDIR}/dclo$$"
 		else
 			echo "WARNING:  Ignoring alternate pattern in file: $1" >&2
 		fi
 	else
 		# file doesn't contain a second regex
 		if test $dcl_dofirst = 1; then
 			# get the only pattern
-			sed -ne '/^\*\* expected: $/,/^\*\* got: $/p' <$1 >/tmp/dcle$$
-			dcl_exprfiles="$dcl_exprfiles /tmp/dcle$$"
+			sed -ne '/^\*\* expected: $/,/^\*\* got: $/p' <$1 >${TMPDIR}/dcle$$
+			dcl_exprfiles="$dcl_exprfiles ${TMPDIR}/dcle$$"
 		fi
 		if test $dcl_doalternate -eq 1; then
 			echo "WARNING:  No alternate pattern in file:  $1" >&2
 		fi
 	fi
 
 	# and get the actual output
-	sed -ne '/^\*\* got: $/,$p' <$1 >/tmp/dclg$$
+	sed -ne '/^\*\* got: $/,$p' <$1 >${TMPDIR}/dclg$$
 	sed -ne '1D
 $D
-p' </tmp/dclg$$ >/tmp/dclh$$
-	mv /tmp/dclh$$ /tmp/dclg$$
+p' <${TMPDIR}/dclg$$ >${TMPDIR}/dclh$$
+	mv ${TMPDIR}/dclh$$ ${TMPDIR}/dclg$$
 
 	# compare the output against each pattern requested
 	for dcl_f in $dcl_exprfiles; do
 		sed -ne '1D
 $D
-p' <$dcl_f >/tmp/dclp$$
-		mv /tmp/dclp$$ $dcl_f
+p' <$dcl_f >${TMPDIR}/dclp$$
+		mv ${TMPDIR}/dclp$$ $dcl_f
 
 		case $dcl_f in
-			/tmp/dcle*)
+			${TMPDIR}/dcle*)
 				echo "********** $1 : Primary **********"
 				;;
-			/tmp/dclo*)
+			${TMPDIR}/dclo*)
 				echo "********** $1 : Alternate **********"
 				;;
 		esac
 
-		expr_line_by_line /tmp/dclg$$ $dcl_f
+		expr_line_by_line ${TMPDIR}/dclg$$ $dcl_f
 
 		rm $dcl_f
 	done
 
-	rm /tmp/dclg$$
+	rm ${TMPDIR}/dclg$$
 }
 
 ###
 ### MAIN
 ###
diff -aprNU5 cvs-1.11.23.orig/contrib/rcs-to-cvs.sh cvs-1.11.23/contrib/rcs-to-cvs.sh
--- cvs-1.11.23.orig/contrib/rcs-to-cvs.sh	2005-07-12 15:57:58 +0200
+++ cvs-1.11.23/contrib/rcs-to-cvs.sh	2016-03-19 14:02:54 +0100
@@ -39,11 +39,14 @@
 #############################################################################
 
 usage="Usage: rcs-to-cvs [-v] [-m message] [-f message_file] repository"
 vbose=0
 message=""
-if [ -d /var/tmp ]; then message_file=/var/tmp/checkin.$$; else message_file=/usr/tmp/checkin.$$; fi
+
+: ${TMPDIR=${TMP=${TEMP=.}}}
+
+if [ -d ${TMPDIR} ]; then message_file=${TMPDIR}/checkin.$$; elif [ -d /var/tmp ]; then message_file=/var/tmp/checkin.$$; else message_file=/usr/tmp/checkin.$$; fi
 got_one=0
 
 if [ $# -lt 1 ]; then
     echo "$usage" >&2
     exit 1
diff -aprNU5 cvs-1.11.23.orig/contrib/rcs2log.sh cvs-1.11.23/contrib/rcs2log.sh
--- cvs-1.11.23.orig/contrib/rcs2log.sh	2005-07-12 15:58:22 +0200
+++ cvs-1.11.23/contrib/rcs2log.sh	2016-03-19 14:02:54 +0100
@@ -94,11 +94,11 @@ nl='
 # Parse options.
 
 # defaults
 : ${MKTEMP="@MKTEMP@"}
 : ${AWK=awk}
-: ${TMPDIR=/tmp}
+: ${TMPDIR=${TMP=${TEMP=.}}}
 
 changelog=ChangeLog # change log file name
 datearg= # rlog date option
 hostname= # name of local host (if empty, will deduce it later)
 indent=8 # indent of log line
diff -aprNU5 cvs-1.11.23.orig/contrib/rcs2sccs.sh cvs-1.11.23/contrib/rcs2sccs.sh
--- cvs-1.11.23.orig/contrib/rcs2sccs.sh	2005-07-12 15:58:42 +0200
+++ cvs-1.11.23/contrib/rcs2sccs.sh	2016-03-19 14:02:54 +0100
@@ -18,23 +18,25 @@
 #
 if [ ! -d SCCS ] ; then
     mkdir SCCS
 fi
 
-logfile=/tmp/rcs2sccs_$$_log
+: ${TMPDIR=${TMP=${TEMP=.}}}
+
+logfile=${TMPDIR}/rcs2sccs_$$_log
 rm -f $logfile
-tmpfile=/tmp/rcs2sccs_$$_tmp
+tmpfile=${TMPDIR}/rcs2sccs_$$_tmp
 rm -f $tmpfile
-emptyfile=/tmp/rcs2sccs_$$_empty
+emptyfile=${TMPDIR}/rcs2sccs_$$_empty
 echo -n "" > $emptyfile
-initialfile=/tmp/rcs2sccs_$$_init
+initialfile=${TMPDIR}/rcs2sccs_$$_init
 echo "Initial revision" > $initialfile
-sedfile=/tmp/rcs2sccs_$$_sed
+sedfile=${TMPDIR}/rcs2sccs_$$_sed
 rm -f $sedfile
-revfile=/tmp/rcs2sccs_$$_rev
+revfile=${TMPDIR}/rcs2sccs_$$_rev
 rm -f $revfile
-commentfile=/tmp/rcs2sccs_$$_comment
+commentfile=${TMPDIR}/rcs2sccs_$$_comment
 rm -f $commentfile
 
 # create the sed script
 cat > $sedfile << EOF
 s,;Id;,%Z%%M% %I% %E%,g
diff -aprNU5 cvs-1.11.23.orig/diff/binary-io.h cvs-1.11.23/diff/binary-io.h
--- cvs-1.11.23.orig/diff/binary-io.h	1970-01-01 01:00:00 +0100
+++ cvs-1.11.23/diff/binary-io.h	2016-03-19 14:02:54 +0100
@@ -0,0 +1,59 @@
+/* Binary mode I/O.
+   Copyright (C) 2001, 2003, 2005, 2008-2012 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef _BINARY_H
+#define _BINARY_H
+
+/* For systems that distinguish between text and binary I/O.
+   O_BINARY is guaranteed by the gnulib <fcntl.h>. */
+#include <fcntl.h>
+
+/* The MSVC7 <stdio.h> doesn't like to be included after '#define fileno ...',
+   so we include it here first.  */
+#include <stdio.h>
+
+/* SET_BINARY (fd);
+   changes the file descriptor fd to perform binary I/O, returns
+   the previous I/O mode.
+
+   UNSET_BINARY (fd);
+   changes the file descriptor fd to perform text I/O, returns
+   the previous I/O mode. */
+#if O_BINARY
+# if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__ || __MINGW32__
+#  include <io.h> /* declares setmode() */
+# else
+#  define setmode _setmode
+#  undef fileno
+#  define fileno _fileno
+# endif
+# ifdef __DJGPP__
+#  include <unistd.h> /* declares isatty() */
+   /* Avoid putting stdin/stdout in binary mode if it is connected to
+      the console, because that would make it impossible for the user
+      to interrupt the program through Ctrl-C or Ctrl-Break.  */
+#  define SET_BINARY(fd) (!isatty (fd) ? setmode (fd, O_BINARY) : -1)
+# else
+#  define SET_BINARY(fd) ((void) setmode (fd, O_BINARY))
+# endif
+# define UNSET_BINARY(fd) (setmode (fd, O_TEXT))
+#else
+  /* On reasonable systems, binary I/O is the default.  */
+# define SET_BINARY(fd) /* do nothing */ (O_BINARY)
+# define UNSET_BINARY(fd) /* do nothing */ (-1)
+#endif
+
+#endif /* _BINARY_H */
diff -aprNU5 cvs-1.11.23.orig/diff/diff.c cvs-1.11.23/diff/diff.c
--- cvs-1.11.23.orig/diff/diff.c	2008-05-07 17:57:32 +0200
+++ cvs-1.11.23/diff/diff.c	2016-03-19 14:02:54 +0100
@@ -21,10 +21,12 @@ GNU General Public License for more deta
 #define GDIFF_MAIN
 #include "diff.h"
 #include <signal.h>
 #include "getopt.h"
 
+#include "binary-io.h"
+
 #ifdef HAVE_FNMATCH
 # include <fnmatch.h> /* This is supposed to be available on Posix systems */
 #else /* HAVE_FNMATCH */
 # include "fnmatch.h" /* Our substitute */
 #endif /* HAVE_FNMATCH */
@@ -588,22 +590,12 @@ diff_run (argc, argv, out, callbacks_arg
 	case 142:
 	  /* Use binary I/O when reading and writing data.
 	     On Posix hosts, this has no effect.  */
 #if HAVE_SETMODE
 	  binary_I_O = 1;
-#  if 0
-	  /* Because this code is leftover from pre-library days,
-	     there is no way to set stdout back to the default mode
-	     when we are done.  As it turns out, I think the only
-	     parts of CVS that pass out == NULL, and thus cause diff
-	     to write to stdout, are "cvs diff" and "cvs rdiff".  So
-	     I'm not going to worry about this too much yet.  */
-	  setmode (STDOUT_FILENO, O_BINARY);
-#  else
-	  if (out == NULL)
-	    error (0, 0, "warning: did not set stdout to binary mode");
-#  endif
+	  if (! isatty (STDOUT_FILENO))
+	    SET_BINARY (STDOUT_FILENO);
 #endif
 	  break;
 
 	default:
 	  return try_help (0);
@@ -701,11 +693,11 @@ diff_run (argc, argv, out, callbacks_arg
 	    }
 	  opened_file = 1;
 	}
     }
 
-  val = compare_files (0, argv[optind], 0, argv[optind + 1], 0);
+  val = compare_files (0, CANONICALIZE_PATH(argv[optind]), 0, CANONICALIZE_PATH(argv[optind + 1]), 0);
 
   /* Print any messages that were saved up for last.  */
   print_message_queue ();
 
   free (switch_string);
@@ -994,10 +986,14 @@ compare_files (dir0, name0, dir1, name1,
 	      stat_result = 0;
 	    }
 	  else if (strcmp (inf[i].name, "-") == 0)
 	    {
 	      inf[i].desc = STDIN_FILENO;
+#if HAVE_SETMODE
+	      if (O_BINARY && binary_I_O && !isatty (STDIN_FILENO))
+		SET_BINARY (STDIN_FILENO);
+#endif
 	      stat_result = CVS_FSTAT (STDIN_FILENO, &inf[i].stat);
 	      if (stat_result == 0 && S_ISREG (inf[i].stat.st_mode))
 		{
 		  off_t pos = lseek (STDIN_FILENO, (off_t) 0, SEEK_CUR);
 		  if (pos == -1)
diff -aprNU5 cvs-1.11.23.orig/diff/diff3.c cvs-1.11.23/diff/diff3.c
--- cvs-1.11.23.orig/diff/diff3.c	2008-05-07 17:57:32 +0200
+++ cvs-1.11.23/diff/diff3.c	2016-03-19 14:02:54 +0100
@@ -360,11 +360,11 @@ diff3_run (argc, argv, out, callbacks_ar
   file = &argv[optind];
 
   optind = optind_old;
 
   for (i = tag_count; i < 3; i++)
-    tag_strings[i] = file[i];
+    tag_strings[i] = CANONICALIZE_PATH(file[i]);
 
   /* Always compare file1 to file2, even if file2 is "-".
      This is needed for -mAeExX3.  Using the file0 as
      the common file would produce wrong results, because if the
      file0-file1 diffs didn't line up with the file0-file2 diffs
@@ -1503,11 +1503,11 @@ output_diff3 (diff, mapping, rev_mapping
 	  if (lowt <= hight)
 	    {
 	      line = 0;
 	      do
 		{
-		  printf_output (line_prefix);
+		  printf_output ("%s", line_prefix);
 		  cp = D_RELNUM (ptr, realfile, line);
 		  length = D_RELLEN (ptr, realfile, line);
 		  write_output (cp, length);
 		}
 	      while (++line < hight - lowt + 1);
@@ -1556,14 +1556,16 @@ static void
 undotlines (leading_dot, start, num)
      int leading_dot, start, num;
 {
   write_output (".\n", 2);
   if (leading_dot)
+  {
     if (num == 1)
       printf_output ("%ds/^\\.//\n", start);
     else
       printf_output ("%d,%ds/^\\.//\n", start, start + num - 1);
+  }
 }
 
 /*
  * This routine outputs a diff3 set of blocks as an ed script.  This
  * script applies the changes between file's 2 & 3 to file 1.  It
@@ -1751,14 +1753,16 @@ output_diff3_merge (infile, diff, mappin
       while (0 <= --i)
 	do
 	  {
 	    c = getc (infile);
 	    if (c == EOF)
+	    {
 	      if (ferror (infile))
 		diff3_perror_with_exit ("input file");
 	      else if (feof (infile))
 		diff3_fatal ("input file shrank");
+	    }
 	    cc = c;
 	    write_output (&cc, 1);
 	  }
 	while (c != '\n');
 
@@ -1805,18 +1809,20 @@ output_diff3_merge (infile, diff, mappin
       i = D_NUMLINES (b, FILE0);
       linesread += i;
       while (0 <= --i)
 	while ((c = getc (infile)) != '\n')
 	  if (c == EOF)
+	  {
 	    if (ferror (infile))
 	      diff3_perror_with_exit ("input file");
 	    else if (feof (infile))
 	      {
 		if (i || b->next)
 		  diff3_fatal ("input file shrank");
 		return conflicts_found;
 	      }
+	  }
     }
   /* Copy rest of common file.  */
   while ((c = getc (infile)) != EOF || !(ferror (infile) | feof (infile)))
     {
       cc = c;
diff -aprNU5 cvs-1.11.23.orig/diff/io.c cvs-1.11.23/diff/io.c
--- cvs-1.11.23.orig/diff/io.c	2005-04-04 22:46:04 +0200
+++ cvs-1.11.23/diff/io.c	2016-03-19 14:02:54 +0100
@@ -14,10 +14,11 @@ MERCHANTABILITY or FITNESS FOR A PARTICU
 GNU General Public License for more details.
 
 */
 
 #include "diff.h"
+#include "binary-io.h"
 
 /* Rotate a value n bits to the left. */
 #define UINT_BIT (sizeof (unsigned) * CHAR_BIT)
 #define ROL(v, n) ((v) << (n) | (v) >> (UINT_BIT - (n)))
 
@@ -97,22 +98,22 @@ sip (current, skip_test)
 
       if (! skip_test)
 	{
 	  /* Check first part of file to see if it's a binary file.  */
 #if HAVE_SETMODE
-	  int oldmode = setmode (current->desc, O_BINARY);
+	  int oldmode = SET_BINARY (current->desc);
 #endif
 	  ssize_t n = read (current->desc, current->buffer, current->bufsize);
 	  if (n == -1)
 	    pfatal_with_name (current->name);
 	  current->buffered_chars = n;
 #if HAVE_SETMODE
 	  if (oldmode != O_BINARY)
 	    {
 	      if (lseek (current->desc, - (off_t) n, SEEK_CUR) == -1)
 		pfatal_with_name (current->name);
-	      setmode (current->desc, oldmode);
+	      (void) UNSET_BINARY (current->desc);
 	      current->buffered_chars = 0;
 	    }
 #endif
 	  return binary_file_p (current->buffer, n);
 	}
@@ -675,12 +676,12 @@ read_files (filevec, pretend_binary)
       filevec[1].buffered_chars = filevec[0].buffered_chars;
     }
   if (appears_binary)
     {
 #if HAVE_SETMODE
-      setmode (filevec[0].desc, O_BINARY);
-      setmode (filevec[1].desc, O_BINARY);
+      (void) SET_BINARY (filevec[0].desc);
+      (void) SET_BINARY (filevec[1].desc);
 #endif
       return 1;
     }
 
   find_identical_ends (filevec);
diff -aprNU5 cvs-1.11.23.orig/diff/side.c cvs-1.11.23/diff/side.c
--- cvs-1.11.23.orig/diff/side.c	1998-06-18 18:57:14 +0200
+++ cvs-1.11.23/diff/side.c	2016-03-19 14:02:54 +0100
@@ -121,20 +121,22 @@ print_half_line (line, indent, out_bound
 	  }
 	  break;
 
 	case '\b':
 	  if (in_position != 0 && --in_position < out_bound)
+	  {
 	    if (out_position <= in_position)
 	      /* Add spaces to make up for suppressed tab past out_bound.  */
 	      for (;  out_position < in_position;  out_position++)
 		write_output (" ", 1);
 	    else
 	      {
 		out_position = in_position;
 		cc = c;
 		write_output (&cc, 1);
 	      }
+	  }
 	  break;
 
 	case '\f':
 	case '\v':
 	control_char:
diff -aprNU5 cvs-1.11.23.orig/diff/system.h cvs-1.11.23/diff/system.h
--- cvs-1.11.23.orig/diff/system.h	2008-05-07 17:57:32 +0200
+++ cvs-1.11.23/diff/system.h	2016-03-19 14:02:54 +0100
@@ -306,5 +306,24 @@ extern int errno;
 #define CVS_STAT stat
 #endif
 #ifndef CVS_FSTAT
 #define CVS_FSTAT fstat
 #endif
+
+#ifdef __DJGPP__
+# include <libc/unconst.h>
+# define CANONICALIZE_PATH(path)              \
+  (__gnuc_extension__                         \
+    ({                                        \
+       if ((path))                            \
+       {                                      \
+         char *_p = unconst((path), char *);  \
+         for (; *_p; _p++)                    \
+           if (*_p == '\\')                   \
+             *_p = '/';                       \
+       }                                      \
+       (path);                                \
+    })                                        \
+  )
+#else /* !__DJGPP__ */
+# define CANONICALIZE_PATH(path)  (path)
+#endif /* !__DJGPP__ */
diff -aprNU5 cvs-1.11.23.orig/diff/util.c cvs-1.11.23/diff/util.c
--- cvs-1.11.23.orig/diff/util.c	2008-05-07 17:57:32 +0200
+++ cvs-1.11.23/diff/util.c	2016-03-19 14:02:54 +0100
@@ -229,11 +229,11 @@ begin_output ()
 	      if (dup2 (pipes[0], STDIN_FILENO) < 0)
 		pfatal_with_name ("dup2");
 	      close (pipes[0]);
 	    }
 
-	  execl (PR_PROGRAM, PR_PROGRAM, "-f", "-h", name, 0);
+	  execl (PR_PROGRAM, PR_PROGRAM, "-f", "-h", name, (char *)NULL);
 	  pfatal_with_name (PR_PROGRAM);
 	}
       else
 	{
 	  close (pipes[0]);
diff -aprNU5 cvs-1.11.23.orig/djgpp/djgpp.h cvs-1.11.23/djgpp/djgpp.h
--- cvs-1.11.23.orig/djgpp/djgpp.h	1970-01-01 01:00:00 +0100
+++ cvs-1.11.23/djgpp/djgpp.h	2016-03-19 14:02:54 +0100
@@ -0,0 +1,72 @@
+/*
+ *  DJGPP specific helpers for CVS.
+ */
+
+#ifndef __DJGPP_H__
+# define __DJGPP_H__
+
+# include <stdlib.h>
+# include <sys/stat.h>
+# include <dirent.h>
+
+# define SYSTEM_INITIALIZE(pargc, pargv)  djgpp_cvs_init(pargc, pargv)
+
+# define HAS_EXE_EXTENSION(n)  ((*--(n) == 'e' || *(n) == 'E') && \
+                                (*--(n) == 'x' || *(n) == 'X') && \
+                                (*--(n) == 'e' || *(n) == 'E') && \
+                                 *--(n) == '.')
+
+static char dos_starting_dir[PATH_MAX] = ".";
+
+
+/* Restore the starting directory to its original value.  Called at exit.  */
+static void
+return_to_starting_directory(void)
+{
+  int orig_errno = errno;
+
+  if (chdir(dos_starting_dir) < 0)
+    error(0, errno, "%s", dos_starting_dir);
+  errno = orig_errno;
+}
+
+static void
+djgpp_cvs_init(int* pargc, char*** pargv)
+{
+  /*
+   *  Set program name, switch backslash to slash
+   *  and strip the ".exe extension.
+   */
+  char *full_name = _truename((*pargv)[0], NULL);
+
+  if (full_name)
+  {
+    char *c = full_name;
+
+    for (; *c; c++)
+      if (*c == '\\')
+        *c = '/';
+
+    if (HAS_EXE_EXTENSION(c))
+      *c = '\0';  /*  Strip .exe extension from file name.  */
+
+    free((*pargv)[0]);
+    (*pargv)[0] = full_name;
+  }
+
+
+  /*
+   *  This is required so that cvs recognizes the CVS directory.
+   */
+  __opendir_flags |= __OPENDIR_PRESERVE_CASE;
+
+
+  /*
+   *  On MS-DOS, CWD is global, so we must remember where we were before
+   *  changing dirs, and return there if the program is interrupted by SIGINT.
+   */
+  getcwd(dos_starting_dir, PATH_MAX);
+  atexit(return_to_starting_directory);
+}
+
+#endif  /* __DJGPP_H__ */
diff -aprNU5 cvs-1.11.23.orig/doc/cvs.1 cvs-1.11.23/doc/cvs.1
--- cvs-1.11.23.orig/doc/cvs.1	2008-05-08 05:55:56 +0200
+++ cvs-1.11.23/doc/cvs.1	2016-03-19 14:02:54 +0100
@@ -21,11 +21,11 @@
 .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 .de Id
 .ds Rv \\$3
 .ds Dt \\$4
 ..
-.TH CVS 1 "\*(Dt"
+.TH CVS 1
 .\" Full space in nroff; half space in troff
 .de SP
 .if n .sp
 .if t .sp .5
 ..
diff -aprNU5 cvs-1.11.23.orig/doc/cvs.texinfo cvs-1.11.23/doc/cvs.texinfo
--- cvs-1.11.23.orig/doc/cvs.texinfo	2008-05-07 03:15:46 +0200
+++ cvs-1.11.23/doc/cvs.texinfo	2016-03-19 14:02:54 +0100
@@ -109,13 +109,13 @@ approved by the Free Software Foundation
 @comment The titlepage section does not appear in the Info file.
 @titlepage
 @sp 4
 @comment The title is printed in a large font.
 @center @titlefont{Version Management}
-@sp
+@sp 1
 @center @titlefont{with}
-@sp
+@sp 1
 @center @titlefont{CVS}
 @sp 2
 @center for @sc{cvs} @value{VERSION}
 @comment -release-
 @sp 3
diff -aprNU5 cvs-1.11.23.orig/lib/getline.c cvs-1.11.23/lib/getline.c
--- cvs-1.11.23.orig/lib/getline.c	2005-04-04 22:46:04 +0200
+++ cvs-1.11.23/lib/getline.c	2016-03-19 14:02:54 +0100
@@ -152,20 +152,20 @@ getstr (lineptr, n, stream, terminator,
 
   ret = read_pos - (*lineptr + offset);
   return ret;
 }
 
-int
+ssize_t
 getline (lineptr, n, stream)
      char **lineptr;
      size_t *n;
      FILE *stream;
 {
   return getstr (lineptr, n, stream, '\n', 0, GETLINE_NO_LIMIT);
 }
 
-int
+ssize_t
 getline_safe (lineptr, n, stream, limit)
      char **lineptr;
      size_t *n;
      FILE *stream;
      int limit;
diff -aprNU5 cvs-1.11.23.orig/lib/getline.h cvs-1.11.23/lib/getline.h
--- cvs-1.11.23.orig/lib/getline.h	2005-04-04 22:46:04 +0200
+++ cvs-1.11.23/lib/getline.h	2016-03-19 14:02:54 +0100
@@ -9,13 +9,13 @@
 #define __PROTO(args) ()
 #endif  /* GCC.  */
 
 #define GETLINE_NO_LIMIT -1
 
-int
+ssize_t
   getline __PROTO ((char **_lineptr, size_t *_n, FILE *_stream));
-int
+ssize_t
   getline_safe __PROTO ((char **_lineptr, size_t *_n, FILE *_stream,
                          int limit));
 int
   getstr __PROTO ((char **_lineptr, size_t *_n, FILE *_stream,
 		   int _terminator, int _offset, int limit));
diff -aprNU5 cvs-1.11.23.orig/lib/getopt.c cvs-1.11.23/lib/getopt.c
--- cvs-1.11.23.orig/lib/getopt.c	2005-04-04 22:46:04 +0200
+++ cvs-1.11.23/lib/getopt.c	2016-03-19 14:02:54 +0100
@@ -45,10 +45,12 @@
 
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
 
+extern char* program_name;
+
 /* Comment out all this code if we are using the GNU C Library, and are not
    actually compiling the library itself.  This code is part of the GNU C
    Library, but also included in many other GNU distributions.  Compiling
    and linking in this code is a waste when using the GNU C library
    (especially if it is a shared library).  Rather than having every GNU
@@ -511,11 +513,11 @@ _getopt_internal (argc, argv, optstring,
 
       if (ambig && !exact)
 	{
 	  if (opterr)
 	    fprintf (stderr, "%s: option `%s' is ambiguous\n",
-		     argv[0], argv[optind]);
+		     program_name, argv[optind]);
 	  nextchar += strlen (nextchar);
 	  optind++;
 	  return '?';
 	}
 
@@ -535,16 +537,16 @@ _getopt_internal (argc, argv, optstring,
 		    {
 		      if (argv[optind - 1][1] == '-')
 			/* --option */
 			fprintf (stderr,
 				 "%s: option `--%s' doesn't allow an argument\n",
-				 argv[0], pfound->name);
+				 program_name, pfound->name);
 		      else
 			/* +option or -option */
 			fprintf (stderr,
 			     "%s: option `%c%s' doesn't allow an argument\n",
-			     argv[0], argv[optind - 1][0], pfound->name);
+			     program_name, argv[optind - 1][0], pfound->name);
 		    }
 		  nextchar += strlen (nextchar);
 		  return '?';
 		}
 	    }
@@ -554,11 +556,11 @@ _getopt_internal (argc, argv, optstring,
 		optarg = argv[optind++];
 	      else
 		{
 		  if (opterr)
 		    fprintf (stderr, "%s: option `%s' requires an argument\n",
-			     argv[0], argv[optind - 1]);
+			     program_name, argv[optind - 1]);
 		  nextchar += strlen (nextchar);
 		  return optstring[0] == ':' ? ':' : '?';
 		}
 	    }
 	  nextchar += strlen (nextchar);
@@ -582,15 +584,15 @@ _getopt_internal (argc, argv, optstring,
 	  if (opterr)
 	    {
 	      if (argv[optind][1] == '-')
 		/* --option */
 		fprintf (stderr, "%s: unrecognized option `--%s'\n",
-			 argv[0], nextchar);
+			 program_name, nextchar);
 	      else
 		/* +option or -option */
 		fprintf (stderr, "%s: unrecognized option `%c%s'\n",
-			 argv[0], argv[optind][0], nextchar);
+			 program_name, argv[optind][0], nextchar);
 	    }
 	  nextchar = (char *) "";
 	  optind++;
 	  return '?';
 	}
@@ -610,13 +612,13 @@ _getopt_internal (argc, argv, optstring,
       {
 	if (opterr)
 	  {
 	    if (posixly_correct)
 	      /* 1003.2 specifies the format of this message.  */
-	      fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c);
+	      fprintf (stderr, "%s: illegal option -- %c\n", program_name, c);
 	    else
-	      fprintf (stderr, "%s: invalid option -- %c\n", argv[0], c);
+	      fprintf (stderr, "%s: invalid option -- %c\n", program_name, c);
 	  }
 	optopt = c;
 	return '?';
       }
     if (temp[1] == ':')
@@ -647,11 +649,11 @@ _getopt_internal (argc, argv, optstring,
 	      {
 		if (opterr)
 		  {
 		    /* 1003.2 specifies the format of this message.  */
 		    fprintf (stderr, "%s: option requires an argument -- %c\n",
-			     argv[0], c);
+			     program_name, c);
 		  }
 		optopt = c;
 		if (optstring[0] == ':')
 		  c = ':';
 		else
diff -aprNU5 cvs-1.11.23.orig/lib/regex.c cvs-1.11.23/lib/regex.c
--- cvs-1.11.23.orig/lib/regex.c	2008-05-07 17:57:32 +0200
+++ cvs-1.11.23/lib/regex.c	2016-03-19 14:02:54 +0100
@@ -1284,11 +1284,10 @@ typedef struct
 
    Does `return FAILURE_CODE' if runs out of memory.  */
 
 #define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code)	\
   do {									\
-    char *destination;							\
     /* Must be int, so when we don't save any registers, the arithmetic	\
        of 0 + -1 isn't done as unsigned.  */				\
     int this_reg;							\
 									\
     DEBUG_STATEMENT (failure_id++);					\
@@ -2349,11 +2348,10 @@ regex_compile (pattern, size, syntax, bu
 		      {
 			/* Handle a range such as \177-\377 in multibyte mode.
 			   Split that into two ranges,,
 			   the low one ending at 0237, and the high one
 			   starting at ...040.  */
-			int c1_base = (c1 & ~0177) | 040;
 			SET_RANGE_TABLE_WORK_AREA (range_table_work, c, c1);
 			c1 = 0237;
 		      }
 		    else if (!SAME_CHARSET_P (c, c1))
 		      FREE_STACK_RETURN (REG_ERANGE);
@@ -2512,14 +2510,16 @@ regex_compile (pattern, size, syntax, bu
 
 	    case ')':
 	      if (syntax & RE_NO_BK_PARENS) goto normal_backslash;
 
 	      if (COMPILE_STACK_EMPTY)
+	      {
 		if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
 		  goto normal_backslash;
 		else
 		  FREE_STACK_RETURN (REG_ERPAREN);
+	      }
 
 	    handle_close:
 	      if (fixup_alt_jump)
 		{ /* Push a dummy failure point at the end of the
 		     alternative for a possible future
@@ -2532,14 +2532,16 @@ regex_compile (pattern, size, syntax, bu
 		  STORE_JUMP (jump_past_alt, fixup_alt_jump, b - 1);
 		}
 
 	      /* See similar code for backslashed left paren above.  */
 	      if (COMPILE_STACK_EMPTY)
+	      {
 		if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
 		  goto normal_char;
 		else
 		  FREE_STACK_RETURN (REG_ERPAREN);
+	      }
 
 	      /* Since we just checked for an empty stack above, this
 		 ``can't happen''.  */
 	      assert (compile_stack.avail != 0);
 	      {
@@ -3170,30 +3172,24 @@ group_in_compile_stack (compile_stack, r
 
 int
 re_compile_fastmap (bufp)
      struct re_pattern_buffer *bufp;
 {
-  int i, j, k;
+  int j, k;
 #ifdef MATCH_MAY_ALLOCATE
   fail_stack_type fail_stack;
 #endif
 #ifndef REGEX_MALLOC
   char *destination;
 #endif
-  /* We don't push any register information onto the failure stack.  */
-  unsigned num_regs = 0;
 
   register char *fastmap = bufp->fastmap;
   unsigned char *pattern = bufp->buffer;
   unsigned long size = bufp->used;
   unsigned char *p = pattern;
   register unsigned char *pend = pattern + size;
 
-  /* This holds the pointer to the failure stack, when
-     it is allocated relocatably.  */
-  fail_stack_elt_t *failure_stack_ptr;
-
   /* Assume that each path through the pattern can be null until
      proven otherwise.	We set this false at the bottom of switch
      statement, to which we get only if a particular path doesn't
      match the empty string.  */
   boolean path_can_be_null = true;
@@ -3839,14 +3835,10 @@ re_search_2 (bufp, string1, size1, strin
 
 	      startpos += irange - range;
 	    }
 	  else				/* Searching backwards.	 */
 	    {
-	      int room = (size1 == 0 || startpos >= size1
-			  ? size2 + size1 - startpos
-			  : size1 - startpos);
-
 	      buf_ch = STRING_CHAR (d, room);
 	      if (RE_TRANSLATE_P (translate))
 		buf_ch = RE_TRANSLATE (translate, buf_ch);
 
 	      if (! (buf_ch >= 0400
@@ -3880,14 +3872,10 @@ re_search_2 (bufp, string1, size1, strin
       else if (range > 0)
 	{
 	  /* Update STARTPOS to the next character boundary.  */
 	  if (multibyte)
 	    {
-	      const unsigned char *p
-		= (const unsigned char *) POS_ADDR_VSTRING (startpos);
-	      const unsigned char *pend
-		= (const unsigned char *) STOP_ADDR_VSTRING (startpos);
 	      int len = MULTIBYTE_FORM_LENGTH (p, pend - p);
 
 	      range -= len;
 	      if (range < 0)
 		break;
@@ -4154,14 +4142,10 @@ re_match_2_internal (bufp, string1, size
 #ifdef DEBUG
   static unsigned failure_id = 0;
   unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0;
 #endif
 
-  /* This holds the pointer to the failure stack, when
-     it is allocated relocatably.  */
-  fail_stack_elt_t *failure_stack_ptr;
-
   /* We fill all the registers internally, independent of what we
      return, for use in backreferences.	 The number here includes
      an element for register zero.  */
   unsigned num_regs = bufp->re_nsub + 1;
 
@@ -5386,12 +5370,10 @@ re_match_2_internal (bufp, string1, size
 	  else
 	    {
 	      /* C1 is the character before D, S1 is the syntax of C1, C2
 		 is the character at D, and S2 is the syntax of C2.  */
 	      int c1, c2, s1, s2;
-	      int pos1 = PTR_TO_OFFSET (d - 1);
-	      int charpos;
 
 	      GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
 	      GET_CHAR_AFTER_2 (c2, d, string1, end1, string2, end2);
 #ifdef emacs
 	      charpos = SYNTAX_TABLE_BYTE_TO_CHAR (pos1);
@@ -5423,12 +5405,10 @@ re_match_2_internal (bufp, string1, size
 	  else
 	    {
 	      /* C1 is the character before D, S1 is the syntax of C1, C2
 		 is the character at D, and S2 is the syntax of C2.  */
 	      int c1, c2, s1, s2;
-	      int pos1 = PTR_TO_OFFSET (d - 1);
-	      int charpos;
 
 	      GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
 	      GET_CHAR_AFTER_2 (c2, d, string1, end1, string2, end2);
 #ifdef emacs
 	      charpos = SYNTAX_TABLE_BYTE_TO_CHAR (pos1);
@@ -5460,12 +5440,10 @@ re_match_2_internal (bufp, string1, size
 	  else
 	    {
 	      /* C1 is the character before D, S1 is the syntax of C1, C2
 		 is the character at D, and S2 is the syntax of C2.  */
 	      int c1, c2, s1, s2;
-	      int pos1 = PTR_TO_OFFSET (d);
-	      int charpos;
 
 	      GET_CHAR_AFTER_2 (c2, d, string1, end1, string2, end2);
 #ifdef emacs
 	      charpos = SYNTAX_TABLE_BYTE_TO_CHAR (pos1);
 	      UPDATE_SYNTAX_TABLE (charpos);
@@ -5504,12 +5482,10 @@ re_match_2_internal (bufp, string1, size
 	  else
 	    {
 	      /* C1 is the character before D, S1 is the syntax of C1, C2
 		 is the character at D, and S2 is the syntax of C2.  */
 	      int c1, c2, s1, s2;
-	      int pos1 = PTR_TO_OFFSET (d);
-	      int charpos;
 
 	      GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
 #ifdef emacs
 	      charpos = SYNTAX_TABLE_BYTE_TO_CHAR (pos1 - 1);
 	      UPDATE_SYNTAX_TABLE (charpos);
diff -aprNU5 cvs-1.11.23.orig/lib/stripslash.c cvs-1.11.23/lib/stripslash.c
--- cvs-1.11.23.orig/lib/stripslash.c	2005-04-04 22:46:06 +0200
+++ cvs-1.11.23/lib/stripslash.c	2016-03-19 14:02:54 +0100
@@ -13,10 +13,12 @@
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
+#include "system.h"
+
 #if STDC_HEADERS || HAVE_STRING_H
 #include <string.h>
 /* An ANSI string.h and pre-ANSI memory.h might conflict. */
 #if !STDC_HEADERS && HAVE_MEMORY_H
 #include <memory.h>
@@ -33,8 +35,14 @@ strip_trailing_slashes (path)
      char *path;
 {
   int last;
 
   last = strlen (path) - 1;
-  while (last > 0 && path[last] == '/')
+#if defined(__DJGPP__)
+  /*  Stripping a root (aka X:/) makes it non-absolute.
+      Fix this.  */
+  if (last > 0 && IS_ROOT(path))
+    return;
+#endif
+  while (last > 0 && ISDIRSEP(path[last]))
     path[last--] = '\0';
 }
diff -aprNU5 cvs-1.11.23.orig/lib/system.h cvs-1.11.23/lib/system.h
--- cvs-1.11.23.orig/lib/system.h	2008-05-07 17:57:32 +0200
+++ cvs-1.11.23/lib/system.h	2016-03-19 14:02:54 +0100
@@ -492,20 +492,173 @@ extern int errno;
 
 
 
 #ifdef FILENAMES_CASE_INSENSITIVE
 
-# if defined (__CYGWIN32__) || defined (WOE32)
-    /* Under Windows, filenames are case-insensitive, and both / and \
-       are path component separators.  */
+# if defined (__CYGWIN32__) || defined (WOE32) || defined (__DJGPP__)
+   /* Under Windows, filenames are case-insensitive, and both / and \
+      are path component separators.  */
+#  if defined (__DJGPP__)
+#   include <libc/unconst.h>
+
+#   if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
+#    define __gnuc_extension__  __extension__
+#   else
+#    define __gnuc_extension__
+#   endif
+
+#   define DIR_EXISTS(name)     (access((name), D_OK) == 0)
+#   define FILE_EXISTS(name)    (access((name), R_OK) == 0)
+
+#   define IS_TMPDIR(dirname)   ((dirname) && DIR_EXISTS(dirname))
+
+#   define IS_SLASH(c)    ((c) == '/' || (c) == '\\')
+#   define ISDIRSEP(c)    IS_SLASH(c)
+#   define HAVE_DRIVE(n)  ((n)[0] && (n)[1] == ':')
+#   define ISABSOLUTE(s)  (ISDIRSEP((s)[0]) || (HAVE_DRIVE(s) && ISDIRSEP((s)[2])))
+#   define IS_ROOT(s)     (ISABSOLUTE(s) && (((s)[1] == '\0') || ((s)[3] == '\0')))
+#   define GET_LAST_SLASH(filename)                \
+    (__gnuc_extension__                            \
+      ({                                           \
+         char *_slash = NULL;                      \
+         if ((filename))                           \
+         {                                         \
+           _slash = unconst((filename), char *);   \
+           while (*_slash++)                       \
+             ;                                     \
+           while ((--_slash - (filename)))         \
+             if (IS_SLASH(*_slash))                \
+               break;                              \
+         }                                         \
+         (_slash);                                 \
+       })                                          \
+    )
+#   define FOLD_FN_CHAR(c)                         \
+    (__gnuc_extension__                            \
+      ({                                           \
+         char _c;                                  \
+         _c = ((c) != '\\') ? (c) : '/';           \
+         _c;                                       \
+      })                                           \
+    )
+#   define IS_EXT(path)      ((path)[0] == ':' &&  \
+                              (path)[1] == 'e' &&  \
+                              (path)[2] == 'x' &&  \
+                              (path)[3] == 't' &&  \
+                              (path)[4] == ':')
+#   define IS_FORK(path)     ((path)[0] == ':' &&  \
+                              (path)[1] == 'f' &&  \
+                              (path)[2] == 'o' &&  \
+                              (path)[3] == 'r' &&  \
+                              (path)[4] == 'k' &&  \
+                              (path)[5] == ':')
+#   define IS_LOCAL(path)    ((path)[0] == ':' &&  \
+                              (path)[1] == 'l' &&  \
+                              (path)[2] == 'o' &&  \
+                              (path)[3] == 'c' &&  \
+                              (path)[4] == 'a' &&  \
+                              (path)[5] == 'l' &&  \
+                              (path)[6] == ':')
+#   define IS_SERVER(path)   ((path)[0] == ':' &&  \
+                              (path)[1] == 's' &&  \
+                              (path)[2] == 'e' &&  \
+                              (path)[3] == 'r' &&  \
+                              (path)[4] == 'v' &&  \
+                              (path)[5] == 'e' &&  \
+                              (path)[6] == 'r' &&  \
+                              (path)[7] == ':')
+#   define IS_GSERVER(path)  ((path)[0] == ':' &&  \
+                              (path)[1] == 'g' &&  \
+                              (path)[2] == 's' &&  \
+                              (path)[3] == 'e' &&  \
+                              (path)[4] == 'r' &&  \
+                              (path)[5] == 'v' &&  \
+                              (path)[6] == 'e' &&  \
+                              (path)[7] == 'r' &&  \
+                              (path)[8] == ':')
+#   define IS_KSERVER(path)  ((path)[0] == ':' &&  \
+                              (path)[1] == 'k' &&  \
+                              (path)[2] == 's' &&  \
+                              (path)[3] == 'e' &&  \
+                              (path)[4] == 'r' &&  \
+                              (path)[5] == 'v' &&  \
+                              (path)[6] == 'e' &&  \
+                              (path)[7] == 'r' &&  \
+                              (path)[8] == ':')
+#   define IS_PSERVER(path)  ((path)[0] == ':' &&  \
+                              (path)[1] == 'p' &&  \
+                              (path)[2] == 's' &&  \
+                              (path)[3] == 'e' &&  \
+                              (path)[4] == 'r' &&  \
+                              (path)[5] == 'v' &&  \
+                              (path)[6] == 'e' &&  \
+                              (path)[7] == 'r' &&  \
+                              (path)[8] == ':')
+#   define STRIP_ACCESS_MODE(path)                 \
+    (__gnuc_extension__                            \
+      ({                                           \
+         int _offset = 0;                          \
+         if ((path))                               \
+         {                                         \
+           if (IS_EXT(path))                       \
+             _offset = 5;                          \
+           else if (IS_FORK(path))                 \
+             _offset = 6;                          \
+           else if (IS_LOCAL(path))                \
+             _offset = 7;                          \
+           else if (IS_SERVER(path))               \
+             _offset = 8;                          \
+           else if (IS_GSERVER(path))              \
+             _offset = 9;                          \
+           else if (IS_KSERVER(path))              \
+             _offset = 9;                          \
+           else if (IS_PSERVER(path))              \
+             _offset = 9;                          \
+         }                                         \
+         ((path) + _offset);                       \
+      })                                           \
+    )
+#   define CANONICALIZE_PATH(path)                 \
+    (__gnuc_extension__                            \
+      ({                                           \
+         if ((path))                               \
+         {                                         \
+           char *_p = unconst((path), char *);     \
+           for (; *_p; _p++)                       \
+             if (*_p == '\\')                      \
+               *_p = '/';                          \
+         }                                         \
+         (path);                                   \
+      })                                           \
+    )
+#   define STRIP_EXTENSION(filename)               \
+    (__gnuc_extension__                            \
+      ({                                           \
+         char *_dot = NULL;                        \
+         if ((filename))                           \
+         {                                         \
+           _dot = unconst((filename), char *);     \
+           for (; *_dot; _dot++)                   \
+             if (*_dot == '.')                     \
+               *_dot = '\0';                       \
+         }                                         \
+         (filename);                               \
+       })                                          \
+    )
+#   undef  _fileno
+#   define _fileno   fileno
+#   undef  _setmode
+#   define _setmode  setmode
+#  else /* !__DJGPP__ */
 #   define FOLD_FN_CHAR(c) (WNT_filename_classes[(unsigned char) (c)])
 extern unsigned char WNT_filename_classes[];
     /* Is the character C a path name separator?  Under
        Windows NT, you can use either / or \.  */
 #   define ISDIRSEP(c) (FOLD_FN_CHAR(c) == '/')
 #   define ISABSOLUTE(s) (ISDIRSEP(s[0]) || FOLD_FN_CHAR(s[0]) >= 'a' && FOLD_FN_CHAR(s[0]) <= 'z' && s[1] == ':' && ISDIRSEP(s[2]))
-# else /* !__CYGWIN32__ && !WOE32 */
+#  endif /* !__DJGPP__ */
+# else /* !__CYGWIN32__ && !WOE32 && !__DJGPP__ */
   /* As far as I know, only Macintosh OS X & VMS make it here, but any
    * platform defining FILENAMES_CASE_INSENSITIVE which isn't WOE32 or
    * piggy-backing the same could, in theory.  Since the OS X fold just folds
    * A-Z into a-z, I'm just allowing it to be used for any case insensitive
    * system which we aren't yet making other specific folds or exceptions for.
@@ -517,11 +670,11 @@ extern unsigned char WNT_filename_classe
 extern unsigned char VMS_filename_classes[];
 #  else
 #   define FOLD_FN_CHAR(c) (OSX_filename_classes[(unsigned char) (c)])
 extern unsigned char OSX_filename_classes[];
 #  endif
-# endif /* __CYGWIN32__ || WOE32 */
+# endif /* __CYGWIN32__ || WOE32 || __DJGPP__ */
 
 /* The following need to be declared for all case insensitive filesystems.
  * When not FOLD_FN_CHAR is not #defined, a default definition for these
  * functions is provided later in this header file.  */
 
@@ -557,10 +710,30 @@ extern void fnfold (char *FILENAME);
  */
 #ifndef ISABSOLUTE
 # define ISABSOLUTE(s) ISDIRSEP(s[0])
 #endif
 
+#ifndef STRIP_ACCESS_MODE
+# define STRIP_ACCESS_MODE(path) (path)
+#endif
+
+#ifndef IS_ROOT
+# define IS_ROOT(s) (ISABSOLUTE(s) && ((s)[1]) == '\0'))
+#endif
+
+#ifndef CANONICALIZE_PATH
+# define CANONICALIZE_PATH(path) (path)
+#endif
+
+#ifndef STRIP_EXTENSION
+# define STRIP_EXTENSION(filename) (filename)
+#endif
+
+#ifndef IS_TMPDIR
+# define IS_TMPDIR(dirname) (dirname)
+#endif
+
 
 /* On some systems, we have to be careful about writing/reading files
    in text or binary mode (so in text mode the system can handle CRLF
    vs. LF, VMS text file conventions, &c).  We decide to just always
    be careful.  That way we don't have to worry about whether text and
diff -aprNU5 cvs-1.11.23.orig/src/checkout.c cvs-1.11.23/src/checkout.c
--- cvs-1.11.23.orig/src/checkout.c	2005-09-27 01:13:24 +0200
+++ cvs-1.11.23/src/checkout.c	2016-03-19 14:02:54 +0100
@@ -375,11 +375,11 @@ checkout (argc, argv)
 	}
     }
 
 
     for (i = 0; i < argc; i++)
-	err += do_module (db, argv[i], m_type, "Updating", checkout_proc,
+	err += do_module (db, CANONICALIZE_PATH(argv[i]), m_type, "Updating", checkout_proc,
 			  where, shorten, local, run_module_prog, !pipeout,
 			  (char *) NULL);
     close_module (db);
     if (options)
     {
@@ -627,10 +627,16 @@ checkout_proc (argc, argv, where_orig, m
        reallocating this string. */
     repository = xmalloc (strlen (current_parsed_root->directory)
 			  + strlen (argv[0])
 			  + (mfile == NULL ? 0 : strlen (mfile))
 			  + 10);
+#if defined(__DJGPP__)
+    /*  Do not add a trailing slash to X:/.  */
+    if (IS_ROOT(current_parsed_root->directory))
+      (void) sprintf (repository, "%s%s", current_parsed_root->directory, argv[0]);
+    else
+#endif
     (void) sprintf (repository, "%s/%s", current_parsed_root->directory, argv[0]);
     Sanitize_Repository_Name (repository);
 
 
     /* save the original value of preload_update_dir */
@@ -1170,11 +1176,11 @@ findslash (start, p)
     char *start;
     char *p;
 {
     for (;;)
     {
-	if (*p == '/') return p;
+	if (ISDIRSEP (*p)) return p;
 	if (p == start) break;
 	--p;
     }
     return NULL;
 }
diff -aprNU5 cvs-1.11.23.orig/src/client.c cvs-1.11.23/src/client.c
--- cvs-1.11.23.orig/src/client.c	2008-05-07 17:57:34 +0200
+++ cvs-1.11.23/src/client.c	2016-03-19 14:02:54 +0100
@@ -3720,12 +3720,14 @@ make_bufs_from_fds (tofd, fromfd, child_
     }
     else
 # endif /* NO_SOCKET_TO_FD */
     {
 	/* todo: some OS's don't need these calls... */
+#ifndef __DJGPP__
 	close_on_exec (tofd);
 	close_on_exec (fromfd);
+#endif
 
 	/* SCO 3 and AIX have a nasty bug in the I/O libraries which precludes
 	   fdopening the same file descriptor twice, so dup it if it is the
 	   same.  */
 	if (tofd == fromfd)
@@ -5446,11 +5448,11 @@ send_file_names (argc, argv, flags)
 	    }
 	    push (stack, r);
 
 	    /* Normalize the path into outstr. */
 	    save_cwd (&sdir);
-	    while (q = pop (stack))
+	    while ((q = pop (stack)))
 	    {
 		Node *node = NULL;
 	        if (isdir (CVSADM))
 		{
 		    List *entries;
@@ -5494,11 +5496,11 @@ send_file_names (argc, argv, flags)
 	    }
 	    restore_cwd (&sdir, NULL);
 	    free_cwd (&sdir);
 
 	    /* Now put everything we didn't find entries for back on. */
-	    while (q = pop (stack))
+	    while ((q = pop (stack)))
 	    {
 		if (line_len)
 		    xrealloc_and_strcat (&line, &line_len, "/");
 		xrealloc_and_strcat (&line, &line_len, q);
 		free (q);
diff -aprNU5 cvs-1.11.23.orig/src/cvs.h cvs-1.11.23/src/cvs.h
--- cvs-1.11.23.orig/src/cvs.h	2006-08-25 17:48:54 +0200
+++ cvs-1.11.23/src/cvs.h	2016-03-19 14:02:54 +0100
@@ -100,13 +100,18 @@ extern int errno;
 #if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT)
 # include "client.h"
 #endif
 
 #ifdef MY_NDBM
-#include "myndbm.h"
+# include "myndbm.h"
 #else
-#include <ndbm.h>
+# include <ndbm.h>
+# ifdef USE_DJGPP_GDBM
+#  undef  dbm_open
+#  define dbm_open  djgpp_gdbm_open
+DBM *djgpp_gdbm_open(char *file, int flags, int mode);
+# endif
 #endif /* MY_NDBM */
 
 #include "regex.h"
 #include "getopt.h"
 #include "wait.h"
@@ -491,11 +496,11 @@ int islink PROTO((const char *file));
 int isdevice PROTO ((const char *));
 int isreadable PROTO((const char *file));
 int iswritable PROTO((const char *file));
 int isaccessible PROTO((const char *file, const int mode));
 int isabsolute PROTO((const char *filename));
-#ifdef HAVE_READLINK
+#if defined(HAVE_READLINK) || defined(__DJGPP__)
 char *xreadlink PROTO((const char *link));
 #endif
 char *xresolvepath PROTO((const char *path));
 const char *last_component PROTO((const char *path));
 char *get_homedir PROTO ((void));
diff -aprNU5 cvs-1.11.23.orig/src/filesubr.c cvs-1.11.23/src/filesubr.c
--- cvs-1.11.23.orig/src/filesubr.c	2008-05-07 17:57:34 +0200
+++ cvs-1.11.23/src/filesubr.c	2016-03-19 14:02:54 +0100
@@ -479,10 +479,18 @@ deep_remove_dir (path)
 
     if (rmdir (path) != 0)
     {
 	if (errno == ENOTEMPTY
 	    || errno == EEXIST
+#ifdef __DJGPP__
+	    /* On plain DOS and Windows an attempt to remove a
+	       not empty directory fails.  On plain DOS and Win98SE,
+	       in this case, errno is set to EACCES -- Permission denied,
+	       but on Windows 2000 and Windows XP errno is set to
+	       ENOTEMPTY -- Directory not empty.  */
+	    || errno == EACCES
+#endif
 	    /* Ugly workaround for ugly AIX 4.1 (and 3.2) header bug
 	       (it defines ENOTEMPTY and EEXIST to 17 but actually
 	       returns 87).  */
 	    || (ENOTEMPTY == 17 && EEXIST == 17 && errno == 87))
 	{
@@ -861,11 +869,24 @@ cvs_temp_file (filename)
     return fp;
 }
 
 
 
-#ifdef HAVE_READLINK
+#if defined(__DJGPP__) && __DJGPP__ == 2 && __DJGPP_MINOR__ < 4
+/* Read the value of a symbolic link.
+   Under DJGPP 2.03, this function always returns EINVAL.  */
+int
+readlink (const char *path, char *buf, int buf_size)
+{
+    errno = EINVAL;
+    return -1;
+}
+#endif /* __DJGPP__ == 2 && __DJGPP_MINOR__ < 4 */
+
+
+
+#if defined(HAVE_READLINK) || defined(__DJGPP__)
 /* char *
  * xreadlink ( const char *link )
  *
  * Like the X/OPEN and 4.4BSD readlink() function, but allocates and returns
  * its own buf.
@@ -921,11 +942,11 @@ xreadlink (link)
 	else
 	    /* Our buffer cannot grow any bigger.  */
 	    error (1, ENAMETOOLONG, "cannot readlink %s", link);
     }
 }
-#endif /* HAVE_READLINK */
+#endif /* HAVE_READLINK || __DJGPP__ */
 
 
 
 /* char *
  * xresolvepath ( const char *path )
@@ -971,11 +992,27 @@ xresolvepath ( path )
 /* Return a pointer into PATH's last component.  */
 const char *
 last_component (path)
     const char *path;
 {
+#ifndef __DJGPP__
     const char *last = strrchr (path, '/');
+#else
+    const char *last = path;
+
+    if (path)
+    {
+      int i;
+
+      for (i = 0; path[i]; i++)
+        ;
+      for (i--; i > -1; i--)
+        if (ISDIRSEP (path[i]))
+          break;
+      last += i;
+    }
+#endif
 
     assert (path);
     if (last && (last != path))
         return last + 1;
     else
@@ -1017,11 +1054,17 @@ get_homedir ()
 
     if (!server_active && (env = getenv ("HOME")) != NULL)
 	home = env;
     else if ((pw = (struct passwd *) getpwuid (getuid ()))
 	     && pw->pw_dir)
+#ifdef __DJGPP__
+      /*  For DJGPP pw->pw_dir is the root directory
+          of the partition.  Do not use it.  */
+        home = xstrdup (DIR_EXISTS("/dev/env/DJDIR") ? "/dev/env/DJDIR" : program_path);
+#else
 	home = xstrdup (pw->pw_dir);
+#endif
     else
 	return 0;
 
     return home;
 }
diff -aprNU5 cvs-1.11.23.orig/src/ignore.c cvs-1.11.23/src/ignore.c
--- cvs-1.11.23.orig/src/ignore.c	2008-05-07 17:57:34 +0200
+++ cvs-1.11.23/src/ignore.c	2016-03-19 14:02:54 +0100
@@ -343,11 +343,16 @@ ignore_directory (name)
 	return 0;
 
     i = dir_ign_current;
     while (i--)
     {
+#if defined(__DJGPP__)
+	/* opendir_preserve_case fails, so this is needed */
+	if (strnicmp (name, dir_ign_list[i], strlen (dir_ign_list[i]) + 1) == 0)
+#else
 	if (strncmp (name, dir_ign_list[i], strlen (dir_ign_list[i])+1) == 0)
+#endif
 	    return 1;
     }
 
     return 0;
 }
diff -aprNU5 cvs-1.11.23.orig/src/import.c cvs-1.11.23/src/import.c
--- cvs-1.11.23.orig/src/import.c	2008-05-07 17:57:34 +0200
+++ cvs-1.11.23/src/import.c	2016-03-19 19:19:16 +0100
@@ -324,15 +324,18 @@ import (argc, argv)
 
     /* Create the logfile that will be logged upon completion */
     if ((logfp = cvs_temp_file (&tmpfile)) == NULL)
 	error (1, errno, "cannot create temporary file `%s'",
 	       tmpfile ? tmpfile : "(null)");
+    /* Unlinking an open file on plain DOS will corrupt the file system.  */
+#ifndef __MSDOS__
     /* On systems where we can unlink an open file, do so, so it will go
        away no matter how we exit.  FIXME-maybe: Should be checking for
        errors but I'm not sure which error(s) we get if we are on a system
        where one can't unlink open files.  */
     (void) CVS_UNLINK (tmpfile);
+#endif
     (void) fprintf (logfp, "\nVendor Tag:\t%s\n", argv[1]);
     (void) fprintf (logfp, "Release Tags:\t");
     for (i = 2; i < argc; i++)
 	(void) fprintf (logfp, "%s\n\t\t", argv[i]);
     (void) fprintf (logfp, "\n");
@@ -1238,20 +1241,22 @@ add_rcs_file (message, rcs, user, add_vh
 
 #ifdef PRESERVE_PERMISSIONS_SUPPORT
 	/* Store initial permissions if necessary. */
 	if (preserve_perms)
 	{
+#ifdef S_ISLNK
 	    if (file_type == S_IFLNK)
 	    {
 		char *link = xreadlink (userfile);
 		if (fprintf (fprcs, "symlink\t@") < 0 ||
 		    expand_at_signs (link, strlen (link), fprcs) < 0 ||
 		    fprintf (fprcs, "@;\012") < 0)
 		    goto write_error;
 		free (link);
 	    }
 	    else
+#endif
 	    {
 		if (fprintf (fprcs, "owner\t%u;\012", sb.st_uid) < 0)
 		    goto write_error;
 		if (fprintf (fprcs, "group\t%u;\012", sb.st_gid) < 0)
 		    goto write_error;
@@ -1296,20 +1301,22 @@ userfile);
 
 #ifdef PRESERVE_PERMISSIONS_SUPPORT
 	    /* Store initial permissions if necessary. */
 	    if (preserve_perms)
 	    {
+#ifdef S_ISLNK
 		if (file_type == S_IFLNK)
 		{
 		    char *link = xreadlink (userfile);
 		    if (fprintf (fprcs, "symlink\t@") < 0 ||
 			expand_at_signs (link, strlen (link), fprcs) < 0 ||
 			fprintf (fprcs, "@;\012") < 0)
 			goto write_error;
 		    free (link);
 		}
 		else
+#endif
 		{
 		    if (fprintf (fprcs, "owner\t%u;\012", sb.st_uid) < 0 ||
 			fprintf (fprcs, "group\t%u;\012", sb.st_gid) < 0 ||
 			fprintf (fprcs, "permissions\t%o;\012",
 				 sb.st_mode & 07777) < 0)
diff -aprNU5 cvs-1.11.23.orig/src/login.c cvs-1.11.23/src/login.c
--- cvs-1.11.23.orig/src/login.c	2008-05-07 17:57:34 +0200
+++ cvs-1.11.23/src/login.c	2016-03-19 14:02:54 +0100
@@ -313,10 +313,19 @@ internal error: can only call password_e
     passfile = construct_cvspass_filename ();
     errno = 0; /* Standard C doesn't require errno be set on error */
     fp = CVS_FOPEN (passfile, "r");
     if (fp == NULL)
     {
+       fp = CVS_FOPEN (passfile, "w");
+       if (fp != NULL)
+       {
+           fclose (fp);
+           fp = CVS_FOPEN (passfile, "r");
+       }
+    }
+    if (fp == NULL)
+    {
 	error (0, errno, "warning: failed to open %s for reading", passfile);
 	goto process;
     }
 
     /* Check each line to see if we have this entry already. */
diff -aprNU5 cvs-1.11.23.orig/src/logmsg.c cvs-1.11.23/src/logmsg.c
--- cvs-1.11.23.orig/src/logmsg.c	2008-05-07 17:57:34 +0200
+++ cvs-1.11.23/src/logmsg.c	2016-03-19 14:02:54 +0100
@@ -267,11 +267,11 @@ do_editor (dir, messagep, repository, ch
 		error (0, errno, "cannot close %s", CVSADM_TEMPLATE);
 	}
     }
 
     (void) fprintf (fp,
-  "%s----------------------------------------------------------------------\n",
+  "\n%s----------------------------------------------------------------------\n",
 		    CVSEDITPREFIX);
     (void) fprintf (fp,
   "%sEnter Log.  Lines beginning with `%.*s' are removed automatically\n%s\n",
 		    CVSEDITPREFIX, CVSEDITPREFIXLEN, CVSEDITPREFIX,
 		    CVSEDITPREFIX);
@@ -295,10 +295,61 @@ do_editor (dir, messagep, repository, ch
     editinfo_editor = (char *) NULL;
     if (!current_parsed_root->isremote && repository != NULL)
 	(void) Parse_Info (CVSROOTADM_EDITINFO, repository, editinfo_proc, 0);
 
     /* run the editor */
+#ifdef __DJGPP__
+   /*
+    *  Default DJGPP/DOS/WINDOWS editor is edit.
+    *  edit does not work with slashes as directory
+    *  separators so all slashes will be converted
+    *  to backslashes.  
+    *  At least all DJGPP specific code can handle
+    *  mixed slash and backslash in path anyway.
+    */
+#ifndef TRUE
+# define TRUE   1
+#endif
+
+#ifndef FALSE
+# define FALSE  !TRUE
+#endif
+
+#define IS_EDIT(name)  (                                    \
+  ((name)[0] == 'e' || (name)[0] == 'E')                    \
+  ? ((name)[1] == 'd' || (name)[1] == 'D')                  \
+    ? ((name)[2] == 'i' || (name)[2] == 'I')                \
+      ? ((name)[3] == 't' || (name)[3] == 'T')              \
+        ? ((name)[4] == '\0')                               \
+          ? TRUE                                            \
+            : ((name)[4] == '.')                            \
+              ? ((name)[5] == 'e' || (name)[4] == 'E')      \
+                ? ((name)[6] == 'x' || (name)[6] == 'X')    \
+                  ? ((name)[7] == 'e' || (name)[7] == 'E')  \
+                    ? ((name)[8] == '\0')                   \
+                      ? TRUE                                \
+                      : FALSE                               \
+                    : FALSE                                 \
+                  : FALSE                                   \
+                : FALSE                                     \
+              : FALSE                                       \
+            : FALSE                                         \
+          : FALSE                                           \
+        : FALSE                                             \
+      : FALSE                                               \
+  )
+
+    if (IS_EDIT(Editor))
+    {
+      int i;
+      for (i = 0; fname[i]; i++)
+        if (fname[i] == '/')
+          fname[i] = '\\';
+    }
+
+#undef IS_EDIT
+#endif
     run_setup (editinfo_editor ? editinfo_editor : Editor);
     run_arg (fname);
     if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY,
 			     RUN_NORMAL | RUN_SIGIGNORE)) != 0)
 	error (editinfo_editor ? 1 : 0, retcode == -1 ? errno : 0,
diff -aprNU5 cvs-1.11.23.orig/src/main.c cvs-1.11.23/src/main.c
--- cvs-1.11.23.orig/src/main.c	2008-01-28 15:55:44 +0100
+++ cvs-1.11.23/src/main.c	2016-03-19 14:02:54 +0100
@@ -18,10 +18,14 @@
  */
 
 #include <assert.h>
 #include "cvs.h"
 
+#if defined(__DJGPP__)
+#include "../djgpp/djgpp.h"
+#endif
+
 #ifdef HAVE_WINSOCK_H
 #include <winsock.h>
 #else
 extern int gethostname ();
 #endif
@@ -449,11 +453,11 @@ main (argc, argv)
     /*
      * Query the environment variables up-front, so that
      * they can be overridden by command line arguments
      */
     tmpdir_update_env = *Tmpdir;	/* TMPDIR_DFLT must be set */
-    if ((cp = getenv (TMPDIR_ENV)) != NULL)
+    if (cp = getenv (TMPDIR_ENV), IS_TMPDIR(cp))
     {
 	Tmpdir = cp;
 	tmpdir_update_env = 0;		/* it's already there */
     }
     if ((cp = getenv (EDITOR1_ENV)) != NULL)
@@ -578,11 +582,11 @@ distribution kit for a complete list of
 		free_Editor = 1;
 		break;
 	    case 'd':
 		if (CVSroot_cmdline != NULL)
 		    free (CVSroot_cmdline);
-		CVSroot_cmdline = xstrdup (optarg);
+		CVSroot_cmdline = xstrdup (CANONICALIZE_PATH (optarg));
 		break;
 	    case 'H':
 	        help = 1;
 		break;
             case 'f':
@@ -1135,8 +1139,8 @@ void
 usage (cpp)
     register const char *const *cpp;
 {
     (void) fprintf (stderr, *cpp++, program_name, cvs_cmd_name);
     for (; *cpp; cpp++)
-	(void) fprintf (stderr, *cpp);
+	(void) fprintf (stderr, "%s", *cpp);
     error_exit ();
 }
diff -aprNU5 cvs-1.11.23.orig/src/mkmodules.c cvs-1.11.23/src/mkmodules.c
--- cvs-1.11.23.orig/src/mkmodules.c	2008-05-07 17:57:34 +0200
+++ cvs-1.11.23/src/mkmodules.c	2016-03-19 14:02:56 +0100
@@ -1033,10 +1033,17 @@ init (argc, argv)
 
     /* Make an empty val-tags file to prevent problems creating it later.  */
     strcpy (info, adm);
     strcat (info, "/");
     strcat (info, CVSROOTADM_VALTAGS);
+#ifndef MY_NDBM
+# if defined(USE_DJGPP_GDBM)
+    strcat (info, ".db");
+# else
+    strcat (info, ".pag");
+# endif
+#endif
     if (!isfile (info))
     {
 	FILE *fp;
 
 	fp = open_file (info, "w");
diff -aprNU5 cvs-1.11.23.orig/src/myndbm.c cvs-1.11.23/src/myndbm.c
--- cvs-1.11.23.orig/src/myndbm.c	2008-05-07 17:57:34 +0200
+++ cvs-1.11.23/src/myndbm.c	2016-03-19 14:02:56 +0100
@@ -329,5 +329,50 @@ mydbm_load_file (fp, list, filename)
     free (line);
     free (value);
 }
 
 #endif				/* MY_NDBM */
+
+#if defined(USE_DJGPP_GDBM) && !defined(MY_NDBM)
+
+DBM *djgpp_gdbm_open(char *file, int flags, int mode)
+{
+  char *db_file;
+  GDBM_FILE db;
+  DBM *ret_val;
+
+
+  db_file = xmalloc(strlen(file) + 4);
+  strcpy(db_file, file);
+  strcat(db_file, ".db");
+
+  /* Call the actual routine, saving the pointer to the file information. */
+  flags &= O_RDONLY | O_RDWR | O_CREAT | O_TRUNC;
+  if (flags == O_RDONLY)
+    db = gdbm_open(db_file, 0, GDBM_READER, 00444, NULL);
+  else if (flags == (O_RDWR | O_CREAT))
+    db = gdbm_open(db_file, 0, GDBM_WRCREAT, mode, NULL);
+  else if ((flags & O_TRUNC) == O_TRUNC)
+    db = gdbm_open(db_file, 0, GDBM_NEWDB, mode, NULL);
+  else
+    db = gdbm_open(db_file, 0, GDBM_WRITER, 00666, NULL);
+
+  if (db && (ret_val = (DBM *)xmalloc(sizeof(*ret_val))))
+  {
+    ret_val->file = db;
+    /*  All other ndbm entries are undefined;
+        set sane dafault values.  */
+    ret_val->dirfd = -1;
+    ret_val->_dbm_memory.dptr = NULL;
+    ret_val->_dbm_memory.dsize = 0;
+    ret_val->_dbm_fetch_val = NULL;
+    __gdbm_error_to_ndbm(ret_val);
+  }
+  else
+    ret_val = NULL;
+
+  free(db_file);
+
+  return ret_val;
+}
+
+#endif  /* USE_DJGPP_GDBM */
diff -aprNU5 cvs-1.11.23.orig/src/rcs.c cvs-1.11.23/src/rcs.c
--- cvs-1.11.23.orig/src/rcs.c	2008-05-07 17:57:34 +0200
+++ cvs-1.11.23/src/rcs.c	2016-03-19 14:02:56 +0100
@@ -5126,19 +5126,21 @@ RCS_checkin (rcs, workfile_in, message,
 	delta->other_delta = getlist();
 
 	if (CVS_LSTAT (workfile, &sb) < 0)
 	    error (1, errno, "cannot lstat %s", workfile);
 
+#ifdef S_ISLNK
 	if (S_ISLNK (sb.st_mode))
 	{
 	    np = getnode();
 	    np->type = RCSFIELD;
 	    np->key = xstrdup ("symlink");
 	    np->data = xreadlink (workfile);
 	    addnode (delta->other_delta, np);
 	}
 	else
+#endif  /* S_ISLNK */
 	{
 	    (void) sprintf (buf, "%u", sb.st_uid);
 	    np = getnode();
 	    np->type = RCSFIELD;
 	    np->key = xstrdup ("owner");
@@ -7126,11 +7128,11 @@ apply_rcs_changes (orig_lines, diffbuf,
 	struct deltafrag *next;
     };
     struct deltafrag *dfhead;
     struct deltafrag **dftail;
     struct deltafrag *df;
-    unsigned long numlines, lastmodline, offset;
+    unsigned long numlines, offset;
     struct linevector lines;
     int err;
 
     dfhead = NULL;
     dftail = &dfhead;
@@ -7200,43 +7202,42 @@ apply_rcs_changes (orig_lines, diffbuf,
 	}
     }
 
     /* New temp data structure to hold new org before
        copy back into original structure. */
-    lines.nlines = lines.lines_alloced = numlines;
+    lines.lines_alloced = numlines;
     lines.vector = xmalloc (numlines * sizeof *lines.vector);
 
     /* We changed the list order to first to last -- so the
        list never gets larger than the size numlines. */
-    lastmodline = 0; 
+    lines.nlines = 0; 
 
     /* offset created when adding/removing lines
        between new and original structure */
     offset = 0; 
     err = 0;
     for (df = dfhead; df != NULL; )
     {
 	unsigned int ln;
-	unsigned long deltaend;
+	unsigned long newpos = df->pos - offset;
 
-	if (df->pos > orig_lines->nlines)
+	if (newpos < lines.nlines || newpos > numlines)
 	    err = 1;
 
 	/* On error, just free the rest of the list.  */
 	if (!err)
 	{
-	    /* Here we need to get to the line where the next insert will
+	    /* Here we need to get to the line where the next change will
 	       begin, which is DF->pos in ORIG_LINES.  We will fill up to
 	       DF->pos - OFFSET in LINES with original items.  */
-	    for (deltaend = df->pos - offset;
-		 lastmodline < deltaend;
-		 lastmodline++)
+	    while (lines.nlines < newpos)
 	    {
 		/* we need to copy from the orig structure into new one */
-		lines.vector[lastmodline] =
-			orig_lines->vector[lastmodline + offset];
-		lines.vector[lastmodline]->refcount++;
+		lines.vector[lines.nlines] =
+			orig_lines->vector[lines.nlines + offset];
+		lines.vector[lines.nlines]->refcount++;
+		lines.nlines++;
 	    }
 
 	    switch (df->type)
 	    {
 		case FRAG_ADD:
@@ -7244,11 +7245,16 @@ apply_rcs_changes (orig_lines, diffbuf,
 		    const char *textend, *p;
 		    const char *nextline_text;
 		    struct line *q;
 		    int nextline_newline;
 		    size_t nextline_len;
-		
+
+		    if (newpos + df->nlines > numlines)
+		    {
+			err = 1;
+			break;
+		    }
 		    textend = df->new_lines + df->len;
 		    nextline_newline = 0;
 		    nextline_text = df->new_lines;
 		    for (p = df->new_lines; p < textend; ++p)
 		    {
@@ -7269,12 +7275,11 @@ apply_rcs_changes (orig_lines, diffbuf,
 			    q->text = (char *)(q + 1);
 			    q->len = nextline_len;
 			    q->has_newline = nextline_newline;
 			    q->refcount = 1;
 			    memcpy (q->text, nextline_text, nextline_len);
-			    lines.vector[lastmodline++] = q;
-			    offset--;
+			    lines.vector[lines.nlines++] = q;
 		    
 			    nextline_text = (char *)p + 1;
 			    nextline_newline = 0;
 			}
 		    }
@@ -7284,33 +7289,37 @@ apply_rcs_changes (orig_lines, diffbuf,
 		    q->text = (char *)(q + 1);
 		    q->len = nextline_len;
 		    q->has_newline = nextline_newline;
 		    q->refcount = 1;
 		    memcpy (q->text, nextline_text, nextline_len);
-		    lines.vector[lastmodline++] = q;
+		    lines.vector[lines.nlines++] = q;
 
 		    /* For each line we add the offset between the #'s
 		       decreases. */
-		    offset--;
+		    offset -= df->nlines;
 		    break;
 		}
 
 		case FRAG_DELETE:
 		    /* we are removing this many lines from the source. */
 		    offset += df->nlines;
 
 		    if (df->pos + df->nlines > orig_lines->nlines)
 			err = 1;
 		    else if (delvers)
+		    {
 			for (ln = df->pos; ln < df->pos + df->nlines; ++ln)
+			{
 			    if (orig_lines->vector[ln]->refcount > 1)
 				/* Annotate needs this but, since the original
 				 * vector is disposed of before returning from
 				 * this function, we only need keep track if
 				 * there are multiple references.
 				 */
 				orig_lines->vector[ln]->vers = delvers;
+			}
+		    }
 		    break;
 	    }
 	}
 
 	df = df->next;
@@ -7326,25 +7335,24 @@ apply_rcs_changes (orig_lines, diffbuf,
 	linevector_free (&lines);
     }
     else
     {
 	/* add the rest of the remaining lines to the data vector */
-	for (; lastmodline < numlines; lastmodline++)
+	while (lines.nlines < numlines)
 	{
 	    /* we need to copy from the orig structure into new one */
-	    lines.vector[lastmodline] = orig_lines->vector[lastmodline
+	    lines.vector[lines.nlines] = orig_lines->vector[lines.nlines
 							   + offset];
-	    lines.vector[lastmodline]->refcount++;
+	    lines.vector[lines.nlines]->refcount++;
+	    lines.nlines++;
 	}
 
 	/* Move the lines vector to the original structure for output,
 	 * first deleting the old.
 	 */
 	linevector_free (orig_lines);
-	orig_lines->vector = lines.vector;
-	orig_lines->lines_alloced = numlines;
-	orig_lines->nlines = lines.nlines;
+	*orig_lines = lines;
     }
 
     return !err;
 }
 
diff -aprNU5 cvs-1.11.23.orig/src/recurse.c cvs-1.11.23/src/recurse.c
--- cvs-1.11.23.orig/src/recurse.c	2008-01-28 15:55:44 +0100
+++ cvs-1.11.23/src/recurse.c	2016-03-19 14:02:56 +0100
@@ -284,11 +284,11 @@ start_recursion (fileproc, filesdoneproc
     for (i = 0; i < argc; i++)
     {
 	/* if this argument is a directory, then add it to the list of
 	   directories. */
 
-	if (!wrap_name_has (argv[i], WRAP_TOCVS) && isdir (argv[i]))
+	if (CANONICALIZE_PATH (argv[i]), !wrap_name_has (argv[i], WRAP_TOCVS) && isdir (argv[i]))
 	{
 	    strip_trailing_slashes (argv[i]);
 	    addlist (&dirlist, argv[i]);
 	}
 	else
diff -aprNU5 cvs-1.11.23.orig/src/root.c cvs-1.11.23/src/root.c
--- cvs-1.11.23.orig/src/root.c	2008-01-28 15:55:44 +0100
+++ cvs-1.11.23/src/root.c	2016-03-19 14:02:56 +0100
@@ -457,11 +457,11 @@ parse_cvsroot (root_in)
     else
     {
 	/* If the method isn't specified, assume EXT_METHOD if the string looks
 	   like a relative path and LOCAL_METHOD otherwise.  */
 
-	newroot->method = ((*cvsroot_copy != '/' && strchr (cvsroot_copy, '/'))
+	newroot->method = ((!isabsolute (cvsroot_copy) && strchr (cvsroot_copy, '/'))
 			  ? ext_method
 			  : local_method);
     }
 
     newroot->isremote = (newroot->method != local_method);
diff -aprNU5 cvs-1.11.23.orig/src/run.c cvs-1.11.23/src/run.c
--- cvs-1.11.23.orig/src/run.c	2008-05-07 17:57:34 +0200
+++ cvs-1.11.23/src/run.c	2016-03-19 14:02:56 +0100
@@ -12,13 +12,24 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.  */
 
 #include "cvs.h"
 
+#if !defined(HAVE_WORKING_VFORK) && !defined(HAVE_WORKING_FORK)
+#define USE_SPAWN
+#endif  /* HAVE_WORKING_VFORK && HAVE_WORKING_FORK */
+
+#ifdef USE_SPAWN
+# include <process.h>
+# if defined(__DJGPP__)
+#  include "subpipe.h"
+# endif
+#else  /* !USE_SPAWN */
 #ifndef HAVE_UNISTD_H
 extern int execvp PROTO((char *file, char **argv));
 #endif
+#endif  /* !USE_SPAWN */
 
 static void run_add_arg PROTO((const char *s));
 
 extern char *strtok ();
 
@@ -115,16 +126,30 @@ run_exec (stin, stout, sterr, flags)
     const char *stin;
     const char *stout;
     const char *sterr;
     int flags;
 {
+#ifdef USE_SPAWN
+/*  This is DJGPP or something similar.
+    Do not assume neither POSIX_SIGNALS nor BSD_SIGNALS behaviour.  */
+#undef POSIX_SIGNALS
+#undef BSD_SIGNALS
+#endif  /* USE_SPAWN */
+
     int shin, shout, sherr;
+#ifdef USE_SPAWN
+    int sain, saout, saerr;	/* saved handles */
+#endif  /* USE_SPAWN */
     int mode_out, mode_err;
-    int status;
     int rc = -1;
     int rerrno = 0;
+#ifndef USE_SPAWN
+    int status;
     int pid, w;
+#else  /* USE_SPAWN */
+    int rval   = -1;
+#endif  /* USE_SPAWN */
 
 #ifdef POSIX_SIGNALS
     sigset_t sigset_mask, sigset_omask;
     struct sigaction act, iact, qact;
 
@@ -190,10 +215,12 @@ run_exec (stin, stout, sterr, flags)
 
     /* Make sure we don't flush this twice, once in the subprocess.  */
     cvs_flushout();
     cvs_flusherr();
 
+
+#ifndef USE_SPAWN
     /* The output files, if any, are now created.  Do the fork and dups.
 
        We use vfork not so much for a performance boost (the
        performance boost, if any, is modest on most modern unices),
        but for the sake of systems without a memory management unit,
@@ -337,10 +364,72 @@ run_exec (stin, stout, sterr, flags)
     (void) signal (SIGINT, istat);
     (void) signal (SIGQUIT, qstat);
 #endif
 #endif
 
+#else  /* USE_SPAWN */
+
+    /* now save the standard handles */
+    sain = saout = saerr = -1;
+    sain  = dup(0); /* dup stdin  */
+    saout = dup(1); /* dup stdout */
+    saerr = dup(2); /* dup stderr */
+    /* the new handles will be dup'd to the standard handles for the spawn. */
+
+    if (shin != 0)
+    {
+      (void) dup2 (shin, 0);
+      (void) close (shin);
+    }
+    if (shout != 1)
+    {
+      (void) dup2 (shout, 1);
+      (void) close (shout);
+    }
+    if (flags & RUN_COMBINED)
+      (void) dup2 (1, 2);
+    else if (sherr != 2)
+    {
+      (void) dup2 (sherr, 2);
+      (void) close (sherr);
+    }
+
+    /* Ignore some signals for now */
+    istat = signal (SIGINT, SIG_IGN);
+    qstat = signal (SIGQUIT, SIG_IGN);
+
+    /* dup'ing is done.  try to run it now */
+    rval = spawnvp (P_WAIT, run_argv[0], run_argv);
+
+    /* Restore signal handling.  */
+    (void) signal (SIGINT, istat);
+    (void) signal (SIGQUIT, qstat);
+
+    /* restore the original file handles   */
+    if (sain  != -1)
+    {
+      (void) dup2(sain, 0);	/* re-connect stdin  */
+      (void) close(sain);
+    }
+    if (saout != -1)
+    {
+      (void) dup2(saout, 1);	/* re-connect stdout */
+      (void) close(saout);
+    }
+    if (saerr != -1)
+    {
+      (void) dup2(saerr, 2);	/* re-connect stderr */
+      (void) close(saerr);
+    }
+
+    /*  Not sure this is required; WinNT does it, so I'm inclined to do so.  */
+    fflush (stderr);
+    fflush (stdout);
+
+    return rval;		/* end, if all went correct */
+#endif  /* USE_SPAWN */
+
     /* cleanup the open file descriptors */
   out:
     if (sterr)
 	(void) close (sherr);
     else
@@ -417,10 +506,11 @@ run_popen (cmd, mode)
     return (popen (cmd, mode));
 }
 
 
 
+#ifndef __USE_DJGPP_SUBPIPE__
 /* Work around an OpenSSH problem: it can put its standard file
    descriptors into nonblocking mode, which will mess us up if we
    share file descriptions with it.  The simplest workaround is
    to create an intervening process between OpenSSH and the
    actual stderr.  */
@@ -507,20 +597,27 @@ work_around_openssh_glitch (void)
 	    error (1, errno, "cannot dup2 pipe");
 	if (close (stderr_pipe[1]) < 0)
 	    error (1, errno, "cannot close pipe");
     }
 }
+#endif  /* !__USE_DJGPP_SUBPIPE__ */
 
 
 
 int
 piped_child (command, tofdp, fromfdp, fix_stderr)
      const char **command;
      int *tofdp;
      int *fromfdp;
      int fix_stderr;
 {
+#ifdef __USE_DJGPP_SUBPIPE__
+  init_subprocess_with_pipe();
+  return 0;
+
+#else  /* # !__USE_DJGPP_SUBPIPE__ */
+
     int pid;
     int to_child_pipe[2];
     int from_child_pipe[2];
 
     if (pipe (to_child_pipe) < 0)
@@ -562,10 +659,11 @@ piped_child (command, tofdp, fromfdp, fi
 	error (1, errno, "cannot close pipe");
 
     *tofdp = to_child_pipe[1];
     *fromfdp = from_child_pipe[0];
     return pid;
+#endif  /* # !__USE_DJGPP_SUBPIPE__ */
 }
 
 
 void
 close_on_exec (fd)
diff -aprNU5 cvs-1.11.23.orig/src/sanity.sh cvs-1.11.23/src/sanity.sh
--- cvs-1.11.23.orig/src/sanity.sh	2008-05-07 03:16:00 +0200
+++ cvs-1.11.23/src/sanity.sh	2016-03-19 14:02:56 +0100
@@ -4193,11 +4193,10 @@ ${PROG} commit: Rebuilding administrativ
 	    CVSROOT=":pserver;proxy=localhost;proxyport=8080:localhost/dev/null"
 	    dotest parseroot-3r "$testcvs -d'$CVSROOT' logout" \
 "$PROG logout: WARNING: Ignoring method options found in CVSROOT: \`proxy=localhost;proxyport=8080'\.
 $PROG logout: Use CVS version 1\.12\.7 or later to handle method options\.
 Logging out of :pserver:$username@localhost:2401/dev/null
-$PROG logout: warning: failed to open $HOME/\.cvspass for reading: No such file or directory
 $PROG logout: Entry not found\."
 	  fi
 
 	  if $keep; then
 		echo Keeping $TESTDIR and exiting due to --keep
@@ -15550,10 +15549,11 @@ total revisions: 2;	selected revisions:
 description:
 ----------------------------
 revision 1\.1
 date: [0-9/]* [0-9:]*;  author: ${username};  state: Exp;
 branches:  1\.1\.2;
+x
 xCVS: ----------------------------------------------------------------------
 xCVS: Enter Log.  Lines beginning with .CVS:. are removed automatically
 xCVS:
 xCVS: Committing in .
 xCVS:
@@ -15561,10 +15561,11 @@ xCVS: Added Files:
 xCVS: 	file1 file2
 xCVS: ----------------------------------------------------------------------
 ----------------------------
 revision 1\.1\.2\.1
 date: [0-9/]* [0-9:]*;  author: ${username};  state: Exp;  lines: ${PLUS}1 -0
+x
 xCVS: ----------------------------------------------------------------------
 xCVS: Enter Log.  Lines beginning with .CVS:. are removed automatically
 xCVS:
 xCVS: Committing in .
 xCVS:
@@ -15588,10 +15589,11 @@ total revisions: 2;	selected revisions:
 description:
 ----------------------------
 revision 1\.1
 date: [0-9/]* [0-9:]*;  author: ${username};  state: Exp;
 branches:  1\.1\.2;
+x
 xCVS: ----------------------------------------------------------------------
 xCVS: Enter Log.  Lines beginning with .CVS:. are removed automatically
 xCVS:
 xCVS: Committing in .
 xCVS:
@@ -15599,10 +15601,11 @@ xCVS: Added Files:
 xCVS: 	file1 file2
 xCVS: ----------------------------------------------------------------------
 ----------------------------
 revision 1\.1\.2\.1
 date: [0-9/]* [0-9:]*;  author: ${username};  state: Exp;  lines: ${PLUS}1 -0
+x
 xCVS: ----------------------------------------------------------------------
 xCVS: Enter Log.  Lines beginning with .CVS:. are removed automatically
 xCVS:
 xCVS: Modified Files:
 xCVS:  Tag: br
@@ -15620,10 +15623,11 @@ total revisions: 2;	selected revisions:
 description:
 ----------------------------
 revision 1\.1
 date: [0-9/]* [0-9:]*;  author: ${username};  state: Exp;
 branches:  1\.1\.2;
+x
 xCVS: ----------------------------------------------------------------------
 xCVS: Enter Log.  Lines beginning with .CVS:. are removed automatically
 xCVS:
 xCVS: Committing in .
 xCVS:
@@ -15631,10 +15635,11 @@ xCVS: Added Files:
 xCVS: 	file1 file2
 xCVS: ----------------------------------------------------------------------
 ----------------------------
 revision 1\.1\.2\.1
 date: [0-9/]* [0-9:]*;  author: ${username};  state: Exp;  lines: ${PLUS}1 -0
+x
 xCVS: ----------------------------------------------------------------------
 xCVS: Enter Log.  Lines beginning with .CVS:. are removed automatically
 xCVS:
 xCVS: Committing in .
 xCVS:
diff -aprNU5 cvs-1.11.23.orig/src/server.c cvs-1.11.23/src/server.c
--- cvs-1.11.23.orig/src/server.c	2008-05-07 17:57:34 +0200
+++ cvs-1.11.23/src/server.c	2016-03-19 14:02:56 +0100
@@ -5572,10 +5572,11 @@ check_repository_password (username, pas
     /* If found_it, then linebuf contains the information we need. */
     if (found_it)
     {
 	char *found_password, *host_user_tmp;
 	char *non_cvsuser_portion;
+	char *crypt_passwd;
 
 	/* We need to make sure lines such as
 	 *
 	 *    "username::sysuser\n"
 	 *    "username:\n"
@@ -5630,24 +5631,26 @@ check_repository_password (username, pas
 	/* Of course, maybe there was no system user portion... */
 	if (host_user_tmp == NULL)
 	    host_user_tmp = username;
 
 	/* Verify blank passwords directly, otherwise use crypt(). */
+	crypt_passwd = found_password ? crypt (password, found_password) : NULL;
 	if ((found_password == NULL)
-	    || ((strcmp (found_password, crypt (password, found_password))
-		 == 0)))
+	    || (crypt_passwd != NULL
+               && (strcmp (found_password, crypt_passwd)
+		    == 0)))
 	{
 	    /* Give host_user_ptr permanent storage. */
 	    *host_user_ptr = xstrdup (host_user_tmp);
 	    retval = 1;
 	}
 	else
 	{
 #ifdef LOG_AUTHPRIV
 	syslog (LOG_AUTHPRIV | LOG_NOTICE,
 		"password mismatch for %s in %s: %s vs. %s", username,
-		repository, crypt(password, found_password), found_password);
+		repository, crypt_passwd, found_password);
 #endif
 	    *host_user_ptr = NULL;
 	    retval	 = 2;
 	}
     }
@@ -5750,21 +5753,23 @@ error 0 %s: no such user\n", username);
     strtok (found_passwd, ",");
 
     if (*found_passwd)
     {
 	/* user exists and has a password */
-	if (strcmp (found_passwd, crypt (password, found_passwd)) == 0)
+	char *crypt_passwd = crypt (password, found_passwd);
+	if ((crypt_passwd != NULL) &&
+	    (strcmp (found_passwd, crypt_passwd) == 0))
 	{
 	    host_user = xstrdup (username);
 	}
 	else
 	{
 	    host_user = NULL;
 #ifdef LOG_AUTHPRIV
 	    syslog (LOG_AUTHPRIV | LOG_NOTICE,
 		    "password mismatch for %s: %s vs. %s", username,
-		    crypt(password, found_passwd), found_passwd);
+		    crypt_passwd, found_passwd);
 #endif
 	}
 	goto handle_return;
     }
 
diff -aprNU5 cvs-1.11.23.orig/src/subpipe.c cvs-1.11.23/src/subpipe.c
--- cvs-1.11.23.orig/src/subpipe.c	1970-01-01 01:00:00 +0100
+++ cvs-1.11.23/src/subpipe.c	2016-03-19 14:02:56 +0100
@@ -0,0 +1,334 @@
+/* Subprocesses with pipes.
+
+   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,2013, 2014, 2015 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Juan Manuel Guerrero <juan.guerrero@gmx.de>. */
+
+
+#include "cvs.h"
+
+#include "subpipe.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <process.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/wait.h>
+//#include "xalloc.h"
+
+
+#ifndef STDIN_FILENO
+# define STDIN_FILENO 0
+#endif
+#ifndef STDOUT_FILENO
+# define STDOUT_FILENO 1
+#endif
+
+
+#include "error.h"
+
+
+/* Initialize this module. */
+
+
+static int old_stdin;
+static int old_stdout;
+static char **arguments;
+static char tmp_file_name[2][L_tmpnam];
+static int spawn_status;
+
+
+#define remove_tmp_file(fd, name)                                      \
+(__gnuc_extension__                                                    \
+  ({                                                                   \
+     if (!close((fd)))                                                 \
+     {                                                                 \
+       if (unlink((name)))                                             \
+         error(EXIT_FAILURE, 0, "removing of \"%s\" failed", (name));  \
+       (name)[0] = '\0';                                               \
+     }                                                                 \
+  })                                                                   \
+)
+
+
+static void
+remove_remaining_tmp_files(void)
+{
+  /*
+   *  On MSDOS/Windows it is always necessary to close()
+   *  a file before remove() or unlink() it.  The tmp files
+   *  used to simulate the pipe are always connected to STDIN
+   *  and STDOUT.
+   */
+  close(STDIN_FILENO);
+  close(STDOUT_FILENO);
+  unlink(tmp_file_name[0]);
+  unlink(tmp_file_name[1]);
+}
+
+
+void
+init_subprocess_with_pipe(void)
+{
+  char *tmpdir;
+  int fd;
+
+  tmpdir = getenv("TMPDIR");
+  if (tmpdir == NULL)
+    tmpdir = getenv("TMP");
+  if (tmpdir == NULL)
+    tmpdir = getenv("TEMP");
+  if (!IS_TMPDIR(tmpdir))
+    tmpdir = ".";
+
+  strcpy(tmp_file_name[0], tmpdir);
+  strcat(tmp_file_name[0], "/spXXXXXX");
+  fd = mkstemp(tmp_file_name[0]);
+  if (fd < 0)
+    error(EXIT_FAILURE, 0, "creation of a temporary file failed");
+  close (fd);
+
+  strcpy(tmp_file_name[1], tmpdir);
+  strcat(tmp_file_name[1], "/spXXXXXX");
+  fd = mkstemp(tmp_file_name[1]);
+  if (fd < 0)
+    error(EXIT_FAILURE, 0, "creation of a temporary file failed");
+  close (fd);
+
+  atexit(remove_remaining_tmp_files);
+}
+
+
+/* Create a subprocess that is run as a filter.  ARGV is the
+   NULL-terminated argument vector for the subprocess.  Store read and
+   write file descriptors for communication with the subprocess into
+   FD[0] and FD[1]: input meant for the process can be written into
+   FD[0], and output from the process can be read from FD[1].  Return
+   the subprocess id.
+
+   Because DOS has neither fork nor pipe functionality to run the subprocess
+   as a filter, the filter is reproduced using temporary files.  First cvs'
+   stdout is redirected to a temporary file.  After cvs has produced all
+   of is output, this file is closed and connected to or ssh's stdin.
+   All rsh's or ssh's output is redirected from rsh's or ssh's stdout
+   to a second temporary file and reopened as cvs' stdin. */
+
+pid_t
+create_subprocess_with_pipe(char const *const *argv, int fd[2])
+{
+  int argc;
+  int from_in_fd;  /* pipe from cvs to rsh or ssh. */
+  pid_t pid;
+
+
+  pid = getpid();
+
+  /*
+   *  Save original stdin and stdout
+   *  for later restauration.
+   */
+  old_stdin = dup(STDIN_FILENO);
+  if (old_stdin < 0)
+    error(EXIT_FAILURE, 0, "saving stdin failed");
+
+  old_stdout = dup(STDOUT_FILENO);
+  if (old_stdout < 0)
+    error(EXIT_FAILURE, 0, "saving stdout failed");
+
+  /*
+   *  Save argv for later use.
+   */
+  for (argc = 0; argv[argc]; argc++)
+    ;
+  argc++;
+  arguments = xmalloc(argc * sizeof(arguments[0]));
+  for (argc = 0; argv[argc]; argc++)
+  {
+    arguments[argc] = xmalloc((strlen(argv[argc]) + 1) * sizeof(arguments[0][0]));
+    strcpy(arguments[argc], argv[argc]);
+  }
+  arguments[argc] = NULL;
+
+  /*
+   *  All cvs' output will be gathered in this temporary file
+   *  and will be redirected to rsh's or ssh's stdin.
+   */
+  from_in_fd = open(tmp_file_name[0], O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR);
+  if (from_in_fd < 0)
+    error(EXIT_FAILURE, 0, "opening of tmpfile failed");
+  if (dup2(from_in_fd, STDOUT_FILENO) < 0)
+  {
+    remove_tmp_file(from_in_fd, tmp_file_name[0]);
+    error(EXIT_FAILURE, 0, "redirecting cvs' stdout to the temporary file failed");
+  }
+  close(from_in_fd);
+
+
+  fd[0] = STDOUT_FILENO;
+  return pid;
+}
+
+
+/* A signal handler that just records that a signal has happened. */
+static int child_interrupted;
+
+static void
+signal_catcher(int signo)
+{
+  child_interrupted++;
+}
+
+
+void
+end_of_output_subprocess_with_pipe(pid_t pid, int fd[2])
+{
+  char *program;
+  int from_out_fd = open(tmp_file_name[0], O_RDONLY, S_IRUSR);                   /* pipe from cvs to rsh or ssh. */
+  int to_in_fd = open(tmp_file_name[1], O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR);  /* pipe from rsh or ssh to cvs. */
+  int status;
+  void (*previous_handler)(int);
+
+
+  program = strrchr(arguments[0], '/');
+  if (program)
+    program++;
+  else
+    program = arguments[0];
+
+  /*
+   *  Redirect cvs' output to rsh's or ssh's stdin.
+   */
+  if (from_out_fd < 0)
+    error(EXIT_FAILURE, 0, "opening of tmpfile failed");
+  if (dup2(from_out_fd, STDIN_FILENO) < 0)
+  {
+    remove_tmp_file(from_out_fd, tmp_file_name[0]);
+    error(EXIT_FAILURE, 0, "redirecting rsh's or ssh's stdin from the temporary file failed");
+  }
+  close(from_out_fd);
+
+  /*
+   *  All rsh's or ssh's output will be gathered in this temporary file
+   *  and will be redirected to cvs' stdin.
+   */
+  if (to_in_fd < 0)
+  {
+    remove_tmp_file(STDIN_FILENO, tmp_file_name[0]);
+    error(EXIT_FAILURE, 0, "opening of a temporary file failed");
+  }
+  if (dup2(to_in_fd, STDOUT_FILENO) < 0)
+  {
+    remove_tmp_file(STDIN_FILENO, tmp_file_name[0]);
+    remove_tmp_file(to_in_fd, tmp_file_name[1]);
+    error(EXIT_FAILURE, 0, "redirecting rsh's or ssh's stdout to a temporary file failed");
+  }
+  close(to_in_fd);
+
+  /*
+   *  Run rsh or ssh.
+   */
+  child_interrupted = 0;
+  errno = 0;
+  previous_handler = signal(SIGINT, signal_catcher);
+  status = spawnvp(P_WAIT, program, arguments);
+  signal(SIGINT, previous_handler);
+
+  spawn_status = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
+  if (child_interrupted)
+  {
+    remove_tmp_file(STDIN_FILENO, tmp_file_name[0]);
+    remove_tmp_file(STDOUT_FILENO, tmp_file_name[1]);
+    error(EXIT_FAILURE, 0, "subsidiary program \"%s\" interrupted", program);
+  }
+  if (spawn_status == -1)
+  {
+    /*
+     *  - spawn returns -1 if rsh or ssh can not be invoked or executed.
+     *  - If rsh or ssh could be executed, then spawn returns rsh's or ssh's
+     *    exit code in the lower 8 bits of status.
+     *  - rsh's or ssh's exit codes are at least: 0, 1 and 63.
+     *
+     *  If rsh or ssh returns with exit code greater than 0 cvs will
+     *  get the chance to examinate rsh's or ssh's output and terminated
+     *  itself in reap_subprocess_with_pipe() if necessary.
+     */
+    remove_tmp_file(STDIN_FILENO, tmp_file_name[0]);
+    remove_tmp_file(STDOUT_FILENO, tmp_file_name[1]);
+    error(EXIT_FAILURE, 0, errno == ENOENT
+                           ? "subsidiary program \"%s\" not found"
+                           : "subsidiary program \"%s\" could not be invoked (status=%i, errno=%i)", program, spawn_status, errno);
+  }
+
+
+  /*
+   *  Redirect rsh's or ssh's output to cvs' stdin.
+   */
+  if (dup2(old_stdout, STDOUT_FILENO) < 0)
+    error(EXIT_FAILURE, 0, "restore of cvs' stdout failed");
+  close(old_stdout);
+  to_in_fd = open(tmp_file_name[1], O_RDONLY, S_IRUSR);  /* pipe from rsh or ssh to cvs. */
+  if (to_in_fd < 0)
+  {
+    remove_tmp_file(STDIN_FILENO, tmp_file_name[0]);
+    error(EXIT_FAILURE, 0, "opening of tmpfile failed");
+  }
+  if (dup2(to_in_fd, STDIN_FILENO) < 0)
+  {
+    remove_tmp_file(STDIN_FILENO, tmp_file_name[0]);
+    remove_tmp_file(to_in_fd, tmp_file_name[1]);
+    error(EXIT_FAILURE, -1, "dup2");
+    error(EXIT_FAILURE, 0, "redirecting cvs' stdin from the temporary file failed");
+  }
+  close(to_in_fd);
+
+
+  fd[1] = STDIN_FILENO;
+}
+
+
+/* Free resources, unlink temporary files and restore stdin and stdout. */
+
+void
+reap_subprocess_with_pipe(pid_t pid, char const *program)
+{
+  if (spawn_status)
+  {
+    /*  rsh or ssh returned with exit code > 0.  Terminate cvs.   */
+    error(EXIT_FAILURE, 0, "subsidiary program \"%s\" failed (status=%i, errno=%i)", program, spawn_status, errno);
+  }
+  else
+  {
+    int argc;
+
+    for (argc = 0; arguments[argc]; argc++)
+      free(arguments[argc]);
+    free(arguments);
+
+    if (unlink(tmp_file_name[0]))
+      error(EXIT_FAILURE, 0, "removing of \"%s\" failed", tmp_file_name[0]);
+    if (unlink(tmp_file_name[1]))
+      error(EXIT_FAILURE, 0, "removing of \"%s\" failed", tmp_file_name[1]);
+
+    if (dup2(old_stdin, STDIN_FILENO) < 0)
+      error(EXIT_FAILURE, 0, "restore of cvs' stdin failed");
+    close(old_stdin);
+  }
+}
diff -aprNU5 cvs-1.11.23.orig/src/subpipe.h cvs-1.11.23/src/subpipe.h
--- cvs-1.11.23.orig/src/subpipe.h	1970-01-01 01:00:00 +0100
+++ cvs-1.11.23/src/subpipe.h	2016-03-19 14:02:56 +0100
@@ -0,0 +1,34 @@
+/* Subprocesses with pipes.
+   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,2013, 2014, 2015 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Juan Manuel Guerrero <juan.guerrero@gmx.de>. */
+
+#ifndef __SUBPIPE_H__
+# define __SUBPIPE_H__
+
+# define __USE_DJGPP_SUBPIPE__
+
+
+# if HAVE_SYS_TYPES_H
+#  include <sys/types.h>
+# endif
+
+void init_subprocess_with_pipe(void);
+pid_t create_subprocess_with_pipe(char const * const *, int[2]);
+void end_of_output_subprocess_with_pipe(pid_t, int[2]);
+void reap_subprocess_with_pipe(pid_t, char const *);
+#endif  /* __SUBPIPE_H__ */
+
diff -aprNU5 cvs-1.11.23.orig/src/subr.c cvs-1.11.23/src/subr.c
--- cvs-1.11.23.orig/src/subr.c	2008-05-07 17:57:34 +0200
+++ cvs-1.11.23/src/subr.c	2016-03-19 14:02:56 +0100
@@ -44,14 +44,12 @@ xmalloc (bytes)
 	bytes = 1;
 
     cp = malloc (bytes);
     if (cp == NULL)
     {
-	char buf[80];
-	sprintf (buf, "out of memory; can not allocate %lu bytes",
-		 (unsigned long) bytes);
-	error (1, 0, buf);
+	error (1, 0, "out of memory; can not allocate %lu bytes",
+		(unsigned long) bytes);
     }
     return (cp);
 }
 
 /*
@@ -71,14 +69,12 @@ xrealloc (ptr, bytes)
     else
 	cp = realloc (ptr, bytes);
 
     if (cp == NULL)
     {
-	char buf[80];
-	sprintf (buf, "out of memory; can not reallocate %lu bytes",
-		 (unsigned long) bytes);
-	error (1, 0, buf);
+	error (1, 0, "out of memory; can not reallocate %lu bytes",
+		(unsigned long) bytes);
     }
     return (cp);
 }
 
 /* Two constants which tune expand_string.  Having MIN_INCR as large
@@ -963,7 +959,10 @@ sleep_past (desttime)
    Trivial under Unix, but more complicated under other systems.  */
 int
 isabsolute (filename)
     const char *filename;
 {
+#ifdef STRIP_ACCESS_MODE
+    filename = STRIP_ACCESS_MODE (filename);
+#endif
     return ISABSOLUTE (filename);
 }
diff -aprNU5 cvs-1.11.23.orig/src/update.c cvs-1.11.23/src/update.c
--- cvs-1.11.23.orig/src/update.c	2008-05-07 17:57:34 +0200
+++ cvs-1.11.23/src/update.c	2016-03-19 14:02:56 +0100
@@ -1985,12 +1985,11 @@ merge_file (finfo, vers)
     if (unlink_file (backup) && !existence_error (errno))
 	error (0, errno, "unable to remove %s", backup);
     copy_file (finfo->file, backup);
     xchmod (finfo->file, 1);
 
-    if (strcmp (vers->options, "-kb") == 0
-	|| wrap_merge_is_copy (finfo->file)
+    if (wrap_merge_is_copy (finfo->file)
 	|| special_file_mismatch (finfo, NULL, vers->vn_rcs))
     {
 	/* For binary files, a merge is always a conflict.  Same for
 	   files whose permissions or linkage do not match.  We give the
 	   user the two files, and let them resolve it.  It is possible
@@ -2101,10 +2100,12 @@ merge_file (finfo, vers)
     else
     {
 	write_letter (finfo, 'M');
 	history_write ('G', finfo->update_dir, vers->vn_rcs, finfo->file,
 		       finfo->repository);
+	if (unlink_file (backup) && !existence_error (errno))
+	    error (0, errno, "unable to remove %s", backup);
     }
     retval = 0;
  out:
     free (backup);
     return retval;
@@ -2276,11 +2277,11 @@ join_file (finfo, vers)
 	    /* file added locally */
 	    !strcmp (vers->vn_user, "0")
 	    || /* destination branch modified in repository */
 	       strcmp (rev1, vers->vn_user)
 	    || /* locally modified */
-	       vers->ts_user && strcmp (vers->ts_user, vers->ts_rcs))
+	       (vers->ts_user && strcmp (vers->ts_user, vers->ts_rcs)))
 	{
 	    /* The removal should happen if either the file has never changed
 	     * on the destination or the file has changed to be identical to
 	     * the first join revision.
 	     *
@@ -2619,12 +2620,11 @@ join_file (finfo, vers)
 	   simple "U foo" is good here; it seems analogous to the case in
 	   which the file was added on the branch in terms of what to
 	   print.  */
 	write_letter (finfo, 'U');
     }
-    else if (strcmp (t_options, "-kb") == 0
-	     || wrap_merge_is_copy (finfo->file)
+    else if (wrap_merge_is_copy (finfo->file)
 	     || special_file_mismatch (finfo, rev1, rev2))
     {
 	/* We are dealing with binary files, or files with a
 	   permission/linkage mismatch (this second case only occurs when
 	   PRESERVE_PERMISSIONS_SUPPORT is enabled), and real merging would








2019-12-11  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* doc/cvs.texinfo:  Fix wrong sequence of paragraphs.


2019-12-08  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* contrib/commit_prep.in:  Use $TMPDIR or $TMP or $TEMP
	or "." as default temporary directory.

	* src/cvsbug.in:  Use $TMPDIR or $TMP or $TEMP or "." as
	default temporary directory.





diff -aprNU5 cvs-1.11.23.orig/contrib/commit_prep.in cvs-1.11.23/contrib/commit_prep.in
--- cvs-1.11.23.orig/contrib/commit_prep.in	2005-09-01 12:12:20 +0000
+++ cvs-1.11.23/contrib/commit_prep.in	2019-12-08 21:38:48 +0000
@@ -40,11 +40,11 @@
 #
 # Contributed by David Hampton <hampton@cisco.com>
 # Stripped to minimum by Roy Fielding
 #
 ############################################################
-$TMPDIR        = $ENV{'TMPDIR'} || '/tmp';
+$TMPDIR        = $ENV{'TMPDIR'} || $ENV{'TMP'} || $ENV{'TEMP'} || '.';
 $FILE_PREFIX   = '#cvs.';
 
 # If see a "-u $USER" argument, then destructively remove it from the
 # argument list, so $ARGV[0] will be the repository dir again, as it
 # used to be before we added the -u flag.
diff -aprNU5 cvs-1.11.23.orig/src/cvsbug.in cvs-1.11.23/src/cvsbug.in
--- cvs-1.11.23.orig/src/cvsbug.in	2005-04-04 20:46:06 +0000
+++ cvs-1.11.23/src/cvsbug.in	2019-12-08 18:35:26 +0000
@@ -82,11 +82,11 @@ else
   ECHON2=
 fi
 
 #
 
-[ -z "$TMPDIR" ] && TMPDIR=/tmp
+[ -z "$TMPDIR" ] && ${TMPDIR=${TMP=${TEMP=.}}}
 
 TEMP="`$MKTEMP $TMPDIR/p.XXXXXX`"
 BAD="`$MKTEMP $TMPDIR/pbad.XXXXXX`"
 REF="`$MKTEMP $TMPDIR/pf.XXXXXX`"

diff -aprNU5 cvs-1.11.23.orig/doc/cvs.texinfo cvs-1.11.23/doc/cvs.texinfo
--- cvs-1.11.23.orig/doc/cvs.texinfo	2019-12-11 14:44:32 +0000
+++ cvs-1.11.23/doc/cvs.texinfo	2019-12-11 14:57:58 +0000
@@ -13325,10 +13325,47 @@ out tree in @file{/u/www/local-docs}.
 @c More info on some of the details?  The "sleep 2" is
 @c so if we are lucky the lock will be gone by the time
 @c we start and we can wait 2 seconds instead of 30.
 
 @c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+@node taginfo
+@appendixsec Taginfo
+@cindex taginfo (admin file)
+@cindex Tags, logging
+@cindex Tags, verifying
+The @file{taginfo} file defines programs to execute
+when someone executes a @code{tag} or @code{rtag}
+command.  The @file{taginfo} file has the standard form
+for trigger scripts (@pxref{Trigger Scripts}),
+where each line is a regular expression
+followed by a command to execute (@pxref{syntax}).  The arguments passed
+to the command are, in order, the @var{tagname},
+@var{operation} (@code{add} for @code{tag},
+@code{mov} for @code{tag -F}, and @code{del} for
+@code{tag -d}), @var{repository}, and any remaining are
+pairs of @var{filename} @var{revision}.  A non-zero
+exit of the filter program will cause the tag to be
+aborted.
+
+Here is an example of using the @file{taginfo} file
+to log @code{tag} and @code{rtag}
+commands.  In the @file{taginfo} file put:
+
+@example
+ALL /usr/local/cvsroot/CVSROOT/loggit
+@end example
+
+@noindent
+Where @file{/usr/local/cvsroot/CVSROOT/loggit} contains the
+following script:
+
+@example
+#!/bin/sh
+echo "$@@" >>/home/kingdon/cvsroot/CVSROOT/taglog
+@end example
+
+@c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 @node rcsinfo
 @appendixsec Rcsinfo
 @cindex rcsinfo (admin file)
 @cindex Form for log message
 @cindex Log message template
@@ -13383,47 +13420,10 @@ directory.
 @c example, a mechanism analogous to CVS/Entries, where
 @c the client keeps track of what version of the template
 @c it has.
 
 @c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-@node taginfo
-@appendixsec Taginfo
-@cindex taginfo (admin file)
-@cindex Tags, logging
-@cindex Tags, verifying
-The @file{taginfo} file defines programs to execute
-when someone executes a @code{tag} or @code{rtag}
-command.  The @file{taginfo} file has the standard form
-for trigger scripts (@pxref{Trigger Scripts}),
-where each line is a regular expression
-followed by a command to execute (@pxref{syntax}).  The arguments passed
-to the command are, in order, the @var{tagname},
-@var{operation} (@code{add} for @code{tag},
-@code{mov} for @code{tag -F}, and @code{del} for
-@code{tag -d}), @var{repository}, and any remaining are
-pairs of @var{filename} @var{revision}.  A non-zero
-exit of the filter program will cause the tag to be
-aborted.
-
-Here is an example of using the @file{taginfo} file
-to log @code{tag} and @code{rtag}
-commands.  In the @file{taginfo} file put:
-
-@example
-ALL /usr/local/cvsroot/CVSROOT/loggit
-@end example
-
-@noindent
-Where @file{/usr/local/cvsroot/CVSROOT/loggit} contains the
-following script:
-
-@example
-#!/bin/sh
-echo "$@@" >>/home/kingdon/cvsroot/CVSROOT/taglog
-@end example
-
-@c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 @node cvsignore
 @appendixsec Ignoring files via cvsignore
 @cindex cvsignore (admin file), global
 @cindex Global cvsignore
 @cindex Ignoring files




2020-04-04  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* cvs-1.11.23/lib/getopt.c (_getopt_internal):  Initialize variable
	and pacify compiler.

	* cvs-1.11.23/diff/diff3.c (diff3_run):  Initialize variable and
	pacify compiler.

	* cvs-1.11.23/src/update.c (checkout_file):  Initialize variable
	and pacify compiler.


2020-04-01  Juan Manuel Guerrero <juan.guerrero@gmx.de>

	* cvs-1.11.23/lib/xselect.h [HAVE_SYS_SELECT_H]:  On DJGPP prefer
	select over usleep to avoid issues if dosidle.exe is used.





diff -aprNU5 cvs-1.11.23.orig/diff/diff3.c cvs-1.11.23/diff/diff3.c
--- cvs-1.11.23.orig/diff/diff3.c	2020-03-31 20:53:08 +0000
+++ cvs-1.11.23/diff/diff3.c	2020-04-04 15:09:02 +0000
@@ -1439,16 +1439,16 @@ static void
 output_diff3 (diff, mapping, rev_mapping)
      struct diff3_block *diff;
      int const mapping[3], rev_mapping[3];
 {
   int i;
-  int oddoneout;
+  int oddoneout = 0;
   char *cp;
   struct diff3_block *ptr;
   int line;
   size_t length;
-  int dontprint;
+  int dontprint = 0;
   static int skew_increment[3] = { 2, 3, 1 }; /* 0==>2==>1==>3 */
   char const *line_prefix = tab_align_flag ? "\t" : "  ";
 
   for (ptr = diff; ptr; ptr = D_NEXT (ptr))
     {
diff -aprNU5 cvs-1.11.23.orig/lib/getopt.c cvs-1.11.23/lib/getopt.c
--- cvs-1.11.23.orig/lib/getopt.c	2020-03-31 20:53:08 +0000
+++ cvs-1.11.23/lib/getopt.c	2020-04-04 15:02:42 +0000
@@ -479,11 +479,11 @@ _getopt_internal (argc, argv, optstring,
       char *nameend;
       const struct option *p;
       const struct option *pfound = NULL;
       int exact = 0;
       int ambig = 0;
-      int indfound;
+      int indfound = 0;
       int option_index;
 
       for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
 	/* Do nothing.  */ ;
 
diff -aprNU5 cvs-1.11.23.orig/lib/xselect.h cvs-1.11.23/lib/xselect.h
--- cvs-1.11.23.orig/lib/xselect.h	2001-06-15 18:04:16 +0000
+++ cvs-1.11.23/lib/xselect.h	2020-03-31 21:59:02 +0000
@@ -15,7 +15,12 @@
 #ifdef HAVE_SYS_BSDTYPES_H
 # include <sys/bsdtypes.h>
 #endif
 
 #if HAVE_SYS_SELECT_H
-# include <sys/select.h>
+# ifdef __DJGPP__
+#  include <string.h>
+#  include "xtime.h"
+# else  /* !__DJGPP__ */
+#  include <sys/select.h>
+# endif /* !__DJGPP__ */
 #endif
diff -aprNU5 cvs-1.11.23.orig/src/update.c cvs-1.11.23/src/update.c
--- cvs-1.11.23.orig/src/update.c	2020-03-31 20:53:08 +0000
+++ cvs-1.11.23/src/update.c	2020-04-04 15:11:56 +0000
@@ -1221,11 +1221,11 @@ checkout_file (finfo, vers_ts, adding, m
     int merging;
     int update_server;
 {
     char *backup;
     int set_time, retval = 0;
-    int status;
+    int status = 0;
     int file_is_dead;
     struct buffer *revbuf;
 
     backup = NULL;
     revbuf = NULL;
