Skip to content

Commit

Permalink
further adjustments for issue kevinlawler#269
Browse files Browse the repository at this point in the history
  • Loading branch information
tavmem committed Jul 29, 2015
1 parent 1ae9a8b commit f939b96
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 42 deletions.
22 changes: 11 additions & 11 deletions src/c.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,27 +420,27 @@ Z K backslash_b(S s,I n) {

Z K backslash_d(S s,I n,K*dict) {
C z[256];
//I len=strlen(d__); if(n==2){K r=newK(-3,len); strncpy(kC(r),d__,len); R r;} // yields contents of d__ enclosed in quotes
if(n==2) {O("%s\n",d__); R _n();} // yields contents of d__ without quotes (same as k3.2)
if(n==4 && s[3]==*".") { d__=""; R _n();}
//I len=strlen(d_); if(n==2){K r=newK(-3,len); strncpy(kC(r),d_,len); R r;} // yields contents of d_ enclosed in quotes
if(n==2) {O("%s\n",d_); R _n();} // yields contents of d_ without quotes (same as k3.2)
if(n==4 && s[3]==*".") { d_=""; R _n();}
if(n==4 && s[3]==*"^") {
if(strlen(d__)==0) R _n();
if(strlen(d__)==2) {d__=""; R _n();}
if(strlen(d__)>3) {
if(strlen(d_)==0) R _n();
if(strlen(d_)==2) {d_=""; R _n();}
if(strlen(d_)>3) {
I c=0,i=0;
for(i=0;i<strlen(d__);i++) if(d__[i]==*".")c=i;
strcpy(z,d__); z[c]=*"\0"; d__=(S)sp(z);
for(i=0;i<strlen(d_);i++) if(d_[i]==*".")c=i;
strcpy(z,d_); z[c]=*"\0"; d_=(S)sp(z);
R _n();
}
}
if(n==5 && s[3]==*"." && s[4]==*"k") { d__=".k"; R _n();}
if(n==5 && s[3]==*"." && s[4]==*"k") { d_=".k"; R _n();}
if(n==5 && s[3]==*"." && s[4]!=*"k") {O("absolute backslash-d should begin with .k\n"); R _n();}
if(isalpha(s[3])) {
denameD(dict,s+3,1);
strcpy(z,d__); strcat(z,"."); strcat(z,s+3); d__=(S)sp(z);
strcpy(z,d_); strcat(z,"."); strcat(z,s+3); d_=(S)sp(z);
R _n();
}
if(n>=6 && s[3]==*"." && s[4]==*"k" && s[5]==*".") {denameD(&KTREE,s+3,1); d__=(S)sp(s+3); R _n();}
if(n>=6 && s[3]==*"." && s[4]==*"k" && s[5]==*".") {denameD(&KTREE,s+3,1); d_=(S)sp(s+3); R _n();}
if(n>=6 && s[3]==*"." && (s[4]!=*"k" || s[5]!=*".")) {O("absolute backslash-d should begin with .k.\n"); R _n();}
R NYI;
}
Expand Down
2 changes: 1 addition & 1 deletion src/k.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Z K XN(S s,I n);
N SYMBOLS;//immutable symbol interning
K KTREE; //dictionary, the main/global variable storage area
I SEED; //seed for PRNG
S d__; //sym: handle of current K-Tree dictionary / mth: thread-local storage
S d_; //sym: handle of current K-Tree dictionary / mth: thread-local storage

S IPC_PORT;
S HTTP_PORT;
Expand Down
2 changes: 1 addition & 1 deletion src/k.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ extern S LS;
extern K NIL;
extern S IPC_PORT;
extern S HTTP_PORT;
extern S d__;
extern S d_;
extern I SEED;
extern K KTREE;
extern N SYMBOLS;
Expand Down
2 changes: 1 addition & 1 deletion src/kapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extern K KTREE;
extern K kap(K*, V);
extern K* denameD(K*,S,I);
extern K* denameS(S,S,I);
extern S d__;
extern S d_;
#define NYI kerr("nyi")

K gi(I x) {K z=newK(1,1); Ki(z)=x; R z;}
Expand Down
2 changes: 1 addition & 1 deletion src/kc.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ I kinit() { //oom (return bad)
seedPRNG(randomBits());
NIL=Kn();
KFIXED=newK(0,0); kap(&KFIXED,&NIL);cd(NIL);
d__ = sp(".k"); LS=sp(""); DO(3,IFP[i]=sp(IFS[i]))
d_ = sp(".k"); LS=sp(""); DO(3,IFP[i]=sp(IFS[i]))

#ifdef DEBUG
test();
Expand Down
2 changes: 1 addition & 1 deletion src/kc.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern V fncp[128];
extern I fnci;
extern I fom;
S sp(S k);
extern S d__;
extern S d_;
K Kn();
extern K NIL;
void seedPRNG(I s);
Expand Down
2 changes: 1 addition & 1 deletion src/km.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ K Kc(C x){K z=newK(3,1);*kC(z)=x;R z;}
K Ks(S x){U(x) K z=newK(4,1);*kS(z)=x;R z;}//KDB+ >= 2.4 tries interning [sp()] by default when generating sym atoms
K Kd( ){R newK(5,0);}
K Kn( ){R newK(6,1);}//Should n instead be 0? (Won't affect #:) in k3.2 yes //In K3.2 _n->n is overridden for error messages.
K Kv( ){K z=newK(7,TYPE_SEVEN_SIZE);U(z) z->n=1;kV(z)[CONTeXT]=d__; M(z,kV(z)[PARAMS]=Kd(),kV(z)[LOCALS]=Kd()) R z;} //z->n == 0-wd 1-wordfunc 2-cfunc 3-charfunc 4-:[] 5-if[] 6-while[] 7-do[]
K Kv( ){K z=newK(7,TYPE_SEVEN_SIZE);U(z) z->n=1;kV(z)[CONTeXT]=d_; M(z,kV(z)[PARAMS]=Kd(),kV(z)[LOCALS]=Kd()) R z;} //z->n == 0-wd 1-wordfunc 2-cfunc 3-charfunc 4-:[] 5-if[] 6-while[] 7-do[]
//Optimization: It's better if Kv() doesn't set PARAMS and LOCALS. Only charfuncs should set params

K newEntry(S s){R newE(s,_n());}//assumes s came from sp()
Expand Down
2 changes: 1 addition & 1 deletion src/km.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
I rp2(I v);
K newE(S s,K k);
K newEntry(S s);
extern S d__;
extern S d_;
K Kv();
K Kn();
K Kd();
Expand Down
4 changes: 2 additions & 2 deletions src/p.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ I mark(I*m,I k,I t){DO(k, m[i]=i?t:-t) R k;}
// this rule doesn't apply to function argument lists, eg: f:{ [a] 1} is ok. however f: {\n\n [a;b;d] 1+1} not ok
// so the check probably has to do with whether some useful symbol occurred on the line already
//other errors: syntax error
K wd(S s, I n){lineA=s; R wd_(s,n,denameD(&KTREE,d__,1),0);}
K wd(S s, I n){lineA=s; R wd_(s,n,denameD(&KTREE,d_,1),0);}
K wd_(S s, I n, K*dict, K func) //parse: s input string, n length ;
//assumes: s does not contain a }])([{ mismatch, s is a "complete" expression
{
Expand Down Expand Up @@ -432,7 +432,7 @@ I capture(S s,I n,I k,I*m,V*w,I*d,K*locals,K*dict,K func)
((K)z)->n=3;
memcpy(kC(g),s+k+1,r-2);

kV(z)[CONTeXT] = func?kV(func)[CONTeXT]:d__;
kV(z)[CONTeXT] = func?kV(func)[CONTeXT]:d_;

K* zdict = (K*)kV(z)+PARAMS;
K* ydict = (K*)kV(z)+LOCALS;
Expand Down
2 changes: 1 addition & 1 deletion src/p.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ K cd(K a);
void pdafree(PDA p);
K newK(I t,I n);
K backslash(S s,I n,K*dict);
extern S d__;
extern S d_;
extern K KTREE;
K *denameD(K *d,S t,I create);
K wd_(S s,I n,K *dict,K func);
Expand Down
2 changes: 1 addition & 1 deletion src/r.c
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ K _h()
P(gethostname(c,256),SE)
R Ks(sp(c)); //oom
}
K _d(){R Ks(d__);}
K _d(){R Ks(d_);}
K _v(){R NYI;}
K _i(){R NYI;}
K _f(){R 0;} //Dummy function. Actual value computed inside of the parse function
Expand Down
2 changes: 1 addition & 1 deletion src/r.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ K _s();
K _f();
K _i();
K _v();
extern S d__;
extern S d_;
K _d();
K _h();
extern K NIL;
Expand Down
2 changes: 1 addition & 1 deletion src/v.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ K at(K x, K y)

if(xt==4) {
if(1==ABS(yt)){
C s[256]; strcpy(s,d__); strcat(s,"."); strcat(s,*kS(x));
C s[256]; strcpy(s,d_); strcat(s,"."); strcat(s,*kS(x));
K *xx=denameD(&KTREE,(S)sp(s),1);
if(6==(*xx)->t) R ci(y);
else R of(*xx,y);}
Expand Down
8 changes: 4 additions & 4 deletions src/vd.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ K of(K a, K b) //TODO: oom all (see of2() for M(z,kK(z)[i]=...) pattern )

K z=0;
if(at==4 && bt==0) {
C s[256]; strcpy(s,d__); strcat(s,"."); strcat(s,*kS(a));
C s[256]; strcpy(s,d_); strcat(s,"."); strcat(s,*kS(a));
K *aa=denameD(&KTREE,(S)sp(s),1);
K *f=&kK(b)[0];
R of2(*aa,f,bn>0?1+f:0,bn-1);
}

if(at==4 && bt==1){
C s[256]; strcpy(s,d__); strcat(s,"."); strcat(s,*kS(a));
C s[256]; strcpy(s,d_); strcat(s,"."); strcat(s,*kS(a));
K *aa=denameD(&KTREE,(S)sp(s),1);
R of(*aa,b);
}
Expand Down Expand Up @@ -271,7 +271,7 @@ K dot_tetradic(K a, K b, K c, K y)//Handles triadic and tetradic case

//triadic & tetradic create dict path if not existing (even on errors). dyadic/monadic create nothing

p = denameS(d__,*kS(a),1);
p = denameS(d_,*kS(a),1);
U(p) //oom
}
else q = kclone(a);
Expand Down Expand Up @@ -318,7 +318,7 @@ K dot_monadic(K x) {
S s=kC(x); if(s[0]=='\\')fbs=1; else fbs=0;
R KX(x); }
if(4==xt) {
K *p = denameS(d__,*kS(x),0);
K *p = denameS(d_,*kS(x),0);
if(!p) R DOE;
R ci(*p); }
if(5==xt)R unmake(x);
Expand Down
2 changes: 1 addition & 1 deletion src/vd.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ K dot_monadic(K x);
K Ks(S x);
K make(K a);
K kclone(K a);
extern S d__;
extern S d_;
extern I fbs;
K *denameS(S dir_string,S t,I create);
extern C errmsg[256];
Expand Down
26 changes: 13 additions & 13 deletions src/win/mman.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
#define FILE_MAP_EXECUTE 0x0020
#endif /* FILE_MAP_EXECUTE */

static int __map_mman_error(const DWORD err, const int deferr)
static int map_mman_error(const DWORD err, const int deferr)
{
if (err == 0)
return 0;
//TODO: implement
return err;
}

static DWORD __map_mmap_prot_page(const int prot)
static DWORD map_mmap_prot_page(const int prot)
{
DWORD protect = 0;

Expand All @@ -38,7 +38,7 @@ static DWORD __map_mmap_prot_page(const int prot)
return protect;
}

static DWORD __map_mmap_prot_file(const int prot)
static DWORD map_mmap_prot_file(const int prot)
{
DWORD desiredAccess = 0;

Expand Down Expand Up @@ -70,8 +70,8 @@ void* mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off)
(DWORD)off : (DWORD)(off & 0xFFFFFFFFL);
const DWORD dwFileOffsetHigh = (sizeof(off_t) <= sizeof(DWORD)) ?
(DWORD)0 : (DWORD)((off >> 32) & 0xFFFFFFFFL);
const DWORD protect = __map_mmap_prot_page(prot);
const DWORD desiredAccess = __map_mmap_prot_file(prot);
const DWORD protect = map_mmap_prot_page(prot);
const DWORD desiredAccess = map_mmap_prot_file(prot);

const off_t maxSize = off + (off_t)len;

Expand Down Expand Up @@ -109,7 +109,7 @@ void* mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off)

if (fm == NULL)
{
errno = __map_mman_error(GetLastError(), EPERM);
errno = map_mman_error(GetLastError(), EPERM);
return MAP_FAILED;
}

Expand All @@ -119,7 +119,7 @@ void* mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off)

if (map == NULL)
{
errno = __map_mman_error(GetLastError(), EPERM);
errno = map_mman_error(GetLastError(), EPERM);
return MAP_FAILED;
}

Expand All @@ -131,20 +131,20 @@ int munmap(void *addr, size_t len)
if (UnmapViewOfFile(addr))
return 0;

errno = __map_mman_error(GetLastError(), EPERM);
errno = map_mman_error(GetLastError(), EPERM);

return -1;
}

int mprotect(void *addr, size_t len, int prot)
{
DWORD newProtect = __map_mmap_prot_page(prot);
DWORD newProtect = map_mmap_prot_page(prot);
DWORD oldProtect = 0;

if (VirtualProtect(addr, len, newProtect, &oldProtect))
return 0;

errno = __map_mman_error(GetLastError(), EPERM);
errno = map_mman_error(GetLastError(), EPERM);

return -1;
}
Expand All @@ -154,7 +154,7 @@ int msync(void *addr, size_t len, int flags)
if (FlushViewOfFile(addr, len))
return 0;

errno = __map_mman_error(GetLastError(), EPERM);
errno = map_mman_error(GetLastError(), EPERM);

return -1;
}
Expand All @@ -164,7 +164,7 @@ int mlock(const void *addr, size_t len)
if (VirtualLock((LPVOID)addr, len))
return 0;

errno = __map_mman_error(GetLastError(), EPERM);
errno = map_mman_error(GetLastError(), EPERM);

return -1;
}
Expand All @@ -174,7 +174,7 @@ int munlock(const void *addr, size_t len)
if (VirtualUnlock((LPVOID)addr, len))
return 0;

errno = __map_mman_error(GetLastError(), EPERM);
errno = map_mman_error(GetLastError(), EPERM);

return -1;
}

0 comments on commit f939b96

Please sign in to comment.