summaryrefslogtreecommitdiff
path: root/usr.bin/tic
diff options
context:
space:
mode:
authorroy <roy@NetBSD.org>2011-11-09 07:40:27 +0000
committerroy <roy@NetBSD.org>2011-11-09 07:40:27 +0000
commit9ea52b92ef6fd605812cc834e4e56a24be55e2b3 (patch)
tree6a052af63e3a4fa89f3a0ae8c67c0da770585048 /usr.bin/tic
parent098f01a35f0bc6307f389d20ef41b001e446531b (diff)
Replace fgetln(3) with the more standard getline(3)
Diffstat (limited to 'usr.bin/tic')
-rw-r--r--usr.bin/tic/tic.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/usr.bin/tic/tic.c b/usr.bin/tic/tic.c
index 1ff23d837f2..d710d2a9240 100644
--- a/usr.bin/tic/tic.c
+++ b/usr.bin/tic/tic.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.11 2011/11/03 10:12:57 roy Exp $ */
+/* $NetBSD: tic.c,v 1.12 2011/11/09 07:40:27 roy Exp $ */
/*
* Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: tic.c,v 1.11 2011/11/03 10:12:57 roy Exp $");
+__RCSID("$NetBSD: tic.c,v 1.12 2011/11/09 07:40:27 roy Exp $");
#include <sys/types.h>
@@ -443,7 +443,8 @@ main(int argc, char **argv)
char *source, *p, *buf, *ofile;
FILE *f;
DBM *db;
- size_t len, buflen, nterm, nalias;
+ size_t buflen, nterm, nalias;
+ ssize_t len;
TBUF tbuf;
TERM *term;
@@ -506,12 +507,13 @@ main(int argc, char **argv)
} else
db = NULL; /* satisfy gcc warning */
- tbuf.buflen = tbuf.bufpos = 0;
- while ((buf = fgetln(f, &buflen)) != NULL) {
+ buf = NULL;
+ buflen = tbuf.buflen = tbuf.bufpos = 0;
+ while ((len = getline(&buf, &buflen, f)) != -1) {
/* Skip comments */
if (*buf == '#')
continue;
- if (buf[buflen - 1] != '\n') {
+ if (buf[len - 1] != '\n') {
process_entry(&tbuf, flags);
dowarn("last line is not a comment"
" and does not end with a newline");
@@ -525,10 +527,10 @@ main(int argc, char **argv)
process_entry(&tbuf, flags);
/* Grow the buffer if needed */
- grow_tbuf(&tbuf, buflen);
+ grow_tbuf(&tbuf, len);
/* Append the string */
- memcpy(tbuf.buf + tbuf.bufpos, buf, buflen);
- tbuf.bufpos += buflen;
+ memcpy(tbuf.buf + tbuf.bufpos, buf, len);
+ tbuf.bufpos += len;
}
/* Process the last entry if not done already */
process_entry(&tbuf, flags);