Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make Fix parsing bug for :ts - patch from Alan Barre...



details:   https://anonhg.NetBSD.org/src/rev/e2eee787eb6b
branches:  trunk
changeset: 550051:e2eee787eb6b
user:      sjg <sjg%NetBSD.org@localhost>
date:      Mon Jul 28 22:52:10 2003 +0000

description:
Fix parsing bug for :ts - patch from Alan Barrett <apb%cequrux.com@localhost>
Also add simple unit-test jig (regress/usr.bin/make will use it too)
but having it local here makes inclusion in bmake simpler.

diffstat:

 usr.bin/make/Makefile            |   9 +++++-
 usr.bin/make/unit-tests/Makefile |  58 ++++++++++++++++++++++++++++++++++++++++
 usr.bin/make/unit-tests/test.exp |  30 ++++++++++++++++++++
 usr.bin/make/var.c               |   9 +++--
 4 files changed, 101 insertions(+), 5 deletions(-)

diffs (159 lines):

diff -r 12314480edb5 -r e2eee787eb6b usr.bin/make/Makefile
--- a/usr.bin/make/Makefile     Mon Jul 28 21:45:13 2003 +0000
+++ b/usr.bin/make/Makefile     Mon Jul 28 22:52:10 2003 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.28 2003/07/26 16:04:29 mrg Exp $
+#      $NetBSD: Makefile,v 1.29 2003/07/28 22:52:10 sjg Exp $
 #      @(#)Makefile    5.2 (Berkeley) 12/28/90
 
 CPPFLAGS+= -I${.CURDIR}
@@ -16,6 +16,9 @@
 .if make(install)
 SUBDIR=        PSD.doc
 .endif
+.if make(obj) || make(clean)
+SUBDIR+= unit-tests
+.endif
 
 .include <bsd.prog.mk>
 .include <bsd.subdir.mk>
@@ -27,3 +30,7 @@
 CPPFLAGS+= ${CPPFLAGS_${.TARGET}}
 main.o:        ${OBJS:Nmain.o} ${MAKEFILE}
 COPTS.var.c+= -Wno-cast-qual
+
+# A simple unit-test driver to help catch regressions
+accept test:
+       cd ${.CURDIR}/unit-tests && ${.MAKE} TEST_MAKE=${TEST_MAKE:U../${PROG:T}} ${.TARGET}
diff -r 12314480edb5 -r e2eee787eb6b usr.bin/make/unit-tests/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Mon Jul 28 22:52:10 2003 +0000
@@ -0,0 +1,58 @@
+# $Id: Makefile,v 1.1 2003/07/28 22:52:12 sjg Exp $
+#
+# Unit tests for make(1)
+# The main targets are:
+# 
+# all: run all the tests
+# test:        run 'all', capture output and compare to expected results
+# accept: move generated output to expected results
+#
+# Adding a test case.  
+# Each feature should get its own set of tests which should be hooked
+# into the 'all' target.
+# 
+
+.MAIN: all
+
+all: mod-ts
+
+LIST= one two three
+LIST+= four five six
+
+FU_mod-ts = a / b / cool
+
+mod-ts:
+       @echo LIST='${LIST}'
+       @echo LIST:ts,='${LIST:ts,}'
+       @echo LIST:ts/:tu='${LIST:ts/:tu}'
+       @echo LIST:tu:ts/='${LIST:tu:ts/}'
+       @echo LIST:ts:='${LIST:ts:}'
+       @echo LIST:ts='${LIST:ts}'
+       @echo LIST:ts:S/two/2/='${LIST:ts:S/two/2/}'
+       @echo LIST:S/two/2/:ts='${LIST:S/two/2/:ts}'
+       @echo LIST:ts/:S/two/2/='${LIST:ts/:S/two/2/}'
+       @echo "LIST:ts\n='${LIST:ts\n}'"
+       @echo "LIST:ts\t='${LIST:ts\t}'"
+       @echo "LIST:ts\012:tu='${LIST:ts\012:tu}'"
+       @echo "LIST:tx='${LIST:tx}'"
+       @echo "LIST:ts\a:tu='${LIST:ts\a:tu}'"
+       @echo "FU_$@='${FU_${@:ts}:ts}'"
+       @echo "FU_$@:ts:T='${FU_${@:ts}:ts:T}' == cool?"
+
+clean:
+       rm -f *.out *.fail *.core
+
+.include <bsd.obj.mk>
+
+TEST_MAKE?= ${MAKE}
+
+# here is the driver
+test:
+       @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
+       @${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1 || { \
+       tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
+       diff -u ${.CURDIR}/${.TARGET}.exp ${.TARGET}.out
+
+accept:
+       mv test.out ${.CURDIR}/test.exp
+
diff -r 12314480edb5 -r e2eee787eb6b usr.bin/make/unit-tests/test.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/test.exp  Mon Jul 28 22:52:10 2003 +0000
@@ -0,0 +1,30 @@
+LIST=one two three four five six
+LIST:ts,=one,two,three,four,five,six
+LIST:ts/:tu=ONE/TWO/THREE/FOUR/FIVE/SIX
+LIST:tu:ts/=ONE/TWO/THREE/FOUR/FIVE/SIX
+LIST:ts:=one:two:three:four:five:six
+LIST:ts=onetwothreefourfivesix
+LIST:ts:S/two/2/=one2threefourfivesix
+LIST:S/two/2/:ts=one2threefourfivesix
+LIST:ts/:S/two/2/=one/2/three/four/five/six
+LIST:ts\n='one
+two
+three
+four
+five
+six'
+LIST:ts\t='one two     three   four    five    six'
+LIST:ts\012:tu='ONE
+TWO
+THREE
+FOUR
+FIVE
+SIX'
+make: Bad modifier `:tx' for LIST
+make: Unclosed substitution for LIST (/ missing)
+LIST:tx='}'
+make: Bad modifier `:ts\a' for LIST
+make: Unclosed substitution for LIST (/ missing)
+LIST:ts\a:tu='\a:tu}'
+FU_mod-ts='a/b/cool'
+FU_mod-ts:ts:T='cool' == cool?
diff -r 12314480edb5 -r e2eee787eb6b usr.bin/make/var.c
--- a/usr.bin/make/var.c        Mon Jul 28 21:45:13 2003 +0000
+++ b/usr.bin/make/var.c        Mon Jul 28 22:52:10 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.75 2003/07/23 18:06:46 sjg Exp $     */
+/*     $NetBSD: var.c,v 1.76 2003/07/28 22:52:10 sjg Exp $     */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -39,14 +39,14 @@
  */
 
 #ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: var.c,v 1.75 2003/07/23 18:06:46 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.76 2003/07/28 22:52:10 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c      8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.75 2003/07/23 18:06:46 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.76 2003/07/28 22:52:10 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2261,7 +2261,8 @@
                             */
                            VarPattern pattern;
 
-                           if (tstr[3] == endc || tstr[3] == ':') {
+                           if (tstr[2] != endc &&
+                               (tstr[3] == endc || tstr[3] == ':')) {
                                varSpace = tstr[2];
                                cp = tstr + 3;
                            } else if (tstr[2] == endc || tstr[2] == ':') {



Home | Main Index | Thread Index | Old Index