-/* number of characters left in input buffer */
-static int parsenleft; /* copy of parsefile->nleft */
-static int parselleft; /* copy of parsefile->lleft */
-
-/* next character in input buffer */
-static char *parsenextc; /* copy of parsefile->nextc */
-
-#define basebuf bb_common_bufsiz1 /* buffer for top level input file */
-
-static int tokpushback; /* last token pushed back */
-#define NEOF ((union node *)&tokpushback)
-static int parsebackquote; /* nonzero if we are inside backquotes */
-static int lasttoken; /* last token read */
-static char *wordtext; /* text of last word returned by readtoken */
-static int checkkwd;
-static struct nodelist *backquotelist;
-static union node *redirnode;
-static struct heredoc *heredoc;
-static int quoteflag; /* set if (part of) last token was quoted */
-
-static void fixredir(union node *, const char *, int);
-
-
-/* shell.h */
-
-static const char spcstr[] = " ";
-static const char dolatstr[] = { CTLVAR, VSNORMAL|VSQUOTE, '@', '=', '\0' };
-
-#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
-#define __builtin_expect(x, expected_value) (x)
-#endif
-
-#define xlikely(x) __builtin_expect((x),1)
-
-#define TEOF 0
-#define TNL 1
-#define TREDIR 2
-#define TWORD 3
-#define TSEMI 4
-#define TBACKGND 5
-#define TAND 6
-#define TOR 7
-#define TPIPE 8
-#define TLP 9
-#define TRP 10
-#define TENDCASE 11
-#define TENDBQUOTE 12
-#define TNOT 13
-#define TCASE 14
-#define TDO 15
-#define TDONE 16
-#define TELIF 17
-#define TELSE 18
-#define TESAC 19
-#define TFI 20
-#define TFOR 21
-#define TIF 22
-#define TIN 23
-#define TTHEN 24
-#define TUNTIL 25
-#define TWHILE 26
-#define TBEGIN 27
-#define TEND 28
-
-/* first char is indicating which tokens mark the end of a list */
-static const char *const tokname_array[] = {
- "\1end of file",
- "\0newline",
- "\0redirection",
- "\0word",
- "\0;",
- "\0&",
- "\0&&",
- "\0||",
- "\0|",
- "\0(",
- "\1)",
- "\1;;",
- "\1`",
-#define KWDOFFSET 13
- /* the following are keywords */
- "\0!",
- "\0case",
- "\1do",
- "\1done",
- "\1elif",
- "\1else",
- "\1esac",
- "\1fi",
- "\0for",
- "\0if",
- "\0in",
- "\1then",
- "\0until",
- "\0while",
- "\0{",
- "\1}",
-};
-
-static const char *
-tokname(int tok)
-{
- static char buf[16];
-
- if (tok >= TSEMI)
- buf[0] = '"';
- sprintf(buf + (tok >= TSEMI), "%s%c",
- tokname_array[tok] + 1, (tok >= TSEMI ? '"' : 0));
- return buf;
-}
-
-/* Wrapper around strcmp for qsort/bsearch/... */
-static int
-pstrcmp(const void *a, const void *b)
-{
- return strcmp((const char *) a, (*(const char *const *) b) + 1);
-}
-
-static const char *const *
-findkwd(const char *s)
-{
- return bsearch(s, tokname_array + KWDOFFSET,
- (sizeof(tokname_array) / sizeof(const char *)) - KWDOFFSET,
- sizeof(const char *), pstrcmp);
-}
-
-/* Syntax classes */
-#define CWORD 0 /* character is nothing special */
-#define CNL 1 /* newline character */
-#define CBACK 2 /* a backslash character */
-#define CSQUOTE 3 /* single quote */
-#define CDQUOTE 4 /* double quote */
-#define CENDQUOTE 5 /* a terminating quote */
-#define CBQUOTE 6 /* backwards single quote */
-#define CVAR 7 /* a dollar sign */
-#define CENDVAR 8 /* a '}' character */
-#define CLP 9 /* a left paren in arithmetic */
-#define CRP 10 /* a right paren in arithmetic */
-#define CENDFILE 11 /* end of file */
-#define CCTL 12 /* like CWORD, except it must be escaped */
-#define CSPCL 13 /* these terminate a word */
-#define CIGN 14 /* character should be ignored */
-
-#if ENABLE_ASH_ALIAS
-#define SYNBASE 130
-#define PEOF -130
-#define PEOA -129
-#define PEOA_OR_PEOF PEOA
-#else
-#define SYNBASE 129
-#define PEOF -129
-#define PEOA_OR_PEOF PEOF
-#endif
-
-/* C99 say: "char" declaration may be signed or unsigned default */
-#define SC2INT(chr2may_be_negative_int) (int)((signed char)chr2may_be_negative_int)
-
-/*
- * is_special(c) evaluates to 1 for c in "!#$*-0123456789?@"; 0 otherwise
- * (assuming ascii char codes, as the original implementation did)
- */
-#define is_special(c) \
- ( (((unsigned int)c) - 33 < 32) \
- && ((0xc1ff920dUL >> (((unsigned int)c) - 33)) & 1))
-
-#if ENABLE_ASH_OPTIMIZE_FOR_SIZE
-#define USE_SIT_FUNCTION
-#endif
-
-/* number syntax index */
-#define BASESYNTAX 0 /* not in quotes */
-#define DQSYNTAX 1 /* in double quotes */
-#define SQSYNTAX 2 /* in single quotes */
-#define ARISYNTAX 3 /* in arithmetic */
-
-#if ENABLE_ASH_MATH_SUPPORT
-static const char S_I_T[][4] = {
-#if ENABLE_ASH_ALIAS
- {CSPCL, CIGN, CIGN, CIGN}, /* 0, PEOA */
-#endif
- {CSPCL, CWORD, CWORD, CWORD}, /* 1, ' ' */
- {CNL, CNL, CNL, CNL}, /* 2, \n */
- {CWORD, CCTL, CCTL, CWORD}, /* 3, !*-/:=?[]~ */
- {CDQUOTE, CENDQUOTE, CWORD, CWORD}, /* 4, '"' */
- {CVAR, CVAR, CWORD, CVAR}, /* 5, $ */
- {CSQUOTE, CWORD, CENDQUOTE, CWORD}, /* 6, "'" */
- {CSPCL, CWORD, CWORD, CLP}, /* 7, ( */
- {CSPCL, CWORD, CWORD, CRP}, /* 8, ) */
- {CBACK, CBACK, CCTL, CBACK}, /* 9, \ */
- {CBQUOTE, CBQUOTE, CWORD, CBQUOTE}, /* 10, ` */
- {CENDVAR, CENDVAR, CWORD, CENDVAR}, /* 11, } */
-#ifndef USE_SIT_FUNCTION
- {CENDFILE, CENDFILE, CENDFILE, CENDFILE}, /* 12, PEOF */
- {CWORD, CWORD, CWORD, CWORD}, /* 13, 0-9A-Za-z */
- {CCTL, CCTL, CCTL, CCTL} /* 14, CTLESC ... */
-#endif
-};
-#else
-static const char S_I_T[][3] = {
-#if ENABLE_ASH_ALIAS
- {CSPCL, CIGN, CIGN}, /* 0, PEOA */
-#endif
- {CSPCL, CWORD, CWORD}, /* 1, ' ' */
- {CNL, CNL, CNL}, /* 2, \n */
- {CWORD, CCTL, CCTL}, /* 3, !*-/:=?[]~ */
- {CDQUOTE, CENDQUOTE, CWORD}, /* 4, '"' */
- {CVAR, CVAR, CWORD}, /* 5, $ */
- {CSQUOTE, CWORD, CENDQUOTE}, /* 6, "'" */
- {CSPCL, CWORD, CWORD}, /* 7, ( */
- {CSPCL, CWORD, CWORD}, /* 8, ) */
- {CBACK, CBACK, CCTL}, /* 9, \ */
- {CBQUOTE, CBQUOTE, CWORD}, /* 10, ` */
- {CENDVAR, CENDVAR, CWORD}, /* 11, } */
-#ifndef USE_SIT_FUNCTION
- {CENDFILE, CENDFILE, CENDFILE}, /* 12, PEOF */
- {CWORD, CWORD, CWORD}, /* 13, 0-9A-Za-z */
- {CCTL, CCTL, CCTL} /* 14, CTLESC ... */
-#endif
-};
-#endif /* ASH_MATH_SUPPORT */
-
-#ifdef USE_SIT_FUNCTION
-
-#define U_C(c) ((unsigned char)(c))
-
-static int
-SIT(int c, int syntax)
-{
- static const char spec_symbls[] = "\t\n !\"$&'()*-/:;<=>?[\\]`|}~";
-#if ENABLE_ASH_ALIAS
- static const char syntax_index_table[] = {
- 1, 2, 1, 3, 4, 5, 1, 6, /* "\t\n !\"$&'" */
- 7, 8, 3, 3, 3, 3, 1, 1, /* "()*-/:;<" */
- 3, 1, 3, 3, 9, 3, 10, 1, /* "=>?[\\]`|" */
- 11, 3 /* "}~" */
- };
-#else
- static const char syntax_index_table[] = {
- 0, 1, 0, 2, 3, 4, 0, 5, /* "\t\n !\"$&'" */
- 6, 7, 2, 2, 2, 2, 0, 0, /* "()*-/:;<" */
- 2, 0, 2, 2, 8, 2, 9, 0, /* "=>?[\\]`|" */
- 10, 2 /* "}~" */
- };
-#endif
- const char *s;
- int indx;
-
- if (c == PEOF) /* 2^8+2 */
- return CENDFILE;
-#if ENABLE_ASH_ALIAS
- if (c == PEOA) /* 2^8+1 */
- indx = 0;
- else
-#endif
- if (U_C(c) >= U_C(CTLESC) && U_C(c) <= U_C(CTLQUOTEMARK))
- return CCTL;
- else {
- s = strchr(spec_symbls, c);
- if (s == NULL || *s == '\0')
- return CWORD;
- indx = syntax_index_table[(s - spec_symbls)];
- }
- return S_I_T[indx][syntax];
-}
-
-#else /* USE_SIT_FUNCTION */
-
-#define SIT(c, syntax) S_I_T[(int)syntax_index_table[((int)c)+SYNBASE]][syntax]
-
-#if ENABLE_ASH_ALIAS
-#define CSPCL_CIGN_CIGN_CIGN 0
-#define CSPCL_CWORD_CWORD_CWORD 1
-#define CNL_CNL_CNL_CNL 2
-#define CWORD_CCTL_CCTL_CWORD 3
-#define CDQUOTE_CENDQUOTE_CWORD_CWORD 4
-#define CVAR_CVAR_CWORD_CVAR 5
-#define CSQUOTE_CWORD_CENDQUOTE_CWORD 6
-#define CSPCL_CWORD_CWORD_CLP 7
-#define CSPCL_CWORD_CWORD_CRP 8
-#define CBACK_CBACK_CCTL_CBACK 9
-#define CBQUOTE_CBQUOTE_CWORD_CBQUOTE 10
-#define CENDVAR_CENDVAR_CWORD_CENDVAR 11
-#define CENDFILE_CENDFILE_CENDFILE_CENDFILE 12
-#define CWORD_CWORD_CWORD_CWORD 13
-#define CCTL_CCTL_CCTL_CCTL 14
-#else
-#define CSPCL_CWORD_CWORD_CWORD 0
-#define CNL_CNL_CNL_CNL 1
-#define CWORD_CCTL_CCTL_CWORD 2
-#define CDQUOTE_CENDQUOTE_CWORD_CWORD 3
-#define CVAR_CVAR_CWORD_CVAR 4
-#define CSQUOTE_CWORD_CENDQUOTE_CWORD 5
-#define CSPCL_CWORD_CWORD_CLP 6
-#define CSPCL_CWORD_CWORD_CRP 7
-#define CBACK_CBACK_CCTL_CBACK 8
-#define CBQUOTE_CBQUOTE_CWORD_CBQUOTE 9
-#define CENDVAR_CENDVAR_CWORD_CENDVAR 10
-#define CENDFILE_CENDFILE_CENDFILE_CENDFILE 11
-#define CWORD_CWORD_CWORD_CWORD 12
-#define CCTL_CCTL_CCTL_CCTL 13
-#endif