Source-Changes-HG archive

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

[src/trunk]: src/bin/sh Do a better job of detecting the error in pkgsrc/deve...



details:   https://anonhg.NetBSD.org/src/rev/0c4a6ab2a6f7
branches:  trunk
changeset: 825204:0c4a6ab2a6f7
user:      kre <kre%NetBSD.org@localhost>
date:      Mon Jul 03 20:16:44 2017 +0000

description:
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...).

diffstat:

 bin/sh/parser.c |  13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diffs (47 lines):

diff -r deac5d1e74f4 -r 0c4a6ab2a6f7 bin/sh/parser.c
--- a/bin/sh/parser.c   Mon Jul 03 18:54:11 2017 +0000
+++ b/bin/sh/parser.c   Mon Jul 03 20:16:44 2017 +0000
@@ -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 @@
                 * 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 @@
                                        } 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;



Home | Main Index | Thread Index | Old Index