30 if(r && utfrune("0123456789+-/$.#,;", r)!=nil)
36 * quite hard: could be almost anything but white space, but we are a little conservative,
37 * aiming for regular expressions of alphanumerics and no white space
46 if(utfrune("^+-.*?#,;[]()$", r)!=nil)
52 number(Mntdir *md, Text *t, Range r, int line, int dir, int size, int *evalp)
64 if(line<0 || line>t->file->nc)
67 return (Range){line, line};
76 while(line>0 && q1<t->file->nc)
77 if(textreadc(t, q1++) == '\n' || q1==t->file->nc)
85 while(q1<t->file->nc && textreadc(t, q1-1) != '\n')
91 while(q0>0 && textreadc(t, q0-1)!='\n')
94 while(line>0 && q0>0){
95 if(textreadc(t, q0-1) == '\n'){
101 /* :1-1 is :0 = #0, but :1-2 is an error */
104 while(q0>0 && textreadc(t, q0-1)!='\n')
108 return (Range){q0, q1};
112 warning(nil, "address out of range\n");
119 regexp(Mntdir *md, Text *t, Range lim, Range r, Rune *pat, int dir, int *foundp)
125 if(pat[0] == '\0' && rxnull()){
126 warning(md, "no previous regular expression\n");
130 if(pat[0] && rxcompile(pat) == FALSE){
135 found = rxbexecute(t, r.q0, &sel);
141 found = rxexecute(t, nil, r.q1, q, &sel);
143 if(!found && md==nil)
144 warning(nil, "no match for regexp\n");
150 address(Mntdir *md, Text *t, Range lim, Range ar, void *a, uint q0, uint q1, int (*getc)(void*, uint), int *evalp, uint *qp)
174 if(prevc == 0) /* lhs defaults to 0 */
176 if(q>=q1 && t!=nil && t->file!=nil) /* rhs defaults to $ */
179 nr = address(md, t, lim, ar, a, q, q1, getc, evalp, &q);
186 if(*evalp && (prevc=='+' || prevc=='-'))
187 if((nc=(*getc)(a, q))!='#' && nc!='/' && nc!='?')
188 r = number(md, t, r, 1, prevc, Line, evalp); /* do previous one */
201 r = (Range){t->file->nc, t->file->nc};
208 if(q==q1 || (c=(*getc)(a, q++))<'0' || '9'<c){
214 case '0': case '1': case '2': case '3': case '4':
215 case '5': case '6': case '7': case '8': case '9':
226 r = number(md, t, r, n, dir, size, evalp);
243 pat = runerealloc(pat, npat+1);
252 pat = runerealloc(pat, npat+1);
256 pat = runerealloc(pat, npat+1);
259 r = regexp(md, t, lim, r, pat, dir, evalp);
266 if(*evalp && dir != None)
267 r = number(md, t, r, 1, dir, Line, evalp); /* do previous one */