From 667010554b30c46e35b9cad62edcfa01e37e1576 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Wed, 24 Apr 2013 20:13:18 +0200 Subject: make all the commands agnostic about Rune width. (from sources) --- sys/src/cmd/sam/regexp.c | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'sys/src/cmd/sam') diff --git a/sys/src/cmd/sam/regexp.c b/sys/src/cmd/sam/regexp.c index 4c655dda3..2bf540636 100644 --- a/sys/src/cmd/sam/regexp.c +++ b/sys/src/cmd/sam/regexp.c @@ -9,7 +9,7 @@ typedef struct Inst Inst; struct Inst { - long type; /* < 0x10000 ==> literal, otherwise action */ + long type; /* <= Runemax ==> literal, otherwise action */ union { int rsid; int rsubid; @@ -46,7 +46,7 @@ struct Ilist #define NLIST 127 -Ilist *tl, *nl; /* This list, next list */ +Ilist *tl, *nl; /* This list, next list */ Ilist list[2][NLIST+1]; /* +1 for trailing null */ static Rangeset sempty; @@ -56,25 +56,28 @@ static Rangeset sempty; * 0x100xx are operators, value == precedence * 0x200xx are tokens, i.e. operands for operators */ -#define OPERATOR 0x10000 /* Bitmask of all operators */ -#define START 0x10000 /* Start, used for marker on stack */ -#define RBRA 0x10001 /* Right bracket, ) */ -#define LBRA 0x10002 /* Left bracket, ( */ -#define OR 0x10003 /* Alternation, | */ -#define CAT 0x10004 /* Concatentation, implicit operator */ -#define STAR 0x10005 /* Closure, * */ -#define PLUS 0x10006 /* a+ == aa* */ -#define QUEST 0x10007 /* a? == a|nothing, i.e. 0 or 1 a's */ -#define ANY 0x20000 /* Any character but newline, . */ -#define NOP 0x20001 /* No operation, internal use only */ -#define BOL 0x20002 /* Beginning of line, ^ */ -#define EOL 0x20003 /* End of line, $ */ -#define CCLASS 0x20004 /* Character class, [] */ -#define NCCLASS 0x20005 /* Negated character class, [^] */ -#define END 0x20077 /* Terminate: match found */ - -#define ISATOR 0x10000 -#define ISAND 0x20000 +enum { + OPERATOR = Runemask+1, /* Bitmask of all operators */ + START = OPERATOR, /* Start, used for marker on stack */ + RBRA, /* Right bracket, ) */ + LBRA, /* Left bracket, ( */ + OR, /* Alternation, | */ + CAT, /* Concatentation, implicit operator */ + STAR, /* Closure, * */ + PLUS, /* a+ == aa* */ + QUEST, /* a? == a|nothing, i.e. 0 or 1 a's */ + + ANY = OPERATOR<<1, /* Any character but newline, . */ + NOP, /* No operation, internal use only */ + BOL, /* Beginning of line, ^ */ + EOL, /* End of line, $ */ + CCLASS, /* Character class, [] */ + NCCLASS, /* Negated character class, [^] */ + END, /* Terminate: match found */ + + ISATOR = OPERATOR, + ISAND = OPERATOR<<1, +}; /* * Parser Information @@ -459,7 +462,7 @@ nextrec(void){ exprp++; return '\n'; } - return *exprp++|0x10000; + return *exprp++|(Runemax+1); } return *exprp++; } -- cgit v1.2.3