3 char *termchars = "\"'= \t"; /*used in parse.c to isolate assignment attribute*/
5 int IWS = ' '; /* inter-word separator in env */
8 * This file contains functions that depend on the shell's syntax. Most
9 * of the routines extract strings observing the shell's escape conventions.
14 * skip a token in quotes.
17 squote(char *cp, int c)
23 n = chartorune(&r, cp);
27 n += chartorune(&r, cp+n);
30 SYNERR(-1); /* should never occur */
31 fprint(2, "missing closing '\n");
35 * search a string for unescaped characters in a pattern set
38 charin(char *cp, char *pat)
45 n = chartorune(&r, cp);
47 case '\\': /* skip escaped char */
49 n = chartorune(&r, cp);
51 case '\'': /* skip quoted string */
53 cp = squote(cp+1, r); /* n must = 1 */
64 else if(utfrune(pat, r))
68 if(vargen == 0 && utfrune(pat, r))
76 fprint(2, "missing closing } in pattern generator\n");
82 * extract an escaped token. Possible escape chars are single-quote,
83 * double-quote,and backslash.
86 expandquote(char *s, Rune esc, Bufblock *b)
91 s += chartorune(&r, s);
97 s += chartorune(&r, s);
102 s += chartorune(&r, s);
110 * Input an escaped token. Possible escape chars are single-quote,
111 * double-quote and backslash.
114 escapetoken(Biobuf *bp, Bufblock *buf, int preserve, int esc)
129 while((c = nextrune(bp, 0)) >= 0){
147 SYNERR(line); fprint(2, "missing closing %c\n", esc);
152 * copy a quoted string; s points to char after opening quote
155 copysingle(char *s, Rune q, Bufblock *buf)
160 s += chartorune(&r, s);
168 * check for quoted strings. backquotes are handled here; single quotes above.
169 * s points to char after opening quote, q.
172 copyq(char *s, Rune q, Bufblock *buf)
174 if(q == '\'' || q == '"') /* copy quoted string */
175 return copysingle(s, q, buf);
177 if(q != '`') /* not quoted */
180 while(*s){ /* copy backquoted string */
181 s += chartorune(&q, s);
185 if(q == '\'' || q == '"')
186 s = copysingle(s, q, buf); /* copy quoted string */