Source-Changes-HG archive

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

[src/trunk]: src/bin/sh NFC: Whitespace, KNF, and (some) consistency.



details:   https://anonhg.NetBSD.org/src/rev/7d7ca0f88612
branches:  trunk
changeset: 353527:7d7ca0f88612
user:      kre <kre%NetBSD.org@localhost>
date:      Wed May 10 11:06:47 2017 +0000

description:
NFC: Whitespace, KNF, and (some) consistency.

diffstat:

 bin/sh/parser.c |  70 +++++++++++++++++++++++++++++++-------------------------
 1 files changed, 39 insertions(+), 31 deletions(-)

diffs (224 lines):

diff -r a4a754d83486 -r 7d7ca0f88612 bin/sh/parser.c
--- a/bin/sh/parser.c   Wed May 10 11:05:17 2017 +0000
+++ b/bin/sh/parser.c   Wed May 10 11:06:47 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parser.c,v 1.125 2017/05/09 05:14:03 kre Exp $ */
+/*     $NetBSD: parser.c,v 1.126 2017/05/10 11:06:47 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.125 2017/05/09 05:14:03 kre Exp $");
+__RCSID("$NetBSD: parser.c,v 1.126 2017/05/10 11:06:47 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -162,6 +162,7 @@
 {
        union node *n1, *n2, *n3;
        int tok;
+
        TRACE(("list(%d,%d): entered\n", nlflag, erflag));
 
        checkkwd = 2;
@@ -230,6 +231,7 @@
        int t;
 
        TRACE(("andor: entered\n"));
+
        n1 = pipeline();
        for (;;) {
                if ((t = readtoken()) == TAND) {
@@ -356,6 +358,7 @@
        case TWHILE:
        case TUNTIL: {
                int got;
+
                n1 = stalloc(sizeof(struct nbinary));
                n1->type = (lasttoken == TWHILE)? NWHILE : NUNTIL;
                n1->nbinary.ch1 = list(0, 0);
@@ -375,7 +378,7 @@
                n1 = stalloc(sizeof(struct nfor));
                n1->type = NFOR;
                n1->nfor.var = wordtext;
-               if (readtoken() == TWORD && ! quoteflag && equal(wordtext, "in")) {
+               if (readtoken()==TWORD && !quoteflag && equal(wordtext,"in")) {
                        app = &ap;
                        while (readtoken() == TWORD) {
                                n2 = stalloc(sizeof(struct narg));
@@ -393,6 +396,7 @@
                        static char argvars[5] = {
                            CTLVAR, VSNORMAL|VSQUOTE, '@', '=', '\0'
                        };
+
                        n2 = stalloc(sizeof(struct narg));
                        n2->type = NARG;
                        n2->narg.text = argvars;
@@ -563,7 +567,7 @@
                n1->nredir.redirect = redir;
        }
 
-checkneg:
+ checkneg:
        if (negate) {
                TRACE(("%snegate command\n", (negate&1) ? "" : "double "));
                n2 = stalloc(sizeof(struct nnot));
@@ -638,7 +642,7 @@
        n->ncmd.args = args;
        n->ncmd.redirect = redir;
 
-checkneg:
+ checkneg:
        if (negate) {
                TRACE(("%snegate simplecmd\n", (negate&1) ? "" : "double "));
                n2 = stalloc(sizeof(struct nnot));
@@ -666,6 +670,7 @@
 void
 fixredir(union node *n, const char *text, int err)
 {
+
        TRACE(("Fix redir %s %d\n", text, err));
        if (!err)
                n->ndup.vname = NULL;
@@ -714,7 +719,7 @@
                 * the parser is, at the minute, is impossible to prevent.
                 * So, leave it like this until the rest of the parser is fixed.
                 */
-               if (! noexpand(wordtext))
+               if (!noexpand(wordtext))
                        synerror("Illegal eof marker for << redirection");
 
                rmescapes(wordtext);
@@ -744,6 +749,7 @@
 static int
 checkend(int c, char * const eofmark, const int striptabs)
 {
+
        if (striptabs) {
                while (c == '\t')
                        c = pgetc();
@@ -941,7 +947,8 @@
                                if (**pp == *wordtext && equal(*pp, wordtext)) {
                                        lasttoken = t = pp -
                                            parsekwd + KWDOFFSET;
-                                       TRACE(("keyword %s recognized\n", tokname[t]));
+                                       TRACE(("keyword %s recognized\n",
+                                           tokname[t]));
                                        goto out;
                                }
                        }
@@ -952,10 +959,11 @@
                                goto top;
                        }
                }
-out:
+ out:
                checkkwd = (t == TNOT) ? savecheckkwd : 0;
        }
-       TRACE(("%stoken %s %s\n", alreadyseen ? "reread " : "", tokname[t], t == TWORD ? wordtext : ""));
+       TRACE(("%stoken %s %s\n", alreadyseen ? "reread " : "",
+           tokname[t], t == TWORD ? wordtext : ""));
        return (t);
 }
 
@@ -1275,20 +1283,20 @@
        }
        handler = &jmploc;
        INTON;
-        if (oldstyle) {
-                /* We must read until the closing backquote, giving special
-                   treatment to some slashes, and then push the string and
-                   reread it as input, interpreting it normally.  */
-                int pc;
-                int psavelen;
-                char *pstr;
+       if (oldstyle) {
+               /* We must read until the closing backquote, giving special
+                  treatment to some slashes, and then push the string and
+                  reread it as input, interpreting it normally.  */
+               int pc;
+               int psavelen;
+               char *pstr;
 
                /*
                 * Because the entire `...` is read here, we don't
                 * need to bother the state stack.  That will be used
                 * (as appropriate) when the processed string is re-read.
                 */
-                STARTSTACKSTR(out);
+               STARTSTACKSTR(out);
                for (;;) {
                        if (needprompt) {
                                setprompt(2);
@@ -1299,7 +1307,7 @@
                                goto done;
 
                        case '\\':
-                                if ((pc = pgetc()) == '\n') {
+                               if ((pc = pgetc()) == '\n') {
                                        plinno++;
                                        if (doprompt)
                                                setprompt(2);
@@ -1313,9 +1321,9 @@
                                         */
                                        continue;
                                }
-                                if (pc != '\\' && pc != '`' && pc != '$'
-                                    && (!ISDBLQUOTE() || pc != '"'))
-                                        STPUTC('\\', out);
+                               if (pc != '\\' && pc != '`' && pc != '$'
+                                   && (!ISDBLQUOTE() || pc != '"'))
+                                       STPUTC('\\', out);
                                break;
 
                        case '\n':
@@ -1332,15 +1340,15 @@
                                break;
                        }
                        STPUTC(pc, out);
-                }
-done:
-                STPUTC('\0', out);
-                psavelen = out - stackblock();
-                if (psavelen > 0) {
+               }
+ done:
+               STPUTC('\0', out);
+               psavelen = out - stackblock();
+               if (psavelen > 0) {
                        pstr = grabstackstr(out);
                        setinputstring(pstr, 1);
-                }
-        }
+               }
+       }
        nlpp = pbqlist;
        while (*nlpp)
                nlpp = &(*nlpp)->next;
@@ -1366,12 +1374,12 @@
        }
 
        (*nlpp)->n = n;
-        if (oldstyle) {
+       if (oldstyle) {
                /*
                 * Start reading from old file again, ignoring any pushed back
                 * tokens left from the backquote parsing
                 */
-                popfile();
+               popfile();
                tokpushback = 0;
        }
 
@@ -1777,7 +1785,7 @@
                        c = pgetc_linecont();
                }
                else {
-badsub:
+ badsub:
                        cleanup_state_stack(stack);
                        synerror("Bad substitution");
                }



Home | Main Index | Thread Index | Old Index