summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-08-07 09:26:06 +0000
committerJim Meyering <jim@meyering.net>2003-08-07 09:26:06 +0000
commit4512fc1668a084f3006892c92a83a291b126d213 (patch)
treef4b4be05cbd3b543ffa39152027bdae6ee420ef7 /lib
parent08fd4795f3e0c84bf5fc3164818720d8597aa622 (diff)
downloadcoreutils-4512fc1668a084f3006892c92a83a291b126d213.tar.xz
Merge from gnulib.
Diffstat (limited to 'lib')
-rw-r--r--lib/getline.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/lib/getline.c b/lib/getline.c
index d8da22cc0..896b6bbd8 100644
--- a/lib/getline.c
+++ b/lib/getline.c
@@ -23,37 +23,36 @@
# include <config.h>
#endif
+/* Specification. */
#include "getline.h"
-#include "getdelim2.h"
-
-/* The `getdelim' function is only declared if the following symbol
- is defined. */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-#endif
#include <stddef.h>
#include <stdio.h>
+/* Get ssize_t. */
+#include <sys/types.h>
+
#if defined __GNU_LIBRARY__ && HAVE_GETDELIM
-int
-getline (char **lineptr, size_t *n, FILE *stream)
+ssize_t
+getline (char **lineptr, size_t *linesize, FILE *stream)
{
- return getdelim (lineptr, n, '\n', stream);
+ return getdelim (lineptr, linesize, '\n', stream);
}
#else /* ! have getdelim */
-int
-getline (char **lineptr, size_t *n, FILE *stream)
+# include "getndelim2.h"
+
+ssize_t
+getline (char **lineptr, size_t *linesize, FILE *stream)
{
- return getdelim2 (lineptr, n, stream, '\n', 0, 0);
+ return getndelim2 (lineptr, linesize, (size_t)(-1), stream, '\n', 0, 0);
}
-int
-getdelim (char **lineptr, size_t *n, int delimiter, FILE *stream)
+ssize_t
+getdelim (char **lineptr, size_t *linesize, int delimiter, FILE *stream)
{
- return getdelim2 (lineptr, n, stream, delimiter, 0, 0);
+ return getndelim2 (lineptr, linesize, (size_t)(-1), stream, delimiter, 0, 0);
}
#endif