diff --binary -Naur rcs-5.7/src/ci.c rcs-5.7-mod/src/ci.c
--- rcs-5.7/src/ci.c	Fri Jun 16 06:19:24 1995
+++ rcs-5.7-mod/src/ci.c	Sun Apr 14 23:25:23 2002
@@ -711,8 +711,7 @@
 		    *++diffp = DIFF;
 		    *++diffp = DIFFFLAGS;
 #		    if OPEN_O_BINARY
-			if (Expand == BINARY_EXPAND)
-			    *++diffp = "--binary";
+		    *++diffp = "--binary";
 #		    endif
 		    *++diffp = newhead ? "-" : expname;
 		    *++diffp = newhead ? expname : "-";
diff --binary -Naur rcs-5.7/src/co.c rcs-5.7-mod/src/co.c
--- rcs-5.7/src/co.c	Fri Jun 16 06:19:24 1995
+++ rcs-5.7-mod/src/co.c	Sun Apr 14 23:25:23 2002
@@ -205,9 +205,6 @@
 	int Ttimeflag;
 	struct buf numericrev;	/* expanded revision number	*/
 	char finaldate[datesize];
-#	if OPEN_O_BINARY
-		int stdout_mode = 0;
-#	endif
 
 	setrid();
 	author = date = rev = state = 0;
@@ -347,12 +344,8 @@
 	workstatstat = -1;
 	if (tostdout) {
 #		if OPEN_O_BINARY
-		    int newmode = Expand==BINARY_EXPAND ? OPEN_O_BINARY : 0;
-		    if (stdout_mode != newmode) {
-			stdout_mode = newmode;
-			oflush();
-			VOID setmode(STDOUT_FILENO, newmode);
-		    }
+		oflush();
+		VOID setmode(STDOUT_FILENO, OPEN_O_BINARY);
 #		endif
 		neworkname = 0;
 		neworkptr = workstdout = stdout;
diff --binary -Naur rcs-5.7/src/conf.sh rcs-5.7-mod/src/conf.sh
--- rcs-5.7/src/conf.sh	Fri Jun 16 06:19:24 1995
+++ rcs-5.7-mod/src/conf.sh	Sun Apr 14 23:25:23 2002
@@ -1052,8 +1052,8 @@
 		# Find out what signal is sent to RCS
 		# when someone unexpectedly truncates a file
 		# while RCS has it mmapped.
-		rm -f a.e && cp a.c a.e &&
-		mmap_signal=`$aout a.e <a.e` || exit
+		rm -f a.e && cp a.c a.e && cp a.e a.e2
+		mmap_signal=`$aout a.e <a.e2` || exit
 	esac
 esac
 echo >&3 $has_map_fd, $has_mmap, $has_madvise, $mmap_signal
diff --binary -Naur rcs-5.7/src/rcsedit.c rcs-5.7-mod/src/rcsedit.c
--- rcs-5.7/src/rcsedit.c	Fri Jun 16 06:19:24 1995
+++ rcs-5.7-mod/src/rcsedit.c	Sun Apr 14 23:25:23 2002
@@ -207,7 +207,7 @@
 static void editEndsPrematurely P((void)) exiting;
 static void editLineNumberOverflow P((void)) exiting;
 static void escape_string P((FILE*,char const*));
-static void keyreplace P((enum markers,struct hshentry const*,int,RILE*,FILE*,int));
+static void keyreplace P((enum markers,struct hshentry const*,int,RILE*,FILE*,int, int));
 
 FILE *fcopy;		 /* result file descriptor			    */
 char const *resultname;	 /* result pathname				    */
@@ -870,6 +870,7 @@
 	char const *tlim;
 	static struct buf keyval;
         enum markers matchresult;
+	int dos_eol;
 
 	setupcache(infile); cache(infile);
 	out = outfile;
@@ -878,6 +879,7 @@
 	bufalloc(&keyval, keylength+3);
 	e = 0;
 	r = -1;
+	dos_eol = 0;
 
         for (;;) {
 	    if (ds)
@@ -966,9 +968,41 @@
 				    continue;   /* last c handled properly */
 			      }
 			}
+
+			/* Look for DOS end-of-lines */
+			if (dolog && matchresult == Log) {
+			    char prev_c;
+			    int extra_chars_read;
+
+			    prev_c = 0;
+			    extra_chars_read = 0;
+			    for (;;) {
+				cachegeteof_(c, break;)
+				++extra_chars_read;
+				if (c=='\n') {
+				    if (prev_c == '\r')
+					dos_eol = 1;
+				    break;
+				}
+				*tp++ =c;
+				if (tlim <= tp)
+				    tp = bufenlarge(&keyval, &tlim);
+				if (c==SDELIM && ds) { /*skip next SDELIM */
+				    cachegeteof_(c, break;)
+				    ++extra_chars_read;
+				    if (c != SDELIM) {
+				        /* end of string before closing KDELIM or newline */
+				        break;
+				    }
+				}
+				prev_c = c;
+			    }
+			    while (extra_chars_read-- > 0)
+				cacheunget_(infile, c);
+			}
 			/* now put out the new keyword value */
 			uncache(infile);
-			keyreplace(matchresult, delta, ds, infile, out, dolog);
+			keyreplace(matchresult, delta, ds, infile, out, dolog, dos_eol);
 			cache(infile);
 			e = 1;
 			break;
@@ -1009,13 +1043,14 @@
 char const ciklog[ciklogsize] = "checked in with -k by ";
 
 	static void
-keyreplace(marker, delta, delimstuffed, infile, out, dolog)
+keyreplace(marker, delta, delimstuffed, infile, out, dolog, dos_eol)
 	enum markers marker;
 	register struct hshentry const *delta;
 	int delimstuffed;
 	RILE *infile;
 	register FILE *out;
 	int dolog;
+	int dos_eol;
 /* function: outputs the keyword value(s) corresponding to marker.
  * Attributes are derived from delta.
  */
@@ -1188,6 +1223,8 @@
 		    } while (c != KDELIM);
 		    uncache(infile);
 		}
+		if (dos_eol)
+		    afputc('\r', out);
 		afputc('\n', out);
 		awrite(cp, cs, out);
 		sp1 = date2str(date, datebuf);
@@ -1209,6 +1246,8 @@
 		    for (;  cw && (cp[cw-1]==' ' || cp[cw-1]=='\t');  --cw)
 			continue;
 		for (;;) {
+		    if (dos_eol)
+			afputc('\r', out);
 		    afputc('\n', out);
 		    awrite(cp, cw, out);
 		    if (!ls)
diff --binary -Naur rcs-5.7/src/rcsgen.c rcs-5.7-mod/src/rcsgen.c
--- rcs-5.7/src/rcsgen.c	Fri Jun 16 06:19:24 1995
+++ rcs-5.7-mod/src/rcsgen.c	Sun Apr 14 23:25:24 2002
@@ -391,7 +391,7 @@
 				p = textfile + 1;
 				s = strlen(p);
 			} else {
-				if (!(txt = fopenSafer(textfile, "r")))
+				if (!(txt = fopenSafer(textfile, FOPEN_RB)))
 					efaterror(textfile);
 				bufalloc(&desc, 1);
 				p = desc.string;
@@ -589,7 +589,7 @@
  */
 {
 	RILE *fin;
-	if (!(fin = Iopen(srcname, "r", (struct stat*)0))) {
+	if (!(fin = Iopen(srcname, FOPEN_RB, (struct stat*)0))) {
 		eerror(srcname);
 		return false;
 	}
diff --binary -Naur rcs-5.7/src/rcslex.c rcs-5.7-mod/src/rcslex.c
--- rcs-5.7/src/rcslex.c	Fri Jun 16 06:19:24 1995
+++ rcs-5.7-mod/src/rcslex.c	Sun Apr 14 23:25:24 2002
@@ -1113,7 +1113,7 @@
 /* Open NAME for reading, yield its descriptor, and set *STATUS.  */
 {
 	int fd = fdSafer(open(name, O_RDONLY
-#		if OPEN_O_BINARY
+#		if !(large_memory && maps_memory) && OPEN_O_BINARY
 			|  (strchr(type,'b') ? OPEN_O_BINARY : 0)
 #		endif
 	));
diff --binary -Naur rcs-5.7/src/rcsutil.c rcs-5.7-mod/src/rcsutil.c
--- rcs-5.7/src/rcsutil.c	Fri Jun 16 06:19:24 1995
+++ rcs-5.7-mod/src/rcsutil.c	Sun Apr 14 23:25:24 2002
@@ -1059,7 +1059,7 @@
 	    }
 	    if (fdreopen(
 		STDOUT_FILENO, outname,
-		O_CREAT | O_TRUNC | O_WRONLY
+		O_CREAT | O_TRUNC | O_WRONLY | OPEN_O_BINARY
 	    ) < 0)
 		efaterror(outname);
 	}
@@ -1095,7 +1095,7 @@
 		if (outname)
 		    if (fdreopen(
 			STDOUT_FILENO, outname,
-			O_CREAT | O_TRUNC | O_WRONLY
+			O_CREAT | O_TRUNC | O_WRONLY | OPEN_O_BINARY
 		    ) < 0) {
 			/* Avoid perror since it may misuse buffers.  */
 			write_stderr(args[1]);
