summaryrefslogtreecommitdiff
path: root/sys/src/cmd/sam/regexp.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-04-24 20:13:18 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-04-24 20:13:18 +0200
commit667010554b30c46e35b9cad62edcfa01e37e1576 (patch)
tree418f828288c6c5c5ba0e6a18775af855966579f0 /sys/src/cmd/sam/regexp.c
parent78c7ba36a1a732c08fbb7e4f8b19d1bc825c5b7e (diff)
make all the commands agnostic about Rune width. (from sources)
Diffstat (limited to 'sys/src/cmd/sam/regexp.c')
-rw-r--r--sys/src/cmd/sam/regexp.c47
1 files changed, 25 insertions, 22 deletions
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++;
}