Module Name: src Committed By: dsl Date: Tue May 17 21:56:52 UTC 2011
Modified Files: src/usr.bin/make: Makefile parse.c Log Message: 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). To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/usr.bin/make/Makefile cvs rdiff -u -r1.177 -r1.178 src/usr.bin/make/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/Makefile diff -u src/usr.bin/make/Makefile:1.51 src/usr.bin/make/Makefile:1.52 --- src/usr.bin/make/Makefile:1.51 Mon Sep 13 15:36:57 2010 +++ src/usr.bin/make/Makefile Tue May 17 21:56:51 2011 @@ -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: Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.177 src/usr.bin/make/parse.c:1.178 --- src/usr.bin/make/parse.c:1.177 Thu Mar 3 14:53:02 2011 +++ src/usr.bin/make/parse.c Tue May 17 21:56:51 2011 @@ -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; } }