~ubuntu-branches/ubuntu/intrepid/dash/intrepid-updates

« back to all changes in this revision

Viewing changes to src/parser.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-07-18 15:38:47 UTC
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20070718153847-z900khc1ukawd3r7
Tags: upstream-0.5.4
ImportĀ upstreamĀ versionĀ 0.5.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 * SUCH DAMAGE.
33
33
 */
34
34
 
 
35
#include <alloca.h>
35
36
#include <stdlib.h>
36
37
 
37
38
#include "shell.h"
38
39
#include "parser.h"
39
40
#include "nodes.h"
40
41
#include "expand.h"     /* defines rmescapes() */
41
 
#include "redir.h"      /* defines copyfd() */
42
42
#include "exec.h"       /* defines find_builtin() */
43
43
#include "syntax.h"
44
44
#include "options.h"
76
76
 
77
77
 
78
78
struct heredoc *heredoclist;    /* list of here documents to read */
79
 
int parsebackquote;             /* nonzero if we are inside backquotes */
80
79
int doprompt;                   /* if set, prompt the user */
81
80
int needprompt;                 /* true if interactive and at start of line */
82
81
int lasttoken;                  /* last token read */
847
846
        int dqvarnest;  /* levels of variables expansion within double quotes */
848
847
        int oldstyle;
849
848
        char const *prevsyntax; /* syntax before arithmetic */
850
 
#if __GNUC__
851
 
        /* Avoid longjmp clobbering */
852
 
        (void) &out;
853
 
        (void) &quotef;
854
 
        (void) &dblquote;
855
 
        (void) &varnest;
856
 
        (void) &arinest;
857
 
        (void) &parenlevel;
858
 
        (void) &dqvarnest;
859
 
        (void) &oldstyle;
860
 
        (void) &prevsyntax;
861
 
        (void) &syntax;
862
 
#endif
863
849
 
864
850
        startlinno = plinno;
865
851
        dblquote = 0;
1019
1005
endword:
1020
1006
        if (syntax == ARISYNTAX)
1021
1007
                synerror("Missing '))'");
1022
 
        if (syntax != BASESYNTAX && ! parsebackquote && eofmark == NULL)
 
1008
        if (syntax != BASESYNTAX && eofmark == NULL)
1023
1009
                synerror("Unterminated quoted string");
1024
1010
        if (varnest != 0) {
1025
1011
                startlinno = plinno;
1263
1249
 
1264
1250
parsebackq: {
1265
1251
        struct nodelist **nlpp;
1266
 
        int savepbq;
1267
1252
        union node *n;
1268
 
        char *volatile str;
1269
 
        struct jmploc jmploc;
1270
 
        struct jmploc *volatile savehandler;
 
1253
        char *str;
1271
1254
        size_t savelen;
1272
1255
        int saveprompt;
1273
 
#ifdef __GNUC__
1274
 
        (void) &saveprompt;
1275
 
#endif
1276
1256
 
1277
 
        savepbq = parsebackquote;
1278
 
        if (setjmp(jmploc.loc)) {
1279
 
                if (str)
1280
 
                        ckfree(str);
1281
 
                parsebackquote = 0;
1282
 
                handler = savehandler;
1283
 
                longjmp(handler->loc, 1);
1284
 
        }
1285
 
        INTOFF;
1286
1257
        str = NULL;
1287
1258
        savelen = out - (char *)stackblock();
1288
1259
        if (savelen > 0) {
1289
 
                str = ckmalloc(savelen);
 
1260
                str = alloca(savelen);
1290
1261
                memcpy(str, stackblock(), savelen);
1291
1262
        }
1292
 
        savehandler = handler;
1293
 
        handler = &jmploc;
1294
 
        INTON;
1295
1263
        if (oldstyle) {
1296
1264
                /* We must read until the closing backquote, giving special
1297
1265
                   treatment to some slashes, and then push the string and
1360
1328
                nlpp = &(*nlpp)->next;
1361
1329
        *nlpp = (struct nodelist *)stalloc(sizeof (struct nodelist));
1362
1330
        (*nlpp)->next = NULL;
1363
 
        parsebackquote = oldstyle;
1364
1331
 
1365
1332
        if (oldstyle) {
1366
1333
                saveprompt = doprompt;
1391
1358
        if (str) {
1392
1359
                memcpy(out, str, savelen);
1393
1360
                STADJUST(savelen, out);
1394
 
                INTOFF;
1395
 
                ckfree(str);
1396
 
                str = NULL;
1397
 
                INTON;
1398
1361
        }
1399
 
        parsebackquote = savepbq;
1400
 
        handler = savehandler;
1401
1362
        if (arinest || dblquote)
1402
1363
                USTPUTC(CTLBACKQ | CTLQUOTE, out);
1403
1364
        else
1452
1413
noexpand(char *text)
1453
1414
{
1454
1415
        char *p;
1455
 
        char c;
 
1416
        signed char c;
1456
1417
 
1457
1418
        p = text;
1458
1419
        while ((c = *p++) != '\0') {