Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make ParseGetLine: don't treat a zero byte as end of...



details:   https://anonhg.NetBSD.org/src/rev/764a55bf3e87
branches:  trunk
changeset: 789184:764a55bf3e87
user:      sjg <sjg%NetBSD.org@localhost>
date:      Sat Aug 10 21:20:03 2013 +0000

description:
ParseGetLine: don't treat a zero byte as end of buffer if P_end says it isn't.
Consume up to next newline, and issue a parse warning.
If no newline found before P_end, carry on as before.

diffstat:

 usr.bin/make/parse.c |  16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diffs (43 lines):

diff -r 827bbb04ea1a -r 764a55bf3e87 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sat Aug 10 21:15:26 2013 +0000
+++ b/usr.bin/make/parse.c      Sat Aug 10 21:20:03 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.189 2013/06/18 19:31:27 sjg Exp $  */
+/*     $NetBSD: parse.c,v 1.190 2013/08/10 21:20:03 sjg Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.189 2013/06/18 19:31:27 sjg Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.190 2013/08/10 21:20:03 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)parse.c    8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: parse.c,v 1.189 2013/06/18 19:31:27 sjg Exp $");
+__RCSID("$NetBSD: parse.c,v 1.190 2013/08/10 21:20:03 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2572,6 +2572,16 @@
                if (cf->P_end == NULL)
                    /* End of string (aka for loop) data */
                    break;
+               /* see if there is more we can parse */
+               while (ptr++ < cf->P_end) {
+                   if ((ch = *ptr) == '\n') {
+                       if (ptr > line && ptr[-1] == '\\')
+                           continue;
+                       Parse_Error(PARSE_WARNING,
+                           "Zero byte read from file, skipping rest of line.");
+                       break;
+                   }
+               }
                if (cf->nextbuf != NULL) {
                    /*
                     * End of this buffer; return EOF and outer logic



Home | Main Index | Thread Index | Old Index