diff --git a/src/common/func.c b/src/common/func.c index 4bf9d36..7750673 100644 --- a/src/common/func.c +++ b/src/common/func.c @@ -303,8 +303,6 @@ static double deg2rad(double x) } /*}}}*/ -#define INTPATIBLE(t) (t.type == INT || t.type == EMPTY) - typedef enum {ABSOLUTE, RELATIVE} LocConvention; /* & */ /*{{{*/ @@ -321,12 +319,19 @@ static Token adr_func(int argc, const Token argv[], LocConvention lcon) /*}}}*/ LOCATION_GETS(result.u.location, upd_l); - if (argc == 1 && argv[0].type == LOCATION) return argv[0]; + if (argc == 1 && argv[0].type == LOCATION) + if (lcon == ABSOLUTE) return argv[0]; + else + { + LOCATION_ADD(result.u.location, argv[0].u.location); + return result; + } for (i = 0; i < argc && i < HYPER; ++i) { - if (!INTPATIBLE(argv[i])) break; - if (lcon == ABSOLUTE) result.u.location[i] = argv[i].u.integer; - else result.u.location[i] += argv[i].u.integer; + if (argv[i].type == INT) + if (lcon == ABSOLUTE) result.u.location[i] = argv[i].u.integer; + else result.u.location[i] += argv[i].u.integer; + else if (argv[i].type != EMPTY) break; } if (i < argc) { @@ -477,6 +482,8 @@ static Token z_func(int argc, const Token argv[]) typedef enum { LOG_AND, LOG_OR } LogicalFunction; +#define INTPATIBLE(t) (t.type == INT || t.type == EMPTY) + static Token bitwise_func(int argc, const Token argv[], LogicalFunction lop) { Token result; diff --git a/src/common/scanner.h b/src/common/scanner.h index d59a993..23f52a5 100644 --- a/src/common/scanner.h +++ b/src/common/scanner.h @@ -31,6 +31,7 @@ typedef enum { X=0, Y=1, Z=2, HYPER} Dimensions; #define LOCATION_GETS(la,lb) ((void)memcpy(la, lb, sizeof(Location))) #define SAME_LOC(la,lb) (memcmp(la,lb,sizeof(Location))==0) #define LOCATION_SUB(la,lb) (la)[X]-=(lb)[X]; (la)[Y]-=(lb)[Y]; (la)[Z]-=(lb)[Z]; +#define LOCATION_ADD(la,lb) (la)[X]+=(lb)[X]; (la)[Y]+=(lb)[Y]; (la)[Z]+=(lb)[Z]; bool loc_in_box(const Location test, const Location b, const Location c);