3 char *termchars = "'= \t"; /*used in parse.c to isolate assignment attribute*/
4 char *shflags = "-I"; /* rc flag to force non-interactive mode */
5 int IWS = '\1'; /* inter-word separator in env - not used in plan 9 */
8 * This file contains functions that depend on rc's syntax. Most
9 * of the routines extract strings observing rc's escape conventions
14 * skip a token in single quotes.
23 n = chartorune(&r, cp);
25 n += chartorune(&r, cp+n);
31 SYNERR(-1); /* should never occur */
32 fprint(2, "missing closing '\n");
37 * search a string for characters in a pattern set
38 * characters in quotes and variable generators are escaped
41 charin(char *cp, char *pat)
48 n = chartorune(&r, cp);
50 case '\'': /* skip quoted string */
51 cp = squote(cp+1); /* n must = 1 */
62 else if(utfrune(pat, r))
66 if(vargen == 0 && utfrune(pat, r))
74 fprint(2, "missing closing } in pattern generator\n");
80 * extract an escaped token. Possible escape chars are single-quote,
81 * double-quote,and backslash. Only the first is valid for rc. the
82 * others are just inserted into the receiving buffer.
85 expandquote(char *s, Rune r, Bufblock *b)
93 s += chartorune(&r, s);
106 * Input an escaped token. Possible escape chars are single-quote,
107 * double-quote and backslash. Only the first is a valid escape for
108 * rc; the others are just inserted into the receiving buffer.
111 escapetoken(Biobuf *bp, Bufblock *buf, int preserve, int esc)
119 while((c = nextrune(bp, 0)) > 0){
133 SYNERR(line); fprint(2, "missing closing %c\n", esc);
138 * copy a single-quoted string; s points to char after opening quote
141 copysingle(char *s, Bufblock *buf)
146 s += chartorune(&r, s);
154 * check for quoted strings. backquotes are handled here; single quotes above.
155 * s points to char after opening quote, q.
158 copyq(char *s, Rune q, Bufblock *buf)
160 if(q == '\'') /* copy quoted string */
161 return copysingle(s, buf);
163 if(q != '`') /* not quoted */
166 while(*s){ /* copy backquoted string */
167 s += chartorune(&q, s);
172 s = copysingle(s, buf); /* copy quoted string */