diff options
author | DJ Delorie <dj@redhat.com> | 2000-05-18 19:03:10 +0000 |
---|---|---|
committer | DJ Delorie <dj@redhat.com> | 2000-05-18 19:03:10 +0000 |
commit | f43932615d05b3a2ee85885693410a3cb62c31a0 (patch) | |
tree | 2304ec1df69f1fcf5a408021acb72d1ad90216aa | |
parent | e73a56e9827a6d9ea4066b8dd75e7838d440adf1 (diff) | |
download | cygnal-f43932615d05b3a2ee85885693410a3cb62c31a0.tar.gz cygnal-f43932615d05b3a2ee85885693410a3cb62c31a0.tar.bz2 cygnal-f43932615d05b3a2ee85885693410a3cb62c31a0.zip |
* libc/stdio/fgets.c (fgets): perform CRLF conversions if __SCLE
-rw-r--r-- | newlib/ChangeLog | 4 | ||||
-rw-r--r-- | newlib/libc/stdio/fgets.c | 19 |
2 files changed, 23 insertions, 0 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog index a955e67f9..26741af57 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,7 @@ +2000-05-18 DJ Delorie <dj@cygnus.com> + + * libc/stdio/fgets.c (fgets): perform CRLF conversions if __SCLE + Mon May 15 18:54:00 2000 Jeff Johnston <jjohnstn@cygnus.com> * libc/include/ctype.h: Changed tolower and toupper macros diff --git a/newlib/libc/stdio/fgets.c b/newlib/libc/stdio/fgets.c index abc2bb97c..d395d3344 100644 --- a/newlib/libc/stdio/fgets.c +++ b/newlib/libc/stdio/fgets.c @@ -79,6 +79,25 @@ _DEFUN (fgets, (buf, n, fp), return 0; s = buf; + +#ifdef __SCLE + if (fp->_flags & __SCLE) + { + int c; + /* Sorry, have to do it the slow way */ + while (--n > 0 && (c = __sgetc(fp)) != EOF) + { + *s++ = c; + if (c == '\n') + break; + } + if (c == EOF && s == buf) + return NULL; + *s = 0; + return buf; + } +#endif + n--; /* leave space for NUL */ do { |