diff options
author | ben <ben@rana> | 2016-04-26 22:23:44 -0500 |
---|---|---|
committer | ben <ben@rana> | 2016-04-26 22:23:44 -0500 |
commit | 0a460e1722c50e31653359f8a86fe0b606d2b513 (patch) | |
tree | b5a00bbfc883aa98709db012e0a7bacc67e234af /sys/src/cmd/awk/re.c | |
parent | 651d6c2bc68e7e5224c3ba41b094e37b1c1890ed (diff) |
New libregexp and APE ported to native
Diffstat (limited to 'sys/src/cmd/awk/re.c')
-rw-r--r-- | sys/src/cmd/awk/re.c | 42 |
1 files changed, 11 insertions, 31 deletions
diff --git a/sys/src/cmd/awk/re.c b/sys/src/cmd/awk/re.c index 32fe2af47..f93a8dd45 100644 --- a/sys/src/cmd/awk/re.c +++ b/sys/src/cmd/awk/re.c @@ -22,18 +22,13 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ****************************************************************/ - -#define DEBUG -#include <stdio.h> +#include <u.h> +#include <libc.h> #include <ctype.h> -#include <setjmp.h> -#include <math.h> -#include <string.h> -#include <stdlib.h> -#include <time.h> +#include <bio.h> +#include <regexp.h> #include "awk.h" #include "y.tab.h" -#include "regexp.h" /* This file provides the interface between the main body of * awk and the pattern matching package. It preprocesses @@ -198,11 +193,11 @@ pmatch(void *p, char *s, char *start) { Resub m; - m.s.sp = start; - m.e.ep = 0; + m.sp = start; + m.ep = 0; if (regexec((Reprog *) p, (char *) s, &m, 1)) { - patbeg = m.s.sp; - patlen = m.e.ep-m.s.sp; + patbeg = m.sp; + patlen = m.ep-m.sp; return 1; } patlen = -1; @@ -250,7 +245,7 @@ quoted(char **s, char **to, char *end) /* handle escaped sequence */ { char *p = *s; char *t = *to; - wchar_t c; + Rune c; switch(c = *p++) { case 't': @@ -273,8 +268,8 @@ quoted(char **s, char **to, char *end) /* handle escaped sequence */ *t++ = '\\'; if (c == 'x') { /* hexadecimal goo follows */ c = hexstr(&p); - if (t < end-MB_CUR_MAX) - t += wctomb(t, c); + if (t < end-UTFmax) + t += runelen(c); else overflow(); *to = t; *s = p; @@ -294,21 +289,6 @@ quoted(char **s, char **to, char *end) /* handle escaped sequence */ *s = p; *to = t; } - /* count rune positions */ -int -countposn(char *s, int n) -{ - int i, j; - char *end; - - for (i = 0, end = s+n; *s && s < end; i++){ - j = mblen(s, n); - if(j <= 0) - j = 1; - s += j; - } - return(i); -} /* pattern package error handler */ |