diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2016-10-23 00:24:25 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2016-10-23 00:24:25 +0000 |
commit | ab1717bb35d85041e0184f79daa1313a1306dc01 (patch) | |
tree | fa0739f76b49b902269f8f7c1e1c7c5ea30c0556 /checknr/checknr.c | |
parent | aa7798c94fa57f6c00fab4393c9fe91334864371 (diff) |
Notes
Diffstat (limited to 'checknr/checknr.c')
-rw-r--r-- | checknr/checknr.c | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/checknr/checknr.c b/checknr/checknr.c index b7dde0af2004..a98b0adc2d04 100644 --- a/checknr/checknr.c +++ b/checknr/checknr.c @@ -179,7 +179,6 @@ static void checkknown(char *mac); static void addcmd(char *line); static void addmac(char *mac); static int binsrch(char *mac); -static char *fgetline(char **line, size_t *linesize, size_t *llen, FILE *fp); static void growstk(void) @@ -307,7 +306,7 @@ process(FILE *f) int pl; stktop = -1; - for (lineno = 1; fgetline(&line, &linesize, NULL, f); lineno++) { + for (lineno = 1; getline(&line, &linesize, f) > 0; lineno++) { if (line[0] == '.') { /* * find and isolate the macro/command name. @@ -636,34 +635,3 @@ binsrch(char *mac) slot = bot; /* place it would have gone */ return (-1); } - -#define LSIZE 256 - -static char * -fgetline(char **line, size_t *linesize, size_t *llen, FILE *fp) -{ - int c; - size_t n = 0; - - if (*line == NULL || *linesize < LSIZE + n + 1) - *line = realloc(*line, *linesize = LSIZE + n + 1); - for (;;) { - if (n >= *linesize - LSIZE / 2) - *line = realloc(*line, *linesize += LSIZE); - c = getc(fp); - if (c != EOF) { - (*line)[n++] = c; - (*line)[n] = '\0'; - if (c == '\n') - break; - } else { - if (n > 0) - break; - else - return NULL; - } - } - if (llen) - *llen = n; - return *line; -} |