Ignore:
Timestamp:
Oct 7, 2007, 1:57:35 AM (18 years ago)
Author:
bird
Message:

input.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/parser.c

    r1199 r1201  
    209209                                parseheredoc();
    210210                        else
    211                                 pungetc();              /* push back EOF on input */
     211                                pungetc(psh);           /* push back EOF on input */
    212212                        return n1;
    213213                default:
     
    661661                if (! noexpand(wordtext) || (i = strlen(wordtext)) == 0 || i > EOFMARKLEN)
    662662                        synerror("Illegal eof marker for << redirection");
    663                 rmescapes(wordtext);
     663                rmescapes(psh, wordtext);
    664664                here->eofmark = wordtext;
    665665                here->next = NULL;
     
    695695                        needprompt = 0;
    696696                }
    697                 readtoken1(pgetc(), here->here->type == NHERE? SQSYNTAX : DQSYNTAX,
     697                readtoken1(pgetc(psh), here->here->type == NHERE? SQSYNTAX : DQSYNTAX,
    698698                                here->eofmark, here->striptabs);
    699699                n = (union node *)stalloc(psh, sizeof (struct narg));
     
    759759                        if(!noalias &&
    760760                            (ap = lookupalias(psh, wordtext, 1)) != NULL) {
    761                                 pushstring(ap->val, strlen(ap->val), ap);
     761                                pushstring(psh, ap->val, strlen(ap->val), ap);
    762762                                checkkwd = savecheckkwd;
    763763                                goto top;
     
    812812        startlinno = plinno;
    813813        for (;;) {      /* until token or start of word found */
    814                 c = pgetc_macro();
     814                c = pgetc_macro(psh);
    815815                if (c == ' ' || c == '\t')
    816816                        continue;               /* quick check for white space first */
     
    819819                        continue;
    820820                case '#':
    821                         while ((c = pgetc()) != '\n' && c != PEOF);
    822                         pungetc();
     821                        while ((c = pgetc(psh)) != '\n' && c != PEOF);
     822                        pungetc(psh);
    823823                        continue;
    824824                case '\\':
    825                         if (pgetc() == '\n') {
     825                        if (pgetc(psh) == '\n') {
    826826                                startlinno = ++plinno;
    827827                                if (doprompt)
     
    831831                                continue;
    832832                        }
    833                         pungetc();
     833                        pungetc(psh);
    834834                        goto breakloop;
    835835                case '\n':
     
    840840                        RETURN(TEOF);
    841841                case '&':
    842                         if (pgetc() == '&')
     842                        if (pgetc(psh) == '&')
    843843                                RETURN(TAND);
    844                         pungetc();
     844                        pungetc(psh);
    845845                        RETURN(TBACKGND);
    846846                case '|':
    847                         if (pgetc() == '|')
     847                        if (pgetc(psh) == '|')
    848848                                RETURN(TOR);
    849                         pungetc();
     849                        pungetc(psh);
    850850                        RETURN(TPIPE);
    851851                case ';':
    852                         if (pgetc() == ';')
     852                        if (pgetc(psh) == ';')
    853853                                RETURN(TENDCASE);
    854                         pungetc();
     854                        pungetc(psh);
    855855                        RETURN(TSEMI);
    856856                case '(':
     
    961961                        if (syntax == BASESYNTAX)
    962962                                return readtoken();
    963                         c = pgetc();
     963                        c = pgetc(psh);
    964964                        goto loop;
    965965                }
     
    978978                                else
    979979                                        setprompt(0);
    980                                 c = pgetc();
     980                                c = pgetc(psh);
    981981                                goto loop;              /* continue outer loop */
    982982                        case CWORD:
     
    989989                                break;
    990990                        case CBACK:     /* backslash */
    991                                 c = pgetc();
     991                                c = pgetc(psh);
    992992                                if (c == PEOF) {
    993993                                        USTPUTC(psh, '\\', out);
    994                                         pungetc();
     994                                        pungetc(psh);
    995995                                        break;
    996996                                }
     
    10931093                                        --parenlevel;
    10941094                                } else {
    1095                                         if (pgetc() == ')') {
     1095                                        if (pgetc(psh) == ')') {
    10961096                                                if (--arinest == 0) {
    10971097                                                        USTPUTC(psh, CTLENDARI, out);
     
    11081108                                                 *  (don't 2nd guess - no error)
    11091109                                                 */
    1110                                                 pungetc();
     1110                                                pungetc(psh);
    11111111                                                USTPUTC(psh, ')', out);
    11121112                                        }
     
    11231123                                USTPUTC(psh, c, out);
    11241124                        }
    1125                         c = pgetc_macro();
     1125                        c = pgetc_macro(psh);
    11261126                }
    11271127        }
     
    11471147                        return lasttoken = TREDIR;
    11481148                } else {
    1149                         pungetc();
     1149                        pungetc(psh);
    11501150                }
    11511151        }
     
    11711171                if (striptabs) {
    11721172                        while (c == '\t')
    1173                                 c = pgetc();
     1173                                c = pgetc(psh);
    11741174                }
    11751175                if (c == *eofmark) {
    1176                         if (pfgets(line, sizeof line) != NULL) {
     1176                        if (pfgets(psh, line, sizeof line) != NULL) {
    11771177                                char *p, *q;
    11781178
     
    11841184                                        needprompt = doprompt;
    11851185                                } else {
    1186                                         pushstring(line, strlen(line), NULL);
     1186                                        pushstring(psh, line, strlen(line), NULL);
    11871187                                }
    11881188                        }
     
    12061206        if (c == '>') {
    12071207                np->nfile.fd = 1;
    1208                 c = pgetc();
     1208                c = pgetc(psh);
    12091209                if (c == '>')
    12101210                        np->type = NAPPEND;
     
    12151215                else {
    12161216                        np->type = NTO;
    1217                         pungetc();
     1217                        pungetc(psh);
    12181218                }
    12191219        } else {        /* c == '<' */
    12201220                np->nfile.fd = 0;
    1221                 switch (c = pgetc()) {
     1221                switch (c = pgetc(psh)) {
    12221222                case '<':
    12231223                        if (sizeof (struct nfile) != sizeof (struct nhere)) {
     
    12281228                        heredoc = (struct heredoc *)stalloc(psh, sizeof (struct heredoc));
    12291229                        heredoc->here = np;
    1230                         if ((c = pgetc()) == '-') {
     1230                        if ((c = pgetc(psh)) == '-') {
    12311231                                heredoc->striptabs = 1;
    12321232                        } else {
    12331233                                heredoc->striptabs = 0;
    1234                                 pungetc();
     1234                                pungetc(psh);
    12351235                        }
    12361236                        break;
     
    12461246                default:
    12471247                        np->type = NFROM;
    1248                         pungetc();
     1248                        pungetc(psh);
    12491249                        break;
    12501250                }
     
    12691269        static const char types[] = "}-+?=";
    12701270
    1271         c = pgetc();
     1271        c = pgetc(psh);
    12721272        if (c != '(' && c != OPENBRACE && !is_name(c) && !is_special(c)) {
    12731273                USTPUTC(psh, '$', out);
    1274                 pungetc();
     1274                pungetc(psh);
    12751275        } else if (c == '(') {  /* $(command) or $((arith)) */
    1276                 if (pgetc() == '(') {
     1276                if (pgetc(psh) == '(') {
    12771277                        PARSEARITH();
    12781278                } else {
    1279                         pungetc();
     1279                        pungetc(psh);
    12801280                        PARSEBACKQNEW();
    12811281                }
     
    12861286                subtype = VSNORMAL;
    12871287                if (c == OPENBRACE) {
    1288                         c = pgetc();
     1288                        c = pgetc(psh);
    12891289                        if (c == '#') {
    1290                                 if ((c = pgetc()) == CLOSEBRACE)
     1290                                if ((c = pgetc(psh)) == CLOSEBRACE)
    12911291                                        c = '#';
    12921292                                else
     
    12991299                        do {
    13001300                                STPUTC(psh, c, out);
    1301                                 c = pgetc();
     1301                                c = pgetc(psh);
    13021302                        } while (is_in_name(c));
    13031303                } else if (is_digit(c)) {
    13041304                        do {
    13051305                                USTPUTC(psh, c, out);
    1306                                 c = pgetc();
     1306                                c = pgetc(psh);
    13071307                        } while (is_digit(c));
    13081308                }
    13091309                else if (is_special(c)) {
    13101310                        USTPUTC(psh, c, out);
    1311                         c = pgetc();
     1311                        c = pgetc(psh);
    13121312                }
    13131313                else
     
    13201320                        case ':':
    13211321                                flags = VSNUL;
    1322                                 c = pgetc();
     1322                                c = pgetc(psh);
    13231323                                /*FALLTHROUGH*/
    13241324                        default:
     
    13341334                                        subtype = c == '#' ? VSTRIMLEFT :
    13351335                                                             VSTRIMRIGHT;
    1336                                         c = pgetc();
     1336                                        c = pgetc(psh);
    13371337                                        if (c == cc)
    13381338                                                subtype++;
    13391339                                        else
    1340                                                 pungetc();
     1340                                                pungetc(psh);
    13411341                                        break;
    13421342                                }
    13431343                        }
    13441344                } else {
    1345                         pungetc();
     1345                        pungetc(psh);
    13461346                }
    13471347                if (ISDBLQUOTE() || arinest)
     
    14151415                                needprompt = 0;
    14161416                        }
    1417                         switch (pc = pgetc()) {
     1417                        switch (pc = pgetc(psh)) {
    14181418                        case '`':
    14191419                                goto done;
    14201420
    14211421                        case '\\':
    1422                                 if ((pc = pgetc()) == '\n') {
     1422                                if ((pc = pgetc(psh)) == '\n') {
    14231423                                        plinno++;
    14241424                                        if (doprompt)
     
    14591459                if (psavelen > 0) {
    14601460                        pstr = grabstackstr(psh, pout);
    1461                         setinputstring(pstr, 1);
     1461                        setinputstring(psh, pstr, 1);
    14621462                }
    14631463        }
     
    14891489                 * tokens left from the backquote parsing
    14901490                 */
    1491                 popfile();
     1491                popfile(psh);
    14921492                tokpushback = 0;
    14931493        }
     
    16291629setprompt(int which)
    16301630{
    1631         whichprompt = which;
     1631        psh->whichprompt = which;
    16321632
    16331633#ifndef SMALL
     
    16441644getprompt(void *unused)
    16451645        {
    1646         switch (whichprompt) {
     1646        switch (psh->whichprompt) {
    16471647        case 0:
    16481648                return "";
Note: See TracChangeset for help on using the changeset viewer.