Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/sh NFC (normal builds): DEBUG only change - convert pars...
details: https://anonhg.NetBSD.org/src/rev/dec8e6d68809
branches: trunk
changeset: 353954:dec8e6d68809
user: kre <kre%NetBSD.org@localhost>
date: Mon May 29 10:43:27 2017 +0000
description:
NFC (normal builds): DEBUG only change - convert parser to newer trace method.
parser tracing is useful when debugging the parser (which admittedly is
fairly often...) but there is a lot of it, and it gets in the way when
looking at something else. Now we can turn it off when not wanted.
diffstat:
bin/sh/parser.c | 48 +++++++++++++++++++++++++++++-------------------
1 files changed, 29 insertions(+), 19 deletions(-)
diffs (178 lines):
diff -r ace5e28fd8e2 -r dec8e6d68809 bin/sh/parser.c
--- a/bin/sh/parser.c Mon May 29 10:11:10 2017 +0000
+++ b/bin/sh/parser.c Mon May 29 10:43:27 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parser.c,v 1.129 2017/05/27 11:19:57 kre Exp $ */
+/* $NetBSD: parser.c,v 1.130 2017/05/29 10:43:27 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.129 2017/05/27 11:19:57 kre Exp $");
+__RCSID("$NetBSD: parser.c,v 1.130 2017/05/29 10:43:27 kre Exp $");
#endif
#endif /* not lint */
@@ -163,7 +163,7 @@
union node *n1, *n2, *n3;
int tok;
- TRACE(("list(%d,%d): entered\n", nlflag, erflag));
+ CTRACE(DBG_PARSE, ("list(%d,%d): entered @%d\n",nlflag,erflag,plinno));
checkkwd = 2;
if (nlflag == 0 && tokendlist[peektoken()])
@@ -230,7 +230,7 @@
union node *n1, *n2, *n3;
int t;
- TRACE(("andor: entered\n"));
+ CTRACE(DBG_PARSE, ("andor: entered @%d\n", plinno));
n1 = pipeline();
for (;;) {
@@ -258,12 +258,12 @@
struct nodelist *lp, *prev;
int negate;
- TRACE(("pipeline: entered\n"));
+ CTRACE(DBG_PARSE, ("pipeline: entered @%d\n", plinno));
negate = 0;
checkkwd = 2;
while (readtoken() == TNOT) {
- TRACE(("pipeline: TNOT recognized\n"));
+ CTRACE(DBG_PARSE, ("pipeline: TNOT recognized\n"));
#ifndef BOGUS_NOT_COMMAND
if (posix && negate)
synerror("2nd \"!\" unexpected");
@@ -290,7 +290,8 @@
}
tokpushback++;
if (negate) {
- TRACE(("%snegate pipeline\n", (negate&1) ? "" : "double "));
+ CTRACE(DBG_PARSE, ("%snegate pipeline\n",
+ (negate&1) ? "" : "double "));
n2 = stalloc(sizeof(struct nnot));
n2->type = (negate & 1) ? NNOT : NDNOT;
n2->nnot.com = n1;
@@ -313,7 +314,7 @@
int negate = 0;
#endif
- TRACE(("command: entered\n"));
+ CTRACE(DBG_PARSE, ("command: entered @%d\n", plinno));
checkkwd = 2;
redir = NULL;
@@ -330,7 +331,7 @@
#ifdef BOGUS_NOT_COMMAND /* only in pileline() */
while (readtoken() == TNOT) {
- TRACE(("command: TNOT recognized\n"));
+ CTRACE(DBG_PARSE, ("command: TNOT (bogus) recognized\n"));
negate++;
}
tokpushback++;
@@ -372,7 +373,8 @@
n1->type = (lasttoken == TWHILE)? NWHILE : NUNTIL;
n1->nbinary.ch1 = list(0, 0);
if ((got=readtoken()) != TDO) {
-TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : ""));
+ VTRACE(DBG_PARSE, ("expecting DO got %s %s\n",
+ tokname[got], got == TWORD ? wordtext : ""));
synexpect(TDO, 0);
}
n1->nbinary.ch2 = list(0, 0);
@@ -579,7 +581,8 @@
checkneg:
#ifdef BOGUS_NOT_COMMAND
if (negate) {
- TRACE(("%snegate command\n", (negate&1) ? "" : "double "));
+ VTRACE(DBG_PARSE, ("bogus %snegate command\n",
+ (negate&1) ? "" : "double "));
n2 = stalloc(sizeof(struct nnot));
n2->type = (negate & 1) ? NNOT : NDNOT;
n2->nnot.com = n1;
@@ -601,6 +604,9 @@
int negate = 0;
#endif
+ CTRACE(DBG_PARSE, ("simple command with%s redir already @%d\n",
+ redir ? "" : "out", plinno));
+
/* If we don't have any redirections already, then we must reset */
/* rpp to be the address of the local redir variable. */
if (redir == 0)
@@ -611,7 +617,7 @@
#ifdef BOGUS_NOT_COMMAND /* pipelines get negated, commands do not */
while (readtoken() == TNOT) {
- TRACE(("simplcmd: TNOT recognized\n"));
+ VTRACE(DBG_PARSE, ("simplcmd: bogus TNOT recognized\n"));
negate++;
}
tokpushback++;
@@ -661,7 +667,8 @@
checkneg:
#ifdef BOGUS_NOT_COMMAND
if (negate) {
- TRACE(("%snegate simplecmd\n", (negate&1) ? "" : "double "));
+ VTRACE(DBG_PARSE, ("bogus %snegate simplecmd\n",
+ (negate&1) ? "" : "double "));
n2 = stalloc(sizeof(struct nnot));
n2->type = (negate & 1) ? NNOT : NDNOT;
n2->nnot.com = n;
@@ -689,7 +696,7 @@
fixredir(union node *n, const char *text, int err)
{
- TRACE(("Fix redir %s %d\n", text, err));
+ VTRACE(DBG_PARSE, ("Fix redir %s %d\n", text, err));
if (!err)
n->ndup.vname = NULL;
@@ -720,7 +727,7 @@
if (quoteflag == 0)
n->type = NXHERE;
- TRACE(("Here document %d\n", n->type));
+ VTRACE(DBG_PARSE, ("Here document %d @%d\n", n->type, plinno));
if (here->striptabs) {
while (*wordtext == '\t')
wordtext++;
@@ -878,8 +885,10 @@
grabstackblock(c);
wordtext = out;
- TRACE(("Slurped a heredoc (to '%s')%s: len %d, \"%.16s\"...\n",
- eofmark, striptabs ? " tab stripped" : "", c, wordtext));
+ VTRACE(DBG_PARSE,
+ ("Slurped a heredoc (to '%s')%s: len %d, \"%.*s%s\" @%d\n",
+ eofmark, striptabs ? " tab stripped" : "", c, (c > 16 ? 16 : c),
+ wordtext, (c > 16 ? "..." : ""), plinno));
}
STATIC void
@@ -965,7 +974,8 @@
if (**pp == *wordtext && equal(*pp, wordtext)) {
lasttoken = t = pp -
parsekwd + KWDOFFSET;
- TRACE(("keyword %s recognized\n",
+ VTRACE(DBG_PARSE,
+ ("keyword %s recognized\n",
tokname[t]));
goto out;
}
@@ -980,7 +990,7 @@
out:
checkkwd = (t == TNOT) ? savecheckkwd : 0;
}
- TRACE(("%stoken %s %s\n", alreadyseen ? "reread " : "",
+ VTRACE(DBG_PARSE, ("%stoken %s %s\n", alreadyseen ? "reread " : "",
tokname[t], t == TWORD ? wordtext : ""));
return (t);
}
Home |
Main Index |
Thread Index |
Old Index