summaryrefslogtreecommitdiff
path: root/read.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1992-12-29 00:20:25 +0000
committerRoland McGrath <roland@redhat.com>1992-12-29 00:20:25 +0000
commit2d89aa53df8d041eff9e5089627f5a2cbef00561 (patch)
treed577fcaa6d56c4c7d10f6a74b82183efd30d753f /read.c
parent52930ae3a97cc864b1010de39a03595693e79d33 (diff)
downloadgunmake-2d89aa53df8d041eff9e5089627f5a2cbef00561.tar.gz
Formerly read.c.~48~
Diffstat (limited to 'read.c')
-rw-r--r--read.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/read.c b/read.c
index 24d606d..02a4ffb 100644
--- a/read.c
+++ b/read.c
@@ -326,7 +326,7 @@ read_makefile (filename, type)
while (!feof (infile))
{
lineno += nlines;
- nlines = readline (&lb, infile, filename);
+ nlines = readline (&lb, infile, filename, lineno);
if (collapsed_length < lb.size)
{
@@ -723,7 +723,7 @@ do_define (name, namelen, origin, lineno, infile, filename)
while (!feof (infile))
{
lineno += nlines;
- nlines = readline (&lb, infile, filename);
+ nlines = readline (&lb, infile, filename, lineno);
p = next_token (lb.buffer);
if ((p[5] == '\0' || isblank (p[5])) && !strncmp (p, "endef", 5))
@@ -1480,10 +1480,11 @@ parse_file_seq (stringp, stopchar, size)
*/
static unsigned int
-readline (linebuffer, stream, filename)
+readline (linebuffer, stream, filename, lineno)
struct linebuffer *linebuffer;
FILE *stream;
char *filename;
+ unsigned int lineno;
{
char *buffer = linebuffer->buffer;
register char *p = linebuffer->buffer;
@@ -1499,11 +1500,15 @@ readline (linebuffer, stream, filename)
{
if (fgets (p, end - p, stream) == 0)
if (feof (stream))
- return nlines;
+ break;
else
pfatal_with_name (filename);
len = strlen (p);
+ if (len == 0)
+ /* This only happens when the first thing on the line is a '\0'. */
+ makefile_fatal (filename, lineno, "NUL not allowed in makefile");
+
p += len;
if (p[-1] != '\n')
{
@@ -1543,7 +1548,7 @@ readline (linebuffer, stream, filename)
if (!backslash)
{
p[-1] = '\0';
- return nlines;
+ break;
}
if (end - p <= 1)
@@ -1557,6 +1562,8 @@ readline (linebuffer, stream, filename)
linebuffer->buffer = buffer;
}
}
+
+ return nlines;
}
/* Construct the list of include directories