summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-03-21 16:23:21 +0000
committerRoland McGrath <roland@gnu.org>1996-03-21 16:23:21 +0000
commit036a2725481f219aa54ce4a55b3a62694f994c82 (patch)
tree97a73cc789c5ff0c92686308e983603081f10502
parentce563359aff66775c71c3e84e7d06a69c199eac0 (diff)
Thu Mar 21 11:19:15 1996 Roland McGrath <roland@charlie-brown.gnu.ai.mit.edu>
* mach/devstream.c (input): Translate \r to \n on input.
-rw-r--r--ChangeLog4
-rw-r--r--mach/devstream.c14
2 files changed, 15 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 1bf429ddce..e259705895 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Mar 21 11:19:15 1996 Roland McGrath <roland@charlie-brown.gnu.ai.mit.edu>
+
+ * mach/devstream.c (input): Translate \r to \n on input.
+
Wed Mar 20 11:28:49 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* stdio-common/printf.h, stdio-common/printf_fp.c,
diff --git a/mach/devstream.c b/mach/devstream.c
index a2162db98b..c35e548dd2 100644
--- a/mach/devstream.c
+++ b/mach/devstream.c
@@ -1,7 +1,7 @@
/* stdio on a Mach device port.
- Translates \n to \r\n on output, echos input.
+ Translates \n to \r\n on output, echos and translates \r to \n on input.
-Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -63,6 +63,14 @@ input (FILE *f)
err = device_write_inband ((device_t) f->__cookie, 0, f->__target,
buffer, nread, (int *) &to_read);
+ /* Translate LF to CR. */
+ {
+ char *p;
+ for (p = memchr (buffer, '\r', nread); p;
+ p = memchr (p + 1, '\r', (buffer + nread) - (p + 1)))
+ *p = '\n';
+ }
+
if (f->__buffer == NULL)
return (unsigned char) c;
@@ -84,7 +92,7 @@ output (FILE *f, int c)
while (to_write > 0)
{
if (err = device_write ((device_t) f->__cookie, 0,
- f->__target, (char *)p,
+ f->__target, (char *)p,
to_write, &wrote))
{
errno = err;