diff options
| author | Jari Aalto <jari.aalto@cante.net> | 2000-03-17 21:46:59 +0000 |
|---|---|---|
| committer | Jari Aalto <jari.aalto@cante.net> | 2009-09-12 16:46:53 +0000 |
| commit | bb70624e964126b7ac4ff085ba163a9c35ffa18f (patch) | |
| tree | ba2dd4add13ada94b1899c6d4aca80195b80b74b /lib/sh/setlinebuf.c | |
| parent | b72432fdcc59300c6fe7c9d6c8a31ad3447933f5 (diff) | |
| download | android_external_bash-bb70624e964126b7ac4ff085ba163a9c35ffa18f.tar.gz android_external_bash-bb70624e964126b7ac4ff085ba163a9c35ffa18f.tar.bz2 android_external_bash-bb70624e964126b7ac4ff085ba163a9c35ffa18f.zip | |
Imported from ../bash-2.04.tar.gz.
Diffstat (limited to 'lib/sh/setlinebuf.c')
| -rw-r--r-- | lib/sh/setlinebuf.c | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/lib/sh/setlinebuf.c b/lib/sh/setlinebuf.c index 05f9579..fb097de 100644 --- a/lib/sh/setlinebuf.c +++ b/lib/sh/setlinebuf.c @@ -20,22 +20,44 @@ #include <config.h> -#if !defined (HAVE_SETLINEBUF) - #include <stdio.h> +extern char *xmalloc(); + +#if defined (USING_BASH_MALLOC) +# define LBUF_BUFSIZE 1008 +#else +# define LBUF_BUFSIZE BUFSIZ +#endif + /* Cause STREAM to buffer lines as opposed to characters or blocks. */ int -setlinebuf (stream) +sh_setlinebuf (stream) FILE *stream; { -#if defined (_IOLBF) + char *local_linebuf; + +#if !defined (HAVE_SETLINEBUF) && !defined (HAVE_SETVBUF) + return (0); +#endif + +#if defined (USING_BASH_MALLOC) + local_linebuf = xmalloc (LBUF_BUFSIZE); +#else + local_linebuf = (char *)NULL; +#endif + +#if defined (HAVE_SETVBUF) + # if defined (SETVBUF_REVERSED) - setvbuf (stream, _IOLBF, (char *)NULL, BUFSIZ); + return (setvbuf (stream, _IOLBF, local_linebuf, LBUF_BUFSIZE)); # else /* !SETVBUF_REVERSED */ - setvbuf (stream, (char *)NULL, _IOLBF, BUFSIZ); + return (setvbuf (stream, local_linebuf, _IOLBF, LBUF_BUFSIZE)); # endif /* !SETVBUF_REVERSED */ -#endif /* _IOLBF */ +# else /* !HAVE_SETVBUF */ + + setlinebuf (stream)); return (0); + +#endif /* !HAVE_SETVBUF */ } -#endif /* !HAVE_SETLINEBUF */ |
