summaryrefslogtreecommitdiff
path: root/usr.bin/error
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>1995-09-10 15:55:13 +0000
committerchristos <christos@NetBSD.org>1995-09-10 15:55:13 +0000
commit49a4e14351ec704c91fe8a35aea8d08ce5006e58 (patch)
tree1042b1ec00561ca7ad76e2b8c2c9bfb2bcd47fc6 /usr.bin/error
parentc08d930690da1ddbe45be45d4452ad67b3084d5d (diff)
Handle long lines without core-dumping.
Diffstat (limited to 'usr.bin/error')
-rw-r--r--usr.bin/error/input.c16
-rw-r--r--usr.bin/error/subr.c10
2 files changed, 14 insertions, 12 deletions
diff --git a/usr.bin/error/input.c b/usr.bin/error/input.c
index c779b8ec414..37a7d3b2d8d 100644
--- a/usr.bin/error/input.c
+++ b/usr.bin/error/input.c
@@ -1,4 +1,4 @@
-/* $NetBSD: input.c,v 1.3 1995/09/02 06:15:32 jtc Exp $ */
+/* $NetBSD: input.c,v 1.4 1995/09/10 15:55:13 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$NetBSD: input.c,v 1.3 1995/09/02 06:15:32 jtc Exp $";
+static char rcsid[] = "$NetBSD: input.c,v 1.4 1995/09/10 15:55:13 christos Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -70,19 +70,23 @@ Errorclass mod2();
* Eat all of the lines in the input file, attempting to categorize
* them by their various flavors
*/
-static char inbuffer[BUFSIZ];
-
eaterrors(r_errorc, r_errorv)
int *r_errorc;
Eptr **r_errorv;
{
extern boolean piflag;
Errorclass errorclass = C_SYNC;
+ char *line;
+ char *inbuffer;
+ size_t inbuflen;
for (;;){
- if (fgets(inbuffer, BUFSIZ, errorfile) == NULL)
+ if ((inbuffer = fgetln(errorfile, &inbuflen)) == NULL)
break;
- wordvbuild(inbuffer, &wordc, &wordv);
+ line = Calloc(inbuflen + 1, sizeof(char));
+ memcpy(line, inbuffer, inbuflen);
+ line[inbuflen] = '\0';
+ wordvbuild(line, &wordc, &wordv);
/*
* for convience, convert wordv to be 1 based, instead
* of 0 based.
diff --git a/usr.bin/error/subr.c b/usr.bin/error/subr.c
index 54e670dc9eb..33e0b0734eb 100644
--- a/usr.bin/error/subr.c
+++ b/usr.bin/error/subr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: subr.c,v 1.3 1995/09/02 06:15:49 jtc Exp $ */
+/* $NetBSD: subr.c,v 1.4 1995/09/10 15:55:15 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$NetBSD: subr.c,v 1.3 1995/09/02 06:15:49 jtc Exp $";
+static char rcsid[] = "$NetBSD: subr.c,v 1.4 1995/09/10 15:55:15 christos Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -333,13 +333,11 @@ wordvbuild(string, r_wordc, r_wordv)
char ***r_wordv;
{
reg char *cp;
- char *saltedbuffer;
char **wordv;
int wordcount;
int wordindex;
- saltedbuffer = strsave(string);
- for (wordcount = 0, cp = saltedbuffer; *cp; wordcount++){
+ for (wordcount = 0, cp = string; *cp; wordcount++){
while (*cp && isspace(*cp))
cp++;
if (*cp == 0)
@@ -348,7 +346,7 @@ wordvbuild(string, r_wordc, r_wordv)
cp++;
}
wordv = (char **)Calloc(wordcount + 1, sizeof (char *));
- for (cp=saltedbuffer,wordindex=0; wordcount; wordindex++,--wordcount){
+ for (cp=string,wordindex=0; wordcount; wordindex++,--wordcount){
while (*cp && isspace(*cp))
cp++;
if (*cp == 0)