aboutsummaryrefslogtreecommitdiffstats
path: root/lib/getline.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-04-22 03:02:55 +0000
committerJim Meyering <jim@meyering.net>1996-04-22 03:02:55 +0000
commit3032beba73297169e05dbcc63093515fe2b90cb2 (patch)
treee36495bc2cbc9b92539127d4456e0727de95d105 /lib/getline.c
parent(md5_check): Remove spurious `\n' at end of error format string. (diff)
downloadcoreutils-3032beba73297169e05dbcc63093515fe2b90cb2.tar.gz
coreutils-3032beba73297169e05dbcc63093515fe2b90cb2.zip
New version from gettext-0.10.12.
Diffstat (limited to 'lib/getline.c')
-rw-r--r--lib/getline.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/lib/getline.c b/lib/getline.c
index c69946148..e95aace34 100644
--- a/lib/getline.c
+++ b/lib/getline.c
@@ -14,21 +14,36 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Jan Brittenson, bson@gnu.ai.mit.edu. */
#ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
#endif
-#include <sys/types.h>
#include <stdio.h>
+#include <sys/types.h>
+
+#if defined __GNU_LIBRARY__ && defined HAVE_GETDELIM
+
+int
+getline (lineptr, n, stream)
+ char **lineptr;
+ size_t *n;
+ FILE *stream;
+{
+ return getdelim (lineptr, n, '\n', stream);
+}
+
+
+#else /* ! have getdelim */
+
#define NDEBUG
#include <assert.h>
#if STDC_HEADERS
-#include <stdlib.h>
+# include <stdlib.h>
#else
char *malloc (), *realloc ();
#endif
@@ -48,7 +63,7 @@ getstr (lineptr, n, stream, terminator, offset)
size_t *n;
FILE *stream;
char terminator;
- int offset;
+ size_t offset;
{
int nchars_avail; /* Allocated but unused chars in *LINEPTR. */
char *read_pos; /* Where we're reading into *LINEPTR. */
@@ -124,3 +139,14 @@ getline (lineptr, n, stream)
{
return getstr (lineptr, n, stream, '\n', 0);
}
+
+int
+getdelim (lineptr, n, delimiter, stream)
+ char **lineptr;
+ size_t *n;
+ int delimiter;
+ FILE *stream;
+{
+ return getstr (lineptr, n, stream, delimiter, 0);
+}
+#endif