Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make If a makefile if a multiple of the page size an...



details:   https://anonhg.NetBSD.org/src/rev/22200495d6bc
branches:  trunk
changeset: 765053:22200495d6bc
user:      dsl <dsl%NetBSD.org@localhost>
date:      Tue May 17 21:56:51 2011 +0000

description:
If a makefile if a multiple of the page size and doesn't end with a
newline, then it all goes horribly wrong when make tries to terminate
the last input line.
This was all ok before the mmap changes (rev 1.169) because the last
32 bytes of the input buffer were never read into.
The non-mmap case has a similar problem.
Bug found because my .depend files don't have a newline at the end of
the .OPTIO|NAL line (don't know if that is a local change).

diffstat:

 usr.bin/make/Makefile |   4 +++-
 usr.bin/make/parse.c  |  14 +++++++++++---
 2 files changed, 14 insertions(+), 4 deletions(-)

diffs (66 lines):

diff -r a8ffae6c7227 -r 22200495d6bc usr.bin/make/Makefile
--- a/usr.bin/make/Makefile     Tue May 17 18:57:02 2011 +0000
+++ b/usr.bin/make/Makefile     Tue May 17 21:56:51 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.51 2010/09/13 15:36:57 sjg Exp $
+#      $NetBSD: Makefile,v 1.52 2011/05/17 21:56:51 dsl Exp $
 #      @(#)Makefile    5.2 (Berkeley) 12/28/90
 
 PROG=  make
@@ -38,6 +38,7 @@
 CPPFLAGS+= -DMAKE_NATIVE
 COPTS.var.c+= -Wno-cast-qual
 
+.if 0
 .ifdef TOOLDIR
 # this is a native netbsd build, 
 # use libutil rather than the local emalloc etc.
@@ -45,6 +46,7 @@
 LDADD+=-lutil
 DPADD+=${LIBUTIL}
 .endif
+.endif
 
 # A simple unit-test driver to help catch regressions
 accept test:
diff -r a8ffae6c7227 -r 22200495d6bc usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Tue May 17 18:57:02 2011 +0000
+++ b/usr.bin/make/parse.c      Tue May 17 21:56:51 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.177 2011/03/03 14:53:02 nakayama Exp $     */
+/*     $NetBSD: parse.c,v 1.178 2011/05/17 21:56:51 dsl Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.177 2011/03/03 14:53:02 nakayama Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.178 2011/05/17 21:56:51 dsl 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.177 2011/03/03 14:53:02 nakayama Exp $");
+__RCSID("$NetBSD: parse.c,v 1.178 2011/05/17 21:56:51 dsl Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -518,6 +518,14 @@
                               MAP_FILE|MAP_COPY, fd, 0);
                if (lf->buf != MAP_FAILED) {
                        /* succeeded */
+                       if (lf->len == lf->maplen && lf->buf[lf->len - 1] != '\n') {
+                               char *b = malloc(lf->len + 1);
+                               b[lf->len] = '\n';
+                               memcpy(b, lf->buf, lf->len++);
+                               munmap(lf->buf, lf->maplen);
+                               lf->maplen = 0;
+                               lf->buf = b;
+                       }
                        goto done;
                }
        }



Home | Main Index | Thread Index | Old Index