Skip to content

Commit

Permalink
Fixed a_malloc bug, wrong cast(!).
Browse files Browse the repository at this point in the history
  • Loading branch information
sazl committed Aug 22, 2010
1 parent e0e6929 commit 9e6e90d
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 17 deletions.
Empty file modified anicca.c
100755 → 100644
Empty file.
Empty file modified anicca.h
100755 → 100644
Empty file.
14 changes: 7 additions & 7 deletions lexer.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
#include "primitive.h"
#include "lexer.h"

/*
parse_literal
input: Length of string, Pointer to string.
output: Array of type string with length (n-2).
*/
static A parse_literal(I n, C *s) { A z = gstr(n-=2, ++s); R z; }

#define DCOL 9
#define DROW 10

Expand All @@ -39,6 +32,13 @@ static ST dfa[DROW][DCOL] = {
/* CX CS CA CN CB C9 CD CC CQ */
};

/*
parse_literal
input: Length of string, Pointer to string.
output: Array of type string with length (n-2).
*/
static A parse_literal(I n, C *s) { A z = gstr(n-=2, ++s); R z; }

/*
token_index
input: Boxed string to be lexed.
Expand Down
Empty file modified lexer.h
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions memory.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "function.h"
#include "memory.h"

VP a_malloc(I size) { V *m = malloc(size); ASSERT(m, ERALLOC); R m; }
VP a_malloc(I size) { VP m = malloc(size); ASSERT(m,ERALLOC); R m; }

VO a_free(A y) {
if (AN(y)>0) { free(AV(y)); if (AR(y)>0) { free(AS(y)); } }
Expand Down Expand Up @@ -49,7 +49,7 @@ A ga(I t, I r, I n, I *s) {
A z = (A)a_malloc(sizeof(struct _array));
AT(z) = t; AC(z) = 1; AR(z) = r;
AN(z) = n; AS(z) = s;
if (n > 0) { AV(z) = a_malloc(ts(t)*n); }
if (n>0) { AV(z) = a_malloc(ts(t)*n); }
R z;
}

Expand Down
Empty file modified memory.h
100755 → 100644
Empty file.
1 change: 0 additions & 1 deletion noun.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
6 changes: 3 additions & 3 deletions util.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -43,16 +44,15 @@ VO print(A y) {
};
break;
}
case MARK: { printf("MARK"); break; }
case MARK: { break; }
case LPAR: { printf("LPAR"); break; }
case RPAR: { printf("RPAR"); break; }
default: { printf("HUH?"); break; }
}
}

VO println(A y) {
print(y);
printf("\n");
if (!(AT(y)&MARK)) { print(y); printf("\n"); }
}

VO a_init(VO) {
Expand Down
8 changes: 4 additions & 4 deletions verb.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ DYAD(plus) { A z = va2(CPLUS,x,y); R z; }
MONAD(duble) { A z = plus(y, y); R z; }

DYAD(append) {
I xt=AT(x), yt=AT(y), xr=AR(x), yr=AR(y);
I xn=AN(x), yn=AN(y), *xs=AS(x), *ys=AS(y);
I xt=AT(x), xn=AN(x), xr=AR(x), *xs=AS(x);
I yt=AT(y), yn=AN(y), yr=AR(y), *ys=AS(y);
I t=MAX(xt,yt), r=MAX(xr,yr), zn=yn+xn, k;
C *xv, *yv, *v; A p=x, q=y, z;
if (xt&NUMERIC&&yt&NUMERIC && (xt!=yt)) {
Expand Down Expand Up @@ -120,8 +120,8 @@ MONAD(indices) { MONAD_PROLOG;
}

MONAD(expntl) {
I yn = AN(y), *yv = IAV(y);
A z = ga(FLT, AR(y), yn, AS(y)); D *v = DAV(z);
I yn=AN(y), *yv=IAV(y); D *v;
A z=ga(FLT, AR(y), yn, AS(y)); v=DAV(z);
DO(yn, v[i] = exp((D)yv[i]));
R z;
}
Expand Down
Empty file modified verb.h
100755 → 100644
Empty file.

0 comments on commit 9e6e90d

Please sign in to comment.