diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-05-04 22:27:55 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-05-04 22:27:55 +0000 |
commit | 53b89be19651f8c622d0ed598123fa411cd34613 (patch) | |
tree | 691afd6c9eac47a3ba2313b650642c0f6a61eb8f /usr.bin/checknr | |
parent | 72cc039d1a6007516dcc3e11dea6ed760e463b4c (diff) |
Remove limitation on input lines by using getline(3)
Notes
Notes:
svn path=/head/; revision=282439
Diffstat (limited to 'usr.bin/checknr')
-rw-r--r-- | usr.bin/checknr/checknr.1 | 6 | ||||
-rw-r--r-- | usr.bin/checknr/checknr.c | 9 |
2 files changed, 8 insertions, 7 deletions
diff --git a/usr.bin/checknr/checknr.1 b/usr.bin/checknr/checknr.1 index 8888fddc5583..a89706eb10cd 100644 --- a/usr.bin/checknr/checknr.1 +++ b/usr.bin/checknr/checknr.1 @@ -28,7 +28,7 @@ .\" @(#)checknr.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd January 26, 2005 +.Dd May 5, 2015 .Dt CHECKNR 1 .Os .Sh NAME @@ -157,7 +157,3 @@ There is no way to define a 1 character macro name using .Pp Does not correctly recognize certain reasonable constructs, such as conditionals. -.Pp -Input lines are limited to -.Dv LINE_MAX -(2048) bytes in length. diff --git a/usr.bin/checknr/checknr.c b/usr.bin/checknr/checknr.c index 549538f39fe6..2945bd9a1fe4 100644 --- a/usr.bin/checknr/checknr.c +++ b/usr.bin/checknr/checknr.c @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); * structured typesetting. */ #include <err.h> +#define _WITH_GETLINE #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -284,11 +285,14 @@ process(FILE *f) { int i, n; char mac[5]; /* The current macro or nroff command */ + char *line; + size_t linecap; int pl; - static char line[256]; /* the current line */ + line = NULL; + linecap = 0; stktop = -1; - for (lineno = 1; fgets(line, sizeof line, f); lineno++) { + for (lineno = 1; getline(&line, &linecap, f) > 0; lineno++) { if (line[0] == '.') { /* * find and isolate the macro/command name. @@ -367,6 +371,7 @@ process(FILE *f) } } } + free(line); /* * We've hit the end and look at all this stuff that hasn't been * matched yet! Complain, complain. |