summaryrefslogtreecommitdiff
path: root/examples/hello_strlcpy/hello.c
diff options
context:
space:
mode:
authorAndrew Shadura <andrewsh@debian.org>2014-01-05 22:42:41 +0100
committerAndrew Shadura <andrew@shadura.me>2015-07-25 14:44:33 +0200
commitc8659b636be5e763c5dc028a5db7294b1af2648c (patch)
tree7dacf7580ff8c7d8c64682eaa28350bc47fbd56e /examples/hello_strlcpy/hello.c
parent004c4cd3db1d9ad252eccbc1e9e6c54ec61a2927 (diff)
parentaba913436a8521abe405a04ed71388989e1d646f (diff)
Imported Debian patch 0.25.0-1
Diffstat (limited to 'examples/hello_strlcpy/hello.c')
-rw-r--r--examples/hello_strlcpy/hello.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/examples/hello_strlcpy/hello.c b/examples/hello_strlcpy/hello.c
index b7dd661..177b6b5 100644
--- a/examples/hello_strlcpy/hello.c
+++ b/examples/hello_strlcpy/hello.c
@@ -5,14 +5,18 @@
size_t strlcpy(char *dst, const char *src, size_t siz);
#endif
+#ifndef HAVE_FUNC3_GETLINE_STDIO_H
+ssize_t getline(char** lineptr, size_t* n, FILE* stream);
+#endif
+
int main (int argc, char ** argv)
{
- char buf [2000];
+ char *buf = NULL;
+ size_t size = 0;
+ ssize_t len = 0;
char small_buf [10];
- size_t len;
-
- while (fgets (buf, sizeof (buf), stdin)){
+ while (len = getline (&buf, &size, stdin), len != -1){
len = strlen (buf);
if (len > 0 && buf [len-1] == '\n')
buf [len-1] = 0;