Skip to content

Commit

Permalink
fix void* to integer conversion problems on 32-bit kevinlawler#141
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlawler committed Jul 29, 2011
1 parent c906a4c commit 4ae1649
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions k.c
Expand Up @@ -102,14 +102,14 @@ I charsAdverb(C c) {R charpos(ac,c);}

I sva(V p) //simpleVerbArity: Use boundaries of arrays to determine verb class in O(1) constant time
{
I q=p;
UI q=p;
if(q<DT_SIZE)R DT[q].arity;
R 0;

}
I adverbClass(V p) //0: not an adverb, 1: / \ ', 2: /: \: ':
{
I q=p;
UI q=p;
if (q<DT_SIZE) R DT[q].adverbClass;
R 0;
}
Expand Down
3 changes: 1 addition & 2 deletions kx.c
Expand Up @@ -470,7 +470,7 @@ Z V ex_(V a, I r)//Expand wd()->7-0 types, expand and evaluate brackets
R z;
}

K ex(K a){ U(a); K z=ex_(&a,0); cd(a);R z;} //Input is 7-0 type from wd()
K ex(K a){U(a);K z=ex_(&a,0); cd(a);R z;} //Input is 7-0 type from wd()

Z K ex0(V*v,K k,I r) //r: {0,1,2} -> {code, (code), [code]} Reverse execution/return multiple (paren not function or script) "list notation" {4,5,6,7} -> {:,if,while,do}
{
Expand Down Expand Up @@ -598,7 +598,6 @@ K ex1(V*w,K k)//convert verb pieces (eg 1+/) to seven-types, default to ex2 (ful
{
//if(in(*w,adverbs)) R NYI;//Adverb at beginning of snippet eg '1 2 3 or ;':1 2 3; or 4;\1+1;4
I d;

if( DT_ADVERB_OFFSET <= *w && *w < DT_VERB_OFFSET )R NYI;

I c=0; while(w[c] && !bk(w[c])){c++; if(offsetColon==w[c-1])break;} //must break or assignment is n^2 (a:b:c:1)
Expand Down
10 changes: 5 additions & 5 deletions p.c
Expand Up @@ -527,7 +527,7 @@ I capture(S s,I n,I k,I*m,V*w,I*d,K*locals,K*dict,K func) //IN string, string le

i=DT_SPECIAL_VERB_OFFSET;
while(i < DT_SIZE && (!DT[i].text || SC(u, DT[i].text)))i++;
if(i < DT_SIZE){z=i;} //faster is sp()/hash-table (compared to SC())
if(i < DT_SIZE){z=(V)i;} //faster is sp()/hash-table (compared to SC())
free(u);
P(!z,(I)kerr("reserved"))// _invalidsystemverbname
break; // _verb does not grab monadic ':' following
Expand Down Expand Up @@ -564,12 +564,12 @@ I capture(S s,I n,I k,I*m,V*w,I*d,K*locals,K*dict,K func) //IN string, string le
else if(modifier_colon){m[k+r]*=-1; r++; a=1; grab=1;} //grab monad ':' sign

i=0;
if(r-grab==1) {z=DT_VERB_OFFSET+2*charsVerb(s[k])+(1==a?0:1);}
if(r-grab==1) {z=(V)(DT_VERB_OFFSET+2*charsVerb(s[k])+(1==a?0:1));}
else
{ j=atol(s+k);
i=DT_SPECIAL_VERB_OFFSET;
while(i < DT_SIZE && (!DT[i].text || j!= atol(DT[i].text)))i++;
if(i<DT_SIZE){z=i+(1==a?0:1);}
if(i<DT_SIZE){z=(V)(i+(1==a?0:1));}
else R (I)PE; //no matching 0: 1: style verb. (if exists, we also allow eg 123: and -2: )
}

Expand All @@ -579,8 +579,8 @@ I capture(S s,I n,I k,I*m,V*w,I*d,K*locals,K*dict,K func) //IN string, string le
//save ':' if a []? + : y ;? ---> dyadic verb
//what passes for y? <--- anything that isn't an end/\0, except colon verb will go on to ex1 to the right and assign _n
)
CS(MARK_ADVERB , z=DT_ADVERB_OFFSET+charsAdverb(s[k])+(r>1?3:0))
CS(MARK_END , z=DT_OFFSET(end))
CS(MARK_ADVERB , z=(V)(DT_ADVERB_OFFSET+charsAdverb(s[k])+(r>1?3:0)))
CS(MARK_END , z=(V)(DT_OFFSET(end)))
}

if(!z) ; //TODO: handle null z, which can happen
Expand Down

0 comments on commit 4ae1649

Please sign in to comment.