mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
64-bit safe (from plan9)
This commit is contained in:
parent
4515de8f50
commit
0afb7989d3
5 changed files with 42 additions and 15 deletions
|
@ -90,6 +90,7 @@ extern int *name;
|
||||||
extern int *left;
|
extern int *left;
|
||||||
extern int *right;
|
extern int *right;
|
||||||
extern int *parent;
|
extern int *parent;
|
||||||
|
extern uchar **ptr;
|
||||||
extern uchar *nullstr;
|
extern uchar *nullstr;
|
||||||
extern int tptr;
|
extern int tptr;
|
||||||
extern uchar pushc[TOKENSIZE];
|
extern uchar pushc[TOKENSIZE];
|
||||||
|
@ -152,6 +153,7 @@ extern void lgate(void);
|
||||||
extern int lookup(uchar *, uchar **);
|
extern int lookup(uchar *, uchar **);
|
||||||
extern int member(int, uchar *);
|
extern int member(int, uchar *);
|
||||||
extern void mkmatch(void);
|
extern void mkmatch(void);
|
||||||
|
extern int mnp(int, void*);
|
||||||
extern int mn0(int);
|
extern int mn0(int);
|
||||||
extern int mn1(int, int);
|
extern int mn1(int, int);
|
||||||
extern int mn2(int, int, int);
|
extern int mn2(int, int, int);
|
||||||
|
|
|
@ -45,6 +45,7 @@ int *left;
|
||||||
int *right;
|
int *right;
|
||||||
int *parent;
|
int *parent;
|
||||||
uchar *nullstr;
|
uchar *nullstr;
|
||||||
|
uchar **ptr;
|
||||||
int tptr;
|
int tptr;
|
||||||
uchar pushc[TOKENSIZE];
|
uchar pushc[TOKENSIZE];
|
||||||
uchar slist[STARTSIZE];
|
uchar slist[STARTSIZE];
|
||||||
|
|
|
@ -120,13 +120,13 @@ r: CHAR
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
p = psave;
|
p = psave;
|
||||||
$$.i = mn1(RCCL,(int)p);
|
$$.i = mnp(RCCL,p);
|
||||||
cclinter(1);
|
cclinter(1);
|
||||||
}
|
}
|
||||||
| CCL
|
| CCL
|
||||||
={ $$.i = mn1(RCCL,$1.i); }
|
={ $$.i = mnp(RCCL,$1.cp); }
|
||||||
| NCCL
|
| NCCL
|
||||||
={ $$.i = mn1(RNCCL,$1.i); }
|
={ $$.i = mnp(RNCCL,$1.cp); }
|
||||||
| r '*'
|
| r '*'
|
||||||
={ $$.i = mn1(STAR,$1.i); }
|
={ $$.i = mn1(STAR,$1.i); }
|
||||||
| r '+'
|
| r '+'
|
||||||
|
@ -253,7 +253,8 @@ yylex(void)
|
||||||
right = myalloc(treesize,sizeof(*right));
|
right = myalloc(treesize,sizeof(*right));
|
||||||
nullstr = myalloc(treesize,sizeof(*nullstr));
|
nullstr = myalloc(treesize,sizeof(*nullstr));
|
||||||
parent = myalloc(treesize,sizeof(*parent));
|
parent = myalloc(treesize,sizeof(*parent));
|
||||||
if(name == 0 || left == 0 || right == 0 || parent == 0 || nullstr == 0)
|
ptr = myalloc(treesize,sizeof(*ptr));
|
||||||
|
if(name == 0 || left == 0 || right == 0 || parent == 0 || nullstr == 0 || ptr == 0)
|
||||||
error("Too little core for parse tree");
|
error("Too little core for parse tree");
|
||||||
return(freturn(DELIM));
|
return(freturn(DELIM));
|
||||||
case 'p': case 'P': /* has overridden number of positions */
|
case 'p': case 'P': /* has overridden number of positions */
|
||||||
|
|
|
@ -287,6 +287,7 @@ gch(void){
|
||||||
if(c == Beof) {
|
if(c == Beof) {
|
||||||
eof = TRUE;
|
eof = TRUE;
|
||||||
Bterm(fin);
|
Bterm(fin);
|
||||||
|
fin = 0;
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
if(c == '\n')yyline++;
|
if(c == '\n')yyline++;
|
||||||
|
@ -330,6 +331,28 @@ mn2(int a, int d, int c)
|
||||||
return(tptr++);
|
return(tptr++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
mnp(int a, void *p)
|
||||||
|
{
|
||||||
|
name[tptr] = a;
|
||||||
|
left[tptr] = 0;
|
||||||
|
parent[tptr] = 0;
|
||||||
|
nullstr[tptr] = 0;
|
||||||
|
ptr[tptr] = p;
|
||||||
|
switch(a){
|
||||||
|
case RCCL:
|
||||||
|
case RNCCL:
|
||||||
|
if(strlen(p) == 0) nullstr[tptr] = TRUE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
error("bad switch mnp %d %P", a, p);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(tptr > treesize)
|
||||||
|
error("Parse tree too big %s",(treesize == TREESIZE?"\nTry using %e num":""));
|
||||||
|
return(tptr++);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mn1(int a, int d)
|
mn1(int a, int d)
|
||||||
{
|
{
|
||||||
|
@ -338,10 +361,6 @@ mn1(int a, int d)
|
||||||
parent[tptr] = 0;
|
parent[tptr] = 0;
|
||||||
nullstr[tptr] = 0;
|
nullstr[tptr] = 0;
|
||||||
switch(a){
|
switch(a){
|
||||||
case RCCL:
|
|
||||||
case RNCCL:
|
|
||||||
if(strlen((char *)d) == 0) nullstr[tptr] = TRUE;
|
|
||||||
break;
|
|
||||||
case STAR:
|
case STAR:
|
||||||
case QUEST:
|
case QUEST:
|
||||||
nullstr[tptr] = TRUE;
|
nullstr[tptr] = TRUE;
|
||||||
|
@ -421,7 +440,9 @@ dupl(int n)
|
||||||
switch(i){
|
switch(i){
|
||||||
case RNULLS:
|
case RNULLS:
|
||||||
return(mn0(i));
|
return(mn0(i));
|
||||||
case RCCL: case RNCCL: case FINAL: case S1FINAL: case S2FINAL:
|
case RCCL: case RNCCL:
|
||||||
|
return(mnp(i,ptr[n]));
|
||||||
|
case FINAL: case S1FINAL: case S2FINAL:
|
||||||
return(mn1(i,left[n]));
|
return(mn1(i,left[n]));
|
||||||
case STAR: case QUEST: case PLUS: case CARAT:
|
case STAR: case QUEST: case PLUS: case CARAT:
|
||||||
return(mn1(i,dupl(left[n])));
|
return(mn1(i,dupl(left[n])));
|
||||||
|
@ -441,6 +462,8 @@ dupl(int n)
|
||||||
void
|
void
|
||||||
allprint(int c)
|
allprint(int c)
|
||||||
{
|
{
|
||||||
|
if(c < 0)
|
||||||
|
c += 256; /* signed char */
|
||||||
switch(c){
|
switch(c){
|
||||||
case 014:
|
case 014:
|
||||||
print("\\f");
|
print("\\f");
|
||||||
|
@ -531,11 +554,11 @@ treedump(void)
|
||||||
break;
|
break;
|
||||||
case RCCL:
|
case RCCL:
|
||||||
print("ccl ");
|
print("ccl ");
|
||||||
strpt(left[t]);
|
allprint(ptr[t]);
|
||||||
break;
|
break;
|
||||||
case RNCCL:
|
case RNCCL:
|
||||||
print("nccl ");
|
print("nccl ");
|
||||||
strpt(left[t]);
|
allprint(ptr[t]);
|
||||||
break;
|
break;
|
||||||
case DIV:
|
case DIV:
|
||||||
print("/ %d %d",left[t],right[t]);
|
print("/ %d %d",left[t],right[t]);
|
||||||
|
|
|
@ -22,7 +22,7 @@ cfoll(int v)
|
||||||
else if(i == RCCL || i == RNCCL){ /* compress ccl list */
|
else if(i == RCCL || i == RNCCL){ /* compress ccl list */
|
||||||
for(j=1; j<NCH;j++)
|
for(j=1; j<NCH;j++)
|
||||||
symbol[j] = (i==RNCCL);
|
symbol[j] = (i==RNCCL);
|
||||||
p = (uchar *)left[v];
|
p = ptr[v];
|
||||||
while(*p)
|
while(*p)
|
||||||
symbol[*p++] = (i == RCCL);
|
symbol[*p++] = (i == RCCL);
|
||||||
p = pcptr;
|
p = pcptr;
|
||||||
|
@ -36,7 +36,7 @@ cfoll(int v)
|
||||||
*pcptr++ = 0;
|
*pcptr++ = 0;
|
||||||
if(pcptr > pchar + pchlen)
|
if(pcptr > pchar + pchlen)
|
||||||
error("Too many packed character classes");
|
error("Too many packed character classes");
|
||||||
left[v] = (int)p;
|
ptr[v] = p;
|
||||||
name[v] = RCCL; /* RNCCL eliminated */
|
name[v] = RCCL; /* RNCCL eliminated */
|
||||||
# ifdef DEBUG
|
# ifdef DEBUG
|
||||||
if(debug && *p){
|
if(debug && *p){
|
||||||
|
@ -238,7 +238,7 @@ cgoto(void)
|
||||||
else switch(name[curpos]){
|
else switch(name[curpos]){
|
||||||
case RCCL:
|
case RCCL:
|
||||||
tryit = TRUE;
|
tryit = TRUE;
|
||||||
q = (uchar *)left[curpos];
|
q = ptr[curpos];
|
||||||
while(*q){
|
while(*q){
|
||||||
for(j=1;j<NCH;j++)
|
for(j=1;j<NCH;j++)
|
||||||
if(cindex[j] == *q)
|
if(cindex[j] == *q)
|
||||||
|
@ -323,7 +323,7 @@ nextstate(int s, int c)
|
||||||
j = name[curpos];
|
j = name[curpos];
|
||||||
if(j < NCH && j == c
|
if(j < NCH && j == c
|
||||||
|| j == RSTR && c == right[curpos]
|
|| j == RSTR && c == right[curpos]
|
||||||
|| j == RCCL && member(c, (uchar *)left[curpos])){
|
|| j == RCCL && member(c, ptr[curpos])){
|
||||||
f = foll[curpos];
|
f = foll[curpos];
|
||||||
number = *f;
|
number = *f;
|
||||||
newpos = f+1;
|
newpos = f+1;
|
||||||
|
|
Loading…
Reference in a new issue