Module Name: src Committed By: kre Date: Mon Jul 3 20:16:44 UTC 2017
Modified Files: src/bin/sh: parser.c Log Message: Do a better job of detecting the error in pkgsrc/devel/libbson-1.6.3's configure script, ie: $(( which is intended to be a sub-shell in a command substitution, but is an arith subst instead, it needs to be written $( ( to do as intended. Instead of just blindly carrying on to find the missing )) somewhere, anywhere, give up as soon as we have seen an unbalanced ')' that isn't immediately followed by another ')' which in a valid arith subst it always would be. While here, there has been a comment in the code for quite a while noting a difference in the standard between the text descr & grammar when it comes to the syntax of case statements. Add more comments to explain why parsing it as we do is in fact definitely the correct way (ie: the grammar wins arguments like this...). To generate a diff of this commit: cvs rdiff -u -r1.140 -r1.141 src/bin/sh/parser.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/sh/parser.c diff -u src/bin/sh/parser.c:1.140 src/bin/sh/parser.c:1.141 --- src/bin/sh/parser.c:1.140 Fri Jun 30 23:02:56 2017 +++ src/bin/sh/parser.c Mon Jul 3 20:16:44 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: parser.c,v 1.140 2017/06/30 23:02:56 kre Exp $ */ +/* $NetBSD: parser.c,v 1.141 2017/07/03 20:16:44 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95"; #else -__RCSID("$NetBSD: parser.c,v 1.140 2017/06/30 23:02:56 kre Exp $"); +__RCSID("$NetBSD: parser.c,v 1.141 2017/07/03 20:16:44 kre Exp $"); #endif #endif /* not lint */ @@ -478,6 +478,12 @@ command(void) * paragraph shows one case is required, but the "Grammar" * section shows a grammar that explicitly allows the no * case option. + * + * The standard also says (section 2.10): + * This formal syntax shall take precedence over the + * preceding text syntax description. + * ie: the "Grammar" section wins. The text is just + * a rough guide (introduction to the common case.) */ while (lasttoken != TESAC) { *cpp = cp = stalloc(sizeof(struct nclist)); @@ -1760,12 +1766,15 @@ readtoken1(int firstc, char const *syn, } else USTPUTC(/*(*/ ')', out); } else { + break; /* to synerror() just below */ +#if 0 /* the old way, causes weird errors on bad input */ /* * unbalanced parens * (don't 2nd guess - no error) */ pungetc(); USTPUTC(/*(*/ ')', out); +#endif } } continue;