Deleted Added
full compact
parser.c (214492) parser.c (214512)
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kenneth Almquist.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 22 unchanged lines hidden (view full) ---

31 */
32
33#ifndef lint
34#if 0
35static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
36#endif
37#endif /* not lint */
38#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kenneth Almquist.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 22 unchanged lines hidden (view full) ---

31 */
32
33#ifndef lint
34#if 0
35static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
36#endif
37#endif /* not lint */
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: head/bin/sh/parser.c 214492 2010-10-28 22:34:49Z jilles $");
39__FBSDID("$FreeBSD: head/bin/sh/parser.c 214512 2010-10-29 13:42:18Z jilles $");
40
41#include <stdlib.h>
42#include <unistd.h>
43#include <stdio.h>
44
45#include "shell.h"
46#include "parser.h"
47#include "nodes.h"

--- 1108 unchanged lines hidden (view full) ---

1156 state[level].syntax = initialsyntax;
1157 state[level].parenlevel = 0;
1158 state[level].category = TSTATE_TOP;
1159
1160 STARTSTACKSTR(out);
1161 loop: { /* for each line, until end of word */
1162 CHECKEND(); /* set c to PEOF if at end of here document */
1163 for (;;) { /* until end of line or end of word */
40
41#include <stdlib.h>
42#include <unistd.h>
43#include <stdio.h>
44
45#include "shell.h"
46#include "parser.h"
47#include "nodes.h"

--- 1108 unchanged lines hidden (view full) ---

1156 state[level].syntax = initialsyntax;
1157 state[level].parenlevel = 0;
1158 state[level].category = TSTATE_TOP;
1159
1160 STARTSTACKSTR(out);
1161 loop: { /* for each line, until end of word */
1162 CHECKEND(); /* set c to PEOF if at end of here document */
1163 for (;;) { /* until end of line or end of word */
1164 CHECKSTRSPACE(3, out); /* permit 3 calls to USTPUTC */
1164 CHECKSTRSPACE(4, out); /* permit 4 calls to USTPUTC */
1165
1166 synentry = state[level].syntax[c];
1167
1168 switch(synentry) {
1169 case CNL: /* '\n' */
1170 if (state[level].syntax == BASESYNTAX)
1171 goto endword; /* exit outer loop */
1172 USTPUTC(c, out);

--- 25 unchanged lines hidden (view full) ---

1198 setprompt(0);
1199 } else {
1200 if (state[level].syntax == DQSYNTAX &&
1201 c != '\\' && c != '`' && c != '$' &&
1202 (c != '"' || (eofmark != NULL &&
1203 newvarnest == 0)) &&
1204 (c != '}' || state[level].category != TSTATE_VAR_OLD))
1205 USTPUTC('\\', out);
1165
1166 synentry = state[level].syntax[c];
1167
1168 switch(synentry) {
1169 case CNL: /* '\n' */
1170 if (state[level].syntax == BASESYNTAX)
1171 goto endword; /* exit outer loop */
1172 USTPUTC(c, out);

--- 25 unchanged lines hidden (view full) ---

1198 setprompt(0);
1199 } else {
1200 if (state[level].syntax == DQSYNTAX &&
1201 c != '\\' && c != '`' && c != '$' &&
1202 (c != '"' || (eofmark != NULL &&
1203 newvarnest == 0)) &&
1204 (c != '}' || state[level].category != TSTATE_VAR_OLD))
1205 USTPUTC('\\', out);
1206 if ((eofmark == NULL ||
1207 newvarnest > 0) &&
1208 state[level].syntax == BASESYNTAX)
1209 USTPUTC(CTLQUOTEMARK, out);
1206 if (SQSYNTAX[c] == CCTL)
1207 USTPUTC(CTLESC, out);
1210 if (SQSYNTAX[c] == CCTL)
1211 USTPUTC(CTLESC, out);
1208 else if (eofmark == NULL ||
1209 newvarnest > 0)
1210 USTPUTC(CTLQUOTEMARK, out);
1211 USTPUTC(c, out);
1212 USTPUTC(c, out);
1213 if ((eofmark == NULL ||
1214 newvarnest > 0) &&
1215 state[level].syntax == BASESYNTAX &&
1216 state[level].category == TSTATE_VAR_OLD)
1217 USTPUTC(CTLQUOTEEND, out);
1212 quotef++;
1213 }
1214 break;
1215 case CSQUOTE:
1216 USTPUTC(CTLQUOTEMARK, out);
1217 state[level].syntax = SQSYNTAX;
1218 break;
1219 case CDQUOTE:
1220 USTPUTC(CTLQUOTEMARK, out);
1221 state[level].syntax = DQSYNTAX;
1222 break;
1223 case CENDQUOTE:
1224 if (eofmark != NULL && newvarnest == 0)
1225 USTPUTC(c, out);
1226 else {
1218 quotef++;
1219 }
1220 break;
1221 case CSQUOTE:
1222 USTPUTC(CTLQUOTEMARK, out);
1223 state[level].syntax = SQSYNTAX;
1224 break;
1225 case CDQUOTE:
1226 USTPUTC(CTLQUOTEMARK, out);
1227 state[level].syntax = DQSYNTAX;
1228 break;
1229 case CENDQUOTE:
1230 if (eofmark != NULL && newvarnest == 0)
1231 USTPUTC(c, out);
1232 else {
1233 if (state[level].category == TSTATE_VAR_OLD)
1234 USTPUTC(CTLQUOTEEND, out);
1227 state[level].syntax = BASESYNTAX;
1228 quotef++;
1229 }
1230 break;
1231 case CVAR: /* '$' */
1232 PARSESUB(); /* parse substitution */
1233 break;
1234 case CENDVAR: /* '}' */

--- 587 unchanged lines hidden ---
1235 state[level].syntax = BASESYNTAX;
1236 quotef++;
1237 }
1238 break;
1239 case CVAR: /* '$' */
1240 PARSESUB(); /* parse substitution */
1241 break;
1242 case CENDVAR: /* '}' */

--- 587 unchanged lines hidden ---