4
* This file contains functions that depend on rc's syntax. Most
5
* of the routines extract strings observing rc's escape conventions
10
* skip a token in single quotes.
19
n = chartorune(&r, cp);
21
n += chartorune(&r, cp+n);
27
SYNERR(-1); /* should never occur */
28
fprint(2, "missing closing '\n");
33
* search a string for characters in a pattern set
34
* characters in quotes and variable generators are escaped
37
rccharin(char *cp, char *pat)
44
n = chartorune(&r, cp);
46
case '\'': /* skip quoted string */
47
cp = squote(cp+1); /* n must = 1 */
58
else if(utfrune(pat, r))
62
if(vargen == 0 && utfrune(pat, r))
70
fprint(2, "missing closing } in pattern generator\n");
76
* extract an escaped token. Possible escape chars are single-quote,
77
* double-quote,and backslash. Only the first is valid for rc. the
78
* others are just inserted into the receiving buffer.
81
rcexpandquote(char *s, Rune r, Bufblock *b)
89
s += chartorune(&r, s);
102
* Input an escaped token. Possible escape chars are single-quote,
103
* double-quote and backslash. Only the first is a valid escape for
104
* rc; the others are just inserted into the receiving buffer.
107
rcescapetoken(Biobuf *bp, Bufblock *buf, int preserve, int esc)
115
while((c = nextrune(bp, 0)) > 0){
129
SYNERR(line); fprint(2, "missing closing %c\n", esc);
134
* copy a single-quoted string; s points to char after opening quote
137
copysingle(char *s, Bufblock *buf)
142
s += chartorune(&r, s);
150
* check for quoted strings. backquotes are handled here; single quotes above.
151
* s points to char after opening quote, q.
154
rccopyq(char *s, Rune q, Bufblock *buf)
156
if(q == '\'') /* copy quoted string */
157
return copysingle(s, buf);
159
if(q != '`') /* not quoted */
162
while(*s){ /* copy backquoted string */
163
s += chartorune(&q, s);
168
s = copysingle(s, buf); /* copy quoted string */
174
rcmatchname(char *name)
178
if((p = strchr(name, '/')) != nil)
180
if(name[0] == 'r' && name[1] == 'c')